Ejemplo n.º 1
0
 public function delete($id)
 {
     if ((int) $this->check_access() < 9) {
         $this->response(null, null, 401);
     }
     if (empty($id)) {
         $this->response(null, null, 400);
     }
     $parts = explode("__", strtolower($id));
     if (count($parts) != 3) {
         $this->response(null, null, 400);
     }
     $category = preg_replace('/[^a-z0-9-_]/', '', $parts[0]);
     $handle = preg_replace('/[^a-z0-9-_]/', '', $parts[1]);
     $extension = preg_replace('/[^a-z0-9-_]/', '', $parts[2]);
     $remove_path = "{$this->ext_path}/{$category}/{$handle}/{$extension}";
     $rars_remove_path = "{$this->rars_path}/{$category}/{$handle}/{$extension}";
     if (!is_dir($remove_path)) {
         $this->response(null, null, 400);
     }
     if (RazorFileTools::delete_directory($remove_path)) {
         if (is_dir($rars_remove_path)) {
             RazorFileTools::delete_directory($rars_remove_path);
         }
         $this->response("success", "json");
     }
     $this->response(null, null, 400);
 }
Ejemplo n.º 2
0
 public function get($id)
 {
     if ((int) $this->check_access() < 9) {
         $this->response(null, null, 401);
     }
     $list_url = "";
     switch ($id) {
         case "extension":
             $list = $this->ext_list;
             break;
         case "category":
             $list = $this->cat_list;
             break;
         case "handle":
             $list = $this->han_list;
             break;
         default:
             $this->response(null, null, 400);
             break;
     }
     $repo_file = RazorFileTools::get_remote_content($this->repo_url . $list);
     if (!empty($repo_file)) {
         $repo = json_decode($repo_file);
         $this->response(array("list" => $repo), "json");
     }
     // send back unnavailable
     $this->response(null, null, 404);
 }
Ejemplo n.º 3
0
 public function post($data)
 {
     if ((int) $this->check_access() < 9) {
         $this->response(null, null, 401);
     }
     if (empty($data) || !isset($data["type"]) || !isset($data["handle"]) || !isset($data["extension"])) {
         $this->response(null, null, 400);
     }
     if (!isset($data["manifests"]) && !isset($data["manifest"])) {
         $this->response(null, null, 400);
     }
     // fetch cleaned data
     $manifest = preg_replace('/[^a-zA-Z0-9-_]/', '', isset($data["manifests"][0]) ? $data["manifests"][0] : $data["manifest"]);
     // grab first only
     $category = preg_replace('/[^a-zA-Z0-9-_]/', '', strtolower($data["type"]));
     $handle = preg_replace('/[^a-zA-Z0-9-_]/', '', strtolower($data["handle"]));
     $name = preg_replace('/[^a-zA-Z0-9-_]/', '', strtolower($data["extension"]));
     // fetch details
     $man_url = $this->repo_url . "extension/{$category}/{$handle}/{$name}/{$manifest}.manifest.json";
     $details_file = RazorFileTools::get_remote_content($man_url);
     if (!empty($details_file)) {
         $details = json_decode($details_file);
         $this->response(array("details" => $details), "json");
     }
     // send back not found if no details
     $this->response(null, null, 404);
 }
Ejemplo n.º 4
0
 public function get($page_id)
 {
     $query = 'SELECT a.*' . ", b.id AS 'content.id'" . ", b.name AS 'content.name'" . ", b.content AS 'content.content'" . ' FROM page_content AS a' . ' LEFT JOIN content AS b ON a.content_id = b.id' . ' WHERE a.page_id = :page_id' . ' ORDER BY a.position ASC';
     $data = $this->razor_db->query_all($query, array('page_id' => $page_id));
     $content = array();
     $locations = array();
     foreach ($data as $row) {
         if (!empty($row["content.id"])) {
             $content[$row['content.id']] = array("content_id" => $row["content.id"], "name" => $row["content.name"], "content" => $row["content.content"]);
         }
         $location_data = array("id" => $row["id"], "content_id" => $row["content_id"], "extension" => $row["extension"], "settings" => json_decode($row["json_settings"]));
         if (!empty($row["extension"])) {
             $manifest = RazorFileTools::read_file_contents(RAZOR_BASE_PATH . "extension/{$row['extension']}", "json");
             if (isset($manifest->content_settings) && !empty($manifest->content_settings)) {
                 // create object
                 if (!is_object($location_data["settings"])) {
                     $location_data["settings"] = new stdClass();
                 }
                 // copy settings
                 $location_data["extension_content_settings"] = $manifest->content_settings;
                 // if no settings present, add defaults from manifest
                 foreach ($manifest->content_settings as $cs) {
                     if (!isset($location_data["settings"]->{$cs->name})) {
                         $location_data["settings"]->{$cs->name} = $cs->value;
                     }
                 }
             }
         }
         $locations[$row["location"]][$row["column"]][] = $location_data;
     }
     // return the basic user details
     $this->response(array("content" => $content, "locations" => $locations), "json");
 }
