Ejemplo n.º 1
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     session_start();
     session_regenerate_id();
 }
Ejemplo n.º 2
0
 public function post($data)
 {
     // check present, token ok, password and password confirm ok
     if (!isset($data["token"], $data["passwords"]["password"], $data["passwords"]["repeat_password"])) {
         $this->response("Bad data", null, 400);
     }
     if (empty($data["token"]) || strlen($data["token"]) < 20) {
         $this->response("Bad data", null, 400);
     }
     if (empty($data["passwords"]["password"]) || empty($data["passwords"]["repeat_password"]) || $data["passwords"]["password"] !== $data["passwords"]["repeat_password"]) {
         $this->response("Bad data", null, 400);
     }
     $token_data = explode("_", $data["token"]);
     if (count($token_data) != 2 || empty($token_data[0]) || empty($token_data[1])) {
         $this->response("Bad data", null, 400);
     }
     /* data present and pre check good, lets do a user search and check */
     // try find user
     $user = $this->razor_db->get_first('user', '*', array('id' => (int) $token_data[1]));
     // no valid user found
     if (empty($user)) {
         $this->response("Bad data", null, 400);
     }
     // check token
     if (empty($user["reminder_token"]) || $token_data[0] != $user["reminder_token"] || $user["reminder_time"] + 3600 < time()) {
         $this->response("Bad data", null, 400);
     }
     /* user ok, token ok, lets change password */
     $password = RazorAPI::create_hash($data["passwords"]["password"]);
     // set new reminder
     $row = array("password" => $password, "reminder_token" => "");
     $this->razor_db->edit_data('user', $row, array('id' => $user['id']));
     $this->response("success", "json");
 }
Ejemplo n.º 3
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // set paths
     $this->ext_path = RAZOR_BASE_PATH . "extension";
 }
Ejemplo n.º 4
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // open extension db and attach razor db
     $this->db = new RazorPDO('sqlite:' . RAZOR_BASE_PATH . 'storage/database/social_razorcms_blog.sqlite');
     $this->db->exec('ATTACH "' . RAZOR_BASE_PATH . 'storage/database/razorcms.sqlite" AS razor');
 }
Ejemplo n.º 5
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // imagepath and relative url (important when shifting domains)
     $this->root_path = RAZOR_BASE_PATH . 'storage/files/images';
     $this->root_url = str_replace("http://{$_SERVER["SERVER_NAME"]}" . ($_SERVER["SERVER_PORT"] == "80" ? "" : ":{$_SERVER["SERVER_PORT"]}"), "", RAZOR_BASE_URL) . 'storage/files/images';
 }
Ejemplo n.º 6
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // set paths
     $this->tmp_path = RAZOR_BASE_PATH . "storage/tmp";
     $this->package_path = RAZOR_BASE_PATH . 'storage/tmp/package';
     $this->backup_path = RAZOR_BASE_PATH . "storage/tmp/backup";
     // includes
     include_once RAZOR_BASE_PATH . "library/php/razor/razor_zip.php";
 }
Ejemplo n.º 7
0
 public function load()
 {
     // check for admin flag
     if ($this->link == "login") {
         $this->link = null;
         $this->login = true;
     }
     // check for logged in
     if (isset($_COOKIE["token"])) {
         include RAZOR_BASE_PATH . "library/php/razor/razor_api.php";
         $api = new RazorAPI();
         $this->logged_in = $api->check_access(86400);
     }
     // load data
     $this->get_all_menus();
     $this->get_site_data();
     $this->get_page_data();
     $this->get_menu_data();
     $this->get_content_data();
 }
Ejemplo n.º 8
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // set paths
     $this->tmp_path = RAZOR_BASE_PATH . "storage/tmp";
     $this->package_path = RAZOR_BASE_PATH . 'storage/tmp/package';
     // check if folders exist
     if (!is_dir($this->tmp_path)) {
         mkdir($this->tmp_path);
     }
     if (!is_dir($this->package_path)) {
         mkdir($this->package_path);
     }
 }
Ejemplo n.º 9
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // set paths
     $this->tmp_path = RAZOR_BASE_PATH . "storage/tmp";
     $this->backup_path = RAZOR_BASE_PATH . "storage/tmp/backup";
     $this->backup_url = RAZOR_BASE_URL . "storage/tmp/backup";
     // includes
     include_once RAZOR_BASE_PATH . "library/php/razor/razor_zip.php";
     // check if folders exist
     if (!is_dir($this->tmp_path)) {
         mkdir($this->tmp_path);
     }
     if (!is_dir($this->backup_path)) {
         mkdir($this->backup_path);
     }
 }
