├── bg.png ├── favicon.ico ├── loading.gif ├── pivory.png ├── title.png ├── title_x.png ├── font ├── fontawesome-webfont.eot ├── fontawesome-webfont.ttf └── fontawesome-webfont.woff ├── footer.php ├── README.md ├── .gitattributes ├── connect.php ├── prettify.css ├── upload_icon.php ├── header.php ├── .gitignore ├── account_func.php ├── account.php ├── account_db.php ├── curiousw_db.sql ├── ws.php ├── index.php ├── post_db.php ├── prettify.js ├── font-awesome.css ├── style.css └── post_func.php /bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/bg.png -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/favicon.ico -------------------------------------------------------------------------------- /loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/loading.gif -------------------------------------------------------------------------------- /pivory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/pivory.png -------------------------------------------------------------------------------- /title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/title.png -------------------------------------------------------------------------------- /title_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/title_x.png -------------------------------------------------------------------------------- /font/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/font/fontawesome-webfont.eot -------------------------------------------------------------------------------- /font/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/font/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /font/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheshirecats/ProjectIvory/HEAD/font/fontawesome-webfont.woff -------------------------------------------------------------------------------- /footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Warning: the codes are in a total mess. 2 | 3 | FULL DEMO: http://pivory.com 4 | 5 | ![Screenshot](https://raw.githubusercontent.com/cheshirecats/ProjectIvory/master/pivory.png) 6 | 7 | 1) Import curiousw_db.sql 8 | 2) Modify connect.php 9 | 3) Install PHP Memcached for caching and session 10 | 4) Install PHP Ratchet 0.4.x for WebSocket server 11 | 5) php ws.php for WebSocket server 12 | 13 | License: MIT 14 | 15 | Simpler version: https://github.com/cheshirecats/CuriousWall 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /connect.php: -------------------------------------------------------------------------------- 1 | addServer('localhost', 11211); 13 | } 14 | else if (class_exists('memcache')) 15 | { 16 | $mcache = new memcache(); 17 | $mcache->addServer('localhost', 11211); 18 | } 19 | } 20 | 21 | if (!isset($GLOBALS['db'])) { 22 | function connect_db() { 23 | $db_host = 'localhost'; 24 | $db_user = 'curiousw_admin'; 25 | $db_pass = '123456'; 26 | $db_name = 'curiousw_db'; 27 | 28 | $GLOBALS['db'] = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass 29 | , array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); 30 | } 31 | connect_db(); 32 | } 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /prettify.css: -------------------------------------------------------------------------------- 1 | .pln { color: #000 } 2 | @media screen 3 | { 4 | .str { color: #080 } 5 | .kwd { color: #008 } 6 | .com { color: #800 } 7 | .typ { color: #606 } 8 | .lit { color: #066 } 9 | .pun, .opn, .clo { color: #660 } 10 | .tag { color: #008 } 11 | .atn { color: #606 } 12 | .atv { color: #080 } 13 | .dec, .var { color: #606 } 14 | .fun { color: red } 15 | } 16 | @media print,projection 17 | { 18 | .str { color: #060 } 19 | .kwd { color: #006; font-weight: bold; } 20 | .com { color: #600; font-style: italic; } 21 | .typ { color: #404; font-weight: bold; } 22 | .lit { color: #044 } 23 | .pun, .opn, .clo { color: #440 } 24 | .tag { color: #006; font-weight: bold; } 25 | .atn { color: #404 } 26 | .atv { color: #060 } 27 | } 28 | ol.linenums { margin-top: 0; margin-bottom: 0; } 29 | li.L0, li.L1, li.L2, li.L3, li.L5, li.L6, li.L7, li.L8 30 | { list-style-type: none } -------------------------------------------------------------------------------- /upload_icon.php: -------------------------------------------------------------------------------- 1 | 0) echo('Upload error code '.$_FILES['file']['error'].'.'); else { 5 | $ext = array('jpg', 'jpeg', 'gif', 'png'); 6 | $type = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); 7 | $extension = end(explode('.', $_FILES['file']['name'])); 8 | if (!in_array($extension, $ext)) echo('Invalid image extension.'); else { 9 | if ($_FILES['file']['size'] > 200000) echo('Image is too large.'); else { 10 | if (!in_array($_FILES['file']['type'], $type)) echo('Invalid image type.'); else { 11 | 12 | testLogin($row); 13 | if ($row['user_level'] == -1) die_Log(); 14 | 15 | if ($_FILES['file']['type'] == 'image/gif') 16 | $img = imagecreatefromgif($_FILES['file']['tmp_name']); 17 | else if ($_FILES['file']['type'] == 'image/png') 18 | $img = imagecreatefrompng($_FILES['file']['tmp_name']); 19 | else 20 | $img = imagecreatefromjpeg($_FILES['file']['tmp_name']); 21 | 22 | $ww = imagesx($img); $hh = imagesy($img); $mm = min($ww, $hh); 23 | if (max($ww, $hh) > 2000) { echo('Image is too large.'); ImageDestroy($img); } else { 24 | 25 | $thumb = imagecreatetruecolor(64, 64); 26 | imagecopyresampled($thumb, $img, 0, 0, ($ww-$mm)/2, ($hh-$mm)/2, 64, 64, $mm, $mm); 27 | imagepng($thumb, 'icon/'.$row['user_id']."_64.png", 9); ImageDestroy($thumb); 28 | 29 | $thumb = imagecreatetruecolor(32, 32); 30 | imagecopyresampled($thumb, $img, 0, 0, ($ww-$mm)/2, ($hh-$mm)/2, 32, 32, $mm, $mm); 31 | imagepng($thumb, 'icon/'.$row['user_id']."_32.png", 9); ImageDestroy($thumb); 32 | 33 | ImageDestroy($img); 34 | echo('Success. You can close this window now.'); 35 | }}}}} 36 | ?> -------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | Project Ivory 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 | 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /account_func.php: -------------------------------------------------------------------------------- 1 | Sign up or sign in first.'; 6 | } 7 | function die_Log() 8 | { 9 | die(info_Log()); 10 | } 11 | 12 | function testName(&$name) 13 | { 14 | if (!$name) die('Fill in username.'); 15 | if (!preg_match("/^[a-zA-Z0-9_]+$/u",$name)) 16 | { 17 | die('Username can only contain a-z, A-Z, 0-9 and underscore.'); 18 | } 19 | if ((strlen($name) < 3) || (strlen($name) > 16)) 20 | { 21 | die('Username length needs to be within [3, 16].'); 22 | } 23 | } 24 | function testPass(&$pass) 25 | { 26 | if (!$pass) die('Fill in password.'); 27 | if ((strlen($pass) < 6) || (strlen($pass) > 255)) 28 | { 29 | die('Password length needs to at least 6.'); 30 | } 31 | } 32 | function testMail(&$mail) 33 | { 34 | $mail = strtolower(trim($mail)); 35 | if (!$mail) die('Fill in email.'); 36 | if (strlen($mail) > 50) 37 | { 38 | die('Email cannot be longer than 50 letters.'); 39 | } 40 | if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) 41 | { 42 | die('Email is invalid.'); 43 | } 44 | } 45 | function testURL(&$url) 46 | { 47 | $url = strtolower(trim($url)); 48 | if (!$url) die('Fill in URL.'); 49 | if (!filter_var($url, FILTER_VALIDATE_URL)) 50 | { 51 | die('URL is invalid.'); 52 | } 53 | } 54 | 55 | function xtestLogin(&$row, $user, $pass) 56 | { 57 | if (!$user) die('Fill in username.'); 58 | 59 | $is_guest = 0; 60 | $query = $GLOBALS['db']->prepare("SELECT * FROM users WHERE user_name LIKE ?"); 61 | $query->execute(array($user)); 62 | $row = $query->fetch(PDO::FETCH_ASSOC); 63 | if ($query->rowCount() > 0) 64 | { 65 | if ($row['user_level'] == -1) 66 | { 67 | $is_guest = 1; 68 | } 69 | if ($row['user_level'] < -99) 70 | { 71 | die('Older accounts are temporarily disabled. Stay tuned.'); 72 | } 73 | } 74 | if ($is_guest == 0) 75 | { 76 | if (!$pass) die('Fill in password.'); 77 | 78 | $query = $GLOBALS['db']->prepare("SELECT * FROM users WHERE user_name LIKE ?"); 79 | $query->execute(array($user)); 80 | if ($query->rowCount() < 1) { 81 | die('Non-existent username. Forgot account?'); 82 | } 83 | 84 | $query = $GLOBALS['db']->prepare("SELECT * FROM users WHERE ((user_name LIKE ?) AND (user_pass = UNHEX(?)))"); 85 | $query->execute(array($user, hash('ripemd160', $pass."24humUfrAw".strtolower($user)))); 86 | $row = $query->fetch(PDO::FETCH_ASSOC); 87 | if ($query->rowCount() < 1) 88 | { 89 | die('Incorrect password. Forgot account?'); 90 | } 91 | } 92 | } 93 | 94 | function testLogin(&$row) 95 | { 96 | xtestLogin($row, $_POST['user'], $_POST['pass']); 97 | } 98 | 99 | function xlogin($user, $pass, $die) 100 | { 101 | xtestLogin($row, $user, $pass); 102 | $_SESSION['user_name'] = $row['user_name']; 103 | $_SESSION['user_id'] = $row['user_id']; 104 | $_SESSION['user_level'] = $row['user_level']; 105 | 106 | $query = $GLOBALS['db']->prepare("UPDATE users SET user_signin = NOW(), user_ip = '".$_SERVER["REMOTE_ADDR"]."' WHERE user_id = ?"); 107 | $query->execute(array($row['user_id'])); 108 | 109 | if ($die) die('Success.'); 110 | } 111 | 112 | function login() 113 | { 114 | xlogin($_POST['user'], $_POST['pass'], true); 115 | } 116 | ?> -------------------------------------------------------------------------------- /account.php: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 |
9 |
Project Ivory
10 |
11 |
'; 15 | } 16 | if ($_GET["a"] == 'login') 17 | { 18 | echo '
sign up?
'; 19 | echo ''; 20 | echo ''; 21 | echo 'sign in'; 22 | } 23 | else if ($_GET["a"] == 'register') 24 | { 25 | echo ''; 26 | echo ''; 27 | echo '
'; 28 | echo ''; 29 | echo ''; 30 | echo 'sign up'; 31 | } 32 | else if ($_GET["a"] == 'change') 33 | { 34 | echo ''; 37 | echo ''; 38 | echo '
'; 39 | //echo ''; 40 | echo ''; 41 | echo ''; 42 | echo 'change'; 43 | } 44 | else if ($_GET["a"] == 'email') 45 | { 46 | echo ''; 49 | echo ''; 50 | echo '
'; 51 | echo ''; 52 | echo ''; 53 | echo 'change'; 54 | } 55 | else if ($_GET["a"] == 'icon') 56 | { 57 | echo '
Make your icon a 64x64 PNG, with no transparency.
'; 58 | echo '
'; 59 | echo ''; 60 | echo ''; 61 | echo '
'; 62 | echo ''; 63 | } 64 | else if ($_GET["a"] == 'forgot') 65 | { 66 | echo ''; 67 | echo 'Proceed'; 68 | } 69 | else if ($_GET["a"] == 'reset') 70 | { 71 | echo '
Reseting password for account : '.$_GET["c"].'
'; 72 | echo ''; 73 | echo ''; 74 | echo 'proceed'; 75 | } 76 | ?> 77 |
78 |
79 |
80 |
81 | 82 | -------------------------------------------------------------------------------- /account_db.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT user_name, user_pass FROM users WHERE user_email LIKE ?"); 11 | $query->execute(array($_POST['mail'])); 12 | if ($query->rowCount() > 0) 13 | { 14 | $row = $query->fetch(PDO::FETCH_ASSOC); 15 | $head = "MIME-Version: 1.0\r\nContent-Type: text/html; charset=ISO-8859-1\r\n"; 16 | $hasx = hash('ripemd160', 'xpfmrhsjfyusl'.$row['user_name'].$row['user_pass']); 17 | $urx = 'http://qivory.com/account.php?a=reset&b='.$hasx.'&c='.$row['user_name']; 18 | mail($_POST['mail'], 'Project Ivory : reseting password', 19 | '
If you have requested to reset the password for your account '.$row['user_name'].' :