Ejemplo n.º 5
0
 public function post($data)
 {
     // Check details
     if (!isset($_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"], $_SERVER["HTTP_REFERER"], $_SESSION["signature"])) {
         $this->response(null, null, 400);
     }
     if (empty($_SERVER["REMOTE_ADDR"]) || empty($_SERVER["HTTP_USER_AGENT"]) || empty($_SERVER["HTTP_REFERER"]) || empty($_SESSION["signature"])) {
         $this->response(null, null, 400);
     }
     // check referer matches the site
     if (strpos($_SERVER["HTTP_REFERER"], RAZOR_BASE_URL) !== 0) {
         $this->response(null, null, 400);
     }
     // check data
     if (!isset($data["signature"], $data["email"], $data["message"], $data["extension"]["type"], $data["extension"]["handle"], $data["extension"]["extension"])) {
         $this->response(null, null, 400);
     }
     if (empty($data["signature"]) || empty($data["email"]) || empty($data["message"]) || empty($data["extension"]["type"]) || empty($data["extension"]["handle"]) || empty($data["extension"]["extension"])) {
         $this->response(null, null, 400);
     }
     if (!isset($data["human"]) || !empty($data["human"])) {
         $this->response("robot", "json", 406);
     }
     // get signature and compare to session
     if ($_SESSION["signature"] !== $data["signature"]) {
         $this->response(null, null, 400);
     }
     unset($_SESSION["signature"]);
     session_destroy();
     // create manifest path for extension that requested email
     $ext_type = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["type"]);
     $ext_handle = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["handle"]);
     $ext_extension = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["extension"]);
     $manifest_path = RAZOR_BASE_PATH . "extension/{$ext_type}/{$ext_handle}/{$ext_extension}/{$ext_extension}.manifest.json";
     if (!is_file($manifest_path)) {
         $this->response(null, null, 400);
     }
     $manifest = RazorFileTools::read_file_contents($manifest_path, "json");
     // grab contact form settings
     $where = array("type" => $manifest->type, "handle" => $manifest->handle, "extension" => $manifest->extension);
     $extension = $this->razor_db->get_first('extension', array('json_settings'), $where);
     if (empty($extension)) {
         $this->response(null, null, 400);
     }
     $extension_settings = json_decode($extension['json_settings']);
     // fetch extension settings and look for email
     $where = array(array("type" => $manifest->type), array("handle" => $manifest->handle), array("extension" => $manifest->extension));
     $site = $this->razor_db->get_first('setting', array('value'), array('name' => 'name'));
     $site_name = json_decode($site['value']);
     // clean email data
     $to = $extension_settings->email;
     $from = preg_replace('/[^A-Za-z0-9-_+@.]/', '', $data["email"]);
     $subject = "{$site_name} Contact Form";
     $message = htmlspecialchars($data["message"], ENT_QUOTES);
     // send to email response
     $this->email($from, $to, $subject, $message);
     // return the basic user details
     $this->response("success", "json");
 }
Ejemplo n.º 6
0
 private function package_system_upgrade()
 {
     if ((int) $this->check_access() < 10) {
         $this->response(null, null, 401);
     }
     $file_contents = file_get_contents($this->upgrade_url);
     if (empty($file_contents)) {
         $this->response(null, null, 404);
     }
     if (!RazorFileTools::write_file_contents("{$this->package_path}/system_upgrade.zip", $file_contents)) {
         throw new Exception("Could not write upgrade file to storage/tmp/package.");
     }
     $this->response("success", "json");
 }
Ejemplo n.º 7
0
 public function get($page_id)
 {
     // go through all changes and update all
     $db = new RazorDB();
     $db->connect("page_content");
     // set options
     $options = array("order" => array("column" => "position", "direction" => "asc"));
     $search = array("column" => "page_id", "value" => (int) $page_id);
     $page_contents = $db->get_rows($search, $options);
     $page_contents = $page_contents["result"];
     $db->disconnect();
     // split into content and locations
     $db->connect("content");
     $content = array();
     $locations = array();
     foreach ($page_contents as $row) {
         if (!empty($row["content_id"])) {
             $options = array("limit" => 1);
             $search = array("column" => "id", "value" => (int) $row["content_id"]);
             $found_content = $db->get_rows($search, $options);
             $found_content = $found_content["result"][0];
             $content[$found_content["id"]] = array("content_id" => $found_content["id"], "name" => $found_content["name"], "content" => $found_content["content"]);
         }
         $location_data = array("id" => $row["id"], "content_id" => $row["content_id"], "extension" => $row["extension"], "settings" => json_decode($row["json_settings"]));
         if (!empty($row["extension"])) {
             $manifest = RazorFileTools::read_file_contents(RAZOR_BASE_PATH . "extension/{$row['extension']}", "json");
             if (isset($manifest->content_settings) && !empty($manifest->content_settings)) {
                 // create object
                 if (!is_object($location_data["settings"])) {
                     $location_data["settings"] = new stdClass();
                 }
                 // copy settings
                 $location_data["extension_content_settings"] = $manifest->content_settings;
                 // if no settings present, add defaults from manifest
                 foreach ($manifest->content_settings as $cs) {
                     if (!isset($location_data["settings"]->{$cs->name})) {
                         $location_data["settings"]->{$cs->name} = $cs->value;
                     }
                 }
             }
         }
         $locations[$row["location"]][$row["column"]][] = $location_data;
     }
     $db->disconnect();
     // return the basic user details
     $this->response(array("content" => $content, "locations" => $locations), "json");
 }