Ejemplo n.º 10
0
 public function post($data)
 {
     // check present, token ok, password and password confirm ok
     if (!isset($data["token"], $data["passwords"]["password"], $data["passwords"]["repeat_password"])) {
         $this->response("Bad data", null, 400);
     }
     if (empty($data["token"]) || strlen($data["token"]) < 20) {
         $this->response("Bad data", null, 400);
     }
     if (empty($data["passwords"]["password"]) || empty($data["passwords"]["repeat_password"]) || $data["passwords"]["password"] !== $data["passwords"]["repeat_password"]) {
         $this->response("Bad data", null, 400);
     }
     $token_data = explode("_", $data["token"]);
     if (count($token_data) != 2 || empty($token_data[0]) || empty($token_data[1])) {
         $this->response("Bad data", null, 400);
     }
     /* data present and pre check good, lets do a user search and check */
     // try find user
     $db = new RazorDB();
     $db->connect("user");
     $search = array("column" => "id", "value" => (int) $token_data[1]);
     $user = $db->get_rows($search);
     $db->disconnect();
     // no valid user found
     if ($user["count"] != 1) {
         $this->response("Bad data", null, 400);
     }
     $user = $user["result"][0];
     // check token
     if (empty($user["reminder_token"]) || $token_data[0] != $user["reminder_token"] || $user["reminder_time"] + 3600 < time()) {
         $this->response("Bad data", null, 400);
     }
     /* user ok, token ok, lets change password */
     $password = RazorAPI::create_hash($data["passwords"]["password"]);
     // set new reminder
     $db->connect("user");
     $search = array("column" => "id", "value" => $user["id"]);
     $row = array("password" => $password, "reminder_token" => "");
     $db->edit_rows($search, $row);
     $db->disconnect();
     $this->response("success", "json");
 }
Ejemplo n.º 11
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
     // ensure folder structure
     if (!is_dir(RAZOR_BASE_PATH . "storage/files")) {
         mkdir(RAZOR_BASE_PATH . "storage/files");
     }
     if (!is_dir(RAZOR_BASE_PATH . "storage/files/extension")) {
         mkdir(RAZOR_BASE_PATH . "storage/files/extension");
     }
     if (!is_dir(RAZOR_BASE_PATH . "storage/files/extension/photo")) {
         mkdir(RAZOR_BASE_PATH . "storage/files/extension/photo");
     }
     if (!is_dir(RAZOR_BASE_PATH . "storage/files/extension/photo/razorcms")) {
         mkdir(RAZOR_BASE_PATH . "storage/files/extension/photo/razorcms");
     }
     if (!is_dir(RAZOR_BASE_PATH . "storage/files/extension/photo/razorcms/photo-gallery")) {
         mkdir(RAZOR_BASE_PATH . "storage/files/extension/photo/razorcms/photo-gallery");
     }
     // imagepath and relative url (important when shifting domains)
     $this->root_path = RAZOR_BASE_PATH . 'storage/files/extension/photo/razorcms/photo-gallery';
     $this->root_url = str_replace("http://{$_SERVER["SERVER_NAME"]}" . ($_SERVER["SERVER_PORT"] == "80" ? "" : ":{$_SERVER["SERVER_PORT"]}"), "", RAZOR_BASE_URL) . 'storage/files/extension/photo/razorcms/photo-gallery';
 }
