Example #1
0
            for ($r = 0; $r < count($course_object); $r++) {
                if ($course_object[$r]->course == $course && $course_object[$r]->section == $section && $course_object[$r]->currentday == $day && $course_object[$r]->currentstart == $start && $course_object[$r]->currentend == $end && $course_object[$r]->type == $type) {
                    unset($course_object[$r]);
                }
            }
            //$array = json_decode(json_encode($course_object), false);
            Chromephp::log($course_object);
            Chromephp::log("this is the new and improved array");
            $correct_format_array = [];
            for ($x = 0; $x <= count($course_object); $x++) {
                Chromephp::log($course_object[$x]);
                if (!is_null($course_object[$x])) {
                    array_push($correct_format_array, $course_object[$x]);
                }
            }
            Chromephp::log($correct_format_array);
            // lets just create new array here...
            // just create a recursive function
            // now that we have the correct array we have to encode and then save...
            $update_string = json_encode($correct_format_array);
            Chromephp::log($update_string);
            $sql = " UPDATE Users\n     \t\t\t\tSET courses='{$update_string}'\n      \t\t\t\tWHERE firstname= '{$firstname}' AND lastname= '{$lastname}'";
            if ($conn->query($sql) === TRUE) {
                Chromephp::log("we have updated successfully");
            } else {
                Chromephp::log("Error Updating " . $conn->error);
            }
        }
    }
    header('Location: Profile.php');
}
<?php