click this link ( '.$urx." ).

Regards,
Project Ivory", 20 | $head); 21 | die('Email sent. Click the link in mail to reset password.'); 22 | } 23 | die('Email is not used by any accounts.'); 24 | } 25 | 26 | $_POST['user'] = trim($_POST['user']); 27 | $pass_salt = "???????????".strtolower($_POST['user']); 28 | 29 | if ($_POST['a'] == 'reset') 30 | { 31 | $_POST['user'] = trim($_POST['user']); 32 | $_POST['new_pass'] = trim($_POST['new_pass']); 33 | testName($_POST['user']); 34 | testPass($_POST['new_pass']); 35 | $query = $GLOBALS['db']->prepare("SELECT user_name, user_pass FROM users WHERE user_name LIKE ?"); 36 | $query->execute(array($_POST['user'])); 37 | if ($query->rowCount() > 0) 38 | { 39 | $row = $query->fetch(PDO::FETCH_ASSOC); 40 | $hasx = hash('ripemd160', 'xpfmrhsjfyusl'.$row['user_name'].$row['user_pass']); 41 | if ($hasx == $_POST['magic']) { 42 | $query = $GLOBALS['db']->prepare("UPDATE users SET user_pass = UNHEX(?) WHERE user_name LIKE ?"); 43 | $query->execute(array(hash('ripemd160', $_POST['new_pass'].$pass_salt), $_POST['user'])); 44 | die('Success.'); 45 | } 46 | } 47 | die('Hello'); 48 | } 49 | 50 | $_POST['pass'] = trim($_POST['pass']); 51 | 52 | 53 | if ($_POST['a'] == 'login') 54 | { 55 | login(); 56 | } 57 | else if ($_POST['a'] == 'register') 58 | { 59 | testName($_POST['user']); 60 | testPass($_POST['pass']); 61 | testMail($_POST['mail']); 62 | 63 | $query = $GLOBALS['db']->prepare("SELECT user_id FROM users WHERE user_name LIKE ?"); 64 | $query->execute(array($_POST['user'])); 65 | if ($query->rowCount() > 0) 66 | { 67 | die('Username is already taken.'); 68 | } 69 | 70 | $query = $GLOBALS['db']->prepare("SELECT user_id FROM users WHERE user_email LIKE ?"); 71 | $query->execute(array($_POST['mail'])); 72 | if ($query->rowCount() > 0) 73 | { 74 | die('Email is already taken.'); 75 | } 76 | 77 | $new_pass = $_POST['pass']; 78 | 79 | $query = $GLOBALS['db']->prepare("INSERT INTO users(user_name,user_pass,user_email,user_date) VALUES(?,UNHEX(?),?,NOW())"); 80 | $query->execute(array($_POST['user'], hash('ripemd160', $new_pass.$pass_salt), $_POST['mail'])); 81 | if ($query->rowCount() < 1) 82 | { 83 | die('Username is already taken.'); 84 | } 85 | 86 | login($db); 87 | } 88 | else if ($_POST['a'] == 'change') 89 | { 90 | testLogin($row); 91 | if ($row['user_level'] == -1) die_Log(); 92 | /* 93 | testName($_POST['new_user']); 94 | $query = $GLOBALS['db']->prepare("SELECT user_id FROM users WHERE user_name LIKE ?"); 95 | $query->execute(array($_POST['new_user'])); 96 | if ($query->rowCount() > 0) 97 | { 98 | die('Username is already taken.'); 99 | } */ 100 | $_POST['new_pass'] = trim($_POST['new_pass']); 101 | testPass($_POST['new_pass']); 102 | 103 | /* $pass_salt = "24humUfrAw".strtolower($_POST['new_user']); 104 | $query = $GLOBALS['db']->prepare("UPDATE users SET user_name LIKE ?, user_pass = UNHEX(?) WHERE user_id = ?"); 105 | $query->execute(array($_POST['new_user'], hash('ripemd160', $_POST['new_pass'].$pass_salt), $row['user_id'])); 106 | $_SESSION['user_name'] = $new_user; */ 107 | 108 | $query = $GLOBALS['db']->prepare("UPDATE users SET user_pass = UNHEX(?) WHERE user_id = ?"); 109 | $query->execute(array(hash('ripemd160', $_POST['new_pass'].$pass_salt), $row['user_id'])); 110 | 111 | die('Success.'); 112 | } 113 | else if ($_POST['a'] == 'email') 114 | { 115 | testLogin($row); 116 | if ($row['user_level'] == -1) die_Log(); 117 | 118 | testMail($_POST['mail']); 119 | $query = $GLOBALS['db']->prepare("SELECT user_id FROM users WHERE user_email LIKE ?"); 120 | $query->execute(array($_POST['mail'])); 121 | if ($query->rowCount() > 0) 122 | { 123 | die('Email is already taken.'); 124 | } 125 | 126 | $query = $GLOBALS['db']->prepare("UPDATE users SET user_email = ? WHERE user_id = ?"); 127 | $query->execute(array($_POST['mail'], $row['user_id'])); 128 | 129 | die('Success.'); 130 | } 131 | ?> 132 | -------------------------------------------------------------------------------- /curiousw_db.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 3.4.10.1 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: Feb 13, 2013 at 08:35 AM 7 | -- Server version: 5.5.20 8 | -- PHP Version: 5.3.10 9 | 10 | SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8 */; 18 | 19 | -- 20 | -- Database: `curiousw_db` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Table structure for table `follow` 27 | -- 28 | 29 | CREATE TABLE IF NOT EXISTS `follow` ( 30 | `follow_a` int(10) unsigned NOT NULL, 31 | `follow_b` int(10) unsigned NOT NULL, 32 | PRIMARY KEY (`follow_a`,`follow_b`), 33 | KEY `follow_a` (`follow_a`), 34 | KEY `follow_b` (`follow_b`) 35 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 36 | 37 | -- -------------------------------------------------------- 38 | 39 | -- 40 | -- Table structure for table `list2top` 41 | -- 42 | 43 | CREATE TABLE IF NOT EXISTS `list2top` ( 44 | `id_topic` int(10) unsigned NOT NULL, 45 | `id_list` int(10) unsigned NOT NULL, 46 | `id_by` int(10) unsigned NOT NULL, 47 | PRIMARY KEY (`id_topic`,`id_list`,`id_by`), 48 | KEY `id_topic` (`id_topic`), 49 | KEY `id_list` (`id_list`), 50 | KEY `id_by` (`id_by`) 51 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 52 | 53 | -- -------------------------------------------------------- 54 | 55 | -- 56 | -- Table structure for table `lists` 57 | -- 58 | 59 | CREATE TABLE IF NOT EXISTS `lists` ( 60 | `list_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 61 | `list_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 62 | `list_by` int(10) unsigned NOT NULL, 63 | `list_date` datetime NOT NULL, 64 | `list_cnt` int(10) unsigned NOT NULL, 65 | PRIMARY KEY (`list_id`), 66 | KEY `list_cnt` (`list_cnt`), 67 | KEY `list_date` (`list_date`), 68 | KEY `list_by` (`list_by`), 69 | KEY `list_name` (`list_name`) 70 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=30 ; 71 | 72 | -- -------------------------------------------------------- 73 | 74 | -- 75 | -- Table structure for table `posts` 76 | -- 77 | 78 | CREATE TABLE IF NOT EXISTS `posts` ( 79 | `post_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 80 | `post_text` text COLLATE utf8_unicode_ci NOT NULL, 81 | `post_date` datetime NOT NULL, 82 | `post_topic` int(10) unsigned DEFAULT NULL, 83 | `post_root` int(11) DEFAULT NULL, 84 | `post_by` int(10) unsigned NOT NULL, 85 | `post_special` int(10) unsigned NOT NULL, 86 | `post_edit` datetime NOT NULL, 87 | `post_ip` varchar(15) COLLATE utf8_unicode_ci NOT NULL, 88 | PRIMARY KEY (`post_id`), 89 | KEY `post_topic` (`post_topic`), 90 | KEY `post_date` (`post_date`), 91 | KEY `post_by` (`post_by`), 92 | KEY `post_root` (`post_root`), 93 | KEY `post_edit` (`post_edit`), 94 | KEY `post_special` (`post_special`), 95 | KEY `post_ip` (`post_ip`) 96 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6937 ; 97 | 98 | -- -------------------------------------------------------- 99 | 100 | -- 101 | -- Table structure for table `topics` 102 | -- 103 | 104 | CREATE TABLE IF NOT EXISTS `topics` ( 105 | `topic_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 106 | `topic_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 107 | `topic_root` int(10) unsigned NOT NULL, 108 | `topic_date` datetime NOT NULL, 109 | `topic_by` int(10) unsigned NOT NULL, 110 | `topic_replies` int(10) unsigned NOT NULL, 111 | `topic_score` double NOT NULL, 112 | `topic_special` int(10) unsigned NOT NULL, 113 | `topic_class` int(10) unsigned NOT NULL, 114 | PRIMARY KEY (`topic_id`), 115 | KEY `topic_date` (`topic_date`), 116 | KEY `topic_by` (`topic_by`), 117 | KEY `topic_score` (`topic_score`), 118 | KEY `topic_root` (`topic_root`), 119 | KEY `topic_replies` (`topic_replies`), 120 | KEY `topic_special` (`topic_special`), 121 | KEY `topic_title` (`topic_title`) 122 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1746 ; 123 | 124 | -- -------------------------------------------------------- 125 | 126 | -- 127 | -- Table structure for table `users` 128 | -- 129 | 130 | CREATE TABLE IF NOT EXISTS `users` ( 131 | `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 132 | `user_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, 133 | `user_pass` binary(20) NOT NULL, 134 | `user_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL, 135 | `user_date` datetime NOT NULL, 136 | `user_ip` varchar(15) COLLATE utf8_unicode_ci NOT NULL, 137 | `user_level` int(10) NOT NULL, 138 | `user_posts` int(10) unsigned NOT NULL, 139 | `user_signin` datetime NOT NULL, 140 | `user_lastpost` datetime NOT NULL, 141 | `user_following` int(10) unsigned NOT NULL, 142 | `user_followers` int(10) unsigned NOT NULL, 143 | `user_css` varchar(30) COLLATE utf8_unicode_ci NOT NULL, 144 | `user_hidposts` int(10) unsigned NOT NULL, 145 | `user_location` varchar(50) COLLATE utf8_unicode_ci NOT NULL, 146 | `user_education` varchar(50) COLLATE utf8_unicode_ci NOT NULL, 147 | `user_major` varchar(50) COLLATE utf8_unicode_ci NOT NULL, 148 | `user_hobby` varchar(100) COLLATE utf8_unicode_ci NOT NULL, 149 | PRIMARY KEY (`user_id`), 150 | UNIQUE KEY `user_name` (`user_name`), 151 | KEY `user_signin` (`user_signin`), 152 | KEY `user_date` (`user_date`), 153 | KEY `user_posts` (`user_posts`), 154 | KEY `user_lastpost` (`user_lastpost`), 155 | KEY `user_following` (`user_following`), 156 | KEY `user_followers` (`user_followers`), 157 | KEY `user_email` (`user_email`), 158 | KEY `user_level` (`user_level`), 159 | KEY `user_hidposts` (`user_hidposts`) 160 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1095 ; 161 | 162 | -- 163 | -- Constraints for dumped tables 164 | -- 165 | 166 | -- 167 | -- Constraints for table `follow` 168 | -- 169 | ALTER TABLE `follow` 170 | ADD CONSTRAINT `follow_ibfk_1` FOREIGN KEY (`follow_a`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, 171 | ADD CONSTRAINT `follow_ibfk_2` FOREIGN KEY (`follow_b`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; 172 | 173 | -- 174 | -- Constraints for table `list2top` 175 | -- 176 | ALTER TABLE `list2top` 177 | ADD CONSTRAINT `list2top_ibfk_1` FOREIGN KEY (`id_topic`) REFERENCES `topics` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, 178 | ADD CONSTRAINT `list2top_ibfk_2` FOREIGN KEY (`id_list`) REFERENCES `lists` (`list_id`) ON DELETE CASCADE ON UPDATE CASCADE; 179 | 180 | -- 181 | -- Constraints for table `lists` 182 | -- 183 | ALTER TABLE `lists` 184 | ADD CONSTRAINT `lists_ibfk_1` FOREIGN KEY (`list_by`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; 185 | 186 | -- 187 | -- Constraints for table `posts` 188 | -- 189 | ALTER TABLE `posts` 190 | ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`post_topic`) REFERENCES `topics` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, 191 | ADD CONSTRAINT `posts_ibfk_3` FOREIGN KEY (`post_by`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; 192 | 193 | -- 194 | -- Constraints for table `topics` 195 | -- 196 | ALTER TABLE `topics` 197 | ADD CONSTRAINT `topics_ibfk_2` FOREIGN KEY (`topic_by`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, 198 | ADD CONSTRAINT `topics_ibfk_3` FOREIGN KEY (`topic_root`) REFERENCES `posts` (`post_id`) ON DELETE CASCADE ON UPDATE CASCADE; 199 | 200 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 201 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 202 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 203 | -------------------------------------------------------------------------------- /ws.php: -------------------------------------------------------------------------------- 1 | set('pivory.threads.list', ''); 17 | $GLOBALS['sessionPrefix'] = (get_class($GLOBALS['mcache']) == 'Memcache') ? '' : 'memc.sess.key.'; 18 | 19 | $GLOBALS['dddd'] = new DateTime(); 20 | $GLOBALS['job_last_usr_count'] = 0; 21 | $GLOBALS['job_new_thread'] = new \SplObjectStorage; 22 | $GLOBALS['clients'] = new \SplObjectStorage; 23 | 24 | function debug($msg) { 25 | //print($msg); 26 | } 27 | 28 | function fetchses($conn) { 29 | $return_data = array(); 30 | 31 | $id = substr($conn->httpRequest->getUri()->getPath(), 1); 32 | $session_data = $GLOBALS['mcache']->get($GLOBALS['sessionPrefix'].$id); 33 | debug($id.' sess '.$session_data); 34 | $offset = 0; 35 | while ($offset < strlen($session_data)) { 36 | if (!strstr(substr($session_data, $offset), "|")) { 37 | throw new Exception("invalid data, remaining: " . substr($session_data, $offset)); 38 | } 39 | $pos = strpos($session_data, "|", $offset); 40 | $num = $pos - $offset; 41 | $varname = substr($session_data, $offset, $num); 42 | $offset += $num + 1; 43 | $data = unserialize(substr($session_data, $offset)); 44 | $return_data[$varname] = $data; 45 | $offset += strlen(serialize($data)); 46 | } 47 | return $return_data; 48 | } 49 | 50 | function process(ConnectionInterface $conn, $msg, &$succ) 51 | { 52 | $query = $GLOBALS['db']->query('SELECT 1'); 53 | if (!$query) connect_db(); 54 | if ((($msg['a'] == 'new') || ($msg['a'] == 'ne1')) && (is_numeric($msg['n']))) { 55 | $ses = fetchses($conn); 56 | if (!isset($ses['user_id'])) return info_Log(); 57 | if ($ses['user_id'] <= 0) return info_Log(); 58 | if (($ses['user_level'] == -1) && (isset($msg['s']))) return info_Log(); 59 | 60 | $mm = verifyText($msg['text']); if ($mm != '') return $mm; 61 | $msg['text'] = mynl2br(htmlspecialchars($msg['text'])); 62 | 63 | $is_hidden_post = false; 64 | $topic_class = 0; if ($msg['a'] == 'ne1') $topic_class = 1; 65 | if ($msg['n'] == 0) 66 | { 67 | if ($ses['user_level'] == -1) $topic_class = 1; 68 | $mm = verifyTitle($msg['title']); if ($mm != '') return $mm; 69 | 70 | $query = $GLOBALS['db']->prepare("INSERT INTO posts(post_text,post_date,post_by,post_topic,post_root,post_ip) VALUES(?,NOW(),?,NULL,NULL,'".$conn->remoteAddress."')"); 71 | $query->execute(array($msg['text'], $ses['user_id'])); 72 | if ($query->rowCount() < 1) 73 | { 74 | return 'Cannot add post.'; 75 | } 76 | $topic_root = $GLOBALS['db']->lastInsertId(); 77 | 78 | $topic_special = 0; 79 | if (isset($msg['s'])) if (($msg['s'] == '1') || ($msg['s'] == '2')) { 80 | $topic_special += 2 * (int)($msg['s']); 81 | } 82 | if ($topic_special == 4) $is_hidden_post = true; 83 | 84 | $query = $GLOBALS['db']->prepare("INSERT INTO topics(topic_title,topic_root,topic_date,topic_by,topic_score,topic_special,topic_class)" 85 | ."VALUES(?,?,NOW(),?,UNIX_TIMESTAMP(NOW()) - ". (($ses['user_level'] >= 999999) ? ('0') : (($ses['user_level'] >= 0) ? ('3600') : ('86400'))).",?,?)"); 86 | $query->execute(array($msg['title'], $topic_root, $ses['user_id'], $topic_special, $topic_class)); 87 | 88 | if ($query->rowCount() < 1) 89 | { 90 | return 'Cannot add post.'; 91 | } 92 | $msg['n'] = $GLOBALS['db']->lastInsertId(); 93 | 94 | $GLOBALS['db']->query("UPDATE posts SET post_root = ".$msg['n']." WHERE post_id = ".$topic_root); 95 | } 96 | else 97 | { 98 | $already_replied = true; 99 | if ($ses['user_level'] >= 999999) 100 | { 101 | $already_replied = false; 102 | } 103 | else if ($msg['n'] > 0) 104 | { 105 | $query = $GLOBALS['db']->query('SELECT post_id FROM posts WHERE (post_root = '.$msg['n'].' AND post_by = '.$ses['user_id'].') LIMIT 1'); 106 | if ($query->rowCount() <= 0) $already_replied = false; 107 | } 108 | if ($msg['n'] < 0) 109 | { 110 | $query = $GLOBALS['db']->query("SELECT * FROM follow WHERE follow_b = ".$ses['user_id']." AND follow_a = ".(-$msg['n'])); 111 | if (($query->rowCount() <= 0) && ($ses['user_id'] != 1) && ($ses['user_id'] != -$msg['n'])) 112 | return "Currently you can post on the walls of your followers."; 113 | } 114 | else { 115 | $query = $GLOBALS['db']->query("SELECT topic_class, topic_by, topic_special FROM topics WHERE topic_id=".$msg['n']); 116 | $top = $query->fetch(PDO::FETCH_ASSOC); 117 | if (($top['topic_special'] >= 2) && ($top['topic_by'] != $ses['user_id'])) // both lock and hidden 118 | return "Currently the topic is locked (only its author can reply)."; 119 | if ($top['topic_special'] == 4) 120 | $is_hidden_post = true; 121 | } 122 | $query = $GLOBALS['db']->prepare("INSERT INTO posts(post_text,post_date,post_by,post_topic,post_root,post_ip) VALUES(?,NOW(),?,?,?,'".$conn->remoteAddress."')"); 123 | $ttopic = ($msg['n'] > 0) ? ($msg['n']) : (NULL); 124 | $query->execute(array($msg['text'], $ses['user_id'], $ttopic, $msg['n'])); 125 | if ($query->rowCount() < 1) 126 | { 127 | return 'Cannot add post.'; 128 | } 129 | if ($msg['n'] > 0) 130 | { 131 | $GLOBALS['db']->query('UPDATE topics SET topic_replies = topic_replies + 1 WHERE topic_id = '.$msg['n']); 132 | $shall_bump = true; 133 | if (isset($msg['s'])) $shall_bump = false; 134 | if (($ses['user_level'] < 0) && ($top['topic_class'] == 0)) $shall_bump = false; 135 | if ($shall_bump) 136 | { 137 | if (!$already_replied) 138 | { 139 | if ($ses['user_level'] >= 999999) 140 | $GLOBALS['db']->query("UPDATE topics SET topic_score = UNIX_TIMESTAMP(NOW()) WHERE ((topic_id = ".$msg['n'].") AND (topic_special <> 1))"); 141 | else 142 | $GLOBALS['db']->query("UPDATE topics SET topic_score = GREATEST((topic_score + UNIX_TIMESTAMP(NOW())) / 2, UNIX_TIMESTAMP(NOW()) - 3600) WHERE ((topic_id = ".$msg['n'].") AND (topic_special <> 1))"); 143 | } 144 | else 145 | { 146 | $GLOBALS['db']->query("UPDATE topics SET topic_score = GREATEST(topic_score, UNIX_TIMESTAMP(NOW()) - 7200) WHERE ((topic_id = ".$msg['n'].") AND (topic_special <> 1))"); 147 | } 148 | } 149 | } 150 | else if ($ses['user_id'] != -$msg['n']) 151 | { 152 | $GLOBALS['db']->query("UPDATE users SET user_posts = user_posts + 1 WHERE user_id = ".(-$msg['n'])); 153 | } 154 | } 155 | $GLOBALS['db']->query("UPDATE users SET user_posts = user_posts + 1, user_lastpost = NOW() WHERE user_id = ".$ses['user_id']); 156 | 157 | if ($is_hidden_post) 158 | $GLOBALS['db']->query("UPDATE users SET user_hidposts = user_hidposts + 1 WHERE user_id = ".$ses['user_id']); 159 | 160 | if ($topic_class == 0) { 161 | if ($msg['n'] >= 0) { // not to users 162 | ob_start(); 163 | post_get('', '', '', 30, '', 0, -1, -1); 164 | $threads_list = ob_get_contents(); 165 | ob_end_clean(); 166 | $GLOBALS['mcache']->set('pivory.threads.list', $threads_list); 167 | $succ = 1; // send global msg to everyone 168 | } 169 | } else { 170 | $succ = -1; // send only to OP 171 | } 172 | return 'SUCCESS'.$msg['n']; 173 | } 174 | else if (($msg['a'] == 'xmo') && (is_numeric($msg['n']))) { 175 | $ses = fetchses($conn); 176 | if (!isset($ses['user_id'])) return info_Log(); 177 | if ($ses['user_id'] <= 0) return info_Log(); 178 | if ($ses['user_level'] < 999999) return "Access denied."; 179 | if ($msg['n'] > 0) 180 | $query = $GLOBALS['db']->query('UPDATE topics SET topic_class = 1 WHERE topic_id = '.$msg['n']); 181 | else 182 | $query = $GLOBALS['db']->query('UPDATE topics SET topic_class = 0 WHERE topic_id = '.(-$msg['n'])); 183 | 184 | ob_start(); 185 | post_get('', '', '', 30, '', 0, -1, -1); 186 | $threads_list = ob_get_contents(); 187 | ob_end_clean(); 188 | $GLOBALS['mcache']->set('pivory.threads.list', $threads_list); 189 | 190 | $succ = 2; // send not to OP. only to everyone else. otherwise OP got a refreshing NAV bad for work 191 | if ($query->rowCount() < 1) return 'Error.'; 192 | return 'SUCCESS'; 193 | } 194 | } 195 | 196 | class WS_SERVER implements MessageComponentInterface { 197 | 198 | public function __construct() { 199 | } 200 | 201 | public function onOpen(ConnectionInterface $conn) { 202 | debug('open'); 203 | $ses = fetchses($conn); 204 | if (isset($ses['user_level'])) { 205 | $GLOBALS['clients']->attach($conn, $GLOBALS['dddd']->getTimestamp()); 206 | } 207 | } 208 | 209 | public function onClose(ConnectionInterface $conn) { 210 | debug('close'); 211 | $GLOBALS['clients']->detach($conn); 212 | } 213 | 214 | public function onError(ConnectionInterface $conn, \Exception $e) { 215 | debug('err '.e); 216 | $conn->close(); 217 | } 218 | 219 | public function onMessage(ConnectionInterface $conn, $msg) { 220 | debug('msg '.$msg); 221 | if (!$GLOBALS['clients']->contains($conn)) return; 222 | if ($msg == '.') { 223 | $GLOBALS['clients'][$conn] = $GLOBALS['dddd']->getTimestamp(); 224 | return; 225 | } 226 | $msg = json_decode($msg, true); 227 | $succ = 0; 228 | $conn->send($msg['id'].','.process($conn, $msg, $succ)); 229 | if ($succ > 0) $GLOBALS['job_new_thread']->attach($conn, $succ); 230 | } 231 | } 232 | 233 | $loop = React\EventLoop\Factory::create(); 234 | $socket = new React\Socket\Server('0.0.0.0:8080', $loop); 235 | 236 | $loop->addPeriodicTimer(1, function () { 237 | // kill hanging 238 | $now = $GLOBALS['dddd']->getTimestamp(); 239 | foreach ($GLOBALS['clients'] as $client) { 240 | if ($now - $GLOBALS['clients'][$client] > 130) { 241 | $client->close(); 242 | } 243 | } 244 | // send client count 245 | $cur_cnt = $GLOBALS['clients']->count(); 246 | if ($cur_cnt != $GLOBALS['job_last_usr_count']) { 247 | foreach ($GLOBALS['clients'] as $client) { 248 | $client->send('-3,'.$cur_cnt); 249 | } 250 | } 251 | $GLOBALS['job_last_usr_count'] = $cur_cnt; 252 | // send new thread 253 | if ($GLOBALS['job_new_thread']->count() > 0) { 254 | foreach ($GLOBALS['clients'] as $client) { 255 | $tttt = -2; 256 | if ($GLOBALS['job_new_thread']->contains($client)) { 257 | if ($GLOBALS['job_new_thread'][$client] == 1) $tttt = -1; 258 | $GLOBALS['job_new_thread']->detach($client); 259 | } 260 | $client->send($tttt.','.$GLOBALS['mcache']->get('pivory.threads.list')); 261 | } 262 | } 263 | }); 264 | 265 | $GLOBALS['server'] = new IoServer(new HttpServer(new WsServer(new WS_SERVER())), $socket, $loop); 266 | $GLOBALS['server']->run(); 267 | ?> 268 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | var $user_css="'; 15 | $shall_default = true; 16 | if ($_SESSION['user_id'] > 0) 17 | { 18 | $query = $GLOBALS['db']->query("SELECT user_css FROM users WHERE user_id = ".$_SESSION['user_id']); 19 | $row = $query->fetch(PDO::FETCH_ASSOC); 20 | if ($row['user_css'] != '') { $shall_default = false; echo $row['user_css']; } 21 | } 22 | if ($shall_default) echo '024034'; 23 | //if ($shall_default) echo '032034'; 24 | echo '";'; 25 | ?> 26 |
27 |
28 |
29 |
30 |
31 |
32 | Project Ivory 33 | 34 | 35 |
36 | 37 | 38 |
39 | sign up 40 |
41 |
42 | Project Ivory 43 | 44 | 45 |
46 | sign in 47 |
48 |
49 | 114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
Home
123 |
Create
124 |
...
125 |
126 | 128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | 138 | 139 | 140 | 141 | 142 | 143 |
DefaultCambriaVerdanaCorbelConsolas
11px12px13px14px15px16px
1.31.41.51.61.71.8
Wide-CornerPane-Switch
Save
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
'.$_SESSION['user_name']; ?>
157 |
158 |
159 |
160 |
161 |
162 | 163 |
164 |
165 |
166 | 167 | 175 |
176 |
177 | -------------------------------------------------------------------------------- /post_db.php: -------------------------------------------------------------------------------- 1 | get('pivory.threads.list'); 15 | if ($threads_list == '') { 16 | ob_start(); 17 | post_get('', '', '', 30, '', 0, -1, -1); 18 | $threads_list = ob_get_contents(); 19 | ob_end_clean(); 20 | $GLOBALS['mcache']->set('pivory.threads.list', $threads_list); 21 | } 22 | echo $threads_list; die(); 23 | } 24 | else if ($_POST['a'] == 'get') 25 | { 26 | if (!isset($_POST['n'])) $_POST['n'] = ''; 27 | if (!isset($_POST['begin'])) $_POST['begin'] = ''; 28 | 29 | $tmp = explode('_', $_POST['n']); 30 | $_POST['n'] = $tmp[0]; 31 | if (isset($tmp[1])) $user = $tmp[1]; else $user = ''; 32 | 33 | $type = ''; 34 | $topic = ''; 35 | if (empty($_POST['n'])) 36 | { 37 | $type = ''; 38 | $topic = ''; 39 | } 40 | else if (is_numeric($_POST['n'])) 41 | { 42 | $type = ''; 43 | $topic = $_POST['n']; 44 | } 45 | else 46 | { 47 | $type = substr($_POST['n'], 0, 1); 48 | $xdetail = substr($_POST['n'], 1); 49 | if (($type == 'a') || ($type == 'b') || ($type == 'c') || ($type == 't')) 50 | { 51 | $topic = $xdetail; 52 | } 53 | else if (is_numeric($xdetail) || (empty($xdetail))) 54 | { 55 | $topic = $xdetail; 56 | } 57 | else 58 | { 59 | die(); 60 | } 61 | } 62 | /*$limit = 10; 63 | if (($type == 'u') && (is_numeric($topic))) 64 | $limit = 10; 65 | else if (($type == '') && (is_numeric($topic))) 66 | $limit = 10; 67 | else 68 | $limit = 10;*/ 69 | $limit = 30; 70 | if (!empty($_POST['limit'])) $limit = min($limit, $_POST['limit']); 71 | if ((empty($_POST['begin']) || is_numeric($_POST['begin']))) 72 | { 73 | if (isset($_POST['r'])) $anchor = isset($_POST['r']); else $anchor = 0; 74 | post_get($type, $topic, $_POST['begin'], $limit, $user, $anchor, $_SESSION['user_id'], $_SESSION['user_level']); die(); 75 | } 76 | } 77 | else if (($_POST['a'] == 'qrx') && is_numeric($_POST['n'])) 78 | { 79 | $query = $db->query("SELECT post_text FROM posts WHERE post_id = ".$_POST['n']); 80 | if ($query->rowCount() == 1) 81 | { 82 | $row = $query->fetch(PDO::FETCH_ASSOC); 83 | die($row['post_text']); 84 | } 85 | die(); 86 | } 87 | else if (($_POST['a'] == 'xou') && is_numeric($_POST['n'])) 88 | { 89 | if ($_SESSION['user_id'] <= 0) die_Log(); 90 | if ($_SESSION['user_level'] == -1) die_Log(); 91 | 92 | if ($_SESSION['user_id'] == 1) 93 | { 94 | $_POST['text'] = mynl2br($_POST['text']); 95 | } 96 | else 97 | { 98 | $mm = verifyText($_POST['text']); 99 | if ($mm != '') die($mm); 100 | $_POST['text'] = mynl2br(htmlspecialchars($_POST['text'])); 101 | } 102 | if ($_POST['n'] > 0) 103 | { // admin editing could be dangerous, cause may active XSS !!! 104 | /*if ($_SESSION['user_id'] == 1) 105 | $query = $db->prepare("UPDATE posts SET post_text = ?, post_edit = NOW() WHERE post_id = ".$_POST['n']); 106 | else*/ 107 | $query = $db->prepare("UPDATE posts SET post_text = ?, post_edit = NOW() WHERE post_id = ".$_POST['n']." AND post_by = ".$_SESSION['user_id']); 108 | } 109 | else 110 | { 111 | /*if ($_SESSION['user_id'] == 1) 112 | $query = $db->prepare("UPDATE topics SET topic_title = ? WHERE topic_id = ".(-$_POST['n'])); 113 | else*/ 114 | $query = $db->prepare("UPDATE topics SET topic_title = ? WHERE topic_id = ".(-$_POST['n'])." AND topic_by = ".$_SESSION['user_id']); 115 | } 116 | $query->execute(array($_POST['text'])); 117 | if ($query->rowCount() < 1) 118 | { 119 | die('Access denied or not modified. However "EDIT" can be used for reading source codes of posts.'); 120 | } 121 | die('SUCCESS'.$_POST['text']); 122 | } 123 | else if (($_POST['a'] == 'xfo') && is_numeric($_POST['n'])) 124 | { 125 | $targ = abs($_POST['n']); 126 | $sign = ($_POST['n'] > 0) ? (1) : (-1); 127 | if ($sign == 1) 128 | { 129 | $query = $db->query("INSERT INTO follow(follow_a, follow_b) VALUES(".$_SESSION['user_id'].",$targ)"); 130 | } 131 | else 132 | { 133 | $query = $db->query("DELETE FROM follow WHERE (follow_a = ".$_SESSION['user_id']." AND follow_b = $targ)"); 134 | } 135 | if ($query->rowCount() > 0) // only change if really changed 136 | { 137 | $db->query("UPDATE users SET user_following = user_following + ($sign) WHERE user_id = ".$_SESSION['user_id'].";". 138 | "UPDATE users SET user_followers = user_followers + ($sign) WHERE user_id = $targ"); 139 | $query = $db->query("SELECT user_followers FROM users WHERE user_id = $targ"); 140 | $row = $query->fetch(PDO::FETCH_ASSOC); 141 | die($row['user_followers']); 142 | } 143 | } 144 | else if ($_POST['a'] == 'xta') 145 | { 146 | $xa = $_SESSION['user_id']; 147 | $xb = substr($_POST['n'], 0, strpos($_POST['n'], '_')); 148 | $xc = substr($_POST['n'], strpos($_POST['n'], '_') + 1); 149 | if ((!is_numeric($xa)) || (!is_numeric($xb)) || (!is_numeric($xc))) die('-1'); 150 | if ($xc > 0) 151 | { 152 | $query = $db->query("INSERT INTO list2top (id_by, id_topic, id_list) VALUES($xa, $xb, $xc)"); 153 | if ($query->rowCount() > 0) 154 | { 155 | $db->query("UPDATE lists SET list_cnt = list_cnt + 1 WHERE list_id = $xc" 156 | .";UPDATE lists SET list_date = NOW() WHERE list_id = $xc"); 157 | die('1'); 158 | } 159 | } 160 | else 161 | { 162 | $xc = -$xc; 163 | $query = $db->query("DELETE FROM list2top WHERE (id_by = $xa AND id_topic = $xb AND id_list = $xc)"); 164 | if ($query->rowCount() > 0) 165 | { 166 | $db->query("UPDATE lists SET list_cnt = list_cnt - 1 WHERE list_id = $xc"); 167 | die('1'); 168 | } 169 | } 170 | die('0'); 171 | } 172 | else if (($_POST['a'] == 'xxl') || ($_POST['a'] == 'xxe') || ($_POST['a'] == 'xxm') || ($_POST['a'] == 'xxh')) 173 | { 174 | if ($_SESSION['user_id'] <= 0) die_Log(); 175 | if ($_SESSION['user_level'] == -1) die_Log(); 176 | $_POST['title'] = htmlspecialchars($_POST['title']); 177 | $ll = ($_POST['a'] == 'xxh') ? (100) : (50); 178 | $_POST['title'] = substr(trim(strtr($_POST['title'], '^', ' ')), 0, $ll); 179 | $tt = 'user_location'; 180 | if ($_POST['a'] == 'xxe') $tt = 'user_education'; 181 | else if ($_POST['a'] == 'xxm') $tt = 'user_major'; 182 | else if ($_POST['a'] == 'xxh') $tt = 'user_hobby'; 183 | $query = $db->prepare('UPDATE users SET '.$tt.' = ? WHERE user_id ='.$_SESSION['user_id']); 184 | $query->execute(array($_POST['title'])); 185 | die($_POST['title']); 186 | } 187 | else if (($_POST['a'] == 'q01') && is_numeric($_POST['n']) && is_numeric($_POST['begin'])) 188 | { 189 | if ($_POST['begin'] > 0) 190 | $query = $db->query('SELECT post_id FROM posts WHERE post_topic = '.$_POST['n'].' AND post_by = '.$_POST['begin'] 191 | .' ORDER BY post_date DESC LIMIT 1'); 192 | else 193 | $query = $db->query('SELECT post_id FROM posts WHERE post_topic = '.$_POST['n'].' AND post_by = '.(-$_POST['begin']) 194 | .' ORDER BY post_date ASC LIMIT 1'); 195 | if ($query->rowCount() > 0) 196 | { 197 | $top = $query->fetch(PDO::FETCH_ASSOC); 198 | die($top['post_id']); 199 | } 200 | die('0'); 201 | } 202 | else if ($_POST['a'] == 'nli') 203 | { 204 | if ($_SESSION['user_id'] <= 0) die_Log(); 205 | if ($_SESSION['user_level'] == -1) die_Log(); 206 | 207 | $_POST['title'] = trim($_POST['title']); 208 | $_POST['title'] = htmlspecialchars($_POST['title']); 209 | $title_len = mb_strlen($_POST['title'],'UTF8'); 210 | if (($title_len < 1) || ($title_len > 100)) 211 | { 212 | die('List name length shall be in [1, 100].'); 213 | } 214 | 215 | $query = $db->prepare("INSERT INTO lists(list_name, list_by, list_date, list_cnt) VALUES(?,?,NOW(),0)"); 216 | $query->execute(array($_POST['title'], $_SESSION['user_id'])); 217 | if ($query->rowCount() < 1) 218 | { 219 | die('Cannot add list.'); 220 | } 221 | die('SUCCESS'); 222 | } 223 | else if (($_POST['a'] == 'dpo') && is_numeric($_POST['n'])) 224 | { 225 | if ($_SESSION['user_id'] <= 0) die_Log(); 226 | if ($_SESSION['user_level'] == -1) die_Log(); 227 | 228 | $query = $db->query('SELECT post_topic, post_by, post_root, topic_special FROM posts LEFT JOIN topics ON post_root = topic_id WHERE post_id = '.$_POST['n']); 229 | $pos = $query->fetch(PDO::FETCH_ASSOC); 230 | if ($pos['post_topic'] > 0) 231 | { 232 | if (($_SESSION['user_id'] == 1) || ($pos['post_by'] == $_SESSION['user_id'])) 233 | { 234 | $db->query('DELETE FROM posts WHERE post_id = '.$_POST['n'].';' 235 | .'UPDATE topics SET topic_replies = topic_replies - 1 WHERE topic_id = '.$pos['post_topic'].';' 236 | .'UPDATE users SET user_posts = user_posts - 1 WHERE user_id = '.$pos['post_by']); 237 | } 238 | else 239 | { 240 | $query = $db->query('SELECT topic_by FROM topics WHERE topic_id = '.$pos['post_topic']); 241 | $ppp = $query->fetch(PDO::FETCH_ASSOC); 242 | if ($ppp['topic_by'] == $_SESSION['user_id']) 243 | { 244 | $db->query('UPDATE posts SET post_topic = NULL, post_root = 0 WHERE post_id = '.$_POST['n'].';' 245 | .'UPDATE topics SET topic_replies = topic_replies - 1 WHERE topic_id = '.$pos['post_topic']); 246 | } 247 | else { 248 | die('Access denied.'); 249 | } 250 | } 251 | } 252 | else if ($pos['post_root'] < 0) 253 | { 254 | if ($pos['post_by'] == $_SESSION['user_id']) 255 | { 256 | $db->query('DELETE FROM posts WHERE post_id = '.$_POST['n'].';' 257 | .'UPDATE users SET user_posts = user_posts - 1 WHERE user_id = '.$pos['post_by']); 258 | if ((-$pos['post_root']) != $pos['post_by']) 259 | { 260 | $db->query('UPDATE users SET user_posts = user_posts - 1 WHERE user_id = '.(-$pos['post_root'])); 261 | } 262 | } 263 | else if ($pos['post_root'] == (-$_SESSION['user_id'])) 264 | { 265 | $db->query('UPDATE posts SET post_topic = NULL, post_root = 0 WHERE post_id = '.$_POST['n'].';' 266 | .'UPDATE users SET user_posts = user_posts - 1 WHERE user_id = '.(-$pos['post_root'])); 267 | } 268 | else { 269 | die('Access denied.'); 270 | } 271 | } 272 | else if ($pos['post_root'] == 0) 273 | { 274 | if ($pos['post_by'] == $_SESSION['user_id']) 275 | { 276 | $db->query('DELETE FROM posts WHERE post_id = '.$_POST['n'].';' 277 | .'UPDATE users SET user_posts = user_posts - 1 WHERE user_id = '.$pos['post_by']); 278 | } 279 | else { 280 | die('Access denied.'); 281 | } 282 | } else { 283 | die(); 284 | } 285 | if ($pos['topic_special'] == 4) { 286 | $db->query('UPDATE users SET user_hidposts = user_hidposts - 1 WHERE user_id = '.$pos['post_by']); 287 | } 288 | die('SUCCESS'); 289 | } 290 | else if (($_POST['a'] == 'mod') && is_numeric($_POST['n'])) 291 | { 292 | if ($_SESSION['user_id'] <= 0) die_Log(); 293 | if ($_SESSION['user_level'] < 999) die('Meow.'); 294 | $db->query('UPDATE posts SET post_topic = 1195, post_root = 1195 WHERE post_id = '.$_POST['n']); 295 | } 296 | else if (($_POST['a'] == 'xli') && is_numeric($_POST['n'])) 297 | { 298 | if ($_SESSION['user_id'] <= 0) die_Log(); 299 | 300 | if (isset($_POST['title'])) 301 | { 302 | $_POST['title'] = htmlspecialchars($_POST['title']); 303 | $_POST['title'] = trim($_POST['title']); 304 | $title_len = mb_strlen($_POST['title'],'UTF8'); 305 | if (($title_len < 1) || ($title_len > 100)) 306 | { 307 | die('List name length shall be in [1, 100].'); 308 | } 309 | 310 | $query = $db->prepare("UPDATE lists SET list_name = ? WHERE list_id = ".$_POST['n']." AND list_by = ".$_SESSION['user_id']); 311 | $query->execute(array($_POST['title'])); 312 | if ($query->rowCount() < 1) 313 | { 314 | die('Access denied or not modified.'); 315 | } 316 | die('SUCCESS'.$_POST['title']); 317 | } 318 | else 319 | { 320 | $query = $db->query("DELETE FROM lists WHERE list_id = ".$_POST['n']." AND list_by = ".$_SESSION['user_id']); 321 | if ($query->rowCount() < 1) 322 | { 323 | die('Access denied.'); 324 | } 325 | die('SUCCESS'); 326 | } 327 | } 328 | else if (($_POST['a'] == 'xhi') && is_numeric($_POST['n'])) 329 | { 330 | if ($_SESSION['user_id'] <= 0) die_Log(); 331 | if ($_SESSION['user_level'] == -1) die_Log(); 332 | 333 | $thi = ($_POST['n'] > 0) ? 4 : 0; 334 | $tht = abs($_POST['n']); 335 | 336 | if (($thi > 0) && ($_SESSION['user_level'] == -1)) die_Log(); 337 | 338 | $query = $db->query("SELECT topic_special, topic_by FROM topics WHERE topic_id = $tht AND topic_by = ".$_SESSION['user_id']); 339 | if ($query->rowCount() < 1) 340 | { 341 | die(); 342 | } 343 | $row = $query->fetch(PDO::FETCH_ASSOC); 344 | if ($row['topic_special'] != $thi) 345 | { 346 | $db->query("UPDATE topics SET topic_special = $thi WHERE topic_id = $tht"); 347 | 348 | $db->query("UPDATE users SET user_hidposts=user_hidposts".(($thi==0)?('-'):('+')) 349 | .'(1+(SELECT COUNT(*) FROM posts WHERE posts.post_topic = '.$tht.' AND posts.post_by = '.$_SESSION['user_id'] 350 | .')) WHERE user_id='.$_SESSION['user_id']); 351 | } 352 | die('s'.$thi); 353 | } 354 | else if (($_POST['a'] == 'xlo') && is_numeric($_POST['n'])) 355 | { 356 | if ($_SESSION['user_id'] <= 0) die_Log(); 357 | if ($_SESSION['user_level'] == -1) die_Log(); 358 | 359 | $thi = ($_POST['n'] > 0) ? 2 : 0; 360 | $tht = abs($_POST['n']); 361 | 362 | if (($thi > 0) && ($_SESSION['user_level'] == -1)) die_Log(); 363 | 364 | $db->query("UPDATE topics SET topic_special = $thi WHERE topic_id = $tht AND topic_by = ".$_SESSION['user_id']); 365 | die('s'.$thi); 366 | } 367 | else if (($_POST['a'] == 'css') && (strlen($_POST['n']) < 20)) 368 | { 369 | if ($_SESSION['user_id'] <= 0) die_Log(); 370 | if ($_SESSION['user_level'] == -1) die_Log(); 371 | 372 | $query = $db->prepare("UPDATE users SET user_css = ? WHERE user_id = ".$_SESSION['user_id']); 373 | $query->execute(array($_POST['n'])); 374 | die('Saved.'); 375 | } 376 | else 377 | { 378 | die('Something is wrong.'); 379 | } 380 | ?> -------------------------------------------------------------------------------- /prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=!0;var prettyPrintOne,prettyPrint;(function(){function A(e){function a(e){var t=e.charCodeAt(0);if(t!==92)return t;var n=e.charAt(1);return t=u[n],t?t:"0"<=n&&n<="7"?parseInt(e.substring(1),8):n==="u"||n==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function f(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);var t=String.fromCharCode(e);return t==="\\"||t==="-"||t==="]"||t==="^"?"\\"+t:t}function l(e){var t=e.substring(1,e.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),n=[],r=t[0]==="^",i=["["];r&&i.push("^");for(var s=r?1:0,o=t.length;s122||(c<65||l>90||n.push([Math.max(65,l)|32,Math.min(c,90)|32]),c<97||l>122||n.push([Math.max(97,l)&-33,Math.min(c,122)&-33]))}}n.sort(function(e,t){return e[0]-t[0]||t[1]-e[1]});var h=[],p=[];for(var s=0;sd[0]&&(d[1]+1>d[0]&&i.push("-"),i.push(f(d[1])))}return i.push("]"),i.join("")}function c(e){var r=e.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),i=r.length,s=[];for(var o=0,u=0;o=2&&h==="["?r[o]=l(a):h!=="\\"&&(r[o]=a.replace(/[a-zA-Z]/g,function(e){var t=e.charCodeAt(0);return"["+String.fromCharCode(t&-33,t|32)+"]"}))}return r.join("")}var t=0,n=!1,r=!1;for(var i=0,s=e.length;i=0;)n[l.charAt(c)]=f;var h=f[1],p=""+h;o.hasOwnProperty(p)||(s.push(h),o[p]=null)}s.push(/[\0-\uffff]/),r=A(s)})();var i=t.length,s=function(e){var o=e.sourceCode,u=e.basePos,a=[u,E],f=0,l=o.match(r)||[],c={};for(var h=0,p=l.length;h=5&&"lang-"===v.substring(0,5),g&&(!m||typeof m[1]!="string")&&(g=!1,v=T),g||(c[d]=v)}var w=f;f+=d.length;if(!g)a.push(u+w,v);else{var S=m[1],x=d.indexOf(S),N=x+S.length;m[2]&&(N=d.length-m[2].length,x=N-S.length);var C=v.substring(5);M(u+w,d.substring(0,x),s,a),M(u+w+x,S,R(C,S),a),M(u+w+N,d.substring(N),s,a)}}e.decorations=a};return s}function H(e){var t=[],n=[];e.tripleQuotedStrings?t.push([v,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):e.multiLineStrings?t.push([v,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):t.push([v,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),e.verbatimStrings&&n.push([v,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var r=e.hashComments;r&&(e.cStyleComments?(r>1?t.push([g,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):t.push([g,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),n.push([v,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):t.push([g,/^#[^\r\n]*/,null,"#"])),e.cStyleComments&&(n.push([g,/^\/\/[^\r\n]*/,null]),n.push([g,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));if(e.regexLiterals){var i="/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/";n.push(["lang-regex",new RegExp("^"+L+"("+i+")")])}var s=e.types;s&&n.push([y,s]);var o=(""+e.keywords).replace(/^ | $/g,"");o.length&&n.push([m,new RegExp("^(?:"+o.replace(/[\s,]+/g,"|")+")\\b"),null]),t.push([E,/^\s+/,null," \r\n \u00a0"]);var u=/^.[^\s\w\.$@\'\"\`\/\\]*/;return n.push([b,/^@[a-z_$][a-z_$@0-9]*/i,null],[y,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[E,/^[a-z_$][a-z_$@0-9]*/i,null],[b,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[E,/^\\[\s\S]?/,null],[w,u,null]),P(t,n)}function j(e,t,n){function a(e){switch(e.nodeType){case 1:if(r.test(e.className))break;if("br"===e.nodeName)f(e),e.parentNode&&e.parentNode.removeChild(e);else for(var t=e.firstChild;t;t=t.nextSibling)a(t);break;case 3:case 4:if(n){var o=e.nodeValue,u=o.match(i);if(u){var l=o.substring(0,u.index);e.nodeValue=l;var c=o.substring(u.index+u[0].length);if(c){var h=e.parentNode;h.insertBefore(s.createTextNode(c),e.nextSibling)}f(e),l||e.parentNode.removeChild(e)}}}}function f(e){function t(e,n){var r=n?e.cloneNode(!1):e,i=e.parentNode;if(i){var s=t(i,1),o=e.nextSibling;s.appendChild(r);for(var u=o;u;u=o)o=u.nextSibling,s.appendChild(u)}return r}while(!e.nextSibling){e=e.parentNode;if(!e)return}var n=t(e.nextSibling,0);for(var r;(r=n.parentNode)&&r.nodeType===1;)n=r;u.push(n)}var r=/(?:^|\s)nocode(?:\s|$)/,i=/\r\n?|\n/,s=e.ownerDocument,o=s.createElement("li");while(e.firstChild)o.appendChild(e.firstChild);var u=[o];for(var l=0;l=E&&(a+=2),s>=S&&(c+=2)}}finally{g&&(g.style.display=y)}}function q(t,n){for(var r=n.length;--r>=0;){var i=n[r];I.hasOwnProperty(i)?e.console&&console.warn("cannot override language handler %s",i):I[i]=t}}function R(e,t){if(!e||!I.hasOwnProperty(e))e=/^\s*|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*",_=/\S/,B=H({keywords:p,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),I={};q(B,["default-code"]),q(P([],[[E,/^[^]*(?:>|$)/],[g,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[w,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),q(P([[E,/^[\s]+/,null," \r\n"],[C,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[S,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[N,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[w,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),q(P([],[[C,/^[\s\S]+/]]),["uq.val"]),q(H({keywords:i,hashComments:!0,cStyleComments:!0,types:d}),["c","cc","cpp","cxx","cyc","m"]),q(H({keywords:"null,true,false"}),["json"]),q(H({keywords:o,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:d}),["cs"]),q(H({keywords:s,cStyleComments:!0}),["java"]),q(H({keywords:h,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]),q(H({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py"]),q(H({keywords:f,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]),q(H({keywords:c,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]),q(H({keywords:a,cStyleComments:!0,regexLiterals:!0}),["js"]),q(H({keywords:u,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),q(P([],[[v,/^[\s\S]+/]]),["regex"]);var X=e.PR={createSimpleLexer:P,registerLangHandler:q,sourceDecorator:H,PR_ATTRIB_NAME:N,PR_ATTRIB_VALUE:C,PR_COMMENT:g,PR_DECLARATION:x,PR_KEYWORD:m,PR_LITERAL:b,PR_NOCODE:k,PR_PLAIN:E,PR_PUNCTUATION:w,PR_SOURCE:T,PR_STRING:v,PR_TAG:S,PR_TYPE:y,prettyPrintOne:e.prettyPrintOne=z,prettyPrint:e.prettyPrint=W};typeof define=="function"&&define.amd&&define("google-code-prettify",[],function(){return X})})() -------------------------------------------------------------------------------- /font-awesome.css: -------------------------------------------------------------------------------- 1 | /* Font Awesome 2 | the iconic font designed for use with Twitter Bootstrap 3 | ------------------------------------------------------- 4 | The full suite of pictographic icons, examples, and documentation 5 | can be found at: http://fortawesome.github.com/Font-Awesome/ 6 | 7 | License 8 | ------------------------------------------------------- 9 | The Font Awesome webfont, CSS, and LESS files are licensed under CC BY 3.0: 10 | http://creativecommons.org/licenses/by/3.0/ A mention of 11 | 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in human-readable 12 | source code is considered acceptable attribution (most common on the web). 13 | If human readable source code is not available to the end user, a mention in 14 | an 'About' or 'Credits' screen is considered acceptable (most common in desktop 15 | or mobile software). 16 | 17 | Contact 18 | ------------------------------------------------------- 19 | Email: dave@davegandy.com 20 | Twitter: http://twitter.com/fortaweso_me 21 | Work: http://lemonwi.se co-founder 22 | 23 | */ 24 | @font-face { 25 | font-family: "FontAwesome"; 26 | src: url('font/fontawesome-webfont.eot'); 27 | src: url('font/fontawesome-webfont.eot?#iefix') format('eot'), url('font/fontawesome-webfont.woff') format('woff'), 28 | url('font/fontawesome-webfont.ttf') format('truetype'), url('font/fontawesome-webfont.svg#FontAwesome') format('svg'); 29 | font-weight: normal; 30 | font-style: normal; 31 | } 32 | 33 | /* Font Awesome styles 34 | ------------------------------------------------------- */ 35 | [class^="icon-"]:before, [class*=" icon-"]:before { 36 | font-family: FontAwesome; 37 | font-weight: normal; 38 | font-style: normal; 39 | display: inline-block; 40 | text-decoration: inherit; 41 | } 42 | a [class^="icon-"], a [class*=" icon-"] { 43 | display: inline-block; 44 | text-decoration: inherit; 45 | } 46 | /* makes the font 33% larger relative to the icon container */ 47 | .icon-large:before { 48 | vertical-align: top; 49 | font-size: 1.3333333333333333em; 50 | } 51 | .btn [class^="icon-"], .btn [class*=" icon-"] { 52 | /* keeps button heights with and without icons the same */ 53 | 54 | line-height: .9em; 55 | } 56 | li [class^="icon-"], li [class*=" icon-"] { 57 | display: inline-block; 58 | width: 1.25em; 59 | text-align: center; 60 | } 61 | li .icon-large[class^="icon-"], li .icon-large[class*=" icon-"] { 62 | /* 1.5 increased font size for icon-large * 1.25 width */ 63 | 64 | width: 1.875em; 65 | } 66 | li[class^="icon-"], li[class*=" icon-"] { 67 | margin-left: 0; 68 | list-style-type: none; 69 | } 70 | li[class^="icon-"]:before, li[class*=" icon-"]:before { 71 | text-indent: -2em; 72 | text-align: center; 73 | } 74 | li[class^="icon-"].icon-large:before, li[class*=" icon-"].icon-large:before { 75 | text-indent: -1.3333333333333333em; 76 | } 77 | /* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen 78 | readers do not read off random characters that represent icons */ 79 | .icon-glass:before { content: "\f000"; } 80 | .icon-music:before { content: "\f001"; } 81 | .icon-search:before { content: "\f002"; } 82 | .icon-envelope:before { content: "\f003"; } 83 | .icon-heart:before { content: "\f004"; } 84 | .icon-star:before { content: "\f005"; } 85 | .icon-star-empty:before { content: "\f006"; } 86 | .icon-user:before { content: "\f007"; } 87 | .icon-film:before { content: "\f008"; } 88 | .icon-th-large:before { content: "\f009"; } 89 | .icon-th:before { content: "\f00a"; } 90 | .icon-th-list:before { content: "\f00b"; } 91 | .icon-ok:before { content: "\f00c"; } 92 | .icon-remove:before { content: "\f00d"; } 93 | .icon-zoom-in:before { content: "\f00e"; } 94 | 95 | .icon-zoom-out:before { content: "\f010"; } 96 | .icon-off:before { content: "\f011"; } 97 | .icon-signal:before { content: "\f012"; } 98 | .icon-cog:before { content: "\f013"; } 99 | .icon-trash:before { content: "\f014"; } 100 | .icon-home:before { content: "\f015"; } 101 | .icon-file:before { content: "\f016"; } 102 | .icon-time:before { content: "\f017"; } 103 | .icon-road:before { content: "\f018"; } 104 | .icon-download-alt:before { content: "\f019"; } 105 | .icon-download:before { content: "\f01a"; } 106 | .icon-upload:before { content: "\f01b"; } 107 | .icon-inbox:before { content: "\f01c"; } 108 | .icon-play-circle:before { content: "\f01d"; } 109 | .icon-repeat:before { content: "\f01e"; } 110 | 111 | /* \f020 doesn't work in Safari. all shifted one down */ 112 | .icon-refresh:before { content: "\f021"; } 113 | .icon-list-alt:before { content: "\f022"; } 114 | .icon-lock:before { content: "\f023"; } 115 | .icon-flag:before { content: "\f024"; } 116 | .icon-headphones:before { content: "\f025"; } 117 | .icon-volume-off:before { content: "\f026"; } 118 | .icon-volume-down:before { content: "\f027"; } 119 | .icon-volume-up:before { content: "\f028"; } 120 | .icon-qrcode:before { content: "\f029"; } 121 | .icon-barcode:before { content: "\f02a"; } 122 | .icon-tag:before { content: "\f02b"; } 123 | .icon-tags:before { content: "\f02c"; } 124 | .icon-book:before { content: "\f02d"; } 125 | .icon-bookmark:before { content: "\f02e"; } 126 | .icon-print:before { content: "\f02f"; } 127 | 128 | .icon-camera:before { content: "\f030"; } 129 | .icon-font:before { content: "\f031"; } 130 | .icon-bold:before { content: "\f032"; } 131 | .icon-italic:before { content: "\f033"; } 132 | .icon-text-height:before { content: "\f034"; } 133 | .icon-text-width:before { content: "\f035"; } 134 | .icon-align-left:before { content: "\f036"; } 135 | .icon-align-center:before { content: "\f037"; } 136 | .icon-align-right:before { content: "\f038"; } 137 | .icon-align-justify:before { content: "\f039"; } 138 | .icon-list:before { content: "\f03a"; } 139 | .icon-indent-left:before { content: "\f03b"; } 140 | .icon-indent-right:before { content: "\f03c"; } 141 | .icon-facetime-video:before { content: "\f03d"; } 142 | .icon-picture:before { content: "\f03e"; } 143 | 144 | .icon-pencil:before { content: "\f040"; } 145 | .icon-map-marker:before { content: "\f041"; } 146 | .icon-adjust:before { content: "\f042"; } 147 | .icon-tint:before { content: "\f043"; } 148 | .icon-edit:before { content: "\f044"; } 149 | .icon-share:before { content: "\f045"; } 150 | .icon-check:before { content: "\f046"; } 151 | .icon-move:before { content: "\f047"; } 152 | .icon-step-backward:before { content: "\f048"; } 153 | .icon-fast-backward:before { content: "\f049"; } 154 | .icon-backward:before { content: "\f04a"; } 155 | .icon-play:before { content: "\f04b"; } 156 | .icon-pause:before { content: "\f04c"; } 157 | .icon-stop:before { content: "\f04d"; } 158 | .icon-forward:before { content: "\f04e"; } 159 | 160 | .icon-fast-forward:before { content: "\f050"; } 161 | .icon-step-forward:before { content: "\f051"; } 162 | .icon-eject:before { content: "\f052"; } 163 | .icon-chevron-left:before { content: "\f053"; } 164 | .icon-chevron-right:before { content: "\f054"; } 165 | .icon-plus-sign:before { content: "\f055"; } 166 | .icon-minus-sign:before { content: "\f056"; } 167 | .icon-remove-sign:before { content: "\f057"; } 168 | .icon-ok-sign:before { content: "\f058"; } 169 | .icon-question-sign:before { content: "\f059"; } 170 | .icon-info-sign:before { content: "\f05a"; } 171 | .icon-screenshot:before { content: "\f05b"; } 172 | .icon-remove-circle:before { content: "\f05c"; } 173 | .icon-ok-circle:before { content: "\f05d"; } 174 | .icon-ban-circle:before { content: "\f05e"; } 175 | 176 | .icon-arrow-left:before { content: "\f060"; } 177 | .icon-arrow-right:before { content: "\f061"; } 178 | .icon-arrow-up:before { content: "\f062"; } 179 | .icon-arrow-down:before { content: "\f063"; } 180 | .icon-share-alt:before { content: "\f064"; } 181 | .icon-resize-full:before { content: "\f065"; } 182 | .icon-resize-small:before { content: "\f066"; } 183 | .icon-plus:before { content: "\f067"; } 184 | .icon-minus:before { content: "\f068"; } 185 | .icon-asterisk:before { content: "\f069"; } 186 | .icon-exclamation-sign:before { content: "\f06a"; } 187 | .icon-gift:before { content: "\f06b"; } 188 | .icon-leaf:before { content: "\f06c"; } 189 | .icon-fire:before { content: "\f06d"; } 190 | .icon-eye-open:before { content: "\f06e"; } 191 | 192 | .icon-eye-close:before { content: "\f070"; } 193 | .icon-warning-sign:before { content: "\f071"; } 194 | .icon-plane:before { content: "\f072"; } 195 | .icon-calendar:before { content: "\f073"; } 196 | .icon-random:before { content: "\f074"; } 197 | .icon-comment:before { content: "\f075"; } 198 | .icon-magnet:before { content: "\f076"; } 199 | .icon-chevron-up:before { content: "\f077"; } 200 | .icon-chevron-down:before { content: "\f078"; } 201 | .icon-retweet:before { content: "\f079"; } 202 | .icon-shopping-cart:before { content: "\f07a"; } 203 | .icon-folder-close:before { content: "\f07b"; } 204 | .icon-folder-open:before { content: "\f07c"; } 205 | .icon-resize-vertical:before { content: "\f07d"; } 206 | .icon-resize-horizontal:before { content: "\f07e"; } 207 | 208 | .icon-bar-chart:before { content: "\f080"; } 209 | .icon-twitter-sign:before { content: "\f081"; } 210 | .icon-facebook-sign:before { content: "\f082"; } 211 | .icon-camera-retro:before { content: "\f083"; } 212 | .icon-key:before { content: "\f084"; } 213 | .icon-cogs:before { content: "\f085"; } 214 | .icon-comments:before { content: "\f086"; } 215 | .icon-thumbs-up:before { content: "\f087"; } 216 | .icon-thumbs-down:before { content: "\f088"; } 217 | .icon-star-half:before { content: "\f089"; } 218 | .icon-heart-empty:before { content: "\f08a"; } 219 | .icon-signout:before { content: "\f08b"; } 220 | .icon-linkedin-sign:before { content: "\f08c"; } 221 | .icon-pushpin:before { content: "\f08d"; } 222 | .icon-external-link:before { content: "\f08e"; } 223 | 224 | .icon-signin:before { content: "\f090"; } 225 | .icon-trophy:before { content: "\f091"; } 226 | .icon-github-sign:before { content: "\f092"; } 227 | .icon-upload-alt:before { content: "\f093"; } 228 | .icon-lemon:before { content: "\f094"; } 229 | .icon-phone:before { content: "\f095"; } 230 | .icon-check-empty:before { content: "\f096"; } 231 | .icon-bookmark-empty:before { content: "\f097"; } 232 | .icon-phone-sign:before { content: "\f098"; } 233 | .icon-twitter:before { content: "\f099"; } 234 | .icon-facebook:before { content: "\f09a"; } 235 | .icon-github:before { content: "\f09b"; } 236 | .icon-unlock:before { content: "\f09c"; } 237 | .icon-credit-card:before { content: "\f09d"; } 238 | .icon-rss:before { content: "\f09e"; } 239 | 240 | .icon-hdd:before { content: "\f0a0"; } 241 | .icon-bullhorn:before { content: "\f0a1"; } 242 | .icon-bell:before { content: "\f0a2"; } 243 | .icon-certificate:before { content: "\f0a3"; } 244 | .icon-hand-right:before { content: "\f0a4"; } 245 | .icon-hand-left:before { content: "\f0a5"; } 246 | .icon-hand-up:before { content: "\f0a6"; } 247 | .icon-hand-down:before { content: "\f0a7"; } 248 | .icon-circle-arrow-left:before { content: "\f0a8"; } 249 | .icon-circle-arrow-right:before { content: "\f0a9"; } 250 | .icon-circle-arrow-up:before { content: "\f0aa"; } 251 | .icon-circle-arrow-down:before { content: "\f0ab"; } 252 | .icon-globe:before { content: "\f0ac"; } 253 | .icon-wrench:before { content: "\f0ad"; } 254 | .icon-tasks:before { content: "\f0ae"; } 255 | 256 | .icon-filter:before { content: "\f0b0"; } 257 | .icon-briefcase:before { content: "\f0b1"; } 258 | .icon-fullscreen:before { content: "\f0b2"; } 259 | 260 | .icon-group:before { content: "\f0c0"; } 261 | .icon-link:before { content: "\f0c1"; } 262 | .icon-cloud:before { content: "\f0c2"; } 263 | .icon-beaker:before { content: "\f0c3"; } 264 | .icon-cut:before { content: "\f0c4"; } 265 | .icon-copy:before { content: "\f0c5"; } 266 | .icon-paper-clip:before { content: "\f0c6"; } 267 | .icon-save:before { content: "\f0c7"; } 268 | .icon-sign-blank:before { content: "\f0c8"; } 269 | .icon-reorder:before { content: "\f0c9"; } 270 | .icon-list-ul:before { content: "\f0ca"; } 271 | .icon-list-ol:before { content: "\f0cb"; } 272 | .icon-strikethrough:before { content: "\f0cc"; } 273 | .icon-underline:before { content: "\f0cd"; } 274 | .icon-table:before { content: "\f0ce"; } 275 | 276 | .icon-magic:before { content: "\f0d0"; } 277 | .icon-truck:before { content: "\f0d1"; } 278 | .icon-pinterest:before { content: "\f0d2"; } 279 | .icon-pinterest-sign:before { content: "\f0d3"; } 280 | .icon-google-plus-sign:before { content: "\f0d4"; } 281 | .icon-google-plus:before { content: "\f0d5"; } 282 | .icon-money:before { content: "\f0d6"; } 283 | .icon-caret-down:before { content: "\f0d7"; } 284 | .icon-caret-up:before { content: "\f0d8"; } 285 | .icon-caret-left:before { content: "\f0d9"; } 286 | .icon-caret-right:before { content: "\f0da"; } 287 | .icon-columns:before { content: "\f0db"; } 288 | .icon-sort:before { content: "\f0dc"; } 289 | .icon-sort-down:before { content: "\f0dd"; } 290 | .icon-sort-up:before { content: "\f0de"; } 291 | 292 | .icon-envelope-alt:before { content: "\f0e0"; } 293 | .icon-linkedin:before { content: "\f0e1"; } 294 | .icon-undo:before { content: "\f0e2"; } 295 | .icon-legal:before { content: "\f0e3"; } 296 | .icon-dashboard:before { content: "\f0e4"; } 297 | .icon-comment-alt:before { content: "\f0e5"; } 298 | .icon-comments-alt:before { content: "\f0e6"; } 299 | .icon-bolt:before { content: "\f0e7"; } 300 | .icon-sitemap:before { content: "\f0e8"; } 301 | .icon-umbrella:before { content: "\f0e9"; } 302 | .icon-paste:before { content: "\f0ea"; } 303 | 304 | .icon-user-md:before { content: "\f200"; } 305 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /* RESET */ 2 | * { margin: 0; padding: 0; border: 0; vertical-align: baseline; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } 3 | table { width: 100%; table-layout: fixed; border-collapse: collapse; border-spacing: 0; } 4 | td { text-align: left; vertical-align:middle; padding: 10px 0px;} 5 | /* FONT */ 6 | body, input, textarea { font-family: "Lucida Grande", "Lucida Sans Unicode", "Helvetica Neue", "DejaVu Sans", "Verdana", "Microsoft YaHei", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif !important; } 7 | pre, code { font-family: Consolas, Monaco, "Bitstream Vera Sans Mono", "Lucida Console", monospace; } 8 | html { overflow-y: hidden; } 9 | body, input, textarea { font-size: 14px; line-height: 1; color: #000; word-wrap: break-word; } 10 | .title p, h1, h2, h3, h4, h5, h6 { font-size: 17px; font-family: "Segoe UI", Segoe, Verdana, Geneva,"Microsoft YaHei","Hiragino Sans GB","WenQuanYi Micro Hei", sans-serif; font-weight: normal;} 11 | i { color: #222; } 12 | .gg { filter: url("data:image/svg+xml;utf8,#grayscale"); 13 | filter: gray; -webkit-filter: grayscale(1); } 14 | /* PAGE */ 15 | #wrap { overflow: hidden; width: 100%; } 16 | #container { width: 100%; position: relative; margin: 6px auto; padding: 0 6px; } 17 | #left_wrap, #mid_wrap { display: none; position: fixed; } 18 | #left_wrap { height:100%;} 19 | #left_sss, #mid_sss { position: relative; } 20 | #magic { background: transparent; position: fixed; top: 6px; right: 6px; z-index: 9999; } 21 | #work_status { padding: 2px } 22 | #post, #nav { position: relative; } 23 | #qaa, #qab, #qac, #qad, #qba, #qbb, #qbc, #qbd 24 | { cursor: pointer; width:12px; position:fixed; z-index:9999; opacity:0.7;} 25 | #qaa { height:10%; top:00%; } 26 | #qab { height:40%; top:10%; } 27 | #qac { height:40%; top:50%; } 28 | #qad { height:10%; bottom:0%; } 29 | #qba { height:10%; top:00%; } 30 | #qbb { height:40%; top:10%; } 31 | #qbc { height:40%; top:50%; } 32 | #qbd { height:10%; bottom:0%; } 33 | #qcx, #qct { height:12px; position:fixed; top:0%; z-index:7777 } 34 | #qca, #qcb { height:12px; width: 100%; } 35 | #qdt, #qdx { height:6px; position:fixed; bottom:0%; z-index:7777 } 36 | #qda, #qdb, #qdc, #qdd { float:left; height:6px; width: 50%; } 37 | #qca, #qcb, #qda, #qdb, #qdc, #qdd { opacity:0.7; cursor: pointer; } 38 | #qea, #qfa { width:12px; top:0px; padding:11px 0; height:100%; position:fixed; z-index:1337; cursor:pointer} 39 | #qea { left:12px; } 40 | #qfa { right:12px;} 41 | #qex, #qfx { display:none; width:12px; position:relative; height:100%; top:0px;background-color:#000; opacity:0.3; cursor:n-resize} 42 | #mid, #left { position: relative; top: 0px; } 43 | #setup { display:none;padding:11px 0px;margin-top:32px; margin-bottom:-6px;} 44 | #panel { display:none;position:fixed; left:0; top:0; width:100%; height:100%; background:rgba(0,0,0,0.78); z-index:11111; } 45 | #signup_panel, #signin_panel { display:none;position:fixed;left:50%;top:40%;background-color:#fff;margin-top:-180px;z-index:11112; padding:40px;} 46 | #signup_panel { height:310px; width:560px; margin-left:-280px;} 47 | #signin_panel { height:250px; width:560px; margin-left:-280px;} 48 | #left_panel { position:fixed; bottom: 0px; z-index: 1234; min-height:42px; } 49 | #mid_panel { width:100%; min-height:42px; } 50 | #mid_panel_wrap { position:fixed; bottom: 0px; z-index: 1234; padding-right:18px;} 51 | /* STYLE */ 52 | #mid, #mid_pad, #left, #left_pad,input, textarea 53 | { background-color: #fff !important; } 54 | .padbox { margin:24px; background:#fff; position:relative; } 55 | .xpadbox { margin:6px 24px 5px 24px; background:#fff; position:relative; } 56 | .box, .xbox, .icon, .tcon, .tmark, input, textarea, #login_button, #mid_panel, #signup_panel 57 | { border-radius: 1px; } 58 | html { background-image: url('bg.png'); } 59 | .box { background: #fff; box-shadow: 0px 1px 3px rgba(65,55,45,0.3); } 60 | .xbox { background: #fff; box-shadow: 0px -1px 3px rgba(65,55,45,0.3); } 61 | input, textarea, #login_button, #panel .button, #signup_panel 62 | { border: 1px solid #e3e2e1; } 63 | .title, .item { border-bottom: 1px dotted #e3e2e1; } 64 | strike { text-decoration: none; color: #ddd !important; text-shadow: 0 0 0 white !important; } 65 | .hidden { display:none !important; } 66 | /* BASE */ 67 | .title p, #nav > .item p { cursor: pointer; } 68 | .item { position: relative; min-height:43px; } 69 | .itemcur { background: #e0ffcd; color: #000; } 70 | .title p, .item p, #mid_preview { padding-left: 42px; padding-right: 37px; line-height: 1.6; position: relative; } 71 | .qrx p { padding: 0 8px; } 72 | #nav > .item p, .pwrap { padding-top: 12px; padding-bottom: 11px; } 73 | .pwrap p { padding-bottom: 6px; } 74 | .pwrap p:last-child { padding-bottom: 0px; } 75 | .title p { text-shadow:0 0 1px rgba(0,0,0,0.3); padding-bottom: 1px; top:-9px; margin-left: -1px; padding-left: 0px; padding-right: 0px; margin-right: 37px;} 76 | @-moz-document url-prefix() { .title p{text-shadow:0 0 1px rgba(0,0,0,0.18);}} 77 | /* MISC */ 78 | .qname, .qref, .qret { color: #999; } 79 | a.qhref { color: #4d8b97 !important; cursor: pointer; } 80 | .qrx { margin:4px 0; background-color:#fff; padding:7px 0; z-index:9999; border: 1px solid #e3e2e1; } 81 | .icon { width: 64px; height: 64px; } 82 | .tmark { position: absolute; top: 6px; left: 0px; } 83 | .tcon, .tmark { cursor: pointer; z-index: 999; width: 32px; height: 32px; background-size: 32px 32px; } 84 | .trep, .frep, .tup, .tdown, .txa, .txb { cursor: pointer; font-size: 13px; position: absolute; overflow: hidden; line-height: 41px; top: 1px; } 85 | .txa, .txb { pointer-events: none; color: transparent; width: 150px; z-index:9999;} 86 | .txa { left: -156px; text-align: right;} 87 | .txb { right: -156px } 88 | .trep, .frep, .tup, .tdown { z-index: 999; color: #aaa; right: 0px; width: 34px; text-align: right; } 89 | #mid .trep { color: #ccc; cursor: default !important; } 90 | .tup, .tdown { line-height: 24px; right: -3px; } 91 | .tup { top: -17px; bottom: auto; } 92 | .tdown { top: auto; bottom: -9px; } 93 | @-moz-document url-prefix() { .tup{top: -16px} .tdown{bottom: -10px} } 94 | .trans { background: transparent !important; } 95 | .white { color: transparent; } 96 | .dark { color: #777; } 97 | .red { color: #900 !important; } 98 | .redd { color: #c00; } 99 | .green { color: #060; } 100 | .disable { color: #ddd !important; text-shadow: 0 0 0 white !important; } 101 | .show { color: #000; background: transparent; } 102 | .aaa { text-decoration: underline !important; cursor: pointer !important; } 103 | .item p { z-index: 3; } 104 | .more { font-weight:bold; color:#f00; } 105 | #xemp { position: absolute; left:-24px; top:0px; background: #fafafa; width: 100%; height:100%; z-index: 2; display:block; } 106 | /* POS */ 107 | #fullview_button { position: absolute; top:-21px; padding:20px 10px 5px 25px; right:-11px; } 108 | #followers_button { padding-bottom:5px; padding-top:20px; } 109 | #following_button { padding-bottom:5px;padding-top:20px;margin-top:-8px; } 110 | #follow_button { padding-bottom:5px; } 111 | #user_img { cursor:pointer; position:absolute; margin-left:0px; margin-top:-73px; } 112 | #refresh_button { float:right;margin-left:12px;margin-right:-14px;margin-top:-27px;padding:12px 12px 12px 0px; } 113 | #create_button { float:right;margin-top:-27px;padding-top:12px;padding-bottom:12px; } 114 | #u_topic_button { float:left; padding:8px 6px 2px 0px; } 115 | #u_post_button { float:left; padding:8px 6px 2px 6px; } 116 | #u_list_button { float:left; padding:8px 6px 2px 6px; } 117 | #u_setup_button { float:left; padding:8px 12px 2px 6px; } 118 | #search_button { position: absolute; padding: 2px; right: 10px; top: 6px; padding-bottom: 10px; } 119 | #search_text { width:100%; padding-right:26px; height:30px; } 120 | #post_msg { display:inline; padding-left:12px; } 121 | #create_msg { display:inline; position:relative; top:10px; left:20px;} 122 | #title_msg { left:20px;top:10px;display:none;position:relative } 123 | .xxb { top:10px; margin-left:12px; padding:12px 0px; } 124 | .xxc { margin-right:16px;padding-bottom:12px; } 125 | .xyb { float:right; padding:8px 8px; } 126 | .xxf { font-weight:bold; top:8px;padding:10px 8px;} 127 | #item_edit, #item_delete, #item_mod { margin-top:-10px;float:right;padding:10px 8px;} 128 | #item_func { display:none;padding-top:8px;padding-bottom:5px; } 129 | #item_msg { margin-left:40px;margin-top:20px;margin-bottom:-4px;display:none } 130 | #item_ref { margin-left:33px; } 131 | #item_text_wrap { padding:12px 36px 6px 42px; padding:12px 36px 13px 42px\9;} 132 | @-moz-document url-prefix() { #item_text_wrap {padding:12px 36px 13px 42px} } 133 | #mid_core { display:none; position:absolute;top:23px;right:-1px;} 134 | #mid_func { height:35px;position:relative;top:-8px;left:-12px; margin-bottom:-4px; } 135 | #mid_func_user { margin-top:3px; margin-bottom:9px; margin-left:0px; } 136 | #left_func { height:35px;position:relative;top:-8px;left:-12px;z-index:222; margin-bottom:-4px; } 137 | #left_create, #left_modify { padding:9px 0px 9px 0px; } 138 | #modify_msg { float:left; margin-left: 20px; } 139 | #create_text { margin-top:-3px; } 140 | #modify_text { margin-top:1px; } 141 | .xyz { height:97px !important; } 142 | #post_wrap { margin-left:42px; margin-right:36px; } 143 | #post_text { height:30px; margin-bottom: -4px; padding-top:3px; } 144 | @-moz-document url-prefix() { #post_text {margin-bottom: 1px} } 145 | #page_top_button, #fullview_button_2 { position:absolute; top:-3px; right:-11px; padding:10px; } 146 | #user_xyz { position:absolute; left:0px; top:-1px; } 147 | #cancel_button { display:inline; padding-bottom:9px; margin-left:12px; } 148 | #post_title { width:100%; margin-bottom:8px;display:none; } 149 | #item_text, #title_text { width:100%; height:32px;overflow:hidden; } 150 | #title_deco { position: relative; height: 29px; top:-10px; } 151 | #title_cancel { position: absolute; padding:6px 0px; right: 33px; } 152 | #title_text_wrap { position: absolute; padding-right: 100px; width:100%} 153 | #sage_button { padding:4px 12px; position:absolute; left:-2px; bottom:38px; } 154 | #hide_button { padding:4px 12px; position:absolute; left:-3px; bottom:68px; display:none;} 155 | #lock_button { padding:4px 12px; position:absolute; left:-1px; bottom:38px; display:none;} 156 | .p_spec { color: #aaa !important; font-style:normal; text-shadow: 0 0 0 white !important; } 157 | #login_form input { margin-right: 7px; width: 233px; } 158 | #login_form input, #panel input { width: 233px; } 159 | #login_form input, #panel input, #login_button, #panel .button 160 | { font-size: 17px; padding: 9px; line-height: 1; box-shadow: 0px 0px 0px white; } 161 | #login_button, #panel .button { font-size: 16px; background: #f8f8f8; top: 0px; padding: 10px 20px 10px 20px; padding: 9px 20px 9px 20px\9;} 162 | #signup_panel ._email, #signup_panel ._pass_again, #signin_panel ._pass 163 | { float:right } 164 | #panel .button { display:block; float:right; } 165 | #panel .msg { font-size: 14px; position:relative; top: 8px;} 166 | @-moz-document url-prefix() { #panel .button{ top: -1px; } } 167 | #upload_button { background-color:#f8f8f8 !important; width:88px !important; position:absolute; left:385px; top:49px; } 168 | /* ETC */ 169 | input, textarea { padding: 5px 5px; background: #fff; outline: none; box-shadow: inset 0px 1px 1px rgba(65,55,45,0.1); } 170 | input::-moz-focus-inner { border: 0 } 171 | textarea { position:relative; height: 350px; width: 100%; resize: vertical; overflow: auto; } 172 | .hover, .button, td { cursor: pointer } 173 | .button { display: inline; background: transparent; position: relative; z-index: 999; } 174 | a, a:visited { color: #000; cursor: pointer; text-decoration: none; outline: none; } 175 | a:hover, .current, .active { color: #b00 !important; text-shadow: 0 0 1px rgba(255,0,0,0.45) !important; } 176 | .currenx { text-shadow: 0 0 2px rgba(0,0,0,0.6) !important; } 177 | @-moz-document url-prefix() { a:hover, .current{text-shadow: 0 0 1px rgba(255,0,0,0.3)} } 178 | .curalt, .dim { color: #aaa; } 179 | .curspec { color: #060 !important; text-shadow: 0 0 1px rgba(0,255,0,0.45) !important; } 180 | @-moz-document url-prefix() { .curspec{text-shadow: 0 0 1px rgba(0,255,0,0.3)} } 181 | .inactive { color: #aaa; } 182 | .butto { cursor: pointer; } 183 | #bad_ie, #bad_ie a { font-size: 20px; } 184 | /* HACK */ 185 | ::selection { color: #000; background: #bbb; } 186 | ::-moz-selection { color: #000; background: #bbb; } 187 | @media only screen and (max-device-width:480px) { html 188 | { -webkit-text-size-adjust: none !important }} 189 | .clearfix:before, .clearfix:after { content: ""; display: table; } 190 | .clearfix:after { clear: both } -------------------------------------------------------------------------------- /post_func.php: -------------------------------------------------------------------------------- 1 | ', '
', '
'); 6 | if ($order) 7 | return str_replace($src, $des, $text); 8 | else 9 | return str_replace($des, $src, $text); 10 | } 11 | function verifyText(&$text) { 12 | $text = trim($text); 13 | $text_len = mb_strlen($text, 'UTF8'); 14 | if (($text_len < 1) || ($text_len > 9999)) 15 | { 16 | return 'Text length needs to be within [1, 9999]. Now it is '.$text_len.'.'; 17 | } 18 | $line_cnt = substr_count($text, '\n') + 1; 19 | if ($line_cnt > 500) 20 | { 21 | return 'Line count needs to be within [1, 500]. Now it is '.$line_cnt.'.'; 22 | } 23 | } 24 | function verifyTitle(&$title) { 25 | $title = trim($title); 26 | if (!$title) 27 | { 28 | return 'Fill in title.'; 29 | } 30 | $title_len = mb_strlen($title,'UTF8'); 31 | if (($title_len < 6) || ($title_len > 100)) 32 | { 33 | return 'Title length needs to be within [6, 100]. Now it is '.$title_len.'.'; 34 | } 35 | $title = htmlspecialchars($title); 36 | } 37 | function get_magic_string($query, $type, $topic, $begin, $limit) 38 | { 39 | $x_begin = $begin + 1; 40 | $x_up = max(1, $begin - $limit + 1); 41 | if ($begin <= 0) 42 | { 43 | $x_up = -1; 44 | } 45 | $x_down = $begin + $limit + 1; 46 | if ($query->rowCount() < $limit + 1) 47 | { 48 | $x_down = -1; 49 | } 50 | return "$type,$topic,$x_begin,$x_up,$x_down"; 51 | } 52 | function get_icon($user) 53 | { 54 | $icon = 'icon/'.$user.'_64.png'; if (!file_exists($icon)) $icon = 'icon/0_64.png'; 55 | return $icon; 56 | } 57 | function have_icon($user) 58 | { 59 | $icon = 'icon/'.$user.'_64.png'; return (file_exists($icon)) ? ('1') : ('0'); 60 | } 61 | function limx($anchor, $type, $begin, $limit_plus_one) 62 | { 63 | if ($type == 1) 64 | return (($anchor > 0) ? (" AND (post_id > ".$anchor.") ORDER BY post_id ASC LIMIT $limit_plus_one") : (" ORDER BY post_id ASC LIMIT $begin, $limit_plus_one")); 65 | else if ($type == 2) 66 | return (($anchor > 0) ? (" AND (topic_id < ".$anchor.") ORDER BY topic_id DESC LIMIT $limit_plus_one") : (" ORDER BY topic_id DESC LIMIT $begin, $limit_plus_one")); 67 | } 68 | function post_get($type, $topic, $begin, $limit, $user, $anchor, $sid, $slevel) 69 | { 70 | if (!is_numeric($anchor)) $anchor = 0; 71 | 72 | $limit_plus_one = $limit + 1; 73 | 74 | if (strlen($user) > 1) { 75 | if ($user[0] == '@') { 76 | $query = $GLOBALS['db']->prepare("SELECT user_id FROM users WHERE user_name = ?"); 77 | $query->execute(array(substr($user, 1))); 78 | $top = $query->fetch(PDO::FETCH_ASSOC); 79 | $user = $top['user_id']; 80 | } 81 | } 82 | if (!is_numeric($user)) $user = ''; 83 | 84 | if (($type == 'u') && (is_numeric($topic))) 85 | { 86 | if (!isset($_POST['par'])) 87 | { 88 | $query = $GLOBALS['db']->query("SELECT user_name, user_level, user_posts, user_followers, user_following, user_hidposts, user_location, user_education, user_major, user_hobby FROM users WHERE user_id = $topic"); 89 | $top = $query->fetch(PDO::FETCH_ASSOC); 90 | if ((($top['user_level'] < -99) && ($topic != $sid)) || ($query->rowCount() < 1)) { 91 | echo 'x002'; return; 92 | } 93 | $query = $GLOBALS['db']->query("SELECT follow_a FROM follow WHERE follow_a = ".$sid." AND follow_b = ".$topic); 94 | $stat = 0; 95 | if ($sid > 0) { 96 | $stat = 1; 97 | if ($topic == $sid) { 98 | $stat = 2; 99 | if ($slevel == -1) 100 | $stat = 3; 101 | } 102 | } 103 | echo 'user<>'.$stat.','.$top['user_name'].','.have_icon($topic).','.$top['user_followers'].','.$top['user_following'].','.$query->rowCount() 104 | .','.$top['user_location'].'^'.$top['user_education'].'^'.$top['user_major'].'^'.$top['user_hobby']; 105 | } 106 | else 107 | { 108 | $query = $GLOBALS['db']->query("SELECT user_posts FROM users WHERE user_id = $topic"); 109 | $top = $query->fetch(PDO::FETCH_ASSOC); 110 | echo 'usex'; 111 | } 112 | 113 | if ($begin < 0) { 114 | $query = $GLOBALS['db']->query("SELECT COUNT(*) AS cnt FROM posts LEFT JOIN topics ON topic_id = post_root WHERE (post_by = $topic OR post_root = ".(-$topic).")" 115 | ." AND (topic_special is null OR topic_special <> 4 OR post_by <> topic_by OR post_by = ".$sid.")" 116 | ." AND post_id < ".(-$begin)); 117 | if ($query->rowCount() < 1) 118 | { 119 | $begin = 0; 120 | } 121 | else 122 | { 123 | $row = $query->fetch(PDO::FETCH_ASSOC); 124 | $anchor = -$begin - 1; 125 | $begin = $row['cnt']; 126 | } 127 | } 128 | else if ($begin == 0) { 129 | if ($sid == $topic) 130 | $begin = $top['user_posts'] - $limit; 131 | else 132 | $begin = $top['user_posts'] - $top['user_hidposts'] - $limit; 133 | } 134 | else 135 | $begin = is_numeric($begin) ? ($begin - 1) : 0; 136 | if ($begin < 0) $begin = 0; 137 | 138 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_by, post_text, post_root, post_id, post_by, user_name FROM posts" 139 | .' JOIN users ON post_by = user_id' 140 | .' LEFT JOIN topics ON topic_id = post_root' 141 | ." WHERE (post_by = $topic OR post_root = ".(-$topic).")" 142 | ." AND (topic_special is null OR topic_special <> 4 OR post_by <> topic_by OR post_by = ".$sid.")" 143 | .limx($anchor, 1, $begin, $limit_plus_one)); 144 | 145 | $upp = ($topic == $sid) ? ($top['user_posts']) : ($top['user_posts'] - $top['user_hidposts']); 146 | echo '<>'.get_magic_string($query, $type, $topic, $begin, $limit).','.$upp; 147 | 148 | $i = $begin; 149 | while ($row = $query->fetch(PDO::FETCH_ASSOC)) 150 | { 151 | $i++; if ($i == $begin + $limit + 1) continue; 152 | if (($row['topic_special'] != 4) || ($sid == $topic) || ($row['post_by'] != $row['topic_by'])) 153 | echo '<>'.$row['post_id'].','.$row['post_root'].','.$row['post_by'].','.$row['user_name'].','.have_icon($row['post_by']).','.$row['post_text']; 154 | else 155 | echo '<>'; 156 | } 157 | return; 158 | } 159 | else if (($type == '') && (is_numeric($topic))) 160 | { 161 | if (!isset($_POST['par'])) 162 | { 163 | $query = $GLOBALS['db']->query('SELECT topic_special, topic_title, topic_root, post_text, topic_replies, topic_by, user_name FROM topics' 164 | .' JOIN users ON topic_by = user_id' 165 | .' JOIN posts ON topic_root = post_id' 166 | .' WHERE topic_id = '.$topic); 167 | if ($query->rowCount() < 1) { 168 | echo 'x001'; return; 169 | } 170 | $top = $query->fetch(PDO::FETCH_ASSOC); 171 | if (($top['topic_special'] == 4) && ($top['topic_by'] != $sid)) { 172 | echo 'y001'; return; 173 | } 174 | 175 | echo 'post<>'.$top['topic_root'].','.$top['topic_by'].','.$top['user_name'].','.have_icon($top['topic_by']).','.$top['topic_special'].','.$top['topic_title']; 176 | echo '<>'.$top['post_text']; 177 | } 178 | else 179 | { 180 | $query = $GLOBALS['db']->query('SELECT topic_replies, topic_by FROM topics' 181 | .' WHERE topic_id = '.$topic); 182 | $top = $query->fetch(PDO::FETCH_ASSOC); 183 | echo 'posx'; 184 | } 185 | 186 | if ($begin < 0) { 187 | $query = $GLOBALS['db']->query("SELECT COUNT(*) AS cnt FROM posts WHERE post_topic = $topic " 188 | .(($user > 0)?(" AND post_by = ".$user):("")) 189 | ." AND post_id < ".(-$begin)); 190 | if ($query->rowCount() < 1) 191 | { 192 | $begin = 0; 193 | } 194 | else 195 | { 196 | $row = $query->fetch(PDO::FETCH_ASSOC); 197 | $anchor = -$begin - 1; 198 | $begin = $row['cnt']; 199 | } 200 | } 201 | else if ($begin == 0) { 202 | if ($user > 0) { 203 | $query = $GLOBALS['db']->query("SELECT COUNT(*) AS cnt FROM posts WHERE post_topic = $topic AND post_by = ".$user); 204 | $row = $query->fetch(PDO::FETCH_ASSOC); 205 | if ($query->rowCount() < 1) 206 | { 207 | $begin = 0; 208 | } 209 | else 210 | { 211 | $row = $query->fetch(PDO::FETCH_ASSOC); 212 | $begin = $row['cnt'] - $limit; 213 | } 214 | } else { 215 | $begin = $top['topic_replies'] - $limit; 216 | } 217 | } else { 218 | $begin = $begin - 1; 219 | } 220 | if ($begin > $top['topic_replies'] - 1) { 221 | $begin = $top['topic_replies'] - 1; 222 | } 223 | if ($begin < 0) { 224 | $begin = 0; 225 | } 226 | 227 | $query = $GLOBALS['db']->query('SELECT post_text, post_id, post_by, user_name FROM posts' 228 | .' JOIN users ON post_by = user_id' 229 | ." WHERE post_topic = $topic".(($user > 0)?(" AND post_by = ".$user):("")) 230 | .limx($anchor, 1, $begin, $limit_plus_one)); 231 | 232 | echo '<>'.get_magic_string($query, $type, $topic.(($user > 0)?('_'.$user):('')), $begin, $limit).','.$top['topic_replies'].','.$top['topic_by']; 233 | 234 | $i = $begin; 235 | while ($row = $query->fetch(PDO::FETCH_ASSOC)) 236 | { 237 | $i++; if ($i == $begin + $limit + 1) continue; 238 | echo '<>'.$row['post_id'].','.$row['post_by'].','.$row['user_name'].','.have_icon($row['post_by']).',' 239 | .$row['post_text']; 240 | } 241 | } 242 | else 243 | { 244 | $begin = is_numeric($begin) ? ($begin - 1) : 0; 245 | $desc = ''; $xxxx = 'list'; 246 | if (($type == 'p') || ($type == 'q') || ($type == 't') || ($type == 'v') || ($type == 'w')) 247 | { 248 | if (is_numeric($topic)) { 249 | $query = $GLOBALS['db']->query("SELECT user_name FROM users WHERE user_id = $topic"); 250 | $xow = $query->fetch(PDO::FETCH_ASSOC); 251 | } 252 | } 253 | if ($type == 'p') 254 | { 255 | $desc = $xow['user_name']."'s Threads"; //DATE_FORMAT(topic_date, '%b %e') AS date 256 | if ($topic == $sid) $desc = 'My Threads'; 257 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title, topic_replies, topic_id, topic_by, topic_root FROM topics" 258 | ." WHERE topic_by = $topic ".limx($anchor, 2, $begin, $limit_plus_one)); 259 | } 260 | else if ($type == 'q') 261 | { 262 | $desc = $xow['user_name']."'s Replies"; //DATE_FORMAT(MAX(post_date), '%b %e') AS date 263 | if ($topic == $sid) $desc = 'My Replies'; 264 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title, topic_replies, topic_id, topic_by, topic_root, user_name FROM topics" 265 | ." JOIN posts ON topic_id = post_topic" 266 | ." JOIN users ON topic_by = user_id" 267 | ." WHERE ((post_by = $topic) AND (topic_by <> $topic)) GROUP BY topic_id ORDER BY MAX(post_id) DESC LIMIT $begin, $limit_plus_one"); 268 | } 269 | else if ($type == 't') 270 | { 271 | $xxxx = 'tist'; 272 | if (strlen($topic) == 0) 273 | { 274 | $desc = 'Lists'; 275 | $query = $GLOBALS['db']->query("SELECT list_id, list_name, list_cnt, list_by, user_name FROM lists " 276 | ." JOIN users ON list_by = user_id" 277 | ." ORDER BY list_id DESC LIMIT $begin, $limit_plus_one"); 278 | } 279 | else if (is_numeric($topic)) 280 | { 281 | if ($topic > 0) 282 | { 283 | $desc = $xow['user_name']."'s Lists"; 284 | if ($topic == $sid) $desc = 'My Lists'; 285 | $query = $GLOBALS['db']->query("SELECT list_id, list_name, list_cnt, list_by FROM lists " 286 | ." WHERE list_by = $topic ORDER BY list_id DESC LIMIT $begin, $limit_plus_one"); 287 | } 288 | else 289 | { 290 | $topic = -$topic; 291 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title FROM topics WHERE topic_id = $topic"); 292 | $xow = $query->fetch(PDO::FETCH_ASSOC); 293 | $desc = "Lists ◂ ".$xow['topic_title']; 294 | $query = $GLOBALS['db']->query("SELECT list_id, list_name, list_cnt, list_by, user_name FROM lists " 295 | ." JOIN list2top ON id_list = list_id" 296 | ." JOIN users ON list_by = user_id" 297 | ." WHERE id_topic = $topic ORDER BY list_cnt DESC LIMIT $begin, $limit_plus_one"); 298 | } 299 | } 300 | else 301 | { 302 | $xx = substr($topic, 0, 1); 303 | $xa = $sid; 304 | $xb = substr($topic, 1); 305 | if ((!is_numeric($xa)) || (!is_numeric($xb))) return; 306 | if ($xx == 'm') 307 | { 308 | $desc = "Removing Topic from List"; 309 | $query = $GLOBALS['db']->query("SELECT list_id, list_name, list_cnt, list_by, user_name FROM lists " 310 | ." JOIN list2top ON id_list = list_id" 311 | ." JOIN users ON list_by = user_id" 312 | ." WHERE (list_by = $xa AND id_topic = $xb) ORDER BY list_id DESC LIMIT $begin, $limit_plus_one"); 313 | } 314 | if ($xx == 'a') 315 | { 316 | $desc = "Adding Topic to List"; 317 | $query = $GLOBALS['db']->query("SELECT list_id, list_name, list_cnt, list_by, user_name FROM lists " 318 | ." JOIN users ON list_by = user_id" 319 | ." WHERE (list_by = $xa AND list_id NOT IN (SELECT id_list AS list_id FROM list2top WHERE id_topic = $xb))" 320 | ." ORDER BY list_id DESC LIMIT $begin, $limit_plus_one"); 321 | } 322 | } 323 | } 324 | else if ($type == 's') 325 | { 326 | $xxxx = 'list'; 327 | $query = $GLOBALS['db']->query("SELECT list_name FROM lists WHERE list_id = $topic"); 328 | $xow = $query->fetch(PDO::FETCH_ASSOC); 329 | $desc = "Threads ▸ ".$xow['list_name']; 330 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title, topic_replies, topic_id, topic_by, topic_root, user_name FROM topics " 331 | ." JOIN list2top ON id_topic = topic_id" 332 | ." JOIN users ON topic_by = user_id" 333 | ." WHERE id_list = $topic".limx($anchor, 2, $begin, $limit_plus_one)); 334 | } 335 | else if ($type == 'a') 336 | { 337 | $desc = 'Title : '.$topic; 338 | if ($slevel == -1) { 339 | echo 'x003'; return; 340 | } else { 341 | $query = $GLOBALS['db']->prepare("SELECT topic_special, topic_title, topic_replies, topic_id, topic_root, topic_by, user_name FROM topics" 342 | ." JOIN users ON topic_by = user_id" 343 | ." WHERE topic_title LIKE ? ".limx($anchor, 2, $begin, $limit_plus_one)); 344 | $query->execute(array('%'.$topic.'%')); 345 | } 346 | } 347 | else if ($type == 'b') 348 | { 349 | $desc = 'Name : '.$topic; $xxxx = 'uist'; 350 | if ($slevel == -1) { 351 | echo 'x003'; return; 352 | } else { 353 | $query = $GLOBALS['db']->prepare("SELECT user_id, user_name, user_posts, user_hidposts FROM users" 354 | ." WHERE ((user_name LIKE ?) AND (user_level >= -99)) ORDER BY user_lastpost DESC LIMIT $begin, $limit_plus_one"); 355 | $query->execute(array('%'.$topic.'%')); 356 | } 357 | } 358 | else if ($type == 'c') 359 | { 360 | $desc = 'List Name : '.$topic; $xxxx = 'tist'; 361 | if ($slevel == -1) { 362 | echo 'x003'; return; 363 | } else { 364 | $query = $GLOBALS['db']->prepare("SELECT list_id, list_name, list_cnt, list_by, user_name FROM lists" 365 | ." JOIN users ON list_by = user_id" 366 | ." WHERE list_name LIKE ? ORDER BY list_cnt DESC LIMIT $begin, $limit_plus_one"); 367 | $query->execute(array('%'.$topic.'%')); 368 | } 369 | } 370 | else if ($type == 'u') 371 | { 372 | $desc = 'Users'; $xxxx = 'uist'; 373 | $query = $GLOBALS['db']->query("SELECT user_id, user_name, user_posts, user_hidposts FROM users WHERE user_level >= -99 ORDER BY user_lastpost DESC LIMIT $begin, $limit_plus_one"); 374 | } 375 | else if ($type == 'v') 376 | { 377 | $desc = $xow['user_name']."'s Following"; $xxxx = 'uist'; 378 | $query = $GLOBALS['db']->query("SELECT user_id, user_name, user_posts, user_hidposts FROM follow JOIN users ON user_id = follow_b WHERE follow_a = $topic ORDER BY user_lastpost DESC LIMIT $begin, $limit_plus_one"); 379 | } 380 | else if ($type == 'w') 381 | { 382 | $desc = $xow['user_name']."'s Followers"; $xxxx = 'uist'; 383 | $query = $GLOBALS['db']->query("SELECT user_id, user_name, user_posts, user_hidposts FROM follow JOIN users ON user_id = follow_a WHERE follow_b = $topic ORDER BY user_lastpost DESC LIMIT $begin, $limit_plus_one"); 384 | } 385 | else if ($type == '') 386 | { 387 | $desc = 'Threads'; 388 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title, topic_replies, user_name, topic_id, topic_root, topic_by FROM topics" 389 | ." JOIN users ON topic_by = user_id" 390 | ." WHERE (topic_special <> 4 OR topic_by = ".$sid.") AND topic_class = 0" 391 | ." ORDER BY topic_score DESC LIMIT $begin, $limit_plus_one"); 392 | } 393 | else if ($type == '@') 394 | { 395 | $desc = 'Limbo'; 396 | $query = $GLOBALS['db']->query("SELECT topic_special, topic_title, topic_replies, user_name, topic_id, topic_root, topic_by FROM topics" 397 | ." JOIN users ON topic_by = user_id" 398 | ." WHERE (topic_special <> 4 OR topic_by = ".$sid.") AND topic_class = 1" 399 | ." ORDER BY topic_score DESC LIMIT $begin, $limit_plus_one"); 400 | } 401 | if ($desc == '') 402 | { 403 | return; 404 | } 405 | if (isset($_POST['par'])) { 406 | $xxxy = $xxxx; 407 | $xxxy[3] = 'x'; 408 | echo $xxxy; 409 | } 410 | else { 411 | echo $xxxx.'<>'.$desc; 412 | } 413 | 414 | echo '<>'.get_magic_string($query, $type, $topic, $begin, $limit); 415 | 416 | $i = $begin; 417 | while($row = $query->fetch(PDO::FETCH_ASSOC)) 418 | { 419 | $i++; if ($i == $begin + $limit + 1) continue; 420 | if (!isset($row['user_name'])) $row['user_name'] = $xow['user_name']; 421 | if ($xxxx == 'uist') 422 | { 423 | $upp = ($row['user_id'] == $sid) ? ($row['user_posts']) : ($row['user_posts'] - $row['user_hidposts']); 424 | echo '<>'.$row['user_id'].','.$row['user_name'].','.have_icon($row['user_id']) 425 | .','.$upp.','.$row['user_name']; 426 | } else if ($xxxx == 'tist') { 427 | echo '<>'.$row['list_id'].','.$row['list_by'].','.$row['user_name'].','.have_icon($row['list_by']) 428 | .','.$row['list_cnt'].','.$row['list_name']; 429 | } else { 430 | if (($row['topic_special'] == 4) && ($sid != $row['topic_by'])) { 431 | echo '<>'; 432 | } else { 433 | echo '<>'.$row['topic_id'].','.$row['topic_by'].','.$row['user_name'].','.have_icon($row['topic_by']) 434 | .','.$row['topic_replies'].','.$row['topic_root'].','.$row['topic_special'].','.$row['topic_title']; 435 | } 436 | } 437 | } 438 | } 439 | } 440 | ?> --------------------------------------------------------------------------------