Beispiel #1
0
 public function executeIndex()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if ($_GET['ban_id'] != '') {
         $_query = mysql_query("update thread set banned=1  where id=" . $_REQUEST['ban_id'], $connection) or die(mysql_error());
     }
     if ($_GET['unban_id'] != '') {
         $_query = mysql_query("update thread set banned=0  where id=" . $_REQUEST['unban_id'], $connection) or die(mysql_error());
     }
     $limit = 10;
     $page = $_GET['page'];
     if ($page) {
         $start = ($page - 1) * $limit;
     } else {
         $start = 0;
     }
     $_query = mysql_query("select * from thread  order by  created_at desc limit {$start},10", $connection) or die(mysql_error());
     $allChat = array();
     $i = 0;
     while ($_row = mysql_fetch_array($_query)) {
         $IP = $_row['user_ip'] != '' ? $_row['user_ip'] : 'Not Available';
         $allChat[$i] = array("id" => $_row['id'], "poster_id" => $_row['poster_id'], "title" => $_row['title'], "user_ip" => $IP, "date" => $_row['created_at']);
         if ($_row['banned'] == 0) {
             $allChat[$i]['banned'] = "<a  href='/admin.php/threads?page=" . $_GET['page'] . "&ban_id=" . $_row['id'] . "'>Ban</a> ";
         } else {
             $allChat[$i]['banned'] = "<a  href='/admin.php/threads?page=" . $_GET['page'] . "&unban_id=" . $_row['id'] . "'>Un-Ban</a> ";
         }
         $i++;
     }
     $this->allChat = $allChat;
 }
Beispiel #2
0
 public function executeUsers()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if (!empty($_GET['id'])) {
         $_Category = mysql_query("delete from expert_category where user_id = " . $_GET['id'] . "", $connection) or die(mysql_error());
         $_Users = mysql_query("delete from user where id = " . $_GET['id'] . "", $connection) or die(mysql_error());
     }
 }
Beispiel #3
0
 public function executeIndex()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if ($_GET['del_id'] != '') {
         $_query = mysql_query("delete from thread where id=" . $_REQUEST['del_id'], $connection);
     }
     if ($_GET['un_report_id'] != '') {
         $_query = mysql_query("update thread set reported=0  where id=" . $_REQUEST['un_report_id'], $connection);
     }
     $limit = 10;
     $page = $_GET['page'];
     if ($page) {
         $start = ($page - 1) * $limit;
     } else {
         $start = 0;
     }
     $_query = mysql_query("select * from thread  where reported=1 order by  reported_date desc limit {$start},10", $connection);
     $repthreads = array();
     $i = 0;
     while ($_row = mysql_fetch_array($_query)) {
         $IP = $_row['user_ip'] != '' ? $_row['user_ip'] : 'Not Available';
         $repthreads[$i] = array("id" => $_row['id'], "poster_id" => $_row['poster_id'], "title" => $_row['title'], "user_ip" => $IP, "date" => $_row['reported_date']);
         $repthreads[$i]['delete'] = "<a  href='/admin.php/reportedposts?page=" . $_GET['page'] . "&del_id=" . $_row['id'] . "'>Delete Post</a> ";
         $repthreads[$i]['un_report'] = "<a  href='/admin.php/reportedposts?page=" . $_GET['page'] . "&un_report_id=" . $_row['id'] . "'>Unreport</a> ";
         $repthreads[$i]['viewthread'] = "<a  href='/forum/thread/" . $_row['id'] . "/1'>View Thread</a> ";
         $i++;
     }
     $this->repthreads = $repthreads;
     if ($_GET['del_post_id'] != '') {
         $_query = mysql_query("delete from post where id=" . $_REQUEST['del_post_id'], $connection);
     }
     if ($_GET['un_report_post_id'] != '') {
         $_query = mysql_query("update post set reported=0  where id=" . $_REQUEST['un_report_post_id'], $connection);
     }
     $limit = 10;
     $page = $_GET['page'];
     if ($page) {
         $start = ($page - 1) * $limit;
     } else {
         $start = 0;
     }
     $_query_post = mysql_query("select * from post  where reported=1 order by  reported_date desc limit {$start},10", $connection);
     $repposts = array();
     $i = 0;
     while ($_row = mysql_fetch_array($_query_post)) {
         $IP = $_row['user_ip'] != '' ? $_row['user_ip'] : 'Not Available';
         $repposts[$i] = array("id" => $_row['id'], "poster_id" => $_row['poster_id'], "title" => substr($_row['content'], 0, 30), "user_ip" => $IP, "date" => $_row['reported_date']);
         $repposts[$i]['delete'] = "<a  href='/admin.php/reportedposts?page=" . $_GET['page'] . "&del_post_id=" . $_row['id'] . "'>Delete Post</a> ";
         $repposts[$i]['un_report'] = "<a  href='/admin.php/reportedposts?page=" . $_GET['page'] . "&un_report_post_id=" . $_row['id'] . "'>Unreport</a> ";
         $repposts[$i]['viewthread'] = "<a  href='/forum/thread/" . $_row['thread_id'] . "/1'>View Thread</a> ";
         $i++;
     }
     $this->repposts = $repposts;
 }
Beispiel #4
0
 public function executeUpdate()
 {
     $id = explode("/", $_SERVER['REQUEST_URI']);
     $connection = RaykuCommon::getDatabaseConnection();
     $query = mysql_query("select * from item_featured where item_id =" . $id[5] . " and status=1", $connection) or die(mysql_error());
     if (mysql_num_rows($query) > 0) {
         mysql_query("delete from `item_featured` where item_id =" . $id[5], $connection) or die(mysql_error());
     } else {
         mysql_query("insert into item_featured(item_id, status) values(" . $id[5] . ", 1) ", $connection) or die(mysql_error());
     }
     $this->redirect('featured/index');
 }
Beispiel #5
0
 /**
  *
  * @param array $historyEntries Many objects of History class
  * @return sfRss201Feed
  */
 public function getFeed($historyEntries)
 {
     $this->createFeed();
     $i = 0;
     foreach ($historyEntries as $historyEntry) {
         $user = $historyEntry->getUser();
         $content = (string) $historyEntry;
         $item = new sfFeedItem();
         $item->initialize(array('title' => strip_tags($content), 'link' => 'http://' . RaykuCommon::getCurrentHttpDomain(), 'pubDate' => strtotime($historyEntry->getCreatedAt()), 'description' => $content));
         $this->feed->addItem($item);
     }
     return $this->feed;
 }
Beispiel #6
0
 /**
  * AJAX action to delete a PM
  */
 public function executeDelete()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $pm = PrivateMessagePeer::getPrivateMessageByIdAndUser($this->getRequestParameter('id'), $this->getUser()->getRaykuUserId());
     //If such a PM doesn't exist, return an error
     if (!$pm) {
         return sfVew::ERROR;
     }
     //If this user was the sender, delete on the sender's end
     if ($pm->getSenderId() == $this->getUser()->getRaykuUserId()) {
         $pm->deleteFromSender();
     } else {
         mysql_query("update private_message set read_status = 1 where id=" . $pm->getId(), $connection) or die(mysql_error());
     }
     $pm->deleteFromRecipient();
 }
Beispiel #7
0
 public function executeIndex($request)
 {
     if ($request->isMethod('post')) {
         RaykuCommon::getDatabaseConnection();
         $time = time();
         $selectedTutors = $request->getParameter('checkbox');
         $count = count($selectedTutors);
         if ($count == 4) {
             $close = 46000;
             $_SESSION['connected_tutors'] = 4;
         }
         if ($count == 3) {
             $close = 46000;
         } else {
             if ($count == 2) {
                 $close = 61000;
             } else {
                 if ($count == 1) {
                     $close = 61000;
                 } else {
                     $close = 61000;
                 }
             }
         }
         $currentUser = $this->getUser()->getRaykuUser();
         $userId = $currentUser->getId();
         $j = 0;
         foreach ($selectedTutors as $selectedTutorId) {
             mysql_query('INSERT INTO `user_expert` ' . '(`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close) ' . "VALUES ('{$userId}', '{$selectedTutorId}', '5', 'To be discussed','" . ++$j . "', '{$time}', 1, {$close}) ") or die(mysql_error());
         }
         $l = 0;
         $source = 'tutorlist';
         mysql_query("DELETE FROM `student_questions` WHERE user_id=" . $userId . "");
         foreach ($selectedTutors as $selectedTutorId) {
             mysql_query('INSERT INTO `student_questions` ' . '(`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close, source) ' . "VALUES ('{$userId}', '{$selectedTutorId}', '5', 'To be discussed','" . ++$l . "', '{$time}', 1, {$close}, '{$source}') ") or die(mysql_error());
         }
         //                setcookie("asker_que", $_SESSION['question'], time() + 600, "/", sfConfig::get('app_cookies_domain'));
         //
         //                $this->getResponse()->setCookie("redirection", 1, time() + 600, '/', sfConfig::get('app_cookies_domain'));
         //
         //                $this->getResponse()->setCookie("forumsub", 1, time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $this->redirect('tutorsList/connect?count=' . $count);
     }
 }
