public function delete() { $tool = $this->get_tool(); # Protect account tool. if ('account' == $tool->system_tool->name) { die('Account tool cannot be deleted, since other tools depend on it!'); } # delete all page instances of this tool first $db = Database::instance(); $db->delete('pages_tools', array('tool_id' => $this->tool_id, 'fk_site' => $this->site_id)); # delete the parent table row. $parent = ORM::factory($tool->system_tool->name)->where('fk_site', $this->site_id)->find($tool->parent_id)->delete_tool(); # is tool protected? # note: the page may not be set if the page was deleted but the tool still exists. if ('yes' == $tool->system_tool->protected) { if (isset($tool->pages->current()->page_name)) { yaml::delete_value($this->site_name, 'pages_config', $tool->pages->current()->page_name); } } # DELETE the custom folder for this tool. (houses custom css files) $custom_folder = $this->assets->themes_dir("{$this->theme}/tools/" . strtolower($tool->system_tool->name) . "/{$tool->parent_id}"); if (is_dir($custom_folder)) { Jdirectory::remove($custom_folder); } $tool->delete(); die('Tool deleted from system'); }
public function delete() { if (!isset($_GET['dir'])) { $_GET['dir'] = ''; } $dir = self::validate_dir($_GET['dir']); if (empty($_POST['json'])) { die('nothing sent'); } $json = self::validate_json($_POST['json']); foreach ($json as $asset) { $ext = strrchr($asset->name, '.'); $full_path = "{$dir}/{$asset->name}"; if (is_dir($full_path)) { if ('_tmb' == $asset->name) { die('Cannot delete this folder.'); } Jdirectory::remove($full_path); } elseif (file_exists($full_path)) { if (unlink($full_path)) { if (array_key_exists($ext, $this->image_types)) { # get and recurse the _tmb directory. $thumb_dirs = Jdirectory::contents("{$dir}/_tmb/", 'root', 'list_dir'); foreach ($thumb_dirs as $tmb_dir) { if (file_exists("{$dir}/_tmb/{$tmb_dir}/{$asset->name}")) { unlink("{$dir}/_tmb/{$tmb_dir}/{$asset->name}"); } } } } } } die('Assets deleted'); }
/** * set some sitewide settings */ public function settings() { if (!$this->client->can_edit($this->site_id)) { die('Please login'); } $site = ORM::factory('site', $this->site_id); if (!$site->loaded) { die('site not found'); } if ($_POST) { $homepage = explode(':', $_POST['homepage']); $site->custom_domain = $_POST['custom_domain']; $site->homepage = $homepage[0]; $site->save(); # should we publish the entire site? if (isset($_POST['publish']) and 'yes' == $_POST['publish']) { $cache_dir = DATAPATH . "{$this->site_name}/cache"; if (is_dir($cache_dir)) { Jdirectory::remove($cache_dir); } mkdir($cache_dir); } # update site_config.yml if new homepage # and force page to be enabled. if ($this->homepage != $homepage[0]) { yaml::edit_site_value($this->site_name, 'site_config', 'homepage', $_POST['homepage']); $page = ORM::factory('page', $homepage[1]); $page->enable = 'yes'; $page->save(); } die('Sitewide settings saved.'); } $pages = ORM::factory('page')->where('fk_site', $this->site_id)->orderby('page_name')->find_all(); $primary = new View('admin/settings'); $primary->pages = $pages; $primary->custom_domain = $site->custom_domain; $primary->js_rel_command = 'close-base'; die($primary); }
public function clear_all_css() { $sites = ORM::factory('site')->find_all(); $x = 0; foreach ($sites as $site) { $theme_dir = DATAPATH . "{$site->subdomain}/themes"; $themes = Jdirectory::contents($theme_dir, 'root', 'list_dir'); foreach ($themes as $theme) { $cache_dir = "{$theme_dir}/{$theme}/cache"; if (is_dir($cache_dir)) { Jdirectory::remove($cache_dir); } mkdir($cache_dir); } ++$x; } die("CSS cache cleared from <b>{$x}</b> sites."); }
private function safe_mode($page_name, $site_name) { if (ROOTACCOUNT != $this->site_name) { die('return 404 not found'); } $site = ORM::factory('site', $site_name); if (!$site->has(ORM::factory('account_user', $this->account_user->get_user()->id))) { return $this->plusjade_dashboard($page_name, 'You cannot edit this site.'); } $theme_path = DATAPATH . "{$site_name}/themes/safe_mode"; # delete safe-mode if it exists (might be tainted) if (is_dir($theme_path)) { Jdirectory::remove($theme_path); } # create it from stock. if (!is_dir(DOCROOT . "_assets/themes/safe_mode")) { return $this->plusjade_dashboard($page_name, 'Safe_mode theme does not exist. Please contact support@plusjade.com!!'); } if (!Jdirectory::copy(DOCROOT . "_assets/themes/safe_mode", $theme_path)) { return $this->plusjade_dashboard($page_name, 'Uh oh, not even this worked. Please contact support@plusjade.com!!'); } $site->theme = 'safe_mode'; $site->save(); if (yaml::edit_site_value($site_name, 'site_config', 'theme', 'safe_mode')) { return $this->plusjade_dashboard($page_name, "Safe-mode activated for <b>{$site_name}</b>"); } return $this->plusjade_dashboard($page_name, 'safe-mode theme could not be activated'); }
public function delete($path = NULL) { if (NULL == $path) { die('No path sent'); } $dirs = explode(':', $path); if ('safe_mode' == $dirs['0']) { die('cannot delete safe-mode files.'); } $path = str_replace(':', '/', $path, $count); $full_path = $this->assets->themes_dir($path); # if trying to delete a theme folder if (0 == $count) { if ($path == $this->theme) { die('Cannot delete active theme.'); } if (is_dir($full_path)) { if (Jdirectory::remove($full_path)) { die("'{$path}' deleted"); } } die('Unable to delete this theme.'); } if (is_dir($full_path)) { die('cannot delete directories'); } if (!file_exists($full_path)) { die('Invalid File'); } if (unlink($full_path)) { die('File deleted.'); } # Success die('Unable to delete file.'); }