From 89517e69801e076925ecec8cfee3b5218a5ac1be Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 22 Aug 2019 16:20:26 +0200 Subject: [PATCH] corrected page definitions & fixed security calls --- uvote/api/votes/bars.php | 8 ++--- uvote/api/votes/comments.php | 8 ++--- uvote/api/votes/graphs.php | 8 ++--- uvote/api/votes/stats_basic.php | 2 +- uvote/api/votes/votes.php | 30 +++++++++---------- .../default_register/default_register.php | 9 ++++-- uvote/page/page_uvote.php | 12 ++++---- .../user_main_analysis/user_main_analysis.php | 9 +++++- .../user_main_impressum.php | 16 ++++++++-- .../user_main_options/user_main_options.php | 9 +++++- uvote/page/user_main_poll/user_main_poll.php | 10 ++++++- .../user_main_poll_sub/user_main_poll_sub.php | 10 ++++++- .../page/user_main_start/user_main_start.php | 12 +++++++- .../user_main_votelist/user_main_votelist.php | 29 +++++++++++------- .../saimod_uvote_vote_edit.php | 2 +- 15 files changed, 119 insertions(+), 55 deletions(-) diff --git a/uvote/api/votes/bars.php b/uvote/api/votes/bars.php index 737853a..b179ca8 100644 --- a/uvote/api/votes/bars.php +++ b/uvote/api/votes/bars.php @@ -47,7 +47,7 @@ class bars{ } public static function bilance_user(){ $result = ''; - $res = \SQL\UVOTE_DATA_USER_BILANCE::QA(array(\SYSTEM\SECURITY\Security::getUser()->id)); + $res = \SQL\UVOTE_DATA_USER_BILANCE::QA(array(\SYSTEM\SECURITY\security::getUser()->id)); foreach($res as $row){ //$res2 = votes::vote_accord_with_party($row['party']); //$row['according_laws'] = self::build_according_law_html($res2, $row['party']); @@ -75,7 +75,7 @@ class bars{ FROM uvote_data INNER JOIN uvote_votes_per_party ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID WHERE user_ID = ? AND uvote_votes_per_party.choice = ? GROUP BY party;', - array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + array(\SYSTEM\SECURITY\security::getUser()->id, $choice)); while($row = $res->next()){ $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); $row['bar'] = $bar; @@ -97,7 +97,7 @@ class bars{ FROM uvote_data INNER JOIN uvote_votes ON uvote_data.poll_ID = uvote_votes.ID WHERE user_ID = ? AND uvote_votes.bt_choice = ? GROUP by user_ID;', - array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + array(\SYSTEM\SECURITY\security::getUser()->id, $choice)); while($row = $res->next()){ if(empty($row['class_MATCH'])){ return 'Keine relevanten Daten verfügbar

'; @@ -122,7 +122,7 @@ class bars{ FROM uvote_data LEFT JOIN uvote_votes ON uvote_data.poll_ID = uvote_votes.ID WHERE user_ID = ?;', - array(\SYSTEM\SECURITY\Security::getUser()->id)); + array(\SYSTEM\SECURITY\security::getUser()->id)); while($row = $res->next()){ $row['match_percentage'] = ($row['class_MATCH']+$row['class_MISSMATCH']) > 0 ? round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2) : 0; $result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('user_main_analysis/tpl/tab_bilance/bars_user_bt.tpl'))->SERVERPATH(), $row); diff --git a/uvote/api/votes/comments.php b/uvote/api/votes/comments.php index c16cf64..f765790 100644 --- a/uvote/api/votes/comments.php +++ b/uvote/api/votes/comments.php @@ -11,12 +11,12 @@ class comments { return \SQL\UVOTE_DATA_USER_COMMENTRATE_PER_COMMENT::Q1(array($c_ID, $val));} public static function write_comment($poll_ID, $c_choice, $c_txt, $c_src){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} - return \SQL\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, utf8_encode($c_txt), $c_src));} + return \SQL\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\security::getUser()->id, utf8_encode($c_txt), $c_src));} public static function write_commentrate($c_ID, $val){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} - return \SQL\UVOTE_DATA_USER_COMMENTRATE_INSERT::Q1(array($c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val, $c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val));} + return \SQL\UVOTE_DATA_USER_COMMENTRATE_INSERT::Q1(array($c_ID, \SYSTEM\SECURITY\security::getUser()->id, $val, $c_ID, \SYSTEM\SECURITY\security::getUser()->id, $val));} } diff --git a/uvote/api/votes/graphs.php b/uvote/api/votes/graphs.php index 02622c7..45c4db2 100644 --- a/uvote/api/votes/graphs.php +++ b/uvote/api/votes/graphs.php @@ -15,7 +15,7 @@ class graphs { public static function graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){ $result = array(); - $res = \SQL\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id)); + $res = \SQL\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\security::getUser()->id, \SYSTEM\SECURITY\security::getUser()->id)); $matchhandler = 0; $missmatchhandler = 0; while ($row = $res->next()){ @@ -31,8 +31,8 @@ class graphs { public static function graph_party_to_user_overall_by_time ($party, $timespan, $returnasjson = true){ $result = array(); - $res = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, $party, \SYSTEM\SECURITY\Security::getUser()->id)); - $total = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH::Q1(array($party, \SYSTEM\SECURITY\Security::getUser()->id)); + $res = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\security::getUser()->id, $party, \SYSTEM\SECURITY\security::getUser()->id)); + $total = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH::Q1(array($party, \SYSTEM\SECURITY\security::getUser()->id)); $matchhandler = 0; $missmatchhandler = 0; while ($row = $res->next()){ @@ -48,7 +48,7 @@ class graphs { public static function donut_party_to_user_overall ($returnasjson = true){ $result = array(); - $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(\SYSTEM\SECURITY\Security::getUser()->id)); + $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(\SYSTEM\SECURITY\security::getUser()->id)); while ($row = $res->next()){ $result[] = array( 0 => $row['party'], 'class_match' => $row['class_MATCH']); diff --git a/uvote/api/votes/stats_basic.php b/uvote/api/votes/stats_basic.php index 16aa511..a7494ca 100644 --- a/uvote/api/votes/stats_basic.php +++ b/uvote/api/votes/stats_basic.php @@ -13,7 +13,7 @@ class stats_basic { else {return 'error';} } public static function user_basic(){ - $vars['basic_stats'] = bars::get_user_choice_overall(\SYSTEM\SECURITY\Security::getUser()->id); + $vars['basic_stats'] = bars::get_user_choice_overall(\SYSTEM\SECURITY\security::getUser()->id); $vars['user_temp_votes'] = votes::get_user_temp_votes(); $vars['user_overall_votes'] = votes::get_user_overall_votes(); $vars['analysis_help_basic_stats'] = \SYSTEM\PAGE\text::get('analysis_help_basic_stats'); diff --git a/uvote/api/votes/votes.php b/uvote/api/votes/votes.php index 72756b1..32854b9 100644 --- a/uvote/api/votes/votes.php +++ b/uvote/api/votes/votes.php @@ -10,22 +10,22 @@ class votes { } public static function getUserPollData($poll_ID){ - if (!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if (!\SYSTEM\SECURITY\security::isLoggedIn()){ return NULL;} $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVoteByGrp', 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 1;', - array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); + array(\SYSTEM\SECURITY\security::getUser()->id,$poll_ID)); $result = $res->next(); return $result['choice']; } public static function getUserPollDataSub($poll_ID){ - if (!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if (!\SYSTEM\SECURITY\security::isLoggedIn()){ return NULL;} $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVoteByGrp', 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 2;', - array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); + array(\SYSTEM\SECURITY\security::getUser()->id,$poll_ID)); $result = $res->next(); return $result['choice']; } @@ -77,7 +77,7 @@ class votes { } public static function get_user_temp_votes(){ - $vars = \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id)); + $vars = \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array(\SYSTEM\SECURITY\security::getUser()->id, \SYSTEM\SECURITY\security::getUser()->id)); $v = $vars['voted']; $nv = $vars['not_voted']; return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('user_main_analysis/tpl/tab_basic/temp_votes.tpl'))->SERVERPATH(), @@ -87,7 +87,7 @@ class votes { 'not_voted'=> $nv));} public static function get_user_overall_votes(){ - $vars = \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate)); + $vars = \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array(\SYSTEM\SECURITY\security::getUser()->id, \SYSTEM\SECURITY\security::getUser()->id, \SYSTEM\SECURITY\security::getUser()->id, \SYSTEM\SECURITY\security::getUser()->creationDate)); $v = $vars['voted']; $nv = $vars['not_voted']; return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('user_main_analysis/tpl/tab_basic/overall_votes.tpl'))->SERVERPATH(), @@ -114,9 +114,9 @@ class votes { } public static function vote_accord_with_party($party){ - if (!\SYSTEM\SECURITY\Security::isloggedin()){ + if (!\SYSTEM\SECURITY\security::isloggedin()){ throw new ERROR("U need to be logged in....sry bro / sis");} - $user = \SYSTEM\SECURITY\Security::getUser()->id; + $user = \SYSTEM\SECURITY\security::getUser()->id; $data = \SQL\UVOTE_ACCORD_WITH_FRACTION::QA(array($party,$user)); //$data_escaped = array_walk_recursive($data, 'mysql_real_escape_string'); //return \SYSTEM\LOG\JsonResult::toString($data); @@ -170,7 +170,7 @@ class votes { $res = $con->prepare( 'insertVote', 'REPLACE uvote_data VALUES (?, ?, ?, 1, NOW());', - array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); + array($poll_ID, \SYSTEM\SECURITY\security::getUser()->id, $vote)); return JsonResult::ok(); } public static function write_vote_sub($poll_ID, $vote){ @@ -181,29 +181,29 @@ class votes { $res = $con->prepare( 'insertVote', 'REPLACE uvote_data VALUES (?, ?, ?, 2, NOW());', - array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); + array($poll_ID, \SYSTEM\SECURITY\security::getUser()->id, $vote)); return JsonResult::ok(); } public static function write_data($location, $birthyear, $gender, $children){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} - return \SQL\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children));} + return \SQL\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\security::getUser()->id, $location, $birthyear, $gender, $children));} public static function get_add_data(){ - return \SQL\UVOTE_DATA_USER_ADD_DATA::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id)); + return \SQL\UVOTE_DATA_USER_ADD_DATA::Q1(array(\SYSTEM\SECURITY\security::getUser()->id)); } public static function write_feedback($feedback){ $feedback = json_decode($feedback); - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'insertFeedback', 'INSERT INTO uvote_beta_feedback VALUES (?, ?);', - array(\SYSTEM\SECURITY\Security::getUser()->id, $feedback)); + array(\SYSTEM\SECURITY\security::getUser()->id, $feedback)); new WARNING("feedback was added"); return JsonResult::ok(); } diff --git a/uvote/page/default_register/default_register.php b/uvote/page/default_register/default_register.php index 8ae9f0e..2eec38f 100644 --- a/uvote/page/default_register/default_register.php +++ b/uvote/page/default_register/default_register.php @@ -1,6 +1,11 @@ html($_escaped_fragment_);} public static function page_user_main_start(){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ return (new default_register ())->html();} return (new user_main_start())->html();} public static function page_user_main_analysis(){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ return (new default_register ())->html();} return (new user_main_analysis())->html();} // public static function page_user_main_options(){ -// if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ +// if(!\SYSTEM\SECURITY\security::isLoggedIn()){ // return (new default_register ())->html();} // return (new user_main_options())->html();} public static function page_user_main_poll($poll_ID) { //return (new user_main_poll($poll_ID))->html();} - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ return (new default_register ())->html();} return (new user_main_poll($poll_ID))->html();} public static function page_user_main_poll_sub($poll_ID) { //return (new user_main_poll($poll_ID))->html();} - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ return (new default_register ())->html();} return (new user_main_poll_sub($poll_ID))->html();} public static function page_user_main_votelist(){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ return (new default_register ())->html();} return (new user_main_votelist())->html();} diff --git a/uvote/page/user_main_analysis/user_main_analysis.php b/uvote/page/user_main_analysis/user_main_analysis.php index b39a006..92243c4 100644 --- a/uvote/page/user_main_analysis/user_main_analysis.php +++ b/uvote/page/user_main_analysis/user_main_analysis.php @@ -1,5 +1,12 @@ SERVERPATH(), $vars); } - } +} \ No newline at end of file diff --git a/uvote/page/user_main_options/user_main_options.php b/uvote/page/user_main_options/user_main_options.php index 2951813..8566195 100644 --- a/uvote/page/user_main_options/user_main_options.php +++ b/uvote/page/user_main_options/user_main_options.php @@ -1,5 +1,12 @@ poll_ID = $poll_ID; diff --git a/uvote/page/user_main_poll_sub/user_main_poll_sub.php b/uvote/page/user_main_poll_sub/user_main_poll_sub.php index 098123a..b6751e4 100644 --- a/uvote/page/user_main_poll_sub/user_main_poll_sub.php +++ b/uvote/page/user_main_poll_sub/user_main_poll_sub.php @@ -1,5 +1,13 @@ poll_ID = $poll_ID; diff --git a/uvote/page/user_main_start/user_main_start.php b/uvote/page/user_main_start/user_main_start.php index 43f7f36..2a4aa49 100644 --- a/uvote/page/user_main_start/user_main_start.php +++ b/uvote/page/user_main_start/user_main_start.php @@ -1,5 +1,15 @@ SERVERPATH(), $tag); - } - return $result; - } - public static function js(){ + + public static function get_list_tags(){ + $result = ''; + $vars = \SQL\UVOTE_DATA_USER_TAGS::QA(array()); + foreach($vars as $tag){ + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('user_main_votelist/tpl/filter.tpl'))->SERVERPATH(), $tag); + } + return $result; + } + public static function js(){ return array(new \PPAGE('user_main_votelist/js/user_main_votelist.js'));} public function html(){ $vars = array(); diff --git a/uvote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.php b/uvote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.php index d8e6b65..0c89890 100644 --- a/uvote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.php +++ b/uvote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.php @@ -76,7 +76,7 @@ class saimod_uvote_vote_edit extends \SYSTEM\SAI\sai_module { } public static function html_li_menu(){return '
  • Edit Votes
  • ';} public static function right_public(){return false;} - public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} + public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} public static function js(){return array( \SYSTEM\WEBPATH(new \PSAI(),'saimod_uvote_vote_edit/saimod_uvote_vote_edit.js') );}