foreach ($file as $ln => $line) { $reg_no = trim(substr($line, 0, 7)); if (ctype_digit($reg_no)) { $result_mini = $db->query("SELECT data from results_2011_raw where regno = '{$reg_no}'"); if ($result_mini) { if ($result_mini->num_rows > 0) { $data = $result_mini->fetch_row(); if (strlen($data[0])) { continue; } } } echo $ln . "/" . $count . "\r"; $form['regno'] = $reg_no; $form['submit'] = "Submit"; $snoopy->submit("http://192.168.216.1/resultstatus.php", $form); if (strpos($snoopy->results, 'is invalid') !== false) { echo "Invalid."; continue; } else { $result = trim(strip_tags(cut_str($snoopy->results, '<p><br />', '<p class="content">'))); if (strpos($snoopy->results, "NOT Qualified") !== false) { //Did not qualify continue; } else { //Maybe qualified //save $res = $db->escape_string($result); $db->query("INSERT INTO results_2011_raw VALUES ('{$reg_no}','{$res}')"); } }
$form['appln_no'] = $people[1]; $form['regn_no'] = $people[0]; $date_db = $people[2]; if ($date_db) { continue; } echo $people[0] . "\n"; for ($y = 1992; $y <= 1993; $y++) { for ($m = 1; $m <= 12; $m++) { for ($d = 1; $d <= 31; $d++) { $form['day'] = str_pad($d, 2, '0', STR_PAD_LEFT); $form['month'] = str_pad($m, 2, '0', STR_PAD_LEFT); $form['year'] = $y; $form['proceed'] = 'Proceed'; $date = $form['day'] . "/" . $form['month'] . "/" . $form['year']; echo $date . "\r"; $snoopy->submit($url, $form); //print_r($snoopy->headers); if ($snoopy->status == 302 || $snoopy->status == 404) { echo "******************[{$date}]\n"; $db->query("UPDATE selected set date = '{$date}' where regno = '{$people[0]}'"); break 3; //move to the next person } } } } if ($y == 1993 && $m == 12 && $d == 31) { $db->query("UPDATE selected set date = '-' where regno = '{$people[0]}'"); } }
$db = mysqli_connect('localhost', 'captnemo_user', 'password', 'captnemo_db'); if (!$db) { die("death"); } $q = "SELECT * FROM results where cat='GE' AND catrank='0' AND course <> 'Not Allotted' order by rank desc"; $res = mysqli_query($db, $q); //echo "<table>"; while ($row = mysqli_fetch_row($res)) { $form['regno'] = $row[0]; //.substr(str_replace(" ","",trim($row[1])),0,4); //$form['Form_No']= $ff = $row[0]; $form['submit'] = 'Submit'; //echo $form['Form_No']."<BR>"; $link = "http://jee.iitm.ac.in/resultstatus.php"; $snoopy->submit($link, $form); //var_dump($snoopy->cookies); //echo $snoopy->lastredirectaddr."<BR>"; // $header=$snoopy->headers; // $ck['PHPSESSID']=cut_str($header[4],"=",";"); //echo $ck."<BR>"; //echo $snoopy->results; // $link="http://jee.iitm.ac.in/allotcourses/courseallot.php"; //echo $link."<BR>"; //$snoopy->cookies=$ck; //$snoopy->fetch($link); //$snoopy->fetch("http://jee.iitm.ac.in/allotcourses/courseallot.php?name=".$ff.$name); $page = $snoopy->results; //$course='Unalloted due to various reasons<sup>[1]</sup>'; //echo $page; //$gen=str_replace(" ","",$gen);
$msgargs = array(base64_encode(prepare_utf8_string($vbulletin->options['bbtitle']))); $pmpart = 0; if ($haspm) { if (count($pms) > 1) { $msgargs[] = base64_encode(count($pms)); $pmpart = 2; } else { $first_pm = array_shift($pms); $msgargs[] = base64_encode(prepare_utf8_string($first_pm['fromusername'])); $pmpart = 1; } } $subpart = 0; if ($hassub) { if (count($subs) > 1) { $msgargs[] = base64_encode(count($subs)); $subpart = 2; } else { $first_sub = array_shift($subs); $msgargs[] = base64_encode(prepare_utf8_string($first_sub['title'])); $subpart = 1; } } $out_msg[] = array('u' => $user['fr_username'], 'b' => $user['b'], 'pm' => $haspm, 'subs' => $hassub, 'm' => "__FR_PUSH_{$pmpart}PM_{$subpart}SUB", 'a' => $msgargs, 't' => $total); } // Send our update to Forum Runner central push server. Silently fail if // necessary. if (count($out_msg) > 0) { $snoopy = new snoopy(); $snoopy->submit('http://push.forumrunner.com/push.php', array('k' => $mykey, 'm' => serialize($out_msg), 'v' => $fr_version, 'p' => $fr_platform)); }
if (file_exists(DIR . '/forumrunner/sitekey.php')) { require_once DIR . '/forumrunner/sitekey.php'; } else { if (file_exists(DIR . '/forumrunner/vb_sitekey.php')) { require_once DIR . '/forumrunner/vb_sitekey.php'; } } // You must have your valid Forum Runner forum site key. This can be // obtained from http://www.forumrunner.com in the Forum Manager. if (!$mykey || $mykey == '') { exit; } // Check to see if our prompt is disabled. If so, exit. if (!$vbulletin->options['forumrunner_redirect_onoff']) { return; } // We know we have a prompt enabled at this point. Phone home for status. $snoopy = new snoopy(); $snoopy->submit('http://www.forumrunner.com/forumrunner/request.php', array('cmd' => 'checkstatus', 'sitekey' => $mykey)); $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); $out = $json->decode($snoopy->results); if (!$out['success']) { // If request failed for any reason, do not change anything. return; } if ($out['data']['pub']) { // We are published and fine. return; } // We are unpublished. Disable prompt. $vbulletin->db->query_write("\n UPDATE " . TABLE_PREFIX . "setting\n SET value = 0\n WHERE varname = 'forumrunner_redirect_onoff'\n");
public static function doPush() { require_once MCWD . '/sitekey.php'; require_once MCWD . '/version.php'; $debug = false; $db = XenForo_Application::get('db'); $visitor = XenForo_Visitor::getInstance(); $watch_model = XenForo_Model::create('XenForo_Model_ThreadWatch'); // You must have your valid Forum Runner forum site key. This can be // obtained from http://www.forumrunner.com in the Forum Manager. if (!$mykey || $mykey == '') { return; } // First of all, expire all users who have not logged in for 2 weeks, so // we don't keep spamming the server with their entries. $db->query("\n\t DELETE FROM xf_forumrunner_push_users\n\t WHERE last_login < DATE_SUB(NOW(), INTERVAL 14 DAY)\n\t"); // Get list of users to check for updates to push $users = $db->fetchAll("\n\t SELECT user_id, fr_username, b, token\n\t FROM xf_forumrunner_push_users\n\t"); $out_msg = array(); foreach ($users as $user) { $conversations = $subscriptions = array(); $convs = $db->fetchAll("\n\t\tSELECT conversation_master.*,\n\t\t conversation_user.*,\n\t\t conversation_starter.*,\n\t\t conversation_recipient.recipient_state, conversation_recipient.last_read_date\n\t\tFROM xf_conversation_user AS conversation_user\n\t\tINNER JOIN xf_conversation_master AS conversation_master ON\n\t\t (conversation_user.conversation_id = conversation_master.conversation_id)\n\t\tINNER JOIN xf_conversation_recipient AS conversation_recipient ON\n\t\t (conversation_user.conversation_id = conversation_recipient.conversation_id\n\t\t AND conversation_user.owner_user_id = conversation_recipient.user_id)\n\t\tLEFT JOIN xf_user AS conversation_starter ON\n\t\t (conversation_starter.user_id = conversation_master.user_id)\n\t\tWHERE conversation_user.owner_user_id = ? AND conversation_user.is_unread = 1\n\t\tORDER BY conversation_user.last_message_date DESC\n\t ", $user['user_id']); // This is the list of all conversations with unread messages foreach ($convs as $conv) { // Let's see if we sent a notice for this conversation already $sentconversation = $db->fetchRow("\n\t\t SELECT * FROM xf_forumrunner_push_data\n\t\t WHERE conversation_id = ? AND user_id = ?", array($conv['conversation_id'], $user['user_id'])); if ($sentconversation) { // We have sent a notice about this conversation at some point, lets see if // our update is newer. if ($sentconversation['threadread'] < $conv['last_activity']) { // Yup. Send a notice and update table. if ($sentconversation['subsent']) { continue; } $conversations[] = array('conversationid' => $conv['conversation_id'], 'last_message_username' => $conv['last_message_username']); if ($debug) { continue; } $db->query("\n\t\t\t UPDATE xf_forumrunner_push_data\n\t\t\t SET threadread = ?, subsent = 1\n\t\t\t WHERE id = ?", array($conv['last_activity'], $sentconversation['id'])); } // Already sent update } else { // Nope, send an update and insert new $conversations[] = array('conversationid' => $conv['conversation_id'], 'last_message_username' => $conv['last_message_username']); if ($debug) { continue; } $db->query("\n\t\t\tINSERT INTO xf_forumrunner_push_data\n\t\t\t(user_id, conversation_id, threadread, subsent)\n\t\t\tVALUES (?, ?, ?, ?)", array($user['user_id'], $conv['conversation_id'], $conv['last_activity'], 1)); } } unset($convs); // Now subscribed (watched) threads $watched = $watch_model->getThreadsWatchedByUser($user['user_id'], true); foreach ($watched as $watch) { // This is an updated thread since last time they were on the forum // Let's see if we sent this already $sentsubscription = $db->fetchRow("\n\t\t SELECT * FROM xf_forumrunner_push_data\n\t\t WHERE thread_id = ? AND user_id = ?", array($watch['thread_id'], $user['user_id'])); if ($sentsubscription) { // We have sent a notice about this thread at some point, lets see if // our update is newer. if ($sentsubscription['threadread'] < $watch['last_post_date']) { // Yup. Send a notice and update table. if ($sentsubscription['subsent']) { continue; } $subscriptions[] = array('threadid' => $watch['thread_id'], 'title' => $watch['title']); if ($debug) { continue; } $db->query("\n\t\t\t UPDATE xf_forumrunner_push_data\n\t\t\t SET threadread = ?, subsent = 1\n\t\t\t WHERE id = ?", array($watch['last_post_date'], $sentsubscription['id'])); } // Already sent update } else { // Nope, send an update and insert new $subscriptions[] = array('threadid' => $watch['thread_id'], 'title' => $watch['title']); if ($debug) { continue; } $db->query("\n\t\t\tINSERT INTO xf_forumrunner_push_data\n\t\t\t(user_id, thread_id, threadread, subsent)\n\t\t\tVALUES (?, ?, ?, ?)", array($user['user_id'], $watch['thread_id'], $watch['last_post_date'], 1)); } } unset($watched); $total = count($subscriptions) + count($conversations); // Nothing to see here... move along.... $hasconv = count($conversations) > 0; $hassub = count($subscriptions) > 0; if (!$hasconv && !$hassub) { continue; } // Forum name is always first arg. $msgargs = array(base64_encode(XenForo_Application::get('options')->boardTitle)); $convpart = 0; if ($hasconv) { if (count($conversations) > 1) { $msgargs[] = base64_encode(count($conversations)); $convpart = 2; } else { $first_conv = array_shift($conversations); $msgargs[] = base64_encode($first_conv['last_message_username']); $convpart = 1; } } $subpart = 0; if ($hassub) { if (count($subscriptions) > 1) { $msgargs[] = base64_encode(count($subscriptions)); $subpart = 2; } else { $first_sub = array_shift($subscriptions); $msgargs[] = base64_encode($first_sub['title']); $subpart = 1; } } $data = array('b' => $user['b'], 'pm' => $hasconv, 'subs' => $hassub, 'm' => "__FR_PUSH_{$convpart}PM_{$subpart}SUB", 'a' => $msgargs, 't' => $total); if ($user['token']) { // Branded app - send along token $data['token'] = $user['token']; } else { if ($user['fr_username']) { // Non branded app - send along push notification username $data['u'] = $user['fr_username']; } } $out_msg[] = $data; } // Send our update to Forum Runner central push server. Silently fail if // necessary. if (count($out_msg) > 0) { $snoopy = new snoopy(); $snoopy->submit('http://push.forumrunner.com/push.php', array('k' => $mykey, 'm' => serialize($out_msg), 'v' => $fr_version, 'p' => $fr_platform)); } }