Example #1
0
 public function preprocess()
 {
     if (isset($_GET["redirect"]) && init_check()) {
         header("Location:" . $_GET['redirect']);
         return false;
     }
     $this->__routes[] = 'get<logout>';
     $this->__routes[] = 'post<name><password>';
     return parent::preprocess();
 }
Example #2
0
function validateUserQuiet($auth, $sub = 'all')
{
    if (!auth_enabled()) {
        return 'null';
    }
    if (init_check()) {
        return 'init';
    }
    $current_user = checkLogin();
    if (!$current_user) {
        return false;
    }
    $groupPriv = checkGroupAuth($current_user, $auth, $sub);
    if ($groupPriv) {
        return $current_user;
    }
    $priv = checkAuth($current_user, $auth, $sub);
    if (!$priv) {
        return false;
    }
    return $current_user;
}
Example #3
0
 function log_view($product_id = 0, $user_id = 0)
 {
     try {
         //Transaction starts here
         $this->CI->db->trans_begin();
         if (!init_check($product_id = 0, $user_id = 0)) {
             throw new Exception($this->CI->error_message);
         }
         $insert = array('product_id' => $product_id, 'user_id' => $user_id);
         $this->CI->views_model->insert($insert);
         //update count of likes of current product
         $this->update_count($product_id, 'views');
         //now end the trnascation.
         if ($this->CI->db->trans_status() === FALSE) {
             throw new Exception("Query failed.");
         } else {
             $this->CI->db->trans_commit();
         }
     } catch (Exception $e) {
         $this->CI->db->trans_rollback();
         //set error message if the variable is available
         if (isset($this->CI->error_message)) {
             $this->CI->error_message = $e->getMessage();
         }
         return FALSE;
     }
 }
Example #4
0
function checkAuth($name, $auth_class, $sub = 'all')
{
    if (init_check()) {
        return 'init';
    }
    if (!isAlphanumeric($name) or !isAlphanumeric($auth_class) or !isAlphanumeric($sub)) {
        return false;
    }
    $uid = getUID($name);
    if (!$uid) {
        return false;
    }
    $sql = dbconnect();
    $checkQ = $sql->prepare_statement("select * from userPrivs where uid=? and auth_class=? and\n             ((? between sub_start and sub_end) or (sub_start='all' and sub_end='all'))");
    $checkR = $sql->exec_statement($checkQ, array($uid, $auth_class, $sub));
    if ($sql->num_rows($checkR) == 0) {
        return false;
    }
    return true;
}