mysql_query("DELETE FROM autofinger WHERE owner = '{$idcookie}' and interest = '{$searchnum}'"); $yay = new InfoText("User " . $planinfo[0][0] . " removed from your autoread list."); } else { if ($privlevel > 0 && $privlevel <= 3) { mysql_query("INSERT INTO autofinger (owner, interest, priority) VALUES ('{$idcookie}', '{$searchnum}', '{$privlevel}') ON DUPLICATE KEY UPDATE priority={$privlevel}"); $yay = new InfoText("User " . $planinfo[0][0] . " is now on your autoread list with priority level of " . $privlevel . "."); } } $page->append($yay); } } // Update autofinger as read. $my_result = mysql_query("Select priority From autofinger where owner = '{$idcookie}' and interest = '{$searchnum}'"); $onlist = mysql_fetch_array($my_result); if ($onlist) { update_read($dbh, $idcookie, $searchnum); //mark as having been read $myonlist = $onlist[0]; // Repopulate the page to get updated autoread populate_page($page, $dbh, $idcookie); } else { $myonlist = "X"; //if not on autoread list, show is not on priority list } } //TODO should this go inside if(!$auth) ? $guest_auth = false; if ($guest_pass = $_GET['guest-pass']) { $real_pass = get_item($dbh, "guest_password", "accounts", "userid", $searchnum); //error_log("JLW real pass is $real_pass"); if ($real_pass == '') {
// note 初始化用户id MooUserInfo(); $userid = $GLOBALS['MooUid']; $h = MooGetGPC('h', 'string', 'G'); if ($h == 'recommendMember') { recommendMember(); exit; } if (!$userid) { echo 'no_login'; exit; } switch ($h) { // note 显示 case "showmsg": public_showmsg($userid); break; // note 仿造XX访问当前会员主页 // note 仿造XX访问当前会员主页 case "makevisitor": make_visitor(); break; case "update_read": update_read(); break; // note // note default: public_showmsg($userid); break; }
/** * Return a users's plan, either complete, partial, or only the remaining text */ function doReadTask() { global $log; $response = array("message" => "", "success" => false); $searchname = $_POST['username']; $read_link = $_POST['readlinkreplacement']; $limit_size = $_POST['limitsize']; $partial = $_POST['partial']; /* * These two are used to define how much of a plan to return if the client * requested a limited plan. The wiggle length is how much over the max length * a plan can be before it gets returned. This way, if the user is prompted to * download more or shown how much data is remaining it will be signifigant, * instead of say, 2kb. */ $MAX_PLAN_LEN = 10240; $WIGGLE_PLAN_LEN = 2048; if (!User::logged_in()) { $response['message'] = 'login required'; } else { $idcookie = User::id(); $mydbh = db_connect(); $dbh = $mydbh; $searchnum = get_item($mydbh, "userid", "accounts", "username", $searchname); if (!isvaliduser($dbh, $searchname)) { $response['message'] = 'invalid user name'; } else { if (Block::isBlocking($searchnum, $idcookie)) { $response['message'] = 'blocked'; } else { $my_result = mysql_query("Select priority From autofinger where\n \t\t\towner = '{$idcookie}' and interest = '{$searchnum}'"); $onlist = mysql_fetch_array($my_result); if ($onlist) { update_read($dbh, $idcookie, $searchnum); //mark as having been read } $response_info = array(); $q = Doctrine_Query::create()->from('Accounts a')->leftJoin('a.Plan p')->where('a.userid = ?', $searchnum); $user = $q->fetchOne(); $response_info['username'] = $user->username; if ($user->login == '0000-00-00 00:00:00') { $response_info['last_login'] = ""; } else { $response_info['last_login'] = date('n/j/y, g:i A', strtotime($user->login)); } if ($user->changed == '0000-00-00 00:00:00') { $response_info['last_updated'] = ""; } else { $response_info['last_updated'] = date('n/j/y, g:i A', strtotime($user->changed)); } $response_info['pseudo'] = $user->pseudo == null ? "" : $user->pseudo; if ($read_link) { //NOTE: If the planlove link ever changes, you may want to look at this pattern.... $search = '/read\\.php\\?searchname=([\\w]*)[^"|\']*/i'; //We expect the read_link to have {username} in it somewhere, which we'll swap in for the username $replace = str_replace('{username}', '\\1', $read_link); $user->Plan->plan = preg_replace($search, $replace, $user->Plan->plan); } if ($limit_size) { //they requested a partial plan $width = strlen($user->Plan->plan); //we're preparing for multi byte characters if ($width > $MAX_PLAN_LEN) { $width_remaining = $width - $MAX_PLAN_LEN; if ($width_remaining > $WIGGLE_PLAN_LEN) { $response_info['partial'] = true; $response_info['plan'] = mb_strimwidth($user->Plan->plan, 0, $MAX_PLAN_LEN); $response_info['remaining'] = $width_remaining; } else { $response_info['plan'] = $user->Plan->plan; } } else { $response_info['partial'] = false; $response_info['plan'] = $user->Plan->plan; } $log->addToLog("PLAN WIDTH: " . strlen($user->Plan->plan)); } else { if ($partial) { //they requested only the last part of the plan $response_info['remainingplan'] = mb_substr($user->Plan->plan, $MAX_PLAN_LEN); } else { $response_info['partial'] = false; $response_info['plan'] = $user->Plan->plan; } } $response['plandata'] = $response_info; $response['success'] = true; } } } return $response; }