/** * include/enable HTMLPurifier * * @access private * @param $config - optional config array passed to HTMLPurifier * @return object **/ private static function getPurifier($config = NULL) { if (is_object(self::$purifier)) { return self::$purifier; } if (!class_exists('HTMLPurifier', false)) { $path = CAT_Helper_Directory::getInstance()->sanitizePath(CAT_PATH . '/modules/lib_htmlpurifier/htmlpurifier/library/HTMLPurifier.auto.php'); if (!file_exists($path)) { CAT_Object::getInstance()->printFatalError('Missing library HTMLPurifier!'); } include $path; } $pconfig = HTMLPurifier_Config::createDefault(); if ($config && is_array($config)) { foreach ($config as $key => $val) { $pconfig->set($key, $val); } } $pconfig->set('AutoFormat.Linkify', TRUE); $pconfig->set('URI.Disable', false); // allow most HTML but not all (no forms, for example) $pconfig->set('HTML.Allowed', 'a[href|title],abbr[title],acronym[title],b,blockquote[cite],br,caption,cite,code,dd,del,dfn,div,dl,dt,em,h1,h2,h3,h4,h5,h6,i,img[src|alt|title|class],ins,kbd,li,ol,p,pre,s,strike,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,tt,u,ul,var'); self::$purifier = new HTMLPurifier($pconfig); return self::$purifier; }
public function __construct($obj) { parent::__construct(); $this->te = $obj; // get current working directory $callstack = debug_backtrace(); $this->te->paths['workdir'] = isset($callstack[0]) && isset($callstack[0]['file']) ? CAT_Helper_Directory::sanitizePath(realpath(dirname($callstack[0]['file']))) : CAT_Helper_Directory::sanitizePath(realpath(dirname(__FILE__))); if (file_exists($this->te->paths['workdir'] . '/templates')) { $this->te->paths['workdir'] .= '/templates'; } $this->te->paths['current'] = $this->te->paths['workdir']; $this->dirh = CAT_Helper_Directory::getInstance(); }
/** * private constructor; use getInstance() to load this class **/ public function __construct($options = array()) { parent::__construct($options); if (!isset($options['lang'])) { if (defined('LANGUAGE')) { $options['lang'] = LANGUAGE; } } if (isset($options['lang'])) { self::$_current_lang = $options['lang']; } if (!is_object($this->_path)) { $this->_path = CAT_Helper_Directory::getInstance(); } $this->init(); }
/** * this method may be called by modules to handle a droplet upload **/ function droplets_upload($input) { // Set temp vars $temp_dir = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/temp/'); $temp_file = CAT_Helper_Directory::sanitizePath($temp_dir . $_FILES[$input]['name']); $temp_unzip = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/temp/unzip/'); $errors = array(); // Try to upload the file to the temp dir if (!move_uploaded_file($_FILES[$input]['tmp_name'], $temp_file)) { return array('error', CAT_Helper_Directory::getInstance()->lang()->translate('Upload failed')); } $result = droplets_import($temp_file, $temp_unzip); // Delete the temp zip file if (file_exists($temp_file)) { unlink($temp_file); } CAT_Helper_Directory::removeDirectory($temp_unzip); // show errors if (isset($result['errors']) && is_array($result['errors']) && count($result['errors']) > 0) { return array('error', $result['errors'], NULL); } // return success return array('success', $result['count']); }
/** * * @access public * @return **/ public static function getEditModuleFilesButton($mod_dir, $print = false) { global $page_id, $section_id; $self = self::getInstance(); if (!$self->checkModulePermissions($mod_dir)) { return; } $content = ''; $path = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $mod_dir); // find JS files $js = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory($path, true, true, $path); // find CSS files $css = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory($path, true, true, $path); if (count($js) || count($css)) { $content = ' <form style="float:right" method="post" action="' . CAT_URL . '/backend/addons/edit_module_files.php" name="edit_module_file"> <input type="hidden" value="' . $page_id . '" name="page_id"> <input type="hidden" value="' . $section_id . '" name="section_id"> <input type="hidden" value="' . $mod_dir . '" name="mod_dir"> <input type="submit" value="' . $self->lang()->translate('Edit module file(s)') . '"> </form>'; } if ($print) { echo $content; } else { return $content; } }
break; case 'sysinfo': // format installation date and time $tpl_data['values']['installation_time'] = CAT_Helper_DateTime::getDateTime(INSTALLATION_TIME); // get page statistics $pg = CAT_Helper_Page::getPagesByVisibility(); foreach (array_keys($pg) as $key) { $tpl_data['values']['pages_count'][] = array('visibility' => $key, 'count' => count($pg[$key])); } break; case 'headers': $files = CAT_Helper_Page::getExtraHeaderFiles(0); $tpl_data['use_core'] = isset($files['use_core']) ? $files['use_core'] : NULL; $tpl_data['use_ui'] = isset($files['use_ui']) ? $files['use_ui'] : NULL; $tpl_data['page_js'] = isset($files['js']) ? $files['js'] : ''; $tpl_data['page_css'] = isset($files['css']) ? $files['css'] : ''; $tpl_data['jquery_plugins'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', false, false, CAT_PATH . '/modules/lib_jquery/plugins/'); $tpl_data['js_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins'); $tpl_data['css_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins'); break; } $result = true; $message = NULL; $output = $parser->get($tpl, $tpl_data); if (!$output || $output == '') { $result = false; $message = 'Unable to load settings sub page'; } $ajax = array('message' => $message, 'success' => $result, 'settings' => $output); print json_encode($ajax); exit;
* @license http://www.gnu.org/licenses/gpl.html * @category CAT_Modules * @package lib_search * */ if (defined('CAT_PATH')) { include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // import droplets $inst_dir = CAT_Helper_Directory::sanitizePath(dirname(__FILE__) . '/install'); $temp_unzip = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/temp/unzip/'); $dirh = CAT_Helper_Directory::getInstance(); $files = $dirh->getFiles($inst_dir); if (is_array($files) && count($files)) { foreach ($files as $file) { // ignore the result here CAT_Helper_Droplet::installDroplet($file, $temp_unzip); } }
/** * edit a droplet's datafile **/ function edit_datafile($id) { global $parser, $val, $backend; $info = $problem = NULL; $groups = CAT_Users::get_groups_id(); if (!CAT_Helper_Droplet::is_allowed('modify_droplets', $groups)) { $backend->print_error($backend->lang()->translate("You don't have the permission to do this")); } if ($val->get('_REQUEST', 'cancel')) { return list_droplets(); } $query = $backend->db()->query("SELECT name FROM " . CAT_TABLE_PREFIX . "mod_droplets WHERE id = '{$id}'"); $data = $query->fetch(); // find the file if (file_exists(dirname(__FILE__) . '/data/' . $data['name'] . '.txt')) { $file = CAT_Helper_Directory::getInstance()->sanitizePath(dirname(__FILE__) . '/data/' . $data['name'] . '.txt'); } elseif (file_exists(dirname(__FILE__) . '/data/' . strtolower($data['name']) . '.txt')) { $file = CAT_Helper_Directory::getInstance()->sanitizePath(dirname(__FILE__) . '/data/' . strtolower($data['name']) . '.txt'); } elseif (file_exists(dirname(__FILE__) . '/data/' . strtoupper($data['name']) . '.txt')) { $file = CAT_Helper_Directory::getInstance()->sanitizePath(dirname(__FILE__) . '/data/' . strtoupper($data['name']) . '.txt'); } // slurp file $contents = implode('', file($file)); if (isset($_POST['save']) || isset($_POST['save_and_back'])) { $new_contents = htmlentities($_POST['contents']); // create backup copy copy($file, $file . '.bak'); $fh = fopen($file, 'w'); if (is_resource($fh)) { fwrite($fh, $new_contents); fclose($fh); $info = $backend->lang()->translate('The datafile has been saved'); if (isset($_POST['save_and_back'])) { return list_droplets($info); } } else { $problem = $backend->lang()->translate('Unable to write to file [{{file}}]', array('file' => str_ireplace(CAT_Helper_Directory::sanitizePath(CAT_PATH), 'CAT_PATH', $file))); } } $parser->output('edit_datafile.tpl', array('info' => $info, 'problem' => $problem, 'name' => $data['name'], 'id' => $id, 'contents' => htmlspecialchars($contents))); }
$new = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->setSkipDirs($seen_dirs)->getDirectories(CAT_PATH . '/' . $type, CAT_PATH . '/' . $type . '/'); if (count($new)) { foreach ($new as $dir) { $info = $addon->checkInfo(CAT_PATH . '/' . $type . '/' . $dir); if ($info) { $tpl_data['not_installed_addons'][$type][$counter] = array('is_installed' => false, 'type' => $type, 'INSTALL' => file_exists(CAT_PATH . '/' . $type . '/' . $dir . '/install.php') ? true : false); foreach ($info as $key => $value) { $tpl_data['not_installed_addons'][$type][$counter][str_ireplace('module_', '', $key)] = $value; } $counter++; } } $tpl_data['not_installed_addons'][$type] = CAT_Helper_Array::ArraySort($tpl_data['not_installed_addons'][$type], 'name', 'asc', true); } } $languages = CAT_Helper_Directory::getInstance()->setSkipFiles(array('index.php'))->maxRecursionDepth(0)->getPHPFiles(CAT_PATH . '/languages', CAT_PATH . '/languages/'); if (count($languages)) { foreach ($languages as $lang) { $directory = pathinfo($lang, PATHINFO_FILENAME); if (!in_array($directory, $seen_dirs)) { $info = $addon->checkInfo(CAT_PATH . '/languages/' . $lang); if (is_array($info) && count($info)) { $tpl_data['not_installed_addons']['languages'][$counter] = array('is_installed' => false, 'type' => 'languages', 'directory' => $directory); foreach ($info as $key => $value) { $tpl_data['not_installed_addons']['languages'][$counter][str_ireplace('module_', '', $key)] = $value; } $counter++; } } } }
/** * scans modules for widgets * * @access public * @return array **/ public static function findWidgets() { // find files called widget.php $widgets = CAT_Helper_Directory::getInstance()->maxRecursionDepth(2)->setSkipFiles(array('index.php'))->findFiles('widget.php', CAT_PATH . '/modules'); // find files in directory called widgets $directories = CAT_Helper_Directory::getInstance()->maxRecursionDepth(2)->findDirectories('widgets', CAT_PATH . '/modules'); if (count($directories)) { if (!is_array($widgets)) { $widgets = array(); } foreach ($directories as $dir) { $widgets = array_merge($widgets, CAT_Helper_Directory::getInstance()->setSkipFiles(array('index.php'))->getPHPFiles($dir)); } } return $widgets; }
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // handle upload if (CAT_Helper_Validate::sanitizePost('upload') && isset($_FILES['userfile']) && is_array($_FILES['userfile'])) { $p = CAT_Helper_Upload::getInstance($_FILES['userfile'], CAT_PATH . '/temp'); $p->file_overwrite = true; $p->process(CAT_PATH . '/temp'); if ($p->processed) { $subdir = $p->file_dst_name_body; $z = CAT_Helper_Zip::getInstance(CAT_PATH . '/temp/' . $p->file_dst_name)->config('Path', CAT_PATH . '/modules/lib_jquery/plugins/' . $subdir); $z->extract(); } } // get already installed plugins $files = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->getDirectories(CAT_PATH . '/modules/lib_jquery/plugins', CAT_PATH . '/modules/lib_jquery/plugins/'); $readmes = jqpmgr_getReadmes($files); $parser->setPath(CAT_PATH . '/modules/jquery_plugin_mgr/templates/default'); $parser->output('tool', array('plugins' => $files, 'readmes' => $readmes)); function jqpmgr_getReadmes($plugins) { $readme_filenames = array('readme_' . strtolower(LANGUAGE) . '.html', 'readme.html'); $dir = CAT_PATH . '/modules/lib_jquery/plugins/'; $readmes = array(); foreach ($plugins as $p) { foreach ($readme_filenames as $rfile) { if (file_exists($dir . $p . '/' . $rfile)) { $readmes[$p] = CAT_URL . '/modules/lib_jquery/plugins/' . $p . '/' . $rfile; break; } if (!isset($readmes[$p])) {
/** * installs all modules, templates, and languages **/ function install_modules($cat_path, $database) { global $admin, $bundled, $mandatory; write2log('> [install_modules()]'); $errors = array(); require $cat_path . '/framework/initialize.php'; // Load addons into DB $dirs = array('modules' => $cat_path . '/modules/', 'templates' => $cat_path . '/templates/', 'languages' => $cat_path . '/languages/'); $ignore_files = array('admin.php', 'index.php', 'edit_module_files.php'); write2log('------------------------------------'); write2log('----- installing addons -----'); write2log('------------------------------------'); foreach ($dirs as $type => $dir) { $subs = $type == 'languages' ? CAT_Helper_Directory::getInstance()->setRecursion(false)->getPHPFiles($dir, $dir . '/') : CAT_Helper_Directory::getInstance()->setRecursion(false)->getDirectories($dir, $dir . '/'); natsort($subs); foreach ($subs as $item) { if (in_array($item, $ignore_files)) { continue; } if ($type == 'languages') { write2log('installing language [' . $item . ']'); $info = CAT_Helper_Addons::checkInfo($dir . '/' . $item); if (!CAT_Helper_Addons::loadModuleIntoDB($dir . '/' . $item, 'install', $info)) { $errors[$dir] = sprintf('Unable to add language [%s] to database!', $item); write2log(sprintf('Unable to add language [%s] to database!', $item)); } else { write2log(sprintf('%s [%s] sucessfully installed', ucfirst(substr($type, 0, -1)), $item)); } } else { write2log('installing module/template [' . $item . ']'); $addon_info = CAT_Helper_Addons::checkInfo($dir . '/' . $item); // load the module info into the database if (!CAT_Helper_Addons::loadModuleIntoDB($dir . '/' . $item, 'install', $addon_info)) { $errors[$dir] = sprintf('Unable to add %s [%s] to database!', $type, $item); write2log(sprintf('Unable to add %s [%s] to database!', $type, $item)); } else { write2log('running ' . $item . '/install.php'); // Run the install script if there is one if (file_exists($dir . '/' . $item . '/install.php')) { require $dir . '/' . $item . '/install.php'; } write2log(sprintf('%s [%s] sucessfully installed', ucfirst(substr($type, 0, -1)), $item)); } } } } // mark bundled modules foreach ($bundled as $module) { $database->query(sprintf('UPDATE `%saddons` SET bundled="Y" WHERE directory="%s"', CAT_TABLE_PREFIX, $module)); } // mark mandatory modules foreach ($mandatory as $module) { $database->query(sprintf('UPDATE `%saddons` SET removable="N" WHERE directory="%s"', CAT_TABLE_PREFIX, $module)); } write2log('< [install_modules()]'); return array(count($errors) ? false : true, $errors); }
function file_list($directory, $skip = array(), $show_hidden = false) { return CAT_Helper_Directory::getInstance()->setSkipDirs($skip)->scanDirectory($directory, true, true); }
$widget_name = CAT_Object::lang()->translate('Logfiles'); $current = strftime('%Y-%m-%d'); $logs = array(); $list = array(); $files = CAT_Helper_Directory::getInstance()->maxRecursionDepth(2)->setSuffixFilter(array('txt'))->setSkipDirs(array('cache', 'compiled'))->setSkipFiles(array('index.php'))->findFiles('log_\\d{4}-\\d{2}-\\d{2}\\.txt', CAT_PATH . '/temp'); if (count($files)) { foreach ($files as $f) { if (filesize($f) !== 0) { $list[] = array('file' => $f, 'size' => filesize($f)); } } } if (count($list)) { foreach (array_values($list) as $f) { $file = str_ireplace(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/temp/'), '', CAT_Helper_Directory::sanitizePath($f['file'])); if (substr($file, 0, 1) == "/") { $file = substr_replace($file, '', 0, 1); } if (pathinfo($f['file'], PATHINFO_BASENAME) == 'log_' . $current . '.txt') { $removable = false; } else { $removable = true; } $logs[] = array('file' => $file, 'size' => CAT_Helper_Directory::byte_convert($f['size']), 'removable' => $removable, 'date' => str_ireplace(array('log_', 'logs/', '.txt'), '', $file)); } } else { echo CAT_Helper_Directory::getInstance()->lang()->translate('No logfiles (or all empty)'); } global $parser; $parser->setPath(dirname(__FILE__) . '/../templates/default'); $parser->output('logs.tpl', array('logs' => $logs));
public static function printUnderConstruction() { // try to find a template $file = CAT_Helper_Directory::getInstance()->findFile('under_construction', CAT_PATH . "/templates/" . DEFAULT_TEMPLATE, true); $image_url = CAT_URL . '/templates/' . DEFAULT_TEMPLATE . '/images'; if (!$file) { $file = CAT_Helper_Directory::getInstance()->findFile('under_construction', CAT_PATH . "/templates/" . DEFAULT_THEME, true); $image_url = CAT_URL . '/templates/' . DEFAULT_THEME . '/images'; } if (!$file) { self::getInstance()->printFatalError('Website Under Construction' . '<br />' . 'Please check back soon...'); } else { global $parser; $parser->setPath(pathinfo($file, PATHINFO_DIRNAME)); $parser->output(pathinfo($file, PATHINFO_FILENAME), array('IMAGE_URL' => $image_url)); } }
/** * Install a Droplet from a ZIP file (the ZIP may contain more than one * Droplet) * * @access public * @param string $temp_file - name of the ZIP file * @return array see droplets_import() method * **/ public static function installDroplet($temp_file) { $self = self::getInstance(); $temp_unzip = CAT_PATH . '/temp/droplets_unzip/'; CAT_Helper_Directory::createDirectory($temp_unzip); $errors = array(); $imports = array(); $count = 0; // extract file $list = CAT_Helper_Zip::getInstance($temp_file)->config('Path', $temp_unzip)->extract(); // get .php files $files = CAT_Helper_Directory::getPHPFiles($temp_unzip, $temp_unzip . '/'); // now, open all *.php files and search for the header; // an exported droplet starts with "//:" foreach ($files as $file) { if (pathinfo($file, PATHINFO_FILENAME) !== 'index' && pathinfo($file, PATHINFO_EXTENSION) == 'php') { $description = NULL; $usage = NULL; $code = NULL; // Name of the Droplet = Filename $name = pathinfo($file, PATHINFO_FILENAME); // Slurp file contents $lines = file($temp_unzip . '/' . $file); // First line: Description if (preg_match('#^//\\:(.*)$#', $lines[0], $match)) { $description = addslashes($match[1]); array_shift($lines); } // Second line: Usage instructions if (preg_match('#^//\\:(.*)$#', $lines[0], $match)) { $usage = addslashes($match[1]); array_shift($lines); } // there may be more comment lines; they will be added to the usage instructions while (preg_match('#^//(.*)$#', $lines[0], $match)) { $usage .= addslashes(trim($match[1])); array_shift($lines); } if (!$description && !$usage) { // invalid file $errors[$file] = CAT_Helper_Directory::getInstance()->lang()->translate('No valid Droplet file (missing description and/or usage instructions)'); continue; } // Remaining: Droplet code $code = implode('', $lines); // replace 'evil' chars in code $tags = array('<?php', '?>', '<?'); //$code = addslashes(str_replace($tags, '', $code)); $code = str_replace($tags, '', $code); // Already in the DB? $stmt = 'INSERT'; $id = NULL; $found = $self->db()->query("SELECT * FROM `:prefix:mod_droplets` WHERE name=:name", array('name' => $name)); if ($found->rowCount()) { $stmt = 'REPLACE'; $id = $found->fetchColumn(); } // execute $q = "{$stmt} INTO `:prefix:mod_droplets` SET " . ($id ? 'id=' . $id . ', ' : '') . '`name`=:name, `code`=:code, `description`=:desc, ' . '`modified_when`=:when, `modified_by`=:userid, ' . '`active`=:active, `comments`=:usage'; $params = array('name' => $name, 'code' => $code, 'desc' => $description, 'when' => time(), 'userid' => CAT_Users::get_user_id(), 'active' => 1, 'usage' => $usage); $result = $self->db()->query($q, $params); if (!$self->db()->isError()) { $count++; $imports[$name] = 1; } else { $errors[$name] = $self->db()->getError(); } } // check for data directory if (file_exists($temp_unzip . '/data')) { // copy all files CAT_Helper_Directory::copyRecursive($temp_unzip . '/data', dirname(__FILE__) . '/data/'); } } // cleanup; ignore errors here CAT_Helper_Directory::removeDirectory($temp_unzip); return array('count' => $count, 'errors' => $errors, 'imported' => $imports); }
} if (!isset($module_version)) { $details = CAT_Helper_Addons::getAddonDetails('wrapper'); $module_version = $details['version']; } if (!CAT_Helper_Addons::versionCompare($module_version, '2.7.2', '>=')) { $database->query('ALTER TABLE `' . CAT_TABLE_PREFIX . 'mod_wrapper` CHANGE COLUMN `type` `wtype` VARCHAR(50) NOT NULL DEFAULT \'iframe\' AFTER `width`;'); } if (!CAT_Helper_Addons::versionCompare($module_version, '2.7.5', '>=')) { $database->query('ALTER TABLE `' . CAT_TABLE_PREFIX . 'mod_wrapper` CHANGE COLUMN `height` `height` VARCHAR(50) NOT NULL DEFAULT \'400\' AFTER `url`, CHANGE COLUMN `width` `width` VARCHAR(50) NOT NULL DEFAULT \'100%\' AFTER `height`;'); } if (!CAT_Helper_Addons::versionCompare($module_version, '2.7.5', '>=')) { $database->query('ALTER TABLE `' . CAT_TABLE_PREFIX . 'mod_wrapper` CHANGE COLUMN `url` `url` TEXT NULL;'); } // remove old template files $ltes = CAT_Helper_Directory::getInstance()->findFiles('.*\\.lte', dirname(__FILE__) . '/htt'); if (count($ltes)) { foreach ($ltes as $file) { @unlink($file); } } // add files to class_secure $addons_helper = new CAT_Helper_Addons(); foreach (array('save.php') as $file) { if (false === $addons_helper->sec_register_file('wrapper', $file)) { error_log("Unable to register file -{$file}-!"); } }
$css = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin, true, true, CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin); foreach ($js as $file) { CAT_Helper_Page::adminAddHeaderComponent('js', $plugin . '/' . $file, $page_id); } foreach ($css as $file) { CAT_Helper_Page::adminAddHeaderComponent('css', $plugin . '/' . $file, $page_id); } $ajax = array('message' => $success ? 'ok' : 'error', 'success' => $success); print json_encode($ajax); exit; } elseif ($val->sanitizePost('del_plugin') != '') { $plugin = $val->sanitizePost('del_plugin'); // find JS files $js = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin, true, true, CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin); // find CSS files $css = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin, true, true, CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin); foreach ($js as $file) { CAT_Helper_Page::adminDelHeaderComponent('js', '/modules/lib_jquery/plugins/' . $plugin . $file, $page_id); } foreach ($css as $file) { CAT_Helper_Page::adminDelHeaderComponent('css', '/modules/lib_jquery/plugins/' . $plugin . $file, $page_id); } print json_encode(array('success' => true, 'message' => 'ok')); exit; } elseif ($val->sanitizePost('order') != '') { if (is_array($val->sanitizePost('order'))) { $type = $val->sanitizePost('type'); $q = sprintf('UPDATE `%spages_headers` SET `page_%s_files` = \'%s\' WHERE `page_id`="%d"', CAT_TABLE_PREFIX, $type, serialize($val->sanitizePost('order')), $page_id); $database->query($q); print json_encode(array('success' => $database->is_error() ? false : true, 'message' => $database->is_error() ? $database->get_error() : 'Success')); exit;
//if(file_exists(CAT_PATH.'/modules/lib_search/upgrade.php')) // include CAT_PATH.'/modules/lib_search/upgrade.php'; // run droplets upgrade //if(file_exists(CAT_PATH.'/modules/droplets/upgrade.php')) // include CAT_PATH.'/modules/droplets/upgrade.php'; // ----- moved for Version 1.1 (mysql strict mode) ----- // run wrapper install script if (file_exists(CAT_PATH . '/modules/wrapper/install.php')) { include CAT_PATH . '/modules/wrapper/install.php'; } // run menu_link install script if (file_exists(CAT_PATH . '/modules/menu_link/install.php')) { include CAT_PATH . '/modules/menu_link/install.php'; } // remove compiled templates $dirs = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->scanDirectory(CAT_PATH . '/temp/compiled', false, false); if (count($dirs)) { CAT_Helper_Directory::removeDirectory($dirs[0]); } /******************************************************************************* 1.0.1 TO 1.0.2 *******************************************************************************/ include CAT_PATH . '/framework/class.database.php'; $database = new database(); // fix cattranslate entry in class_secure table $database->query(sprintf('UPDATE `%sclass_secure` SET `filepath`="%s" WHERE `filepath`="%s"', CAT_TABLE_PREFIX, '/modules/lib_jquery/plugins/cattranslate/cattranslate.php', '/modules/lib_jquery/plugins/catranslate/cattranslate.php')); // reset default template (set to empty value in DB) - see issue #205 $res = $database->query(sprintf('SELECT `value` FROM `%ssettings` WHERE `name`="%s"', CAT_TABLE_PREFIX, 'default_template')); if ($res && $res->numRows()) { $row = $res->fetchRow(MYSQL_ASSOC); $database->query(sprintf('UPDATE `%spages` SET `template`="" WHERE `template`="%s"', CAT_TABLE_PREFIX, $row['value']));
public function getSkins($skin_path) { $d = CAT_Helper_Directory::getInstance(); $d->setRecursion(false); $skins = $d->getDirectories($skin_path, $skin_path . '/'); $d->setRecursion(true); return $skins; }
$mod_file = fopen($file, 'wb'); $bytes = fwrite($mod_file, $content); fclose($mod_file); } if ($bytes == 0) { $backend->print_error('Cannot save file', CAT_ADMIN_URL . '/pages/modify.php?page_id=' . $page_id); } else { $backend->print_success('Success', CAT_ADMIN_URL . '/pages/modify.php?page_id=' . $page_id); } } } else { if (!CAT_Helper_Validate::sanitizePost('edit_file')) { // find JS files $js = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory($path, true, true, $path); // find CSS files $css = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory($path, true, true, $path); $list = true; } else { $file = CAT_Helper_Directory::sanitizePath($path . '/' . CAT_Helper_Validate::sanitizePost('edit_file')); if (!file_exists($file)) { $backend->printFatalError("No such file"); } $in = fopen($file, 'r'); $code = fread($in, filesize($file)); fclose($in); if (file_exists(CAT_PATH . '/modules/edit_area/include.php')) { include_once CAT_PATH . '/modules/edit_area/include.php'; ea_syntax('css'); $js = show_wysiwyg_editor('code', 'code', $code, '100%', '350px', false); $code = NULL; }