From f8e059c291a17baf16762838007ea2f8d1795cbd Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 05:28:43 +0400 Subject: [PATCH 1/6] Changed array initialization syntax for portability --- resources/db_query.php | 2 +- resources/globals.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/db_query.php b/resources/db_query.php index f74a5b2..7733df2 100644 --- a/resources/db_query.php +++ b/resources/db_query.php @@ -49,7 +49,7 @@ function open_db() { return TRUE; } - $a_configs = []; + $a_configs = array(); $filename = dirname(__FILE__)."/mysql_config.ini"; if (file_exists($filename)) { $a_configs = parse_ini_file($filename); diff --git a/resources/globals.php b/resources/globals.php index f6ef38e..a1b7914 100644 --- a/resources/globals.php +++ b/resources/globals.php @@ -23,7 +23,7 @@ function define_global_vars() { $global_loaded_server_settings = FALSE; $mysqli = NULL; - $a_configs = []; + $a_configs = array(); $filename = dirname(__FILE__) . "/server_config.ini"; if (file_exists($filename)) { $a_configs = parse_ini_file($filename); From 865868ac5282c16bfda037d3a24c86253015de3b Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 05:29:57 +0400 Subject: [PATCH 2/6] Fixed erroneous help message --- help.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help.php b/help.php index c1977c0..84e5f85 100644 --- a/help.php +++ b/help.php @@ -34,7 +34,7 @@ function draw_jquery($block_style) { This page will not work very will until jquery has been set up.
To use jquery, create a file in
- /some/path/banwebplus/server_config.ini + /some/path/banwebplus/resources/server_config.ini
with the following line:
From c5c5ffc31dd0600c936ff1b9d6ac2c5e8175519c Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 07:29:53 +0400 Subject: [PATCH 3/6] Additional array initialization syntax changes for portability --- pages/users/forgot_password.php | 2 +- resources/ajax_calls.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/users/forgot_password.php b/pages/users/forgot_password.php index 88be5c5..c4aecda 100644 --- a/pages/users/forgot_password.php +++ b/pages/users/forgot_password.php @@ -21,7 +21,7 @@ function change_input(select_element) { var jselect = $(select_element); var option = jselect.val().toLowerCase(); var all = $(".credential_type"); - var others = []; + var others = array(); var joption = $("#"+option); // get a list of the other options and store values diff --git a/resources/ajax_calls.php b/resources/ajax_calls.php index 2b501ff..07401d2 100644 --- a/resources/ajax_calls.php +++ b/resources/ajax_calls.php @@ -405,7 +405,7 @@ function load_shared_user_schedules() { // build the list of commands and what to say to the guest $sgc = json_encode(array(new command("failure", ""))); - $no_nos = []; + $no_nos = array(); $no_nos_base = array( array('save_classes', 'load_user_classes', json_encode(array(new command("failure", "Guest can't save classes")))), From 450a0c7c350a25237441a3908f9375e88f6a2118 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 07:31:34 +0400 Subject: [PATCH 4/6] Specified default parser to BS4, also sanitized quotes in course names --- scraping/new_mexico_tech_banweb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scraping/new_mexico_tech_banweb.py b/scraping/new_mexico_tech_banweb.py index 92111ee..90095af 100755 --- a/scraping/new_mexico_tech_banweb.py +++ b/scraping/new_mexico_tech_banweb.py @@ -21,7 +21,8 @@ def writeSelectToFile(selectArray, filename, path, title): f.write(title+" = [['") optionStrings = [] for optionParts in selectArray: - optionStrings.append("','".join(optionParts)) + sanitizedParts = [ p.replace('"', '\\"').replace("'", "\\'") for p in optionParts ] + optionStrings.append("','".join(sanitizedParts)) f.write("'],\n\t['".join(optionStrings)) f.write("']]") f.close() @@ -178,7 +179,7 @@ def main(parser): page = urllib2.urlopen(url) - soup = BeautifulSoup(page) + soup = BeautifulSoup(page, "html.parser") path = "" if (type(parser.path) == type("")): From 7a84fdbe58d97e5810b296c85a33ab2176ef0a3d Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 07:59:30 +0400 Subject: [PATCH 5/6] Force bs4 to use default parser, pt II --- scraping/new_mexico_tech_banweb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scraping/new_mexico_tech_banweb.py b/scraping/new_mexico_tech_banweb.py index 90095af..0d650b9 100755 --- a/scraping/new_mexico_tech_banweb.py +++ b/scraping/new_mexico_tech_banweb.py @@ -159,7 +159,7 @@ def getTerm(semester, subjects, parser): url = "http://banweb7.nmt.edu/pls/PROD/hwzkcrof.P_UncgSrchCrsOff?p_term="+t.getSemester()+"&p_subj="+subjectName.replace(" ", "%20") print url page = urllib2.urlopen(url) - soup = BeautifulSoup(page) + soup = BeautifulSoup(page, "html.parser") trs = soup.findAll("tr") trs = trs[1:] #discard the retarded row that banweb is retarded about print_verbose("adding subject "+subjectName) From b60f3438247f65c06e5f60031bf9c4698d476971 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 16 Aug 2015 08:17:04 +0400 Subject: [PATCH 6/6] Force bs4 to use lxml instead. --- scraping/new_mexico_tech_banweb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scraping/new_mexico_tech_banweb.py b/scraping/new_mexico_tech_banweb.py index 0d650b9..3269a47 100755 --- a/scraping/new_mexico_tech_banweb.py +++ b/scraping/new_mexico_tech_banweb.py @@ -159,7 +159,7 @@ def getTerm(semester, subjects, parser): url = "http://banweb7.nmt.edu/pls/PROD/hwzkcrof.P_UncgSrchCrsOff?p_term="+t.getSemester()+"&p_subj="+subjectName.replace(" ", "%20") print url page = urllib2.urlopen(url) - soup = BeautifulSoup(page, "html.parser") + soup = BeautifulSoup(page, "lxml") trs = soup.findAll("tr") trs = trs[1:] #discard the retarded row that banweb is retarded about print_verbose("adding subject "+subjectName) @@ -179,7 +179,7 @@ def main(parser): page = urllib2.urlopen(url) - soup = BeautifulSoup(page, "html.parser") + soup = BeautifulSoup(page, "lxml") path = "" if (type(parser.path) == type("")):