Ejemplo n.º 12
0
// include error handler
include_once RAZOR_BASE_PATH . 'library/php/razor/razor_file_tools.php';
include_once RAZOR_BASE_PATH . 'library/php/razor/razor_error_handler.php';
include_once RAZOR_BASE_PATH . 'library/php/razor/razor_api.php';
include_once RAZOR_BASE_PATH . "library/php/razor/razor_db.php";
// Load error handler
$error = new RazorErrorHandler();
set_error_handler(array($error, 'handle_error'));
set_exception_handler(array($error, 'handle_error'));
// login function - process login
if (isset($_GET["login"])) {
    $POST = RazorAPI::clean_data(!empty($_POST) ? $_POST : json_decode(file_get_contents('php://input')));
    if (isset($_GET["u"], $_GET["p"]) || isset($POST["u"], $POST["p"])) {
        $u = isset($POST["u"]) ? $POST["u"] : $_GET["u"];
        $p = isset($POST["p"]) ? $POST["p"] : $_GET["p"];
        $api = new RazorAPI();
        $api->login(array("username" => $u, "password" => $p));
    } else {
        RazorAPI::response(null, null, 400);
    }
    exit;
}
// grab method
$method = preg_replace("/[^a-z]/", '', strtolower($_SERVER["REQUEST_METHOD"]));
// check for path data to REST classes and grab them
if (!isset($_GET["path"])) {
    RazorAPI::response(null, null, $code = 404);
}
$path_parts = explode("/", $_GET["path"]);
$filename = "";
$classname = "";
Ejemplo n.º 13
0
 function __construct()
 {
     // REQUIRED IN EXTENDED CLASS TO LOAD DEFAULTS
     parent::__construct();
 }
Ejemplo n.º 14
0
 private static function xml($data)
 {
     $data = RazorAPI::clean_output($data);
     // build sitemap index
     $output = '<?xml version="1.0" encoding="UTF-8"?>';
     $output .= $data;
     header('Content-Type: application/xml; charset=utf-8');
     header("Cache-Control: no-cache, no-store, must-revalidate");
     echo $output;
     exit;
 }
 /**
  * Handle Error
  * Handles all errors and exceptions
  *
  * @param string $error_type Type of error
  * @param string $error_string Actual error string
  * @param string $error_file File error happened in
  * @param string $error_line Line error happened on
  * @return bool True on pass
  */
 public function handle_error($error_type = "", $error_string = "", $error_file = "", $error_line = "")
 {
     $error_group = 'log';
     // changeing log type to chrome php
     $type = '';
     if (is_int($error_type)) {
         switch ($error_type) {
             case E_ERROR:
                 // 1 //
                 $error_group = 'error';
                 $type = 'E_ERROR';
                 break;
             case E_WARNING:
                 // 2 //
                 $error_group = 'warn';
                 $type = 'E_WARNING';
                 break;
             case E_PARSE:
                 // 4 //
                 $type = 'E_PARSE';
                 break;
             case E_NOTICE:
                 // 8 //
                 $type = 'E_NOTICE';
                 break;
             case E_CORE_ERROR:
                 // 16 //
                 $error_group = 'error';
                 $type = 'E_CORE_ERROR';
                 break;
             case E_CORE_WARNING:
                 // 32 //
                 $error_group = 'warn';
                 $type = 'E_CORE_WARNING';
                 break;
             case E_CORE_ERROR:
                 // 64 //
                 $error_group = 'error';
                 $type = 'E_COMPILE_ERROR';
                 break;
             case E_CORE_WARNING:
                 // 128 //
                 $error_group = 'warn';
                 $type = 'E_COMPILE_WARNING';
                 break;
             case E_USER_ERROR:
                 // 256 //
                 $error_group = 'error';
                 $type = 'E_USER_ERROR';
                 break;
             case E_USER_WARNING:
                 // 512 //
                 $error_group = 'warn';
                 $type = 'E_USER_WARNING';
                 break;
             case E_USER_NOTICE:
                 // 1024 //
                 $type = 'E_USER_NOTICE';
                 break;
             case E_STRICT:
                 // 2048 //
                 $type = 'E_STRICT';
                 break;
             case E_RECOVERABLE_ERROR:
                 // 4096 //
                 $error_group = 'error';
                 $type = 'E_RECOVERABLE_ERROR';
                 break;
             case E_DEPRECATED:
                 // 8192 //
                 $type = 'E_DEPRECATED';
                 break;
             case E_USER_DEPRECATED:
                 // 16384 //
                 $type = 'E_USER_DEPRECATED';
                 break;
         }
     }
     $error['error'] = $type;
     $error['type'] = $error_type;
     $error['file'] = $error_file;
     $error['line'] = $error_line;
     $error['string'] = $error_string;
     $error['group'] = $error_group;
     // log error
     $this->log_error($error);
     // log error to chromephp
     $this->chrome_php($error, false);
     // display error on screen
     $this->display_error($error);
     if (class_exists("RazorAPI")) {
         RazorAPI::response(null, null, 500);
     } else {
         return true;
     }
 }