Beispiel #1
0
 public function do_ajax()
 {
     $class = $_REQUEST['module'];
     $function = $_REQUEST['act'];
     if ($class == 'core' || $class == 'this') {
         $module = 'core';
     } else {
         if (class_exists($class)) {
             $module = $class;
         } else {
             $module = '\\module\\' . $class . '\\controller';
         }
     }
     if (class_exists($module)) {
         $class = new \ReflectionClass($module);
         if ($class->hasMethod($function)) {
             $method = new \ReflectionMethod($module, $function);
             if ($method->isStatic()) {
                 $module::$function();
             } else {
                 if ($module != 'core') {
                     $object = new $module();
                     $object->{$function}();
                 } else {
                     $this->{$function}();
                 }
             }
         }
     }
     ajax::do_serve();
     exit;
 }
Beispiel #2
0
 /**
  * @param $sql
  * @param array $params
  * @param bool $throwable
  * @return \PDOStatement
  */
 static function query($sql, $params = [], $throwable = false)
 {
     // Attempt to reconnect if connection has gone away.
     if (!_db::connected()) {
         _db::reconnect();
     }
     $prep_sql = _db::$con->prepare($sql);
     if (!empty($params)) {
         foreach ($params as $key => $val) {
             $prep_sql->bindValue($key, $val);
         }
     }
     try {
         $prep_sql->execute();
     } catch (\PDOException $e) {
         $error = node::create('div.error_message.mysql', [], node::create('p', [], $e->getMessage() . \core::get_backtrace() . print_r(isset($prep_sql->queryString) ? $prep_sql->queryString : '', 1) . print_r($params, true)));
         if (ajax) {
             _ajax::inject('body', 'append', $error);
             if (!$throwable) {
                 _ajax::do_serve();
                 die;
             }
         } else {
             echo $error;
             if (!$throwable) {
                 die;
             }
         }
     }
     return $prep_sql;
 }