Beispiel #8
0
 public function executeAjaxidle()
 {
     RaykuCommon::getDatabaseConnection();
     if ($_GET['status'] == '1') {
         $selmisqry = mysql_query("SELECT * FROM popup_close WHERE user_id ='" . $_GET['userid'] . "'");
         $misqrys = mysql_fetch_array($selmisqry);
         if ($misqrys['user_id'] == "") {
             mysql_query("INSERT INTO `popup_close` (\n\t\t\t\t\t `id` ,\n\t\t\t\t\t `user_id`,\n\t\t\t\t\t `ustatus`\n\t\t\t\t\t )\n\t\t\t\t\t VALUES (\n\t\t\t\t\t NULL , '" . $_GET['userid'] . "','1' )");
         }
     } else {
         if ($_GET['status'] == '2') {
             $selmisqry = mysql_query("SELECT * FROM popup_close WHERE user_id ='" . $_GET['userid'] . "' and ustatus='1' ");
             $misqrys = mysql_fetch_array($selmisqry);
             if ($misqrys['user_id'] != "") {
                 $sel_misqry = mysql_query("DELETE FROM popup_close WHERE user_id='" . $_GET['userid'] . "'");
             }
         }
     }
 }
Beispiel #9
0
 public function executeAnswer()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if (empty($_REQUEST['id'])) {
         return;
     }
     $id = $_REQUEST['id'];
     $time = time() - 600;
     $query = mysql_query("select * from user_expert where id=" . $id . " and time >= '" . $time . "' and status != 7 ", $connection) or die("Error1" . mysql_error());
     if (mysql_num_rows($query) > 0) {
         $row = mysql_fetch_assoc($query);
         $x = new Criteria();
         $x->add(UserPeer::ID, $row['checked_id']);
         $testUser = UserPeer::doSelectOne($x);
         $this->getUser()->signIn($testUser);
         $asker = UserPeer::retrieveByPK($row['user_id']);
         $askerUsername = $asker->getUsername();
         $askerName = $asker->getName();
         $this->getResponse()->setCookie("check_nick", urlencode($askerName), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("askerUsername", $askerUsername, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("askerid", $row['user_id'], time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("expertid", $row['checked_id'], time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("asker_que", urlencode($row['question']), time() + 600, "/", sfConfig::get('app_cookies_domain'));
         $userdetail = mysql_query("select * from user where id=" . $row['checked_id'] . " ", $connection) or die("Error2" . mysql_error());
         if (mysql_num_rows($userdetail) > 0) {
             $rowuser = mysql_fetch_assoc($userdetail);
             $name = str_replace(" ", "", $rowuser['name']);
             $this->getResponse()->setCookie("loginname", $name, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
             mysql_query("update user_expert set status = 7 where user_id =" . $row['checked_id'], $connection) or die("Error5" . mysql_error());
             mysql_query("delete from user_expire_msg where userid=" . $row['checked_id'], $connection) or die("Error_Expire2" . mysql_error());
             $this->redirect("/");
         }
     }
 }
Beispiel #10
0
 public function executeFollow()
 {
     RaykuCommon::getDatabaseConnection();
 }
Beispiel #11
0
 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if (@$_SESSION['modelPopupOpen']) {
         if (@$_SESSION['popup_session']) {
             $_now = time();
             $_remain_time = $_now - $_SESSION['popup_session'];
             if ($_remain_time < 20) {
                 return $this->renderText('redirect');
             }
         } else {
             return $this->renderText('redirect');
         }
     }
     /* @var $currentUser User */
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $time = time() - 300;
     $query = mysql_query($s = "select * from user_expert where checked_id = " . $userId . " and exe_order = 1 and time >= " . $time . "", $connection) or die(mysql_error());
     if (mysql_num_rows($query) > 0) {
         $row = mysql_fetch_assoc($query);
         if ($row['category_id']) {
             $category = CategoryPeer::retrieveByPk($row['category_id']);
             $subject = $category->getName();
         }
         //School Selection
         $usr_school_query = mysql_query("select * from user_expert where user_id = " . $row['user_id'] . "", $connection);
         $usr_school = mysql_fetch_array($usr_school_query);
         $school = $usr_school['school'];
         $length = strlen(trim($row['question']));
         if ($length <= 200) {
             $question = $row['question'];
         } else {
             $question = substr(trim($row['question']), 0, 200);
         }
         $x = new Criteria();
         $x->add(UserPeer::ID, $row['checked_id']);
         $newloginId = UserPeer::doSelectOne($x);
         $raykuCharge = $currentUser->getRate();
         mysql_query("update user_expert set status = 0 where id = " . $row['id'] . " ", $connection) or die(mysql_error());
         //User Course Info
         $usr_course_query = mysql_query("select * from user_expert as u join courses as c on u.course_id = c.id where u.user_id = " . $row['user_id'] . "", $connection);
         $usr_course = mysql_fetch_array($usr_course_query);
         if (!empty($usr_course['year']) && !empty($usr_course['course_code'])) {
             $course_info = $usr_course['course_name'] . ' | ' . $usr_course['year'] . ' | ' . $usr_course['course_code'];
         } else {
             $course_info = $usr_course['course_name'];
         }
         $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
         $browser = "others";
         if (eregi("(Chrome/)", $HTTP_USER_AGENT) == true) {
             $browser = "chrome";
         }
         if (eregi("(Safari/)", $HTTP_USER_AGENT) == true) {
             $browser = "safari";
         }
         $_SESSION["_modelbox"] = @$_SESSION["_modelbox"] + 1;
         $criteria = new Criteria();
         $criteria->add(StudentQuestionPeer::USER_ID, $row['user_id']);
         $criteria->add(StudentQuestionPeer::CHECKED_ID, $row['checked_id']);
         $criteria->add(StudentQuestionPeer::TIME, $time, '>=');
         $studentQuestion = StudentQuestionPeer::doSelectOne($criteria);
         if (!$studentQuestion) {
             exit;
         }
         $studentQuestion->setStatus(0);
         $studentQuestion->save();
         @setcookie('_popupclose', 1, time() + 300, '/', sfConfig::get('app_cookies_domain'));
         echo join('-', array($studentQuestion->getTutor()->getId(), $studentQuestion->getStudent()->getId(), base64_encode($studentQuestion->getQuestion()), $school, $subject, $course_info, $row['id'], $newloginId->getName(), "expert", $raykuCharge, $row['close'], $browser, $_SESSION["_modelbox"], $studentQuestion->getId()));
     }
     exit(0);
 }
Beispiel #12
0
 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $this->userId = $currentUser->getId();
     $time = time();
     if (empty($_SESSION["course_id"])) {
         $_SESSION["course_id"] = '1';
     }
     $this->cat = $this->getRequestParameter('category');
     $this->course_id = $this->getRequestParameter('course');
     if (empty($this->course_id)) {
         if (!empty($_SESSION['course_id'])) {
             $this->course_id = $_SESSION['course_id'];
         } else {
             $this->course_id = 1;
         }
     } else {
         $_SESSION['course_id'] = $this->course_id;
     }
     if (empty($this->cat)) {
         if (!empty($_SESSION['subject'])) {
             $this->cat = $_SESSION['subject'];
         } else {
             $this->cat = 1;
         }
     } else {
         $_SESSION['subject'] = $this->cat;
     }
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $c = new Criteria();
     $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN);
     if ($this->cat == 5) {
         $experts = ExpertCategoryPeer::doSelect($c);
     } else {
         $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat);
         $experts = ExpertCategoryPeer::doSelect($c);
     }
     $queryPoints = mysql_query("select * from user where id = " . $userId, $connection) or die("Error In rate" . mysql_error());
     if (mysql_num_rows($queryPoints) > 0) {
         $rowPoints = mysql_fetch_assoc($queryPoints);
         $_points = $rowPoints['points'];
     }
     $newUser = array();
     $i = 0;
     $eachExpertOnlyOnce = array();
     foreach ($experts as $exp) {
         if ($userId != $exp->getUserId()) {
             if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) {
                 continue;
             }
             $eachExpertOnlyOnce[] = $exp->getUserId();
             /* Testing - Student match with Tutors */
             $_queryCourse = '';
             $tutorsq = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
             $tutors = mysql_fetch_array($tutorsq);
             $tutor = '';
             $tutor = explode("-", $tutors['course_id']);
             if (in_array($_SESSION["course_id"], $tutor)) {
                 $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
                 //echo "select * from tutor_profile where category = 1 and user_id = ".$exp->getUserId()."";
             }
             if (@mysql_num_rows($_queryCourse) > 0) {
                 $query = mysql_query("select * from user_score where user_id = " . $exp->getUserId(), $connection) or die(mysql_error());
                 $score = mysql_fetch_assoc($query);
                 if ($score['score'] != 0) {
                     if ($_points == '' || $_points == '0.00') {
                         $emptyRCquery = mysql_query("select * from user_rate where userid = " . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ", $connection) or die("Error In rate" . mysql_error());
                         if (mysql_num_rows($emptyRCquery) > 0) {
                             $dv = new Criteria();
                             $dv->add(UserPeer::ID, $exp->getUserId());
                             $_thisUser = UserPeer::doSelectOne($dv);
                             $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $i++;
                         }
                     } else {
                         $dv = new Criteria();
                         $dv->add(UserPeer::ID, $exp->getUserId());
                         $_thisUser = UserPeer::doSelectOne($dv);
                         $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $i++;
                     }
                 }
             }
         }
     }
     asort($newUser);
     arsort($newUser);
     asort($rankUsersFinal);
     arsort($rankUsersFinal);
     $this->rankCheckUsers = $rankUsersFinal;
     ////if no online expert available redirecting to the board page
     // // ant-edit remove for now
     $onlineusers = array();
     $offlineusers = array();
     $newOnlineUser = array();
     $newOfflineUser = array();
     $j = 0;
     $k = 0;
     // $facebookTutors = BotServiceProvider::createFor("http://facebook.rayku.com/tutor")->getContent();
     // $onlineTutorsByNotificationBot = BotServiceProvider::createFor("http://notification-bot.rayku.com/tutor")->getContent();
     foreach ($newUser as $new) {
         $a = new Criteria();
         $a->add(UserPeer::ID, $new['userid']);
         $users_online = UserPeer::doSelectOne($a);
         $onlinecheck = '';
         if ($users_online->isOnline()) {
             $onlinecheck = "online";
         }
         // ant-edit remove for now
         if (empty($onlinecheck)) {
             $userGtalk = $users_online->getUserGtalk();
             if ($userGtalk) {
                 $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent();
                 // echo 'hello '  . $onlinecheck     ;
             }
         }
         // if (empty($onlinecheck) || ($onlinecheck != "online")) {
         //     $userFb = UserFbPeer::retrieveByUserId($new['userid']);
         //     if ($userFb) {
         //         $fb_username = $userFb->getFbUsername();
         //         $Users = json_decode($facebookTutors, true);
         //         foreach ($Users as $key => $user) {
         //             if ($user['username'] == $fb_username) {
         //                 $onlinecheck = 'online';
         //                 break;
         //             }
         //         }
         //     }
         // }
         // if (empty($onlinecheck) || ($onlinecheck != "online")) {
         //     $_Users = json_decode($onlineTutorsByNotificationBot, true);
         //     foreach ($_Users as $key => $_user) {
         //         if ($_user['email'] == $users_online->getEmail()) {
         //             $onlinecheck = 'online';
         //             break;
         //         }
         //     }
         // }
         if ($onlinecheck == "online") {
             $onlineusers[$j] = $new['userid'];
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $j++;
         } elseif ($users_online->isOnline()) {
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $onlineusers[$j] = $new['userid'];
             $j++;
         } else {
             $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $offlineusers[$k] = $new['userid'];
             $k++;
         }
     }
     $this->newOnlineUser = $newOnlineUser;
     $this->newOfflineUser = $newOfflineUser;
     $this->_checkOnlineUsers = $onlineusers;
     if (count($onlineusers) < 1) {
         $this->redirect('/forum/newthread/' . $_SESSION['subject'] . '?exp_online = 1');
     }
     $onoff = isset($_COOKIE["onoff"]) ? $_COOKIE["onoff"] : null;
     if ($onoff == 1) {
         if (!empty($_COOKIE["school"])) {
             $cookieSchool = array();
             $m = 0;
             foreach ($newOnlineUser as $new) {
                 $b = new Criteria();
                 $b->add(UserPeer::ID, $new['userid']);
                 $schoolusers = UserPeer::doSelectOne($b);
                 $mail = explode("@", $schoolusers->getEmail());
                 $newMail = explode(".", $mail[1]);
                 if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                     $cookieSchool[$m] = $new;
                     $m++;
                 }
             }
             $this->expert_cats = $cookieSchool;
         } else {
             $this->expert_cats = $newOnlineUser;
         }
     } else {
         if ($onoff == 2) {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newOfflineUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newOfflineUser;
             }
         } else {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newUser;
             }
         }
     }
     $this->tutorsCount = count($this->expert_cats);
     $c = new Criteria();
     $c->add(CategoryPeer::ID, $this->cat);
     $this->e = CategoryPeer::doSelectOne($c);
 }