Ejemplo n.º 8
0
 public function get($id)
 {
     if ($id != "current") {
         $this->response(null, null, 400);
     }
     $host = isset($_SERVER["SERVER_NAME"]) ? urlencode($_SERVER["SERVER_NAME"]) : (isset($_SERVER["HTTP_HOST"]) ? urlencode($_SERVER["HTTP_HOST"]) : "current");
     $version_file = RazorFileTools::get_remote_content($this->check_url . $host);
     if (!empty($version_file)) {
         $version = json_decode($version_file);
         $this->response($version, "json");
     } else {
         // send back unnavailable
         $this->response(null, null, 404);
     }
     // send back unnavailable
     $this->response(null, null, 404);
 }
Ejemplo n.º 9
0
 public function post($data)
 {
     if ((int) $this->check_access() < 10) {
         $this->response(null, null, 401);
     }
     if (empty($data) || !isset($data["type"]) || !isset($data["handle"]) || !isset($data["extension"])) {
         $this->response(null, null, 400);
     }
     // fetch cleaned data
     $category = preg_replace('/[^a-zA-Z0-9-_]/', '', $data["type"]);
     $handle = preg_replace('/[^a-zA-Z0-9-_]/', '', $data["handle"]);
     $name = preg_replace('/[^a-zA-Z0-9-_]/', '', $data["extension"]);
     // fetch details
     $package_url = $this->package_url . "{$category}/{$handle}/{$name}/{$name}.zip";
     $headers = @get_headers($package_url);
     if (strpos($headers[0], "404") === false) {
         $ctx = stream_context_create(array('http' => array('timeout' => 60)));
         // copy package to temp location
         $package_contents = @file_get_contents($package_url, false, $ctx);
         if (!empty($package_contents)) {
             if (!RazorFileTools::write_file_contents("{$this->tmp_package_path}/{$name}.zip", $package_contents)) {
                 throw new Exception("Could not write upgrade file to storage/tmp/package.");
             }
         }
         // extract to file system
         if (!is_file("{$this->tmp_package_path}/{$name}.zip")) {
             throw new exception("Extension file not found.");
         }
         // open extension package
         $zip = new RazorZip();
         $zip->open("{$this->tmp_package_path}/{$name}.zip");
         // extract
         $zip->extractTo(RAZOR_BASE_PATH);
         $zip->close();
         // cleanup
         RazorFileTools::delete_directory($this->tmp_path);
         // send back not found if no details
         $this->response("success", "json");
     }
     // send back not found if no details
     $this->response(null, null, 404);
 }
Ejemplo n.º 10
0
 public function post($data)
 {
     if ((int) $this->check_access() < 10) {
         $this->response(null, null, 401);
     }
     if (!isset($data["backup"])) {
         $this->response(null, null, 400);
     }
     $parts = explode("/", $data["backup"]);
     $file = end($parts);
     if (!is_file("{$this->backup_path}/{$file}")) {
         throw new exception("Upgrade file not found.");
     }
     // open backup
     $zip = new RazorZip();
     $zip->open("{$this->backup_path}/{$file}");
     /* UPGRADE */
     $zip->extractTo(RAZOR_BASE_PATH);
     $zip->close();
     // remove tmp files
     RazorFileTools::delete_directory($this->tmp_path);
     $this->response("success", "json");
 }
Ejemplo n.º 11
0
 public function get()
 {
     if ((int) $this->check_access() < 10) {
         $this->response(null, null, 401);
     }
     // check if folders exist
     if (!is_dir($this->root_path)) {
         $this->response(null, null, 401);
     }
     // grab folder here, load in the files for a particular folder
     $files = RazorFileTools::read_dir_contents($this->root_path, $type = 'files');
     // remove anything not an image file ext
     foreach ($files as $key => $file) {
         $path_parts = explode('.', $file);
         if (!in_array(end($path_parts), $this->image_ext) || !in_array(exif_imagetype("{$this->root_path}/{$file}"), $this->image_types)) {
             unset($files[$key]);
             continue;
         }
         $files[$key] = array("url" => "{$this->root_url}/{$file}", "name" => $file);
     }
     sort($files);
     // json encode
     $this->response(array("imageList" => array_values($files)), "json");
 }
