Exemple #1
0
 /**
  * Not have permition to view this page
  */
 public function Not_have_Perm()
 {
     /** @noinspection PhpIncludeInspection */
     require_once controllers_dir() . default_error();
     $err = new error();
     $err->error403();
     exit;
 }
Exemple #2
0
function run_sql($sql, $arg = array(), $fatal = true)
{
    global $sql_open;
    global $sql_dbh;
    global $sql_server;
    global $sql_error;
    if (substr($sql_server, 0, 4) == "http") {
        $request = array("sql" => $sql, "count" => count($arg));
        for ($i = 0; $i < count($arg); $i++) {
            if (is_int($arg[$i])) {
                $request["type_{$i}"] = "int";
            } else {
                if (is_numeric($arg[$i])) {
                    $request["type_{$i}"] = "float";
                } else {
                    $request["{$type_}{$i}"] = "string";
                }
            }
            $request["value_{$i}"] = $arg[$i];
        }
        $request = map_to_url_string($request);
        $body = http_slap($sql_server, $request);
        $row = array();
        $a = explode("\n", trim($body));
        for ($i = 0; $i < count($a); $i++) {
            if ($a[$i] != "") {
                $row[] = map_from_tag_string($a[$i]);
            }
        }
    } else {
        if (!$sql_open) {
            open_database();
        }
        $sth = $sql_dbh->prepare($sql);
        try {
            //if (string_has($sql_server, "sqlsrv:")) {
            //	// XXX: bug workaround - can't bind a zero length string when using mssql native client
            //	for ($i = 0; $i < count($arg); $i++) {
            //		if (is_string($arg[$i])) {
            //			if ($arg[$i] == "") {
            //				$arg[$i] = " ";
            //			}
            //		}
            //	}
            //}
            $sth->execute($arg);
            if ($sth->columnCount() == 0) {
                return;
            }
            $row = $sth->fetchAll();
        } catch (PDOException $exception) {
            $msg = $exception->getMessage();
            $sql_error = "sql [{$sql}] arg [" . implode(", ", $arg) . "] msg [{$msg}]";
            if ($fatal) {
                default_error($sql_error);
            }
            return false;
        }
    }
    return $row;
}
Exemple #3
0
 /**
  * getting error
  *
  * @param $code
  */
 public function _Error($code)
 {
     $file = controllers_dir() . default_error() . '.php';
     /** @noinspection PhpIncludeInspection */
     require_once $file;
     $this->_Controller = new error();
     switch ($code) {
         case 404:
             $this->_Controller->error404();
             break;
         case 403:
             $this->_Controller->error403();
             break;
         case 503:
             $this->_Controller->error503();
             break;
         default:
     }
     exit;
 }