Beispiel #13
0
<?php

$raykuUser = $sf_user->getRaykuUser();
$num_of_row = 0;
$IP = $_SERVER['REMOTE_ADDR'];
$_query = mysql_query("select * from thread  where user_ip='" . $IP . "' and banned=1");
$num_of_row = mysql_num_rows($_query);
if ($num_of_row > 0) {
    echo "\n        <script type='text/javascript'>\n     document.location='http://" . RaykuCommon::getCurrentHttpDomain() . "/error';\n\t\t</script>";
}
$_query = mysql_query("select * from banned_ips  where ip like '%" . $IP . "%' ");
$num_of_row = mysql_num_rows($_query);
if ($num_of_row > 0) {
    echo "\n        <script type='text/javascript'>\n     document.location='http://" . RaykuCommon::getCurrentHttpDomain() . "/error';\n\t\t</script>";
}
$logedUserId = @$_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
if ($logedUserId != '') {
    $user_id = $raykuUser->getId();
    $num_of_row = 0;
    $_query = mysql_query("select * from thread  where \tposter_id='" . $user_id . "' and banned=1");
    $num_of_row = mysql_num_rows($_query);
    if ($num_of_row > 0) {
        echo "\n\t\t\t\t<script type='text/javascript'>\n     document.location='http://" . RaykuCommon::getCurrentHttpDomain() . "/error';\n\t\t\t\t</script>";
    }
}
Beispiel #14
0
 public function getExpertScore()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $query = mysql_query("select * from user_score where user_id=" . $logedUserId . " ", $connection) or die(mysql_error());
     $row = mysql_fetch_assoc($query);
     return $row['score'];
 }
Beispiel #15
0
 public function executeStay()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $userId = $this->getUser()->getRaykuUser()->getId();
     $user = $this->getUser()->getRaykuUser();
     $time = time() - 1800;
     $query = mysql_query("select * from user_stay where user_id=" . $userId . " ", $connection) or die(mysql_error());
     if (mysql_num_rows($query) > 0 && $user->isOnline()) {
         $queryStay = mysql_query("select * from user_stay where user_id=" . $userId . " and time <= '" . $time . "' ", $connection) or die(mysql_error());
         if (mysql_num_rows($queryStay) > 0) {
             $_time = time();
             $_rowStay = mysql_fetch_assoc($queryStay);
             $stayTime = $_rowStay['stay'] + 1;
             mysql_query("update user_stay set stay = '" . $stayTime . "', time = '" . $_time . "' where user_id=" . $userId, $connection) or die(mysql_error());
         }
     } elseif ($user->isOnline()) {
         $_time = time();
         mysql_query("insert into user_stay(user_id,time, stay) values(" . $userId . ",'" . $_time . "', 1) ", $connection) or die(mysql_error());
     }
     exit(0);
 }
Beispiel #16
0
	<tr class="sf_admin_row_<?php 
    echo $row;
    ?>
">

	<td><?php 
    echo $j;
    ?>
</td>

      <td><a href="#"><?php 
    echo $item['title'];
    ?>
</a></td>
<?php 
    $connection = RaykuCommon::getDatabaseConnection();
    $query = mysql_query("select * from item_featured where item_id =" . $item['id'] . " and status = 1", $connection) or die(mysql_error());
    if (mysql_num_rows($query) > 0) {
        ?>

	<td>Yes</td>

	<?php 
    } else {
        ?>

	<td>No</td>

	<?php 
    }
    ?>
Beispiel #17
0
 /**
  * Ban Ip Action for handling the user deletion/unbanning
  */
 public function executeBanIp()
 {
     if ($this->getRequestParameter('banip') != '') {
         $ips = $this->getRequestParameter('banip');
         $connection = RaykuCommon::getDatabaseConnection();
         $_query = mysql_query("insert into banned_ips set ip='" . $ips . "'  ", $connection);
     }
     $this->redirect('/admin.php/users/deleteUser', 'Successfully Ip has been banned');
 }