Ejemplo n.º 12
0
 public function delete($name)
 {
     if ((int) $this->check_access() < 8) {
         $this->response(null, null, 401);
     }
     if (empty($name)) {
         $this->response(null, null, 400);
     }
     // ensure name is clean
     $name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $name);
     // ensure we deleting a image
     $file_ext = explode(".", strtolower($name));
     if (!in_array(end($file_ext), $this->image_ext)) {
         $this->response(null, null, 406);
     }
     // check exists
     if (!is_file(RAZOR_BASE_PATH . "storage/files/images/{$name}")) {
         $this->response(null, null, 406);
     }
     RazorFileTools::delete_file(RAZOR_BASE_PATH . "storage/files/images/{$name}");
     $this->response("success", "json");
 }
Ejemplo n.º 13
0
     if (in_array(strtolower(end($path_parts)), $media_files)) {
         $type = strtolower(end($path_parts));
     }
 }
 if (isset($content_ext_settings->track_name)) {
     // play single track
     $path = RAZOR_BASE_PATH . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$content_ext_settings->track_name}";
     $url = RAZOR_BASE_URL . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$content_ext_settings->track_name}";
     if (is_file($path)) {
         $track = $url;
         $path_parts = explode(".", $track);
         $type = $type ? $type : "." . end($track);
     }
 }
 // grab folder here, load in the files for a particular folder
 $files = RazorFileTools::read_dir_contents(RAZOR_BASE_PATH . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}", 'files');
 // remove anything not an image file ext
 foreach ($files as $key => $file) {
     $file_parts = explode(".", $file);
     if (!in_array(strtolower(end($file_parts)), $media_files) || end($file_parts) != (!empty($type) ? $type : "mp3")) {
         continue;
     }
     $playlist[$key] = array("url" => RAZOR_BASE_URL . "storage/files/razorcms/media-element-player/{$content_ext_settings->playlist_name}/{$file}", "name" => $file);
 }
 $playlist = array_values($playlist);
 // one final type check
 if (empty($type) && isset($playlist[0]["name"])) {
     $path_parts = explode(".", $content_ext_settings->track_name);
     if (in_array(strtolower(end($playlist[0]["name"])), $media_files)) {
         $type = strtolower(end($playlist[0]["name"]));
     }
Ejemplo n.º 14
0
    public function content($loc, $col)
    {
        // create extension dependancy list
        $ext_dep_list = array();
        // admin angluar loading for editor, return
        if (isset($_GET["edit"]) && ($this->logged_in > 6 || $this->logged_in > 5 && !$this->page["active"])) {
            //<div text-angular name="{$loc}{$col}{{block.content_id}}" ng-if="!block.extension" ta-disabled="!editingThis('{$loc}{$col}' + block.content_id)" class="content-edit" ng-model="content[block.content_id].content" ng-click="startBlockEdit('{$loc}{$col}',  block.content_id)" ></div>
            echo <<<OUTPUT
<div class="content-column" ng-if="changed" ng-class="{'edit': toggle}">
\t<div class="content-block" ng-class="{'active': editingThis('{$loc}{$col}' + block.content_id)}" ng-repeat="block in locations.{$loc}.{$col}">

\t\t<div class="input-group block-controls" ng-if="!block.extension">
\t\t\t<span class="input-group-btn">
\t\t\t\t<button class="btn btn-default" ng-click="locations.{$loc}.{$col}.splice(\$index - 1, 0, locations.{$loc}.{$col}.splice(\$index, 1)[0])" ng-show="toggle"><i class="fa fa-arrow-up"></i></button>
\t\t\t\t<button class="btn btn-default" ng-click="locations.{$loc}.{$col}.splice(\$index + 1, 0, locations.{$loc}.{$col}.splice(\$index, 1)[0])" ng-show="toggle"><i class="fa fa-arrow-down"></i></button>
\t\t\t</span>
\t\t\t<input type="text" class="form-control" placeholder="Add Content Name" ng-show="toggle" ng-model="content[block.content_id].name"/>
\t\t\t<span class="input-group-btn">
\t\t\t\t<button class="btn btn-warning" ng-show="toggle" ng-click="removeContent('{$loc}', '{$col}', \$index)"><i class="fa fa-times"></i></button>
\t\t\t</span>
\t\t</div>

\t\t<div id="{$loc}{$col}{{block.content_id}}" ng-if="!block.extension" class="content-edit" ng-click="startBlockEdit('{$loc}{$col}',  block.content_id)" ng-bind-html="content[block.content_id].content | html"></div>

\t\t<div class="content-settings" ng-if="block.extension">
\t\t\t<div class="extension-controls">
\t\t\t\t<span class="btn-group pull-left">
\t\t\t\t\t<button class="btn btn-default" ng-click="locations.{$loc}.{$col}.splice(\$index - 1, 0, locations.{$loc}.{$col}.splice(\$index, 1)[0])" ng-show="toggle"><i class="fa fa-arrow-up"></i></button>
\t\t\t\t\t<button class="btn btn-default" ng-click="locations.{$loc}.{$col}.splice(\$index + 1, 0, locations.{$loc}.{$col}.splice(\$index, 1)[0])" ng-show="toggle"><i class="fa fa-arrow-down"></i></button>
\t\t\t\t</span>
\t\t\t\t<h3 class="extension-title pull-left"><i class="fa fa-puzzle-piece"></i> Extension</h3>
\t\t\t\t<button class="btn btn-warning pull-right" ng-show="toggle" ng-click="removeContent('{$loc}', '{$col}', \$index)"><i class="fa fa-times"></i></button>
\t\t\t</div>
\t\t\t<form class="form-horizontal" role="form" name="form" novalidate>
\t\t\t\t<div class="form-group">
\t\t\t\t\t<label class="col-sm-3 control-label">Type</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" value="{{block.extension.split('/')[0]}}" disabled>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group">
\t\t\t\t\t<label class="col-sm-3 control-label">Handle</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" value="{{block.extension.split('/')[1]}}" disabled>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group">
\t\t\t\t\t<label class="col-sm-3 control-label">Extension</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" value="{{block.extension.split('/')[2]}}" disabled>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[0]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[0].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[0].placeholder}}" name="input0" ng-model="block.settings[block.extension_content_settings[0].name]" ng-pattern="{{block.extension_content_settings[0].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input0.\$dirty && form.input0.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input0.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[1]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[1].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[1].placeholder}}" name="input1" ng-model="block.settings[block.extension_content_settings[1].name]" ng-pattern="{{block.extension_content_settings[1].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input1.\$dirty && form.input1.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input1.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[2]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[2].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[2].placeholder}}" name="input2" ng-model="block.settings[block.extension_content_settings[2].name]" ng-pattern="{{block.extension_content_settings[2].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input2.\$dirty && form.input2.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input2.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[3]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[3].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[3].placeholder}}" name="input3" ng-model="block.settings[block.extension_content_settings[3].name]" ng-pattern="{{block.extension_content_settings[3].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input3.\$dirty && form.input3.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input3.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[4]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[4].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[4].placeholder}}" name="input4" ng-model="block.settings[block.extension_content_settings[4].name]" ng-pattern="{{block.extension_content_settings[4].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input4.\$dirty && form.input4.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input4.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[5]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[5].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[5].placeholder}}" name="input5" ng-model="block.settings[block.extension_content_settings[5].name]" ng-pattern="{{block.extension_content_settings[5].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input5.\$dirty && form.input5.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input5.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[6]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[6].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[6].placeholder}}" name="input6" ng-model="block.settings[block.extension_content_settings[6].name]" ng-pattern="{{block.extension_content_settings[6].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input6.\$dirty && form.input6.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input6.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div class="form-group" ng-if="block.extension_content_settings[7]">
\t\t\t\t\t<label class="col-sm-3 control-label">{{block.extension_content_settings[7].label}}</label>
\t\t\t\t\t<div class="col-sm-7">
\t\t\t\t\t\t<input type="text" class="form-control" placeholder="{{block.extension_content_settings[7].placeholder}}" name="input7" ng-model="block.settings[block.extension_content_settings[7].name]" ng-pattern="{{block.extension_content_settings[7].regex}}" >
\t\t\t\t\t</div>
\t\t\t\t\t<div class="col-sm-2 error-block" ng-show="form.input7.\$dirty && form.input7.\$invalid">
\t\t\t\t\t\t<span class="alert alert-danger alert-form" ng-show="form.input7.\$error.pattern">Invalid</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t</form>\t  
\t\t</div>
\t</div>
\t<button class="btn btn-default" ng-show="toggle" ng-click="addNewBlock('{$loc}', '{$col}')"><i class="fa fa-plus"></i></button>
\t<button class="btn btn-default" ng-show="toggle" ng-click="findBlock('{$loc}', '{$col}')"><i class="fa fa-search"></i></button>
\t<button class="btn btn-default" ng-show="toggle" ng-click="findExtension('{$loc}', '{$col}')"><i class="fa fa-puzzle-piece"></i></button>
</div>
OUTPUT;
            return;
        }
        $db = new RazorDB();
        // if not editor and not empty, output content for public
        foreach ($this->content as $c_data) {
            if ($c_data["location"] == $loc && $c_data["column"] == $col) {
                if (!empty($c_data["content_id"])) {
                    // load content
                    echo '<div ng-if="!changed" content-id="' . $c_data["content_id"] . '">';
                    $db->connect("content");
                    $search = array("column" => "id", "value" => $c_data["content_id"]);
                    $content = $db->get_rows($search);
                    $content = $content["result"][0];
                    $db->disconnect();
                    echo str_replace("\\n", "", $content["content"]);
                    echo '</div>';
                } elseif (!empty($c_data["extension"])) {
                    // load extension
                    $manifest = RazorFileTools::read_file_contents(RAZOR_BASE_PATH . "extension/{$c_data['extension']}", "json");
                    $view_path = RAZOR_BASE_PATH . "extension/{$manifest->type}/{$manifest->handle}/{$manifest->extension}/view/{$manifest->view}.php";
                    echo '<div ng-if="!changed">';
                    include $view_path;
                    echo '</div>';
                }
            }
        }
    }
Ejemplo n.º 15
0
 /**
  * Copy Dir
  * Copy a directory and all its contents
  *
  * @param string $fromDir Full path to dir to copy
  * @param string $toDir Full path to new location of copy
  * @return bool True on pass, false on fail
  */
 public static function copy_dir($fromDir, $toDir)
 {
     $file_tools = new RazorFileTools(get_class($this));
     $result = false;
     $readFromDir = $fromDir;
     $readToDir = $toDir;
     $file_tools->create_dir($readToDir);
     if (is_dir($readFromDir)) {
         $filesArray = array();
         $filesArray = $file_tools->read_dir_contents($readFromDir);
         // do recursive delete if dir contains files //
         foreach ($filesArray as $name) {
             if (is_dir($readFromDir . '/' . $name)) {
                 $result = self::copy_dir($fromDir . '/' . $name, $toDir . '/' . $name);
             } elseif (file_exists($readFromDir . '/' . $name)) {
                 $result = self::copy_file($fromDir . '/' . $name, $toDir . '/' . $name, false);
             }
         }
     }
     return $result;
 }
Ejemplo n.º 16
0
 public function delete($album_file)
 {
     if ((int) $this->check_access() < MANAGER) {
         $this->response(null, null, 401);
     }
     if (empty($album_file)) {
         $this->response(null, null, 400);
     }
     $parts = explode("|", $album_file);
     if (count($parts) != 2) {
         $this->response("Invalid album/file format (album|filename.png).", null, 400);
     }
     // ensure album and filename is clean
     $album = preg_replace("/[^a-zA-Z0-9-_]/", "", $parts[0]);
     $name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $parts[1]);
     // ensure we deleting a image
     $file_ext = explode(".", strtolower($name));
     if (!in_array(end($file_ext), $this->image_ext)) {
         $this->response("Can only delete image files (jpg, png, gif).", null, 406);
     }
     // check exists
     if (!is_file("{$this->root_path}/{$album}/{$name}")) {
         $this->response("File does not exist ({$album}/{$name})", null, 406);
     }
     RazorFileTools::delete_file("{$this->root_path}/{$album}/{$name}");
     $this->response("success", "json");
 }
