function index() { $this->load->model('twitter_model'); if (get_username() == $this->config->item('default_user')) { /* $this->load->library('postmark'); $query = $this->db->query("SELECT username, email FROM user"); foreach ($query->result() as $row) { $this->postmark->clear(); $this->postmark->from('*****@*****.**', 'Stephen Ou'); $this->postmark->to($row->email); $this->postmark->subject('Some updates from OneExtraLap HQ'); $this->postmark->message_html('Hello, there,<br /><br />Sorry to bug you, but I have some great things to tell you. :)<br /><br />First, I released some really cool features earlier this week, including view grades, edit tags, and more. Also our landing page has a featured user list. If you want to be stood out, participate as much as possible! More info: http://oneextralap.tumblr.com/post/965814476<br /><br />Second, I want to give you the privilege to invite friends to the site, your invite link is http://oneextralap.com/refer/'.$row->username.'. There are awards for it too, 3 new users = Promotion Ambassador badge!<br /><br />Lastly, I made a handy survey.io feedback form for your guys, because I want to know your opinions about OneExtraLap and help us grow together! http://survey.io/survey/99b06<br /><br />Stephen,<br />Founder of OneExtraLap<br />http://oneextralap.com'); $this->postmark->send(); echo $row->email.' '.$row->code.'<br />'; } $query = $this->db->query("SELECT answer_id FROM activity"); foreach ($query->result() as $row) { $row1 = $this->db->query("SELECT question_id FROM answer WHERE id='$row->answer_id'")->row(); $this->db->update('activity', array('question_id' => $row1->question_id), array('answer_id' => $row->answer_id)); } $query = $this->db->query("SELECT username FROM user"); foreach ($query->result() as $row) { $this->db->update('user', array('notification' => 1), array('username' => $username)); } $query = $this->db->query("SELECT username FROM user WHERE avatar='http://www.gravatar.com/avatar'"); foreach ($query->result() as $row) { $this->db->update('user', array('avatar' => 'http://www.gravatar.com/avatar/'), array('username' => $username)); } $query = $this->db->query("SELECT username FROM user WHERE twitter!=''"); foreach ($query->result() as $row) { $this->db->update('user', array('share_created' => 1, 'share_badge' => 1), array('username' => $username)); } $quiz = array('netspencer', 'stephenou', 'danielbru', 'hiten', 'crystalcy', 'imkevinxu', 'zacharycollins', 'markbao', 'powdahound', 'jp', 'andmurphoto', 'jakemates', 'mike3k'); $a = 0; while ($a < count($quiz)) { $this->db->insert('preset', array('content' => $quiz[$a], 'type' => 'people')); $a++; } $query = $this->db->query("SELECT username, twitter, twitter_id FROM user WHERE twitter!='' AND twitter_id=0"); foreach ($query->result() as $row) { $call = $this->twitter->call('users/show', array('screen_name' => $row->twitter)); $this->db->update('user', array('twitter_id' => $call->id), array('username' => $username)); } $query = $this->db->query("SELECT username FROM user"); foreach ($query->result() as $row) { $this->badge_model->check($row->username, 'test'); } */ /* */ } else { stupid(); } }
function submit_login_form() { $username = $this->db->escape_str($this->input->post('username')); $password = md5($this->input->post('password')); if (substr($this->input->post('username'), -2, 2) == '\'#') { stupid(); } $query = $this->db->query("SELECT COUNT(id) AS total FROM user WHERE username='******' AND password='******'"); if ($query->row()->total == 1) { $this->session->set_flashdata('message', array('Welcome back!')); return TRUE; } else { $this->session->set_flashdata('message', array('Uh Oh, wrong combination. Please try again.')); $this->session->set_flashdata('username', $this->input->post('username')); $this->session->set_flashdata('password', $this->input->post('password')); } }
function prevent_more_stupid($page) { $CI =& get_instance(); if ($page == 'profile') { if (!isset($_POST['fullname']) || !isset($_POST['bio']) || !isset($_POST['website']) || !isset($_POST['avatar'])) { stupid(); } } if ($page == 'account') { if (!isset($_POST['email']) || !isset($_POST['oldpassword']) || !isset($_POST['newpassword'])) { stupid(); } } if ($page == 'login') { if (!isset($_POST['username']) || !isset($_POST['password'])) { stupid(); } } if ($page == 'signup') { if (!isset($_POST['username']) || !isset($_POST['email']) || !isset($_POST['password'])) { stupid(); } } if ($page == 'reset_without_code') { if (!isset($_POST['email'])) { stupid(); } } if ($page == 'reset_with_code') { if (!isset($_POST['password'])) { stupid(); } } }
function follow() { $following = get_username(); $follower = $this->input->post('follower'); if ($follower == '' || $this->input->post('hell_yeah') != 52012) { stupid(); } $page = $this->input->post('page'); $query = $this->db->query("SELECT id FROM follow WHERE following_user_id='{$following}' AND follower_user_id='{$follower}' AND deleted_time='' LIMIT 1"); if ($query->num_rows() == 1) { $data = array('deleted_time' => mktime()); manipulate_database('update', 'follow', $data, array('following_user_id' => $following, 'follower_user_id' => $follower, 'deleted_time' => '')); $return = '+ Follow'; } else { $data = array('following_user_id' => $following, 'follower_user_id' => $follower, 'time' => mktime()); manipulate_database('insert', 'follow', $data); $return = '- Unfollow'; } if ($page == $following) { $followingquery = $this->db->query("SELECT COUNT(id) AS total FROM follow WHERE following_user_id='{$following}' AND deleted_time=''"); $followerquery = $this->db->query("SELECT COUNT(id) AS total FROM follow WHERE follower_user_id='{$following}' AND deleted_time=''"); } else { $followerquery = $this->db->query("SELECT COUNT(id) AS total FROM follow WHERE follower_user_id='{$follower}' AND deleted_time=''"); $followingquery = $this->db->query("SELECT COUNT(id) AS total FROM follow WHERE following_user_id='{$follower}' AND deleted_time=''"); } if ($page == $following || $page == $follower) { $followernumber = $followerquery->row()->total; $followingnumber = $followingquery->row()->total; $type = 1; } else { $followernumber = 0; $followingnumber = 0; $type = 0; } $badge = $this->badge_model->check($following, 'follow'); $data = array('result' => $return, 'type' => $type, 'followernumber' => $followernumber, 'followingnumber' => $followingnumber); echo json_encode($data); }
function index($quizid, $action) { $return = $this->global_function->initialize('quiz', TRUE, $quizid); $username = $return['username']; $return['body_title'] = get_title($quizid, FALSE); $existance = $this->quiz_model->check_quiz_existance($quizid); $status = $this->quiz_model->check_user_status($quizid, $username, $action); if ($this->config->item('enable_edit') == FALSE && $status == 'edit') { $this->global_function->load_view($return, TRUE, 503); } elseif ($existance == TRUE) { if ($this->session->flashdata('took') == 'yes') { $status = 'took'; } if ($this->input->post('Submit')) { if ($username == '') { stupid(); } if ($status == 'edit') { prevent_stupid($quizid); $number = 1; $amount = $this->input->post('id') - 1; $tagnumber = 1; $tagamount = $this->input->post('tagamount') - 1; $change = ''; while ($number <= $amount) { $answernumber = 'A'; $answeramount = chr(ord($this->input->post('id' . $number)) - 1); $answerid = ''; $questionid = $this->input->post('qid' . $number); while ($answernumber <= $answeramount) { if ($this->quiz_model->if_answer_changed($this->input->post($answernumber . $number), $this->input->post('aid' . $number . $answernumber)) == TRUE) { $change = TRUE; } $answerid .= $this->quiz_model->update_answers($questionid, $this->input->post($answernumber . $number), $this->input->post('aid' . $number . $answernumber), $answernumber, $this->input->post('answer' . $number)); $answernumber++; } if ($this->quiz_model->if_question_changed($questionid, $answerid, $this->input->post('question' . $number)) == TRUE) { $change = TRUE; } $this->quiz_model->update_questions($questionid, $answerid, $this->input->post('question' . $number)); $number++; } $this->quiz_model->delete_tags($quizid); while ($tagnumber <= $tagamount) { $questionid = $this->quiz_model->insert_tags($quizid, $this->input->post('tag' . $tagnumber), $this->input->post('tagid' . $tagnumber)); $tagnumber++; } $this->quiz_model->edit_form_submit($quizid, $this->input->post('title'), $change); $badge = $this->badge_model->check($username, 'edit'); $this->session->set_flashdata('badge', $badge); $this->session->set_flashdata('message', array('Awesome! Your edit had been saved!')); } elseif ($status == 'untake') { $main = ''; $correct = 0; $number = 1; $amount = $this->input->post('amount'); while ($number <= $amount) { $answernumber = 'answer' . $number; $idnumber = 'id' . $number; ${$answernumber} = $this->input->post($number); ${$idnumber} = $this->input->post($number . 'id'); $answer = ${$answernumber}; $id = ${$idnumber}; $result = $this->quiz_model->submit_individual_question($answer, $id, $number, $amount, $username); if ($result == TRUE) { $correct++; } $number++; } $this->quiz_model->submit_score($quizid, $username, $correct, $amount); $this->load->model('twitter_model'); $this->twitter_model->auto_share($username, $quizid); $badge = $this->badge_model->check($username, 'take'); $this->session->set_flashdata('badge', $badge); $this->session->set_flashdata('message', array('Awesome! You just earned ' . $correct . ' points!')); $this->session->set_flashdata('took', 'yes'); } redirect('/' . $quizid); } if ($status == 'edit') { if (get_fullname($username) !== get_creator($quizid)) { redirect('/' . $quizid); } $return['content_type'] = 'create'; $return['body_title'] .= ' - Edit'; } $return['tag'] = $this->quiz_model->get_tag($quizid); if ($status == 'take' || $status == 'create' || $status == 'untake' || $status == 'edit' || $status == 'took') { $return['main'] = $this->quiz_model->get_questions($quizid); } elseif ($status == 'grade') { $return['main'] = $this->quiz_model->get_quiz_grade($quizid, $username); } else { redirect('/' . $quizid); } $return['onehundred'] = $this->quiz_model->get_onehundred($quizid); $return['status'] = $status; $this->global_function->load_view($return); } else { $this->global_function->load_view($return, TRUE, 404); } }