Beispiel #18
0
 if ($sfcategory == 5) {
     $allsub = "General Student";
 } else {
     $titSQL = "SELECT `tutor_role`,`school`,`study` FROM `tutor_profile` WHERE `user_id` = " . $newOne['userid'] . "";
     $titRes = mysql_query($titSQL);
     $allsub = "";
     if (mysql_num_rows($titRes)) {
         $tutData = mysql_fetch_assoc($titRes);
         $allsub = @$tutData['tutor_title'];
         if ($tutData['tutor_role'] != '') {
             $allsub .= $tutData['tutor_role'];
             if ($tutData['school'] != '') {
                 $allsub .= " at " . $tutData['school'];
             }
             if ($tutData['study'] != '') {
                 $allsub .= " " . RaykuCommon::getTitlePre($tutData['tutor_role']) . " " . $tutData['study'];
             }
         }
     }
     if ($allsub == "") {
         $allsub = "Student";
     }
 }
 $query5 = mysql_query("select * from user_rate where userid=" . $newOne['userid'] . " ") or die(mysql_error());
 if (mysql_num_rows($query5) > 0) {
     $rowValues = mysql_fetch_assoc($query5);
     $rate = $rowValues['rate'] . "RP";
 } else {
     $rate = "0.00RP";
 }
 $curr_user_rank = '';
Beispiel #19
0
 public function preExecute()
 {
     RaykuCommon::getDatabaseConnection();
 }