Ejemplo n.º 17
0
 public function post($data)
 {
     // Check details
     if (!isset($_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"], $_SERVER["HTTP_REFERER"], $_SESSION["signature"])) {
         $this->response(null, null, 400);
     }
     if (empty($_SERVER["REMOTE_ADDR"]) || empty($_SERVER["HTTP_USER_AGENT"]) || empty($_SERVER["HTTP_REFERER"]) || empty($_SESSION["signature"])) {
         $this->response(null, null, 400);
     }
     // check referer matches the site
     if (strpos($_SERVER["HTTP_REFERER"], RAZOR_BASE_URL) !== 0) {
         $this->response(null, null, 400);
     }
     // check data
     if (!isset($data["signature"], $data["email"], $data["message"], $data["extension"]["type"], $data["extension"]["handle"], $data["extension"]["extension"])) {
         $this->response(null, null, 400);
     }
     if (empty($data["signature"]) || empty($data["email"]) || empty($data["message"]) || empty($data["extension"]["type"]) || empty($data["extension"]["handle"]) || empty($data["extension"]["extension"])) {
         $this->response(null, null, 400);
     }
     if (!isset($data["human"]) || !empty($data["human"])) {
         $this->response("robot", "json", 406);
     }
     // get signature and compare to session
     if ($_SESSION["signature"] !== $data["signature"]) {
         $this->response(null, null, 400);
     }
     unset($_SESSION["signature"]);
     session_destroy();
     // create manifest path for extension that requested email
     $ext_type = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["type"]);
     $ext_handle = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["handle"]);
     $ext_extension = preg_replace('/[^A-Za-z0-9-]/', '', $data["extension"]["extension"]);
     $manifest_path = RAZOR_BASE_PATH . "extension/{$ext_type}/{$ext_handle}/{$ext_extension}/{$ext_extension}.manifest.json";
     if (!is_file($manifest_path)) {
         $this->response(null, null, 400);
     }
     $manifest = RazorFileTools::read_file_contents($manifest_path, "json");
     // fetch extension settings and look for email
     $db = new RazorDB();
     $db->connect("extension");
     $options = array("amount" => 1, "filter" => array("json_settings"));
     $search = array(array("column" => "type", "value" => $manifest->type), array("column" => "handle", "value" => $manifest->handle), array("column" => "extension", "value" => $manifest->extension));
     $extension_settings = $db->get_rows($search, $options);
     $extension_settings = $extension_settings["result"][0]["json_settings"];
     $db->disconnect();
     if (empty($extension_settings)) {
         $this->response(null, null, 400);
     }
     $extension_settings = json_decode($extension_settings);
     // get site data
     $db->connect("setting");
     $res = $db->get_rows(array("column" => "id", "value" => null, "not" => true));
     $db->disconnect();
     $settings = array();
     foreach ($res["result"] as $result) {
         switch ($result["type"]) {
             case "bool":
                 $settings[$result["name"]] = (bool) $result["value"];
                 break;
             case "int":
                 $settings[$result["name"]] = (int) $result["value"];
                 break;
             default:
                 $settings[$result["name"]] = (string) $result["value"];
                 break;
         }
     }
     // clean email data
     $to = $extension_settings->email;
     $from = preg_replace('/[^A-Za-z0-9-_+@.]/', '', $data["email"]);
     $subject = "{$settings["name"]} Contact Form";
     $message = htmlspecialchars($data["message"], ENT_QUOTES);
     // send to email response
     $this->email($from, $to, $subject, $message);
     // return the basic user details
     $this->response("success", "json");
 }