// try to access ratemyprofessor
include 'ChromePhp.php';
$url = 'http://www.ratemyprofessors.com/';
$ch = curl_init();
if ($ch === false) {
    die('Failed to create curl object');
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
// The submitted form data, encoded as query-string-style name-value pairs
// this is the data that we need to post...
//Chromephp::log($CourseSubj);
//Chromephp::log($CourseNumb);
$post_data = "professor-name=wolfman";
//$post_data = "subj=CPSC&crsno=304";
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
Chromephp::log($output);
Example #3
0
function find_courses_and_display_SFU($CourseSubj, $CourseNumb, $term)
{
    Chromephp::log("inside the SFU course searcher right now!!");
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    try {
        $url3 = 'https://www.sfu.ca/students/enrollment/class-search.html';
        $url4 = 'https://go.sfu.ca/psp/paprd/EMPLOYEE/EMPL/h/?tab=PAPP_GUEST';
        $url = 'http://go.sfu.ca';
        $url1 = 'https://go.sfu.ca/paprd/signon.html';
        $url2 = "../psp/paprd/?cmd=login'";
        $ch = curl_init();
        if ($ch === false) {
            die('Failed to create curl object');
        }
        curl_setopt($ch, CURLOPT_URL, $url2);
        curl_setopt($ch, CURLOPT_POST, true);
        // Chromephp::log($post_data);
        //curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
        //$params=array(
        // );
        // curl_setopt($ch, CURLOPT_POST, TRUE);
        //curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        curl_setopt($ch, CURLOPT_HTTPGET, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        //curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
        curl_setopt($ch, CURLOPT_USERAGENT, "booyah!");
        $output = curl_exec($ch);
        if (FALSE === $output) {
            throw new Exception(curl_error($ch), curl_errno($ch));
        }
        //  curl_error($ch);
        curl_close($ch);
        // we can open a new webpage then grab the information from that webpage and then try and navigate through it.
        //echo $output;
        // couple options I can do here
        // 1.) try and make another window where we navigate through to the course search page
        // 2.) hold off on the chromephp echo and wait maybe it will redirect and display correctly...
        // 3.) just try and use the course search page instead...
        // we can redirect the webpage back to localhost while getting all the information on the page?
        //  header('Location: http://localhost/CourseMatch/CourseFinder.php?School=SFU&term=Term+1&CourseSubj=asdf&CourseNumb=sadf');
        Chromephp::log("before the output");
        sleep(1);
        Chromephp::log($output);
        // we need to search through the output here and go to the link that it redirects too...
        Chromephp::log("after the output");
    } catch (Exception $e) {
        Chromephp::log("exception was thrown!!");
        trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);
    }
    // win0 is the form name!!
    // this is going to be the subject name.
    // name="SSR_CLSRCH_WRK_SUBJECT_SRCH$0" id="SSR_CLSRCH_WRK_SUBJECT_SRCH$0"
    // <input type="text" name="SSR_CLSRCH_WRK_CATALOG_NBR$1" id="SSR_CLSRCH_WRK_CATALOG_NBR$1"
    //name="CLASS_SRCH_WRK2_STRM$45$" id="CLASS_SRCH_WRK2_STRM$45$"
    //<select name="SSR_CLSRCH_WRK_ACAD_CAREER$2" id="SSR_CLSRCH_WRK_ACAD_CAREER$2"  this is the type of classes we are searching.
    //<a name="CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH" id="CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH" ptlinktgt="pt_peoplecode" tabindex="1035" href="javascript:submitAction_win0(document.win0,'CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH');" class="SSSBUTTON_CONFIRMLINK">Search</a>
    // this is going to be the submit button post data i believe.
}
Example #4
0
function whosfree($arguments)
{
    $db = "CourseMatcher";
    $servername = "localhost";
    $username = "******";
    $password = "";
    $conn = new mysqli($servername, $username, $password, $db);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    //Chromephp::log($_SESSION['FULLNAME']);
    $name_array = explode(' ', $_SESSION['FULLNAME']);
    $firstname = $name_array[0];
    $lastname = $name_array[1];
    // need to grab the current users info... meaning we need the initial fb code at the top...
    $sql = "SELECT * FROM Users WHERE firstname = '{$firstname}' AND lastname = '{$lastname}'";
    $friends = '';
    $courses = '';
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $friends = $row['friends'];
            $courses = $row["Courses"];
        }
    }
    $friends = explode(', ', $friends);
    $conflicting_friends = array();
    for ($y = 0; $y < count($friends); $y++) {
        $current_friend_name = $friends[$y];
        // for this friend find his or here schedule.
        $name_array1 = explode(' ', $current_friend_name);
        $firstname = $name_array1[0];
        $lastname = $name_array1[1];
        $sql = "SELECT Courses FROM Users WHERE firstname = '{$firstname}' AND lastname = '{$lastname}'";
        $result = $conn->query($sql);
        $daCourse = $result->fetch_assoc();
        $daCourse = $daCourse['Courses'];
        $daCourse = str_replace('[', '', $daCourse);
        $daCourse = str_replace(']', '', $daCourse);
        $current_friend_courses = array();
        $daCourse1 = explode('}', $daCourse);
        // this function populates the array of courses for each friend.
        for ($b = 0; $b < count($daCourse1); $b++) {
            if ($daCourse1[$b] == '') {
                continue;
            }
            if (substr($daCourse1[$b], 0, 1) == ',') {
                $daCourse2 = substr($daCourse1[$b], 1, strlen($daCourse1[$b]));
                $daCourse2 = $daCourse2 . '}';
            } else {
                $daCourse2 = $daCourse1[$b] . '}';
            }
            array_push($current_friend_courses, $daCourse2);
        }
        //    Chromephp::log($current_friend_courses);
        //Chromephp::log(count($current_friend_courses));
        for ($l = 0; $l < count($current_friend_courses); $l++) {
            $thecourse = json_decode($current_friend_courses[$l]);
            $starttime = $thecourse->currentstart;
            $endtime = $thecourse->currentend;
            $day = $thecourse->currentday;
            $array_of_time = array();
            $minute;
            $hour;
            $added_time = $starttime;
            while ($added_time != $endtime) {
                $split_time = explode(":", $added_time);
                $minute = $split_time[1];
                $hour = $split_time[0];
                if ($minute == "00") {
                    $minute = "30";
                } else {
                    $minute = "00";
                    $hour = intval($hour) + 1;
                    $hour = strval($hour);
                }
                $added_time = $hour . ':' . $minute;
                array_push($array_of_time, $added_time);
            }
            //Chromephp::log($array_of_time);
            $dayoncalendar;
            // first check the day here...
            if ($arguments[1] == 0) {
                $dayoncalendar = 'Sun';
            }
            if ($arguments[1] == 1) {
                $dayoncalendar = 'Mon';
            }
            if ($arguments[1] == 2) {
                $dayoncalendar = 'Tue';
            }
            if ($arguments[1] == 3) {
                $dayoncalendar = 'Wed';
            }
            if ($arguments[1] == 4) {
                $dayoncalendar = 'Thu';
            }
            if ($arguments[1] == 5) {
                $dayoncalendar = 'Fri';
            }
            if ($arguments[1] == 6) {
                $dayoncalendar = 'Sat';
            }
            if ($dayoncalendar == $day) {
                for ($g = 0; $g < count($arguments); $g++) {
                    //Chromephp::log($arguments[$g]);
                    for ($k = 0; $k < count($array_of_time); $k++) {
                        if ($array_of_time[$k] == $arguments[$g]) {
                            array_push($conflicting_friends, $current_friend_name);
                            break 3;
                        }
                    }
                }
            }
        }
    }
    Chromephp::log("this is the conflicting friend!!");
    Chromephp::log($conflicting_friends);
    $returning_friends = $friends;
    for ($e = 0; $e < count($friends); $e++) {
        for ($p = 0; $p < count($conflicting_friends); $p++) {
            if ($friends[$e] == $conflicting_friends[$p]) {
                unset($returning_friends[$e]);
            }
        }
    }
    $real_array = [];
    foreach ($returning_friends as $value) {
        array_push($real_array, $value);
    }
    return $real_array;
}
Example #5
0
function course_events($value)
{
    // we need to find the rest of the info related to this course...
    // i dont need this i just need the other course info
    if (isset($_GET['courses'])) {
        //Chromephp::log('this is running right now');
        $_SESSION['courses'] = $_GET['courses'];
    }
    //--->>
    //Chromephp::log($_SESSION['user_courses']);
    // we need to go through this in order to gather the other info about this course...
    for ($r = 0; $r < count($_SESSION['user_courses']); $r++) {
        // we need to check every single one of these user courses
        $current_course = $_SESSION['user_courses'][$r];
        $course_name = $current_course->course;
        $course_type = $current_course->type;
        if ($course_name == $value && $course_type == 'Lecture') {
            //Chromephp::log($current_course);
            // we have all the info right now from this current course content...
            // ---->>
            // we should grab the start time and the end time and the day
            $course_start = $current_course->currentstart;
            $course_end = $current_course->currentend;
            $course_day = $current_course->currentday;
            $day_array = explode(',', $course_day);
            //Chromephp::log($day_array);
            $times_a_week = count($day_array);
            $number_of_classes = $times_a_week * 14;
            // this will be the number of times the loop is going to run!!
            //$date = date_create_from_format('d/m/y', '07/09/2015');
            $d = new DateTime('2015-09-07');
            $theArray = array();
            // need to do one week at a time
            for ($x = 0; $x < 14; $x++) {
                $days_adding;
                // we actaully do need the rest of that incase for other classes during that week...
                $day_one;
                $day_two;
                $day_three;
                for ($f = 0; $f < count($day_array); $f++) {
                    $curday = $day_array[$f];
                    if ($curday == "Mon") {
                        if ($f == 0) {
                            $day_one = 1;
                            $days_adding = 1;
                        }
                        if ($f == 1) {
                            $day_two = 1;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 1;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    if ($curday == "Tue") {
                        if ($f == 0) {
                            $day_one = 2;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 2;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 2;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    if ($curday == "Wed") {
                        if ($f == 0) {
                            $day_one = 3;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 3;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 3;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    if ($curday == "Thu") {
                        if ($f == 0) {
                            $day_one = 4;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 4;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 4;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    if ($curday == "Fri") {
                        if ($f == 0) {
                            $day_one = 5;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 5;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 5;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    if ($curday == "Sat") {
                        if ($f == 0) {
                            $day_one = 6;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 6;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 6;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    // sunday is going to be zero...
                    if ($curday == "Sun") {
                        if ($f == 0) {
                            $day_one = 0;
                            $days_adding = $day_one;
                        }
                        if ($f == 1) {
                            $day_two = 0;
                            $days_adding = $day_two - $day_one;
                        }
                        if ($f == 2) {
                            $day_three = 0;
                            $days_adding = $day_three - $day_two;
                        }
                    }
                    date_modify($d, '+' . $days_adding . ' day');
                    Chromephp::log($d);
                    //Chromephp::log($d->date);
                    $date_array = explode('-', $d->date);
                    //--->>
                    $year = $date_array[0];
                    // take away the first two in the string
                    //$year = substr($year, 2, 4);
                    //Chromephp::log($year);
                    $month = $date_array[1];
                    $monthName = date('F', mktime(0, 0, 0, $month, 10));
                    // March
                    // Chromephp::log($monthName);
                    // Chromephp::log($month);
                    $day = $date_array[2];
                    $day = explode(' ', $day);
                    $day = $day[0];
                    //Chromephp::log($year.'.'.$month.'.'.$day);
                    //Chromephp::log($day);
                    //$date_string = $year.'.'.$month.'.'.$day ;
                    $date_string = $day . ' ' . $monthName . ' ' . $year;
                    //Chromephp::log($date_string);
                    $myvar = strtotime($date_string) * 1000;
                    $myvar = (string) $myvar;
                    // Chromephp::log($myvar);
                    $obj = array('class' => 'event-warning', 'end' => $myvar, 'id' => '1', 'start' => $myvar, 'title' => $course_name . ' Lecture', 'url' => 'http://www.example.com/');
                    //Chromephp::log($obj);
                    array_push($theArray, $obj);
                }
                Chromephp::log("inside the weekly loop");
                Chromephp::log($day_one);
                Chromephp::log($day_two);
                Chromephp::log($day_three);
                // we need to see what the days_adding has been made up to be must add up to 7
                if (!is_null($day_one) && is_null($day_two) && is_null($day_three)) {
                    $days_adding_week = 7 - $day_one;
                }
                // TODO!! this code is only working for CPSC 304...
                if (!is_null($day_one) && !is_null($day_two) && is_null($day_three)) {
                    $days_adding_week = 7 - $day_two;
                }
                if (!is_null($day_one) && !is_null($day_two) && !is_null($day_three)) {
                    $days_adding_week = 7 - $day_three;
                }
                date_modify($d, '+' . $days_adding_week . ' day');
            }
            $jsonString = file_get_contents('./bootstrap-calendar/events.json.php');
            $data = json_decode($jsonString);
            $data->result = $theArray;
            $encoded_data = json_encode($data);
            file_put_contents('./bootstrap-calendar/events.json.php', $encoded_data);
        }
    }
}
Example #6
0
<?php

include 'ChromePhp.php';
Chromephp::log("this file is being called right now");
print_r($_POST);
Example #7
0
function save_user_data($fbid, $fbfullname, $email, $friends)
{
    Chromephp::log("this function is being called right now");
    // connect to the db here
    $db = "CourseMatcher";
    $servername = "localhost";
    $username = "******";
    $password = "";
    $conn = new mysqli($servername, $username, $password, $db);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    // split up the username...
    $fullnameArray = explode(" ", $fbfullname);
    $firstName = $fullnameArray[0];
    $lastName = $fullnameArray[1];
    // query and check...
    $sql = "SELECT id, firstname, lastname FROM Users WHERE firstname = '{$firstName}' AND lastname = '{$lastName}'";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            echo "id: " . $row["id"] . " - Name: " . $row["firstname"] . " " . $row["lastname"] . "<br>";
        }
    } else {
        echo "0 results meaning that this person has not been saved inside the db yet... ";
        // save the user into the db...
        $sql = "INSERT INTO Users (firstname, lastname, email, friends, courses)\n    VALUES ('{$firstName}', '{$lastName}', '{$email}', '{$friends}', '')";
        if ($conn->query($sql) === TRUE) {
            echo "New record created successfully";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
        }
    }
}
Example #8
0
  <li role="presentation"><a href="CourseFinder.php">Course Browser</a></li>
  <li role="presentation" class="active" ><a href="#">Profile</a></li>
  <li role="presentation"><a href="StudyGroup.php">Study Groups</a></li>
  <li role="presentation"><a href="WhosFree.php">Who's Free</a></li>
</ul>


<body>



<?php 
if (isset($_GET['remove'])) {
    $course = $_GET['$course'];
    Chromephp::log($course);
    Chromephp::log("the delete button was pressed here!!");
    echo "this is being called";
}
$name = $_SESSION['FULLNAME'];
$name_array = explode(' ', $name);
$_SESSION['firstname'] = $firstname = $name_array[0];
$_SESSION['lastname'] = $lastname = $name_array[1];
//Chromephp::log($_GET['remove']);
//Chromephp::log($_POST['remove']);
//if(isset($_POST['remove'])){
// Chromephp::log("the remove button has been pressed");
// }
gather_user_courses();
// this function is going to gather the courses of the user
function gather_user_courses()
{