Beispiel #20
0
 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     mysql_query("delete from popup_close where user_id=" . $logedUserId, $connection) or die(mysql_error());
     if (isset($_SERVER['HTTP_COOKIE'])) {
         $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
         foreach ($cookies as $cookie) {
             $parts = explode('=', $cookie);
             $name = trim($parts[0]);
             if ($name != "rayku_frontend" && $name != "ratingExpertId" && $name != "ratingUserId" && $name != "timer" && $name != "whiteboardChatId") {
                 $this->getResponse()->setCookie($name, "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             }
         }
     }
     if (!empty($_POST)) {
         if (empty($_POST["rating"])) {
             $this->redirect('/dashboard/rating');
         }
         if (empty($_COOKIE['ratingExpertId']) && empty($_COOKIE['ratingUserId'])) {
             $this->redirect('/dashboard');
         } else {
             if (!empty($_COOKIE['raykuCharge'])) {
                 $rate = $_COOKIE['raykuCharge'];
             } else {
                 $user = UserPeer::retrieveByPK($_COOKIE["ratingExpertId"]);
                 if ($user) {
                     $rate = $user->getRate();
                 } else {
                     $rate = 0;
                 }
             }
             $timer = explode(":", $_COOKIE["timer"]);
             $newTimer = ($timer[0] * 3600 + $timer[1] * 60) / 60;
             $raykuPercentage = $newTimer * $rate;
             $_chat_rating = $_POST["rating"];
             $date = date('Y-m-d H:i:s');
             $queryScore = mysql_query("select * from user_score where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             $rowScore = mysql_fetch_assoc($queryScore);
             $queryAsker = mysql_query("select * from user where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
             $rowAsker = mysql_fetch_assoc($queryAsker);
             $queryExpert = mysql_query("select * from user where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             $rowExpert = mysql_fetch_assoc($queryExpert);
             $queryKinkarso = mysql_query("select * from user where id=124", $connection) or die(mysql_error());
             $rowKinkarso = mysql_fetch_assoc($queryKinkarso);
             if ($_POST["rating"] == 1) {
                 $check1RatingScore = $rowScore['score'] - 20;
                 if ($check1RatingScore < 1) {
                     $newRatingScore = "1";
                 } else {
                     $newRatingScore = $rowScore['score'] - 20;
                 }
                 mysql_query("update user_score set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $kinkarsoPoints = $rowKinkarso["points"] + $raykuPercentage;
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 2) {
                 $tiptutor = $_POST["tiptutor"];
                 $askerPoints = $rowAsker["points"] - $raykuPercentage;
                 mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                 $expertPer = $raykuPercentage * 25 / 100;
                 $kinkarsoPer = $raykuPercentage * 75 / 100;
                 $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                 $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                 mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
             } elseif ($_POST["rating"] == 3) {
                 $tiptutor = $_POST["tiptutor"];
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 10;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 4;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage * 50 / 100;
                     $kinkarsoPer = $raykuPercentage * 50 / 100;
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 4) {
                 $tiptutor = $_POST["tiptutor"];
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 18;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 7;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage * 75 / 100;
                     //60;
                     $kinkarsoPer = $raykuPercentage * 25 / 100;
                     //40;
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 5) {
                 $tiptutor = $_POST["tiptutor"];
                 $ratingScore = !empty($rowScore['score']) ? $rowScore['score'] : 0;
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage;
                     // 5 stars: 100% RP
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 25;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 10;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             }
             if (isset($_POST["checkbox"]) && !empty($_POST["checkbox"])) {
                 if (!empty($_COOKIE["ratingExpertId"]) && !empty($_COOKIE["ratingUserId"])) {
                     $query = mysql_query("select * from expert_subscribers where expert_id = " . $_COOKIE["ratingExpertId"] . " and user_id =" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     if (mysql_num_rows($query) == 0) {
                         mysql_query("insert into expert_subscribers(expert_id, user_id) values('" . $_COOKIE["ratingExpertId"] . "', '" . $_COOKIE["ratingUserId"] . "')", $connection) or die(mysql_error());
                         $queryScore = mysql_query("select * from user_score where user_id =" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                         $rowScore = mysql_fetch_assoc($queryScore);
                         $newScore = '';
                         $newScore = $rowScore['score'] + 10;
                         mysql_query("update user_score set score = " . $newScore . " where user_id =" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     }
                 }
             }
             if (!empty($_COOKIE["whiteboardChatId"]) && !empty($_COOKIE["whiteboardChatId"])) {
                 $chatId = $_COOKIE["whiteboardChatId"];
                 $_SESSION["whiteboard_Chat_Id"] = $_COOKIE["whiteboardChatId"];
                 if (isset($_POST["chkIsPublic"]) && !empty($_POST["chkIsPublic"])) {
                     $criteria = new Criteria();
                     $criteria->add(WhiteboardChatPeer::ID, $chatId);
                     $chat = WhiteboardChatPeer::doSelectOne($criteria);
                     if ($chat) {
                         $chat->setIsPublic(true);
                         $chat->save();
                     }
                 }
                 $_comments = !empty($_POST['content']) ? $_POST['content'] : '';
                 $_chat_query = mysql_query("select * from whiteboard_chat where id=" . $chatId . "", $connection) or "Error In Select" . mysql_error();
                 if (mysql_num_rows($_chat_query) > 0) {
                     $_chat_row = mysql_fetch_assoc($_chat_query);
                     mysql_query("update whiteboard_chat set timer = '" . $newTimer . "', rating = " . $_chat_rating . ", amount=" . $raykuPercentage . ", comments = '" . $_comments . "' where id=" . $chatId . " ", $connection) or die(mysql_error());
                 }
             }
             $this->getResponse()->setCookie("timer", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("whiteboardChatId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("ratingExpertId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("ratingUserId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->user = $this->getUser()->getRaykuUser();
             $this->userPoints = $this->user->getPoints();
             $this->userFirstCharge = $this->user->getFirstCharge();
             if ($this->userPoints < 0 && empty($this->userFirstCharge)) {
                 $datetime = strtotime($row->createdate);
                 $mysqldate = date("m/d/y g:i A", $datetime);
                 $this->user->setFirstCharge($mysqldate);
             }
             if ($_chat_rating == 1 || $_chat_rating == 2) {
                 $this->redirect('/dashboard/moneyback');
             }
             $this->redirect('/referrals?session=complete');
         }
     }
 }
Beispiel #21
0
 public function executeCurrenttutor()
 {
     // connect to the database and get the current user's id
     $connection = RaykuCommon::getDatabaseConnection();
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     // make a query to the user_expert table (which should hold current questions)
     // sort by status, lowest first, and limit to one
     $sql = "SELECT * FROM user_expert WHERE user_id='" . mysql_real_escape_string($userId) . "' ORDER BY exe_order LIMIT 0,1";
     $result = mysql_query($sql);
     // if there is nothing else, let sami know by returning a blank object
     if (mysql_num_rows($result) === 0) {
         print "";
         exit;
     }
     // get the target tutor's id, and get their information
     $tutor_row = mysql_fetch_assoc($result);
     $tutor_id = $tutor_row['checked_id'];
     // get their username, firt, and last name
     $sql = "SELECT * FROM user WHERE id='" . mysql_real_escape_string($tutor_id) . "'";
     $result = mysql_query($sql);
     $tutor_info = mysql_fetch_assoc($result);
     $tutor_user_name = $tutor_info['username'];
     $tutor_full_name = $tutor_info['name'];
     $tutor_pic_url = 'http://' . RaykuCommon::getCurrentHttpDomain() . "/avatar/{$tutor_id}/0";
     // get their experience and profile
     $sql = "SELECT * FROM tutor_profile WHERE user_id='" . mysql_real_escape_string($tutor_id) . "'";
     $result = mysql_query($sql);
     $tutor_info = mysql_fetch_assoc($result);
     $tutor_school = $tutor_info['school'];
     $tutor_role = $tutor_info['tutor_role'];
     $tutor_study = $tutor_info['study'];
     // get an object ready to return to client end
     $return_obj = new stdClass();
     $return_obj->id = $tutor_id;
     $return_obj->user_name = $tutor_user_name;
     $return_obj->full_name = $tutor_full_name;
     $return_obj->pic_url = $tutor_pic_url;
     $return_obj->school = $tutor_school;
     $return_obj->role = $tutor_role;
     $return_obj->study = $tutor_study;
     // return json-encoded object
     print json_encode($return_obj);
     exit;
 }
Beispiel #22
0
?>
      </div>
      <div class="cmmt">
        <div class="info">
          <div> <img src="<?php 
echo image_path('forum-threads-statuson.gif', false);
?>
" alt="" />
            <p><?php 
echo $thread->getTitle();
?>
</p>
          </div>
          <div class="postdate">
            <?php 
$date = RaykuCommon::formatDateForPost($post->getUpdatedAt());
?>
            Posted on <?php 
echo $date;
?>
 </div>
          <?php 
$logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
if ($sf_user->getRaykuUserId() == $user->getId()) {
    echo '<div class="btns">';
    if ($thread->getVisible() == 1) {
        echo link_to('close', '@thread_status?thread_id=' . $thread->getId() . '&status=close', array('class' => 'close'));
    } else {
        // echo link_to('Re-activate','@thread_status?thread_id='.$thread->getId().'&status=reactive',array('class' => 'reac'));
        echo link_to('Closed', '@view_thread?thread_id=' . $thread->getId(), array('class' => 'closed'));
    }
Beispiel #23
0
 public function executeDelete()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $newCommentId = explode("/", $_SERVER['REDIRECT_URL']);
     //To Select Profile User
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $query = mysql_query("select * from user where id=" . $logedUserId, $connection) or die(mysql_error());
     $row = mysql_fetch_assoc($query);
     // For delete Shout
     $querynew = mysql_query("delete from shout where id=" . $newCommentId[4] . " ", $connection) or die(mysql_error());
     $this->redirect('@profile?username='******'username']);
     //$this->redirect('@homepage');
 }
Beispiel #24
0
    ?>
/js/widget/jquery.ui.core.js"></script> 
   <script src="http://<?php 
    echo RaykuCommon::getCurrentHttpDomain();
    ?>
/js/widget/jquery.ui.widget.js"></script> 
   <script src="http://<?php 
    echo RaykuCommon::getCurrentHttpDomain();
    ?>
/js/widget/jquery.ui.mouse.js"></script> 
   <script src="http://<?php 
    echo RaykuCommon::getCurrentHttpDomain();
    ?>
/js/widget/jquery.ui.slider.js"></script> 
   <script type="text/javascript" src="http://<?php 
    echo RaykuCommon::getCurrentHttpDomain();
    ?>
/js/widget/jquery.qtip-1.0.0-rc3.min.js"></script> 
   <script type="text/javascript">
    var vd = jQuery.noConflict();

    vd('#rank').qtip({
        content: '<span id="rank-heading">Rank in the <b>top #25</b> and<br >you will show up on the<br >1st page of tutor search lists.</span>',
        position: {
            corner: {
                target: 'topRight',
                tooltip: 'topLeft'
            }
        },
        show: 'mouseover',
        hide: 'mouseout',
Beispiel #25
0
 public function execute($request)
 {
     RaykuCommon::getDatabaseConnection();
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $time = time();
     $_SESSION["_modelbox"] = 0;
     @setcookie('_popupclose', '', time() - 300, '/', sfConfig::get('app_cookies_domain'));
     if (@$_SESSION['modelPopupOpen']) {
         unset($_SESSION['modelPopupOpen']);
         if ($_SESSION['popup_session']) {
             unset($_SESSION['popup_session']);
         }
     }
     $details = explode(",", $_REQUEST['details']);
     if (count($details) > 4) {
         $details[2] = base64_decode($details[2]);
         $peer = new StudentQuestionPeer();
         $studentQuestion = $peer->retrieveByPk($this->getRequestParameter('questionId'));
         $questionId = $this->getRequestParameter('questionId');
         $sessionService = new WhiteboardSessionService();
         $session = $sessionService->connect($userId, $questionId);
         mysql_query("delete from user_expert where user_id = " . $userId) or die(mysql_error());
         $this->getResponse()->setCookie('sessionToken', $session->getToken(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $expertId = $details[0];
         $raykuCharge = $this->getRaykuCharge($expertId);
         $this->getResponse()->setCookie("raykuCharge", $raykuCharge, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         // redirect to rayku whiteboard
         $this->redirect(sfConfig::get('app_whiteboard_url') . '/');
     } else {
         $criteria = new Criteria();
         $criteria->add(WhiteboardSessionPeer::CHAT_ID, $details[1]);
         $tutorSession = WhiteboardSessionPeer::doSelectOne($criteria);
         $studentQuestion = $tutorSession->getStudentQuestion();
         $student = $studentQuestion->getStudent();
         $tutor = $studentQuestion->getTutor();
         $this->getResponse()->setCookie('ratingExpertId', $tutor->getId(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie('ratingUserId', $student->getId(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("askerpoints", $student->getPoints(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("loginname", $student->getUsername(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("check_nick", $student->getUsername(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("chatid", $tutorSession->getChatId(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $sessionService = new WhiteboardSessionService();
         $studentSession = $sessionService->connect($student->getId(), $studentQuestion->getId());
         $studentSession->setChatId($tutorSession->getChatId());
         $studentSession->save();
         $this->getResponse()->setCookie("sessionToken", $studentSession->getToken(), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $_record_id = $details[0];
         $_queryRecord = mysql_query("select * from sendmessage where id = " . $_record_id . " ") or die(mysql_error());
         if (mysql_num_rows($_queryRecord)) {
             $row = mysql_fetch_array($_queryRecord);
             $raykuCharge = $this->getRaykuCharge($row['expert_id']);
             $this->getResponse()->setCookie("raykuCharge", $raykuCharge, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("newredirect", 1, time() + 100, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("redirection", "", time() - 600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("forumsub", "", time() - 600, '/', sfConfig::get('app_cookies_domain'));
             if (!empty($userId)) {
                 mysql_query("insert into popup_close(user_id) values(" . $userId . ")") or die("error3" . mysql_error());
             }
             if (!empty($details[0])) {
                 mysql_query("delete from sendmessage where id = " . $details[0]) or die("error4" . mysql_error());
             }
             // redirect to rayku whiteboard
             $this->redirect(sfConfig::get('app_whiteboard_url') . '/');
         } else {
             $this->redirect('/dashboard');
         }
     }
 }
Beispiel #26
0
    public function executeExpertReplyThread()
    {
        $connection = RaykuCommon::getDatabaseConnection();
        $c = new Criteria();
        $c->add(ForumPeer::TYPE, 0);
        $this->publicforums = ForumPeer::doSelect($c);
        $this->allcategories = CategoryPeer::doSelect($c = new Criteria());
        $this->forum = $this->getRequestParameter('forum_id');
        $this->thread = ThreadPeer::retrieveByPK($this->getRequestParameter('thread_id'));
        $c = new Criteria();
        $c->add(PostPeer::THREAD_ID, $this->thread->getId());
        $this->post = PostPeer::doSelectOne($c);
        $user = $this->getUser()->getRaykuUser();
        if ($this->getRequestParameter('post_edit_content') != '') {
            $threadId = $this->getRequestParameter('thread_id');
            $_thread = ThreadPeer::retrieveByPK($threadId);
            $_thread->setTitle($this->getRequestParameter('post_edit_title'));
            $_thread->save();
            $v = new Criteria();
            $v->add(PostPeer::THREAD_ID, $threadId);
            $v->addAscendingOrderByColumn(PostPeer::ID);
            $post = PostPeer::doSelectOne($v);
            $post->setContent($this->getRequestParameter('post_edit_content'));
            $post->save();
            return $this->redirect('@view_thread?thread_id=' . $threadId);
        }
        if ($this->getRequestParameter('post_body') != '') {
            if ($this->getRequestParameter('final_id') != '') {
                $_quick_reply = '';
                $_post_id = $this->getRequestParameter('final_id');
                $_Post = PostPeer::retrieveByPK($_post_id);
                $_User = UserPeer::retrieveByPK($_Post->getPosterId());
                $_quick_reply .= "<div style='margin-left:20px'><em><strong>Quote from " . $_User->getUsername() . "</strong></em><br><br>";
                $_explode_post = explode("*^-", $_Post->getContent());
                if (count($_explode_post) > 1) {
                    $_quick_reply .= $_explode_post[1];
                } else {
                    $_quick_reply .= $_Post->getContent();
                }
                $_quick_reply .= "</div>";
                $_post_body_msg = $this->getRequestParameter('post_body');
                $_quick_reply .= $_post_body_msg;
                $user->makeNewPost($this->getRequestParameter('thread_id'), $_quick_reply);
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            } else {
                $user->makeNewPost($this->getRequestParameter('thread_id'), $this->getRequestParameter('post_body'));
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            }
            if ($this->getUser()->getRaykuUser()->getType() == '5') {
                $c = new Criteria();
                $c->add(ThreadPeer::ID, $this->getRequestParameter('thread_id'));
                $thread = ThreadPeer::doSelectOne($c);
                $c = new Criteria();
                $c->add(UserPeer::ID, $thread->getPosterId());
                $user = UserPeer::doSelectOne($c);
                if ($thread->getNotifyPm() == '1') {
                    $subject = 'Expert Response for your Question';
                    $body = 'Hi there, <br><br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '" has just responsed to your question, "' . $thread->getTitle() . '" on the question boards. Take a look!<br><br>
							Rayku Administration';
                    //Grab the user object
                    $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId());
                    //Send the message
                    $currentuser->sendMessage($user->getId(), $subject, $body);
                }
                if ($thread->getNotifyEmail() == '1') {
                    $this->mail = new sfMail();
                    //Set the to, from, and subject headers
                    $this->mail->addAddress($user->getEmail());
                    $this->mail->setFrom('Expert <' . $this->getUser()->getRaykuUser()->getEmail() . '>');
                    $this->mail->setSubject('Expert Response to your Question');
                    $this->mail->setBody('Hi there,<br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '", has just responded to your question (below) on the question boards. Take a look!<br><br>
							' . $thread->getTitle() . '');
                    $this->mail->send();
                }
            }
            return $this->redirect('@view_thread?thread_id=' . $this->thread->getId());
        }
    }
Beispiel #27
0
function getUsername($id)
{
    $name = '';
    RaykuCommon::getDatabaseConnection();
    $_query = mysql_query("select * from user where id=" . $id) or die("Error1" . mysql_error());
    if (mysql_num_rows($_query)) {
        $_row = mysql_fetch_assoc($_query);
        $name = ucfirst($_row['name']);
    }
    return $name;
}
Beispiel #28
0
 /**
  * all members database
  */
 public function execute($request)
 {
     RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $this->userId = $currentUser->getId();
     /* Clearing Cookies 
     
               if($_COOKIE['onoff'] != 1) {
     
               for($u=$_COOKIE['cookcount'];$u>=1;$u--) {
     
               $cookname =  'tutor_'.$u;
     
               setcookie($cookname,'', time()-3600, "/");
     
               }
     
               setcookie("tutorcount",'', time()-3600, "/");
               setcookie("cookcount",'', time()-3600, "/");
     
               }
     
               /* Clearing Cookies */
     $time = time();
     if (!empty($_POST['hidden'])) {
         $count = count($_POST['checkbox']);
         /* Clearing Cookies */
         for ($u = $_COOKIE['cookcount']; $u >= 1; $u--) {
             $cookname = 'tutor_' . $u;
             $this->getResponse()->setCookie($cookname, '', time() - 3600, '/', sfConfig::get('app_cookies_domain'));
         }
         $this->getResponse()->setCookie("tutorcount", '', time() - 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("cookcount", '', time() - 3600, '/', sfConfig::get('app_cookies_domain'));
         /* Clearing Cookies */
         if ($count == 4) {
             $close = 46000;
             $_SESSION['connected_tutors'] = 4;
         }
         if ($count == 3) {
             $close = 46000;
             $_SESSION['connected_tutors'] = 3;
         } else {
             if ($count == 2) {
                 $close = 61000;
                 $_SESSION['connected_tutors'] = 2;
             } else {
                 if ($count == 1) {
                     $close = 61000;
                     $_SESSION['connected_tutors'] = 1;
                 } else {
                     $close = 61000;
                     $_SESSION['connected_tutors'] = 1;
                 }
             }
         }
         $j = 0;
         for ($i = 0; $i < $count; $i++) {
             mysql_query("INSERT INTO `user_expert` (`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close) VALUES ('" . $userId . "', '" . $_POST['checkbox'][$i] . "', '5', 'To be discussed','" . ++$j . "', '" . $time . "', 1, " . $close . ") ") or die(mysql_error());
         }
         /* Notify same tutor again */
         $l = 0;
         $source = 'tutorlist';
         mysql_query("DELETE FROM `student_questions` WHERE user_id=" . $userId . "");
         for ($i = 0; $i < $count; $i++) {
             mysql_query("INSERT INTO `student_questions` (`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close, source) VALUES ('" . $userId . "', '" . $_POST['checkbox'][$i] . "', '5', 'To be discussed','" . ++$l . "', '" . $time . "', 1, " . $close . ", '" . $source . "') ") or die(mysql_error());
         }
         setcookie("asker_que", $_SESSION['question'], time() + 600, "/", sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("redirection", 1, time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("forumsub", 1, time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $this->redirect('expertmanager/connect');
     }
     $this->cat = $this->getRequestParameter('category');
     $this->course_id = $this->getRequestParameter('course');
     if (empty($this->course_id)) {
         $this->course_id = 1;
     }
     if (empty($this->cat)) {
         $this->cat = 1;
     }
     $queryPoints = mysql_query("select * from user where id=" . $userId) or die("Error In rate" . mysql_error());
     if (mysql_num_rows($queryPoints) > 0) {
         $rowPoints = mysql_fetch_assoc($queryPoints);
         $_points = $rowPoints['points'];
     }
     $c = new Criteria();
     $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN);
     if ($this->cat == 5) {
         $experts = ExpertCategoryPeer::doSelect($c);
     } else {
         $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat);
         $experts = ExpertCategoryPeer::doSelect($c);
     }
     $newUser = array();
     $i = 0;
     $eachExpertOnlyOnce = array();
     foreach ($experts as $exp) {
         if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) {
             continue;
         }
         $eachExpertOnlyOnce[] = $exp->getUserId();
         $_queryCourse = mysql_query("select * from expert_course where user_id =" . $exp->getUserId() . " and category_id = 1 and course_id = " . $this->course_id . " ") or die("Er-1-->" . mysql_error());
         if (mysql_num_rows($_queryCourse) > 0) {
             $query = mysql_query("select * from user_score where user_id=" . $exp->getUserId()) or die(mysql_error());
             $score = mysql_fetch_assoc($query);
             if ($score['score'] != 0) {
                 if (false) {
                     //$_points == '' || $_points == '0.00'     Temporary hack
                     $emptyRCquery = mysql_query("select * from user_rate where userid=" . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ") or die("Error In rate" . mysql_error());
                     if (mysql_num_rows($emptyRCquery) > 0) {
                         $dv = new Criteria();
                         $dv->add(UserPeer::ID, $exp->getUserId());
                         $_thisUser = UserPeer::doSelectOne($dv);
                         $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $i++;
                     }
                 } else {
                     $dv = new Criteria();
                     $dv->add(UserPeer::ID, $exp->getUserId());
                     $_thisUser = UserPeer::doSelectOne($dv);
                     $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                     $i++;
                 }
             }
         }
     }
     asort($newUser);
     arsort($newUser);
     $this->rankCheckUsers = $newUser;
     ////if no online expert available redirecting to the board page
     $onlineusers = array();
     $offlineusers = array();
     $newOnlineUser = array();
     $newOfflineUser = array();
     $j = 0;
     $k = 0;
     $facebookResponse = BotServiceProvider::createFor(sfConfig::get('app_facebook_url') . "/tutor")->getContent();
     $facebookUsers = json_decode($facebookResponse, true);
     $botResponse = BotServiceProvider::createFor(sfConfig::get('app_notification_bot_url') . "/tutor")->getContent();
     $botUsers = json_decode($botResponse, true);
     foreach ($newUser as $new) {
         $a = new Criteria();
         $a->add(UserPeer::ID, $new['userid']);
         $users_online = UserPeer::doSelectOne($a);
         $onlinecheck = '';
         if ($users_online->isOnline()) {
             $onlinecheck = "online";
         }
         if (empty($onlinecheck)) {
             $userGtalk = $users_online->getUserGtalk();
             if ($userGtalk) {
                 $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent();
             }
         }
         if ((empty($onlinecheck) || $onlinecheck != "online") && is_array($facebookUsers)) {
             $fb_query = mysql_query("select * from user_fb where userid=" . $new['userid']) or die(mysql_error());
             if (mysql_num_rows($fb_query) > 0) {
                 $fbRow = mysql_fetch_assoc($fb_query);
                 $fb_username = $fbRow['fb_username'];
                 foreach ($facebookUsers as $key => $user) {
                     if ($user['username'] == $fb_username) {
                         $onlinecheck = 'online';
                         break;
                     }
                 }
             }
         }
         if ((empty($onlinecheck) || $onlinecheck != "online") && is_array($botUsers)) {
             foreach ($botUsers as $key => $_user) {
                 if ($_user['email'] == $users_online->getEmail()) {
                     $onlinecheck = 'online';
                     break;
                 }
             }
         }
         if ($onlinecheck == "online") {
             $onlineusers[$j] = $new['userid'];
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $j++;
         } elseif ($users_online->isOnline()) {
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $onlineusers[$j] = $new['userid'];
             $j++;
         } else {
             $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $offlineusers[$k] = $new['userid'];
             $k++;
         }
     }
     $this->newOnlineUser = $newOnlineUser;
     $this->newOfflineUser = $newOfflineUser;
     $this->_checkOnlineUsers = $onlineusers;
     /////////////////////////////////////////////////////
     if (isset($_COOKIE["onoff"]) && $_COOKIE["onoff"] == 1) {
         if (!empty($_COOKIE["school"])) {
             $cookieSchool = array();
             $m = 0;
             foreach ($newOnlineUser as $new) {
                 $b = new Criteria();
                 $b->add(UserPeer::ID, $new['userid']);
                 $schoolusers = UserPeer::doSelectOne($b);
                 $mail = explode("@", $schoolusers->getEmail());
                 $newMail = explode(".", $mail[1]);
                 if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                     $cookieSchool[$m] = $new;
                     $m++;
                 }
             }
             $this->expert_cats = $cookieSchool;
         } else {
             $this->expert_cats = $newOnlineUser;
         }
     } else {
         if (isset($_COOKIE["onoff"]) && $_COOKIE["onoff"] == 2) {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newOfflineUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newOfflineUser;
             }
         } else {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newUser;
             }
         }
     }
     $this->tutorsCount = count($this->expert_cats);
     $c = new Criteria();
     $c->add(CategoryPeer::ID, $this->cat);
     $this->e = CategoryPeer::doSelectOne($c);
 }
Beispiel #29
0
 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $this->userId = $currentUser->getId();
     $time = time();
     $this->cat = $this->getRequestParameter('category');
     $this->course_id = $this->getRequestParameter('course');
     if (empty($this->course_id)) {
         if (!empty($_SESSION['course_id'])) {
             $this->course_id = $_SESSION['course_id'];
         } else {
             $this->course_id = 1;
         }
     } else {
         $_SESSION['course_id'] = $this->course_id;
     }
     if (empty($this->cat)) {
         if (!empty($_SESSION['subject'])) {
             $this->cat = $_SESSION['subject'];
         } else {
             $this->cat = 1;
         }
     } else {
         $_SESSION['subject'] = $this->cat;
     }
     if (empty($_SESSION["course_id"])) {
         $_SESSION["course_id"] = '1';
     }
     /* Quick Registration Users - Listing Tutors */
     if ($this->studentFromQuickRegistrationAskingAQuestion()) {
         $_dash_question = '';
         $_dash_course_id = '';
         $_school = '';
         $_dash_education = '';
         $_dash_code_id = '';
         $_dash_year = '';
         $_SESSION['subject'] = 1;
         $_dash_education = $_SESSION['edu'];
         $_dash_course_id = $_SESSION['course_id'];
         if ($_dash_course_id) {
             $queryCname = mysql_query("select * from courses where id ='" . $_dash_course_id . "'", $connection) or die(mysql_error());
             $rowCoursename = mysql_fetch_array($queryCname);
             $_SESSION['course_name_sess'] = $rowCoursename['course_name'];
         }
         if (strtolower($_SESSION['year']) != "Choose year") {
             $_dash_year = trim($_SESSION['year']);
         } elseif (strtolower($_SESSION['grade']) != "Choose grade") {
             $_dash_year = trim($_SESSION['grade']);
         }
         $c = new Criteria();
         $c->add(UserQuestionTagPeer::CATEGORY_ID, 1);
         $c->add(UserQuestionTagPeer::USER_ID, $userId);
         $c->add(UserQuestionTagPeer::COURSE_ID, $_dash_course_id);
         $c->add(UserQuestionTagPeer::COURSE_CODE, $_dash_code_id);
         $c->add(UserQuestionTagPeer::EDUCATION, $_dash_education);
         $c->add(UserQuestionTagPeer::SCHOOL, $_school);
         $c->add(UserQuestionTagPeer::YEAR, $_dash_year);
         $userQuestionTag = UserQuestionTagPeer::doSelectOne($c);
         if ($userQuestionTag) {
             $userQuestionTag->delete();
         }
         $userQuestionTag = new UserQuestionTag();
         $userQuestionTag->setUserId($userId);
         $userQuestionTag->setCategoryId(1);
         $userQuestionTag->setCourseId($_dash_course_id);
         $userQuestionTag->setCourseCode($_dash_code_id);
         $userQuestionTag->setEducation($_dash_education);
         $userQuestionTag->setSchool($_school);
         $userQuestionTag->setYear($_dash_year);
         $userQuestionTag->setQuestion($_SESSION['question']);
         $userQuestionTag->save();
     } else {
         if ($this->loggedStudentAsksAQuestion()) {
             $_dash_question = '';
             $_dash_course_id = '';
             $_school = '';
             $_dash_education = '';
             $_dash_code_id = '';
             $_dash_year = '';
             $_dash_question = $_POST['question'];
             $_SESSION['question'] = $_dash_question;
             $_SESSION['subject'] = 1;
             if (!empty($_POST['course_category_hidden'])) {
                 $course_name = trim($_POST['course_category_hidden']);
                 $_SESSION['course_name_sess'] = $course_name;
                 $_queryCourse = mysql_query("select * from courses where course_name ='" . $course_name . "' ", $connection) or die(mysql_error());
                 $_rowCourse = mysql_fetch_assoc($_queryCourse);
                 $_dash_course_id = $_rowCourse['id'];
                 $_SESSION["course_id"] = $_dash_course_id;
             }
             $_dash_education = $_POST['edu'];
             /* Student Confirmation */
             $_SESSION['edu'] = $_dash_education;
             if (strtolower($_POST['year_hidden']) != "choose year") {
                 $_dash_year = trim($_POST['year_hidden']);
                 /* student confirmation */
                 $_SESSION['year'] = $_dash_year;
             } elseif (strtolower($_POST['grade_hidden']) != "choose grade") {
                 $_dash_year = trim($_POST['grade_hidden']);
                 /* student confirmation */
                 $_SESSION['grade'] = $_dash_year;
             }
             $c = new Criteria();
             $c->add(UserQuestionTagPeer::CATEGORY_ID, 1);
             $c->add(UserQuestionTagPeer::USER_ID, $userId);
             $c->add(UserQuestionTagPeer::COURSE_ID, $_dash_course_id);
             $c->add(UserQuestionTagPeer::COURSE_CODE, $_dash_code_id);
             $c->add(UserQuestionTagPeer::EDUCATION, $_dash_education);
             $c->add(UserQuestionTagPeer::SCHOOL, $_school);
             $c->add(UserQuestionTagPeer::YEAR, $_dash_year);
             $userQuestionTag = UserQuestionTagPeer::doSelectOne($c);
             if ($userQuestionTag) {
                 $userQuestionTag->delete();
             }
             $userQuestionTag = new UserQuestionTag();
             $userQuestionTag->setUserId($userId);
             $userQuestionTag->setCategoryId(1);
             $userQuestionTag->setCourseId($_dash_course_id);
             $userQuestionTag->setCourseCode($_dash_code_id);
             $userQuestionTag->setEducation($_dash_education);
             $userQuestionTag->setSchool($_school);
             $userQuestionTag->setYear($_dash_year);
             $userQuestionTag->setQuestion($_POST['question']);
             $userQuestionTag->save();
         }
     }
     /**
      * @todo - below block of code could be extracted to separate action 
      */
     if (!empty($_POST['hidden'])) {
         $count = count($_POST['checkbox']);
         /* Clearing Cookies */
         if (isset($_COOKIE['cookcount'])) {
             for ($u = $_COOKIE['cookcount']; $u >= 1; $u--) {
                 $cookname = 'expert_' . $u;
                 setcookie($cookname, '', time() - 3600, "/", sfConfig::get('app_cookies_domain'));
             }
         }
         setcookie("expertscount", '', time() - 3600, "/", sfConfig::get('app_cookies_domain'));
         setcookie("cooktotal", '', time() - 3600, "/", sfConfig::get('app_cookies_domain'));
         /* Clearing Cookies */
         if ($count == 4) {
             $close = 46000;
             $_SESSION['connected_tutors'] = 4;
         } else {
             if ($count == 3) {
                 $close = 46000;
                 $_SESSION['connected_tutors'] = 3;
             } else {
                 if ($count == 2) {
                     $close = 61000;
                     $_SESSION['connected_tutors'] = 2;
                 } else {
                     if ($count == 1) {
                         $close = 61000;
                         $_SESSION['connected_tutors'] = 1;
                     } else {
                         $close = 61000;
                         $_SESSION['connected_tutors'] = 1;
                     }
                 }
             }
         }
         $j = 0;
         $c = new Criteria();
         $c->add(UserQuestionTagPeer::USER_ID, $userId);
         $c->addDescendingOrderByColumn(UserQuestionTagPeer::ID);
         $userQuestionTag = UserQuestionTagPeer::doSelectOne($c);
         $course_code = '';
         $year = '';
         $course_id = '1';
         $school = '';
         if ($userQuestionTag) {
             $course_id = $userQuestionTag->getCourseId();
             $course_code = $userQuestionTag->getCourseCode();
             $year = $userQuestionTag->getYear();
             $school = $userQuestionTag->getSchool();
             if ($userQuestionTag->getEducation() == 2) {
                 $school = "High School";
             }
         }
         // this is where the sql injection error is happening, fix this
         // escape single quotes
         for ($i = 0; $i < $count; $i++) {
             mysql_query("INSERT INTO `user_expert` (`user_id`, `checked_id`, `category_id`, course_id, `question`, `exe_order`, `time`,course_code, year, school, status, close) VALUES ('" . mysql_real_escape_string($userId) . "', '" . mysql_real_escape_string($_POST['checkbox'][$i]) . "', " . mysql_real_escape_string($this->cat) . ", " . mysql_real_escape_string($course_id) . ",'" . mysql_real_escape_string($_SESSION['question']) . "','" . mysql_real_escape_string(++$j) . "', '" . mysql_real_escape_string($time) . "', '" . mysql_real_escape_string($course_code) . "', '" . mysql_real_escape_string($year) . "', '" . mysql_real_escape_string($school) . "', 1, " . mysql_real_escape_string($close) . ") ", $connection) or die("Error In Insert-->" . mysql_error());
         }
         /* Notify same tutor again */
         $l = 0;
         $source = 'expertmanager';
         mysql_query("DELETE FROM `student_questions` WHERE user_id = " . $userId . "", $connection);
         for ($i = 0; $i < $count; $i++) {
             $question = new StudentQuestion();
             $question->setStudentId($userId);
             $question->setTutorId($_POST['checkbox'][$i]);
             $question->setCategoryId($this->cat);
             $question->setCourseId($course_id);
             $question->setQuestion($_SESSION['question']);
             $question->setExeOrder(++$l);
             $question->setTime($time);
             $question->setCourseCode($course_code);
             $question->setYear($year);
             $question->setSchool($school);
             $question->setStatus(1);
             $question->setClose($close);
             $question->setSource($source);
             $question->save();
         }
         setcookie("asker_que", urldecode($_SESSION['question']), time() + 600, "/", sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("redirection", 1, time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("forumsub", $_SESSION['subject'], time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $this->redirect('expertmanager/connect');
     }
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $c = new Criteria();
     $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN);
     if ($this->cat == 5) {
         $experts = ExpertCategoryPeer::doSelect($c);
     } else {
         $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat);
         $experts = ExpertCategoryPeer::doSelect($c);
     }
     $queryPoints = mysql_query("select * from user where id = " . $userId, $connection) or die("Error In rate" . mysql_error());
     if (mysql_num_rows($queryPoints) > 0) {
         $rowPoints = mysql_fetch_assoc($queryPoints);
         $_points = $rowPoints['points'];
     }
     $newUser = array();
     $i = 0;
     $eachExpertOnlyOnce = array();
     foreach ($experts as $exp) {
         if ($userId != $exp->getUserId()) {
             if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) {
                 continue;
             }
             $eachExpertOnlyOnce[] = $exp->getUserId();
             $_queryCourse = '';
             $tutorsq = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
             $tutors = mysql_fetch_array($tutorsq);
             $tutor = '';
             $tutor = explode("-", $tutors['course_id']);
             if (in_array($_SESSION["course_id"], $tutor)) {
                 $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
             }
             if ($_queryCourse && mysql_num_rows($_queryCourse) > 0) {
                 $query = mysql_query("select * from user_score where user_id = " . $exp->getUserId(), $connection) or die(mysql_error());
                 $score = mysql_fetch_assoc($query);
                 if ($score['score'] != 0) {
                     if ($_points == '' || $_points == '0.00') {
                         $emptyRCquery = mysql_query("select * from user_rate where userid = " . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ", $connection) or die("Error In rate" . mysql_error());
                         if (mysql_num_rows($emptyRCquery) > 0) {
                             $dv = new Criteria();
                             $dv->add(UserPeer::ID, $exp->getUserId());
                             $_thisUser = UserPeer::doSelectOne($dv);
                             $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $i++;
                         }
                     } else {
                         $dv = new Criteria();
                         $dv->add(UserPeer::ID, $exp->getUserId());
                         $_thisUser = UserPeer::doSelectOne($dv);
                         $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $i++;
                     }
                 }
             }
         }
     }
     asort($newUser);
     arsort($newUser);
     asort($rankUsersFinal);
     arsort($rankUsersFinal);
     $this->rankCheckUsers = $rankUsersFinal;
     ////if no online expert available redirecting to the board page
     // // ant-edit get rid of adding notification bots right now
     $onlineusers = array();
     $offlineusers = array();
     $newOnlineUser = array();
     $newOfflineUser = array();
     $j = 0;
     $k = 0;
     // $facebookTutors = BotServiceProvider::createFor("http://facebook.rayku.com/tutor")->getContent();
     // $onlineTutorsByNotificationBot = BotServiceProvider::createFor("http://notification-bot.rayku.com/tutor")->getContent();
     // $Users = json_decode($facebookTutors, true);
     // $_Users = json_decode($onlineTutorsByNotificationBot, true);
     //Iterate through every user and check if they are online (either on fb gchat local rayku etc...
     foreach ($newUser as $new) {
         $a = new Criteria();
         $a->add(UserPeer::ID, $new['userid']);
         $users_online = UserPeer::doSelectOne($a);
         $onlinecheck = '';
         if ($users_online->isOnline()) {
             $onlinecheck = "online";
         }
         // // ant-edit get rid of gtalk users for now
         if (empty($onlinecheck)) {
             $userGtalk = $users_online->getUserGtalk();
             if ($userGtalk) {
                 $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent();
             }
         }
         // if ((empty($onlinecheck) || ($onlinecheck != "online")) && is_array($Users)) {
         //     $userFb = UserFbPeer::retrieveByUserId($new['userid']);
         //     if ($userFb) {
         //         $fb_username = $userFb->getFbUsername();
         //         foreach ($Users as $key => $user) {
         //             if ($user['username'] == $fb_username) {
         //                 $onlinecheck = 'online';
         //                 break;
         //             }
         //         }
         //     }
         // }
         // if ((empty($onlinecheck) || ($onlinecheck != "online")) && is_array($_Users)) {
         //     foreach ($_Users as $key => $_user) {
         //         if ($_user['email'] == $users_online->getEmail()) {
         //             $onlinecheck = 'online';
         //             break;
         //         }
         //     }
         // }
         //if user was online then store ;
         if ($onlinecheck == "online") {
             $onlineusers[$j] = $new['userid'];
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $j++;
         } elseif ($users_online->isOnline()) {
             $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $onlineusers[$j] = $new['userid'];
             $j++;
         } else {
             $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']);
             $offlineusers[$k] = $new['userid'];
             $k++;
         }
     }
     $this->newOnlineUser = $newOnlineUser;
     $this->newOfflineUser = $newOfflineUser;
     $this->_checkOnlineUsers = $onlineusers;
     if (count($onlineusers) < 1) {
         $this->redirect('http://' . RaykuCommon::getCurrentHttpDomain() . '/forum/newthread/' . $_SESSION['subject'] . '?exp_online = 1');
     }
     $onoff = isset($_COOKIE['onoff']) ? $_COOKIE['onoff'] : null;
     if ($onoff == 1) {
         if (!empty($_COOKIE["school"])) {
             $cookieSchool = array();
             $m = 0;
             foreach ($newOnlineUser as $new) {
                 $b = new Criteria();
                 $b->add(UserPeer::ID, $new['userid']);
                 $schoolusers = UserPeer::doSelectOne($b);
                 $mail = explode("@", $schoolusers->getEmail());
                 $newMail = explode(".", $mail[1]);
                 if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                     $cookieSchool[$m] = $new;
                     $m++;
                 }
             }
             $this->expert_cats = $cookieSchool;
         } else {
             $this->expert_cats = $newOnlineUser;
         }
     } else {
         if ($onoff == 2) {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newOfflineUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newOfflineUser;
             }
         } else {
             if (!empty($_COOKIE["school"])) {
                 $cookieSchool = array();
                 $m = 0;
                 foreach ($newUser as $new) {
                     $b = new Criteria();
                     $b->add(UserPeer::ID, $new['userid']);
                     $schoolusers = UserPeer::doSelectOne($b);
                     $mail = explode("@", $schoolusers->getEmail());
                     $newMail = explode(".", $mail[1]);
                     if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) {
                         $cookieSchool[$m] = $new;
                         $m++;
                     }
                 }
                 $this->expert_cats = $cookieSchool;
             } else {
                 $this->expert_cats = $newUser;
             }
         }
     }
     $this->tutorsCount = count($this->expert_cats);
     $c = new Criteria();
     $c->add(CategoryPeer::ID, $this->cat);
     $this->e = CategoryPeer::doSelectOne($c);
 }