Ejemplo n.º 18
0
 public function get($type)
 {
     if ((int) $this->check_access() < 10) {
         $this->response(null, null, 401);
     }
     if (empty($type) || !in_array($type, $this->types)) {
         $this->response(null, null, 400);
     }
     // first scan the folders for manifests
     $manifests = RazorFileTools::find_file_contents(RAZOR_BASE_PATH . "extension", "manifest.json", "json", "end");
     // split into types, so we can filter a little
     $extensions = array();
     $db = new RazorDB();
     $db->connect("extension");
     foreach ($manifests as $mf) {
         $mf->created = date("D jS M Y", $mf->created);
         // grab settings if any
         if (isset($mf->settings)) {
             $options = array("amount" => 1);
             $search = array(array("column" => "extension", "value" => $mf->extension), array("column" => "type", "value" => $mf->type), array("column" => "handle", "value" => $mf->handle));
             $extension = $db->get_rows($search, $options);
             if ($extension["count"] == 1) {
                 $db_settings = json_decode($extension["result"][0]["json_settings"]);
                 foreach ($mf->settings as $key => $setting) {
                     if (isset($db_settings->{$setting->name})) {
                         $mf->settings[$key]->value = $db_settings->{$setting->name};
                     }
                 }
             }
         }
         // sort list
         if ($mf->type == $type) {
             if ($mf->type == "theme") {
                 // group manifest layouts for themes
                 if (!isset($extensions[$mf->type . $mf->handle . $mf->extension])) {
                     $extensions[$mf->type . $mf->handle . $mf->extension] = array("layouts" => array(), "type" => $mf->type, "handle" => $mf->handle, "description" => $mf->description, "name" => $mf->name);
                 }
                 $extensions[$mf->type . $mf->handle . $mf->extension]["layouts"][] = $mf;
             } else {
                 $extensions[] = $mf;
             }
         } else {
             if ($type == "system" && $mf->type != "theme") {
                 $extensions[] = $mf;
             } else {
                 if ($type == "all") {
                     $mf->type = ucfirst($mf->type);
                     if ($mf->type == "Theme") {
                         // group manifest layouts for themes
                         if (!isset($extensions[$mf->type . $mf->handle . $mf->extension])) {
                             $extensions[$mf->type . $mf->handle . $mf->extension] = array("layouts" => array(), "type" => $mf->type, "handle" => $mf->handle, "extension" => $mf->extension, "description" => $mf->description, "name" => $mf->name);
                         }
                         $extensions[$mf->type . $mf->handle . $mf->extension]["layouts"][] = $mf;
                     } else {
                         $extensions[] = $mf;
                     }
                 }
             }
         }
     }
     // ensure we have array return and not object
     $extensions = array_values($extensions);
     $db->disconnect();
     $this->response(array("extensions" => $extensions), "json");
 }
