static function _get_all_question_by_date() { if (self::$counter == 0) { $connection = _database::get_connection(); $query = "SELECT * FROM `_questions` ORDER BY `_q_time` DESC"; if (!($res = $connection->query($query))) { return false; } else { $i = 0; while ($arr = $res->fetch_array()) { $obj = new _question(); $obj->setQid($arr['_qid']); $obj->setQUid($arr['_q_uid']); $obj->setDescription($arr['_description']); $obj->setCurious($arr['_curious']); $obj->setQTime($arr['_q_time']); self::$_all_question[$i] = $obj; $i++; } } return self::$_all_question; } else { if (self::$counter++ == 10) { self::$counter = 0; } return self::$_all_question; } }
/** * gets all answers for the the given qid */ public static function _get_all_answer_by_qid($ref_qid) { $all_answers = array(); $connection = _database::get_connection(); $query = "SELECT * FROM `_answers` WHERE `_a_qid` = {$ref_qid} ORDER BY `_a_time` DESC"; if ($res = $connection->query($query)) { $i = 0; while ($arr = $res->fetch_array()) { $obj = new _answers(); $obj->setAid($arr['_aid']); $obj->setDescription($arr['_description']); $obj->setAUid($arr['_a_uid']); $obj->setAQid($arr['_a_qid']); $obj->setApt($arr['_apt']); $obj->setNotApt($arr['_notapt']); $obj->setATime($arr['_a_time']); $all_answers[$i] = $obj; $i++; } return $all_answers; } else { return false; } }
static function _verify_password($_username, $_check_password) { $connection = _database::get_connection(); $query = "SELECT `_password` FROM `_users` WHERE _username='******'"; $result = $connection->query($query); if ($result->num_rows > 0) { $result_array = $result->fetch_assoc(); $_temp_password = $result_array['_password']; if ($_temp_password == _user::cipher($_check_password)) { return true; } else { return false; } } return false; }