Ejemplo n.º 19
0
 public function get($type)
 {
     if ((int) $this->check_access() < 9) {
         $this->response(null, null, 401);
     }
     if (empty($type) || !in_array($type, $this->types)) {
         $this->response(null, null, 400);
     }
     // first scan the folders for manifests
     $manifests = RazorFileTools::find_file_contents(RAZOR_BASE_PATH . "extension", "manifest.json", "json", "end");
     // split into types, so we can filter a little
     $extensions = array();
     $extension_settings = $this->razor_db->get_all('extension');
     foreach ($manifests as $mf) {
         // grab settings if any
         if (isset($mf->settings)) {
             if (is_array($extension_settings)) {
                 foreach ($extension_settings as $es) {
                     if ($es['extension'] == $mf->extension && $es['type'] == $mf->type && $es['handle'] == $mf->handle) {
                         $db_settings = json_decode($es["json_settings"]);
                         foreach ($mf->settings as $key => $setting) {
                             if (isset($db_settings->{$setting->name})) {
                                 $mf->settings[$key]->value = $db_settings->{$setting->name};
                             }
                         }
                     }
                 }
             }
         }
         // sort list
         if ($mf->type == $type) {
             if ($mf->type == "theme") {
                 // group manifest layouts for themes
                 if (!isset($extensions[$mf->type . $mf->handle . $mf->extension])) {
                     $extensions[$mf->type . $mf->handle . $mf->extension] = array("layouts" => array(), "type" => $mf->type, "handle" => $mf->handle, "description" => $mf->description, "name" => $mf->name);
                 }
                 $extensions[$mf->type . $mf->handle . $mf->extension]["layouts"][] = $mf;
             } else {
                 $extensions[] = $mf;
             }
         } else {
             if ($type == "system" && $mf->type != "theme") {
                 $extensions[] = $mf;
             } else {
                 if ($type == "all") {
                     $mf->type = ucfirst($mf->type);
                     if ($mf->type == "Theme") {
                         // group manifest layouts for themes
                         if (!isset($extensions[$mf->type . $mf->handle . $mf->extension])) {
                             $extensions[$mf->type . $mf->handle . $mf->extension] = array("layouts" => array(), "type" => $mf->type, "handle" => $mf->handle, "extension" => $mf->extension, "description" => $mf->description, "name" => $mf->name);
                         }
                         $extensions[$mf->type . $mf->handle . $mf->extension]["layouts"][] = $mf;
                     } else {
                         $extensions[] = $mf;
                     }
                 }
             }
         }
     }
     // ensure we have array return and not object
     $extensions = array_values($extensions);
     $this->response(array("extensions" => $extensions), "json");
 }
Ejemplo n.º 20
0
// grab settings for this content area and from that, find folder to use
$content_ext_settings = json_decode($c_data["json_settings"]);
$photos = "[]";
if (isset($content_ext_settings->album_name)) {
    // check if folders exist
    if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms")) {
        mkdir(RAZOR_BASE_PATH . "storage/files/razorcms");
    }
    if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery")) {
        mkdir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery");
    }
    if (!is_dir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}")) {
        mkdir(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}");
    }
    // grab folder here, load in the files for a particular folder
    $files = RazorFileTools::read_dir_contents(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}", $type = 'files');
    // remove anything not an image file ext
    foreach ($files as $key => $file) {
        if (!in_array(strtolower(substr($file, -4)), $image_files)) {
            unset($files[$key]);
            continue;
        }
        $files[$key] = array("url" => RAZOR_BASE_URL . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}/{$file}");
        if (strtolower(substr($file, -4) == ".jpg" || strtolower(substr($file, -4) == "jpeg"))) {
            $details = exif_read_data(RAZOR_BASE_PATH . "storage/files/razorcms/photo-gallery/{$content_ext_settings->album_name}/{$file}");
            if (isset($details["DocumentName"])) {
                $files[$key]["title"] = $details["DocumentName"];
            }
            if (isset($details["ImageDescription"])) {
                $files[$key]["description"] = $details["ImageDescription"];
            }
 /**
  * Log Error
  * Log the error to log file
  *
  * @param array $error Error data array
  * @param string $log_book The log book to write to
  * @return bool False on fail
  */
 private function log_error($error, $log_book = 'razor-error-log')
 {
     if (empty($error)) {
         return false;
     }
     // get file contents
     $log = array();
     if (is_file(RAZOR_BASE_PATH . "storage/log/{$log_book}.php")) {
         $log = RazorFileTools::read_file_contents(RAZOR_BASE_PATH . "storage/log/{$log_book}.php", 'array');
     }
     // set date time
     $date_time = @date('d m Y - h:i:s', time());
     $entry = "<?php /* [{$date_time}] [{$error['error']}]";
     $entry .= isset($error['type']) ? " [type: {$error['type']}]" : "";
     $entry .= isset($error['file']) ? " [file: {$error['file']}]" : "";
     $entry .= isset($error['line']) ? " [line: {$error['line']}]" : "";
     $entry .= " [message: {$error['string']}] */ ?>\n\r";
     $log[] = $entry;
     if (count($log) > 100) {
         array_shift($log);
     }
     $log_string = implode('', $log);
     if (!is_dir(RAZOR_BASE_PATH . 'storage/log')) {
         mkdir(RAZOR_BASE_PATH . 'storage/log');
     }
     RazorFileTools::write_file_contents(RAZOR_BASE_PATH . "storage/log/{$log_book}.php", $log_string);
 }