function deltree($dir) { $current_dir = opendir($dir); while ($entryname = readdir($current_dir)) { if (is_dir($dir . '/' . $entryname) and ($entryname != '.' and $entryname != '..')) { if (!files::deltree($dir . '/' . $entryname)) { return false; } } elseif ($entryname != '.' and $entryname != '..') { if (!@unlink($dir . '/' . $entryname)) { return false; } } } closedir($current_dir); return @rmdir($dir); }
exit; } # affichage des notes d'un thème if (!empty($_GET['notes']) && file_exists(OKT_THEMES_PATH . '/' . $_GET['notes'] . '/notes.md')) { include_once OKT_VENDOR_PATH . '/phpmarkdown/extra/markdown.php'; echo Markdown(file_get_contents(OKT_THEMES_PATH . '/' . $_GET['notes'] . '/notes.md')); exit; } # Ré-initialisation filtres if (!empty($_GET['init_filters'])) { $oFilters->initFilters(); $okt->redirect('configuration.php?action=themes'); } # Suppression d'un thème if (!empty($_GET['delete']) && isset($aInstalledThemes[$_GET['delete']]) && !$aInstalledThemes[$_GET['delete']]['is_active']) { if (files::deltree(OKT_THEMES_PATH . '/' . $_GET['delete'])) { $okt->redirect('configuration.php?action=themes&deleted=1'); } } # Utilisation d'un thème if (!empty($_GET['use'])) { try { # write config $okt->config->write(array('theme' => $_GET['use'])); # modules config sheme $sTplScheme = OKT_THEMES_PATH . '/' . $_GET['use'] . '/modules_config_scheme.php'; if (file_exists($sTplScheme)) { include $sTplScheme; } $okt->redirect('configuration.php?action=themes&used=1'); } catch (InvalidArgumentException $e) {
/** * Install a module from a zip file * * @param string $zip_file * @param oktModules $modules */ public static function installPackage($zip_file, oktModules $modules) { $zip = new fileUnzip($zip_file); $zip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|Thumbs\\.db)(/|$)#'); $zip_root_dir = $zip->getRootDir(); if ($zip_root_dir !== false) { $target = dirname($zip_file); $destination = $target . '/' . $zip_root_dir; $define = $zip_root_dir . '/_define.php'; $has_define = $zip->hasFile($define); } else { $target = dirname($zip_file) . '/' . preg_replace('/\\.([^.]+)$/', '', basename($zip_file)); $destination = $target; $define = '_define.php'; $has_define = $zip->hasFile($define); } if ($zip->isEmpty()) { $zip->close(); unlink($zip_file); throw new Exception(__('Empty module zip file.')); } if (!$has_define) { $zip->close(); unlink($zip_file); throw new Exception(__('The zip file does not appear to be a valid module.')); } $ret_code = 1; if (is_dir($destination)) { copy($target . '/_define.php', $target . '/_define.php.bak'); # test for update $sandbox = clone $modules; $zip->unzip($define, $target . '/_define.php'); $sandbox->resetCompleteList(); $sandbox->requireDefine($target, basename($destination)); unlink($target . '/_define.php'); $new_modules = $sandbox->getCompleteList(); $old_modules = $modules->getModulesFromFileSystem(); $modules->disableModule(basename($destination)); $modules->generateCacheList(); if (!empty($new_modules)) { $tmp = array_keys($new_modules); $id = $tmp[0]; $cur_module = $old_modules[$id]; if (!empty($cur_module) && $new_modules[$id]['version'] != $cur_module['version']) { # delete old module if (!files::deltree($destination)) { throw new Exception(__('An error occurred during module deletion.')); } $ret_code = 2; } else { $zip->close(); unlink($zip_file); if (file_exists($target . '/_define.php.bak')) { rename($target . '/_define.php.bak', $target . '/_define.php'); } throw new Exception(sprintf(__('Unable to upgrade "%s". (same version)'), basename($destination))); } } else { $zip->close(); unlink($zip_file); if (file_exists($target . '/_define.php.bak')) { rename($target . '/_define.php.bak', $target . '/_define.php'); } throw new Exception(sprintf(__('Unable to read new _define.php file'))); } } $zip->unzipAll($target); $zip->close(); unlink($zip_file); return $ret_code; }
/** * Delete a template * * @param string $sId * @return boolean */ protected function deleteTemplate($sId) { $aTemplatesInfos = $this->getTplInfos(); $aTplInfos = $aTemplatesInfos[$sId]; if (!is_dir($aTplInfos['dir']) || !is_writable($aTplInfos['dir'])) { return false; } files::deltree($aTplInfos['dir']); }
/** * Suppression d'une image donnée d'un élément donné. * * @param integer $iItemId * @param array $aCurrentImages * @param integer $iImgId * @return array */ public function deleteImage($iItemId, $aCurrentImages, $iImgId) { if (!isset($aCurrentImages[$iImgId])) { $this->error->set('L’image n’existe pas.'); return false; } $sCurrentImagesDir = $this->getCurrentUploadDir($iItemId); $sCurrentImagesUrl = $this->getCurrentUploadUrl($iItemId); # suppression des fichiers sur le disque if (files::isDeletable($sCurrentImagesDir . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'o-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'o-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'min-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'min-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'min2-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'min2-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'min3-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'min3-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'min4-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'min4-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'min5-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'min5-' . $aCurrentImages[$iImgId]['img_name']); } if (files::isDeletable($sCurrentImagesDir . 'sq-' . $aCurrentImages[$iImgId]['img_name'])) { unlink($sCurrentImagesDir . 'sq-' . $aCurrentImages[$iImgId]['img_name']); } # suppression du nom pour les infos de la BDD unset($aCurrentImages[$iImgId]); $aNewImages = array(); $j = 1; for ($i = 1; $i <= $this->aConfig['number']; $i++) { if (!isset($aCurrentImages[$i])) { continue; } $sExtension = pathinfo($aCurrentImages[$i]['img_name'], PATHINFO_EXTENSION); $sNewName = $j . '.' . $sExtension; if (file_exists($sCurrentImagesDir . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . $sNewName); } if (file_exists($sCurrentImagesDir . 'o-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'o-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'o-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'min-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'min-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'min2-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'min2-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min2-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'min3-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'min3-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min3-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'min4-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'min4-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min4-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'min5-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'min5-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min5-' . $sNewName); } if (file_exists($sCurrentImagesDir . 'sq-' . $aCurrentImages[$i]['img_name'])) { rename($sCurrentImagesDir . 'sq-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'sq-' . $sNewName); } # récupération des infos des images $aNewImages[$j] = self::getImagesFilesInfos($sCurrentImagesDir, $sCurrentImagesUrl, $sNewName); $j++; } if (!util::dirHasFiles($sCurrentImagesDir)) { files::deltree($sCurrentImagesDir); } return array_filter($aNewImages); }
if (!empty($_POST['buttons'])) { foreach ($_POST['buttons'] as $plugin_name => $button_name) { $plugins[$plugin_name]['button'] = $button_name; } } $core->blog->settings->dcCKEditorAddons->put('plugins', json_encode($plugins), 'string'); if ($_POST['action'] == 'activate') { $verb = 'activated'; } else { $verb = 'deactivated'; } dcPage::addSuccessNotice(sprintf(__('Selected addon has been ' . $verb . '.', 'Selected (%d) addons have been ' . $verb . '.', count($_POST['plugins'])), count($_POST['plugins']))); http::redirect($p_url); } elseif ($_POST['action'] == 'delete') { try { foreach ($_POST['plugins'] as $plugin_name) { if (!files::deltree($dcckeditor_addons_repository_path . '/' . $dcckeditor_addons_plugins[$plugin_name]['path'])) { throw new Exception(sprintf(__('Cannot remove addon "%s" files'), $plugin_name)); } unset($plugins[$plugin_name]); } dcPage::addSuccessNotice(sprintf(__('Selected addon has been deleted.', 'Selected (%d) addons have been deleted.', count($_POST['plugins'])), count($_POST['plugins']))); $core->blog->settings->dcCKEditorAddons->put('plugins', json_encode($plugins), 'string'); } catch (Exception $e) { dcPage::addErrorNotice($e->getMessage()); } http::redirect($p_url); } } } include __DIR__ . '/tpl/index.tpl';
function dotclearUpgrade($core) { $cleanup_sessions = false; // update it in a step that needed sessions to be removed $version = $core->getVersion('core'); if ($version === null) { return false; } if (version_compare($version, DC_VERSION, '<') == 1 || strpos(DC_VERSION, 'dev')) { try { if ($core->con->driver() == 'sqlite') { return false; // Need to find a way to upgrade sqlite database } # Database upgrade $_s = new dbStruct($core->con, $core->prefix); require dirname(__FILE__) . '/db-schema.php'; $si = new dbStruct($core->con, $core->prefix); $changes = $si->synchronize($_s); /* Some other upgrades ------------------------------------ */ # Populate media_dir field (since 2.0-beta3.3) if (version_compare($version, '2.0-beta3.3', '<')) { $strReq = 'SELECT media_id, media_file FROM ' . $core->prefix . 'media '; $rs_m = $core->con->select($strReq); while ($rs_m->fetch()) { $cur = $core->con->openCursor($core->prefix . 'media'); $cur->media_dir = dirname($rs_m->media_file); $cur->update('WHERE media_id = ' . (int) $rs_m->media_id); } } if (version_compare($version, '2.0-beta7.3', '<')) { # Blowup becomes default theme $strReq = 'UPDATE ' . $core->prefix . 'setting ' . "SET setting_value = '%s' " . "WHERE setting_id = 'theme' " . "AND setting_value = '%s' " . 'AND blog_id IS NOT NULL '; $core->con->execute(sprintf($strReq, 'blueSilence', 'default')); $core->con->execute(sprintf($strReq, 'default', 'blowup')); } if (version_compare($version, '2.1-alpha2-r2383', '<')) { $schema = dbSchema::init($core->con); $schema->dropUnique($core->prefix . 'category', $core->prefix . 'uk_cat_title'); # Reindex categories $rs = $core->con->select('SELECT cat_id, cat_title, blog_id ' . 'FROM ' . $core->prefix . 'category ' . 'ORDER BY blog_id ASC , cat_position ASC '); $cat_blog = $rs->blog_id; $i = 2; while ($rs->fetch()) { if ($cat_blog != $rs->blog_id) { $i = 2; } $core->con->execute('UPDATE ' . $core->prefix . 'category SET ' . 'cat_lft = ' . $i++ . ', cat_rgt = ' . $i++ . ' ' . 'WHERE cat_id = ' . (int) $rs->cat_id); $cat_blog = $rs->blog_id; } } if (version_compare($version, '2.1.6', '<=')) { # ie7js has been upgraded $ie7files = array('ie7-base64.php ', 'ie7-content.htc', 'ie7-core.js', 'ie7-css2-selectors.js', 'ie7-css3-selectors.js', 'ie7-css-strict.js', 'ie7-dhtml.js', 'ie7-dynamic-attributes.js', 'ie7-fixed.js', 'ie7-graphics.js', 'ie7-html4.js', 'ie7-ie5.js', 'ie7-layout.js', 'ie7-load.htc', 'ie7-object.htc', 'ie7-overflow.js', 'ie7-quirks.js', 'ie7-server.css', 'ie7-standard-p.js', 'ie7-xml-extras.js'); foreach ($ie7files as $f) { @unlink(DC_ROOT . '/admin/js/ie7/' . $f); } } if (version_compare($version, '2.2-alpha1-r3043', '<')) { # metadata has been integrated to the core. $core->plugins->loadModules(DC_PLUGINS_ROOT); if ($core->plugins->moduleExists('metadata')) { $core->plugins->deleteModule('metadata'); } # Tags template class has been renamed $sqlstr = 'SELECT blog_id, setting_id, setting_value ' . 'FROM ' . $core->prefix . 'setting ' . 'WHERE (setting_id = \'widgets_nav\' OR setting_id = \'widgets_extra\') ' . 'AND setting_ns = \'widgets\';'; $rs = $core->con->select($sqlstr); while ($rs->fetch()) { $widgetsettings = base64_decode($rs->setting_value); $widgetsettings = str_replace('s:11:"tplMetadata"', 's:7:"tplTags"', $widgetsettings); $cur = $core->con->openCursor($core->prefix . 'setting'); $cur->setting_value = base64_encode($widgetsettings); $sqlstr = 'WHERE setting_id = \'' . $rs->setting_id . '\' AND setting_ns = \'widgets\' ' . 'AND blog_id ' . ($rs->blog_id == NULL ? 'is NULL' : '= \'' . $core->con->escape($rs->blog_id) . '\''); $cur->update($sqlstr); } } if (version_compare($version, '2.3', '<')) { # Add global favorites $init_fav = array(); $init_fav['new_post'] = array('new_post', 'New entry', 'post.php', 'images/menu/edit.png', 'images/menu/edit-b.png', 'usage,contentadmin', null, null); $init_fav['newpage'] = array('newpage', 'New page', 'plugin.php?p=pages&act=page', 'index.php?pf=pages/icon-np.png', 'index.php?pf=pages/icon-np-big.png', 'contentadmin,pages', null, null); $init_fav['media'] = array('media', 'Media manager', 'media.php', 'images/menu/media.png', 'images/menu/media-b.png', 'media,media_admin', null, null); $init_fav['widgets'] = array('widgets', 'Presentation widgets', 'plugin.php?p=widgets', 'index.php?pf=widgets/icon.png', 'index.php?pf=widgets/icon-big.png', 'admin', null, null); $init_fav['blog_theme'] = array('blog_theme', 'Blog appearance', 'blog_theme.php', 'images/menu/themes.png', 'images/menu/blog-theme-b.png', 'admin', null, null); $count = 0; foreach ($init_fav as $k => $f) { $t = array('name' => $f[0], 'title' => $f[1], 'url' => $f[2], 'small-icon' => $f[3], 'large-icon' => $f[4], 'permissions' => $f[5], 'id' => $f[6], 'class' => $f[7]); $sqlstr = 'INSERT INTO ' . $core->prefix . 'pref (pref_id, user_id, pref_ws, pref_value, pref_type, pref_label) VALUES (' . '\'' . sprintf("g%03s", $count) . '\',NULL,\'favorites\',\'' . serialize($t) . '\',\'string\',NULL);'; $core->con->execute($sqlstr); $count++; } # A bit of housecleaning for no longer needed files $remfiles = array('admin/style/cat-bg.png', 'admin/style/footer-bg.png', 'admin/style/head-logo.png', 'admin/style/tab-bg.png', 'admin/style/tab-c-l.png', 'admin/style/tab-c-r.png', 'admin/style/tab-l-l.png', 'admin/style/tab-l-r.png', 'admin/style/tab-n-l.png', 'admin/style/tab-n-r.png', 'inc/clearbricks/_common.php', 'inc/clearbricks/common/lib.crypt.php', 'inc/clearbricks/common/lib.date.php', 'inc/clearbricks/common/lib.files.php', 'inc/clearbricks/common/lib.form.php', 'inc/clearbricks/common/lib.html.php', 'inc/clearbricks/common/lib.http.php', 'inc/clearbricks/common/lib.l10n.php', 'inc/clearbricks/common/lib.text.php', 'inc/clearbricks/common/tz.dat', 'inc/clearbricks/common/_main.php', 'inc/clearbricks/dblayer/class.cursor.php', 'inc/clearbricks/dblayer/class.mysql.php', 'inc/clearbricks/dblayer/class.pgsql.php', 'inc/clearbricks/dblayer/class.sqlite.php', 'inc/clearbricks/dblayer/dblayer.php', 'inc/clearbricks/dbschema/class.dbschema.php', 'inc/clearbricks/dbschema/class.dbstruct.php', 'inc/clearbricks/dbschema/class.mysql.dbschema.php', 'inc/clearbricks/dbschema/class.pgsql.dbschema.php', 'inc/clearbricks/dbschema/class.sqlite.dbschema.php', 'inc/clearbricks/diff/lib.diff.php', 'inc/clearbricks/diff/lib.unified.diff.php', 'inc/clearbricks/filemanager/class.filemanager.php', 'inc/clearbricks/html.filter/class.html.filter.php', 'inc/clearbricks/html.validator/class.html.validator.php', 'inc/clearbricks/image/class.image.meta.php', 'inc/clearbricks/image/class.image.tools.php', 'inc/clearbricks/mail/class.mail.php', 'inc/clearbricks/mail/class.socket.mail.php', 'inc/clearbricks/net/class.net.socket.php', 'inc/clearbricks/net.http/class.net.http.php', 'inc/clearbricks/net.http.feed/class.feed.parser.php', 'inc/clearbricks/net.http.feed/class.feed.reader.php', 'inc/clearbricks/net.xmlrpc/class.net.xmlrpc.php', 'inc/clearbricks/pager/class.pager.php', 'inc/clearbricks/rest/class.rest.php', 'inc/clearbricks/session.db/class.session.db.php', 'inc/clearbricks/template/class.template.php', 'inc/clearbricks/text.wiki2xhtml/class.wiki2xhtml.php', 'inc/clearbricks/url.handler/class.url.handler.php', 'inc/clearbricks/zip/class.unzip.php', 'inc/clearbricks/zip/class.zip.php', 'themes/default/tpl/.htaccess', 'themes/default/tpl/404.html', 'themes/default/tpl/archive.html', 'themes/default/tpl/archive_month.html', 'themes/default/tpl/category.html', 'themes/default/tpl/home.html', 'themes/default/tpl/post.html', 'themes/default/tpl/search.html', 'themes/default/tpl/tag.html', 'themes/default/tpl/tags.html', 'themes/default/tpl/user_head.html', 'themes/default/tpl/_flv_player.html', 'themes/default/tpl/_footer.html', 'themes/default/tpl/_head.html', 'themes/default/tpl/_mp3_player.html', 'themes/default/tpl/_top.html'); $remfolders = array('inc/clearbricks/common', 'inc/clearbricks/dblayer', 'inc/clearbricks/dbschema', 'inc/clearbricks/diff', 'inc/clearbricks/filemanager', 'inc/clearbricks/html.filter', 'inc/clearbricks/html.validator', 'inc/clearbricks/image', 'inc/clearbricks/mail', 'inc/clearbricks/net', 'inc/clearbricks/net.http', 'inc/clearbricks/net.http.feed', 'inc/clearbricks/net.xmlrpc', 'inc/clearbricks/pager', 'inc/clearbricks/rest', 'inc/clearbricks/session.db', 'inc/clearbricks/template', 'inc/clearbricks/text.wiki2xhtml', 'inc/clearbricks/url.handler', 'inc/clearbricks/zip', 'inc/clearbricks', 'themes/default/tpl'); foreach ($remfiles as $f) { @unlink(DC_ROOT . '/' . $f); } foreach ($remfolders as $f) { @rmdir(DC_ROOT . '/' . $f); } } if (version_compare($version, '2.3.1', '<')) { # Remove unecessary file @unlink(DC_ROOT . '/' . 'inc/libs/clearbricks/.hgignore'); } if (version_compare($version, '2.4.0', '<=')) { # setup media_exclusion $strReq = 'UPDATE ' . $core->prefix . 'setting ' . "SET setting_value = '/\\.php\$/i' " . "WHERE setting_id = 'media_exclusion' " . "AND setting_value = '' "; $core->con->execute($strReq); } if (version_compare($version, '2.5', '<=')) { # Try to disable daInstaller plugin if it has been installed outside the default plugins directory $path = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); $default = path::real(dirname(__FILE__) . '/../../plugins/'); foreach ($path as $root) { if (!is_dir($root) || !is_readable($root)) { continue; } if (substr($root, -1) != '/') { $root .= '/'; } if (($p = @dir($root)) === false) { continue; } if (path::real($root) == $default) { continue; } if (($d = @dir($root . 'daInstaller')) === false) { continue; } $f = $root . '/daInstaller/_disabled'; if (!file_exists($f)) { @file_put_contents($f, ''); } } } if (version_compare($version, '2.5.1', '<=')) { // Flash enhanced upload no longer needed @unlink(DC_ROOT . '/' . 'inc/swf/swfupload.swf'); } if (version_compare($version, '2.6', '<=')) { // README has been replaced by README.md and CONTRIBUTING.md @unlink(DC_ROOT . '/' . 'README'); // trackbacks are now merged into posts @unlink(DC_ROOT . '/' . 'admin/trackbacks.php'); # daInstaller has been integrated to the core. # Try to remove it $path = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT); foreach ($path as $root) { if (!is_dir($root) || !is_readable($root)) { continue; } if (substr($root, -1) != '/') { $root .= '/'; } if (($p = @dir($root)) === false) { continue; } if (($d = @dir($root . 'daInstaller')) === false) { continue; } files::deltree($root . '/daInstaller'); } # Some settings change, prepare db queries $strReqFormat = 'INSERT INTO ' . $core->prefix . 'setting'; $strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)'; $strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')'; $strReqSelect = 'SELECT count(1) FROM ' . $core->prefix . 'setting'; $strReqSelect .= ' WHERE setting_id = \'%s\''; $strReqSelect .= ' AND setting_ns = \'system\''; $strReqSelect .= ' AND blog_id IS NULL'; # Add date and time formats $date_formats = array('%Y-%m-%d', '%m/%d/%Y', '%d/%m/%Y', '%Y/%m/%d', '%d.%m.%Y', '%b %e %Y', '%e %b %Y', '%Y %b %e', '%a, %Y-%m-%d', '%a, %m/%d/%Y', '%a, %d/%m/%Y', '%a, %Y/%m/%d', '%B %e, %Y', '%e %B, %Y', '%Y, %B %e', '%e. %B %Y', '%A, %B %e, %Y', '%A, %e %B, %Y', '%A, %Y, %B %e', '%A, %Y, %B %e', '%A, %e. %B %Y'); $time_formats = array('%H:%M', '%I:%M', '%l:%M', '%Hh%M', '%Ih%M', '%lh%M'); if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $date_formats = array_map(create_function('$f', 'return str_replace(\'%e\',\'%#d\',$f);'), $date_formats); } $rs = $core->con->select(sprintf($strReqSelect, 'date_formats')); if ($rs->f(0) == 0) { $strReq = sprintf($strReqFormat, 'date_formats', serialize($date_formats), 'Date formats examples'); $core->con->execute($strReq); } $rs = $core->con->select(sprintf($strReqSelect, 'time_formats')); if ($rs->f(0) == 0) { $strReq = sprintf($strReqFormat, 'time_formats', serialize($time_formats), 'Time formats examples'); $core->con->execute($strReq); } # Add repository URL for themes and plugins as daInstaller move to core $rs = $core->con->select(sprintf($strReqSelect, 'store_plugin_url')); if ($rs->f(0) == 0) { $strReq = sprintf($strReqFormat, 'store_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'Plugins XML feed location'); $core->con->execute($strReq); } $rs = $core->con->select(sprintf($strReqSelect, 'store_theme_url')); if ($rs->f(0) == 0) { $strReq = sprintf($strReqFormat, 'store_theme_url', 'http://update.dotaddict.org/dc2/themes.xml', 'Themes XML feed location'); $core->con->execute($strReq); } } if (version_compare($version, '2.7', '<=')) { # Some new settings should be initialized, prepare db queries $strReqFormat = 'INSERT INTO ' . $core->prefix . 'setting'; $strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)'; $strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')'; $strReqCount = 'SELECT count(1) FROM ' . $core->prefix . 'setting'; $strReqCount .= ' WHERE setting_id = \'%s\''; $strReqCount .= ' AND setting_ns = \'system\''; $strReqCount .= ' AND blog_id IS NULL'; $strReqSelect = 'SELECT setting_value FROM ' . $core->prefix . 'setting'; $strReqSelect .= ' WHERE setting_id = \'%s\''; $strReqSelect .= ' AND setting_ns = \'system\''; $strReqSelect .= ' AND blog_id IS NULL'; # Add nb of posts for home (first page), copying nb of posts on every page $rs = $core->con->select(sprintf($strReqCount, 'nb_post_for_home')); if ($rs->f(0) == 0) { $rs = $core->con->select(sprintf($strReqSelect, 'nb_post_per_page')); $strReq = sprintf($strReqFormat, 'nb_post_for_home', $rs->f(0), 'Nb of posts on home (first page only)'); $core->con->execute($strReq); } } if (version_compare($version, '2.8.1', '<=')) { # switch from jQuery 1.11.1 to 1.11.2 $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '1.11.3' " . " WHERE setting_id = 'jquery_version' " . " AND setting_ns = 'system' " . " AND setting_value = '1.11.1' "; $core->con->execute($strReq); # setup media_exclusion (cope with php, php5, php7, … rather than only .php) $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '/\\.php[0-9]*\$/i' " . " WHERE setting_id = 'media_exclusion' " . " AND setting_ns = 'system' " . " AND setting_value = '/\\.php\$/i' "; $core->con->execute($strReq); # Some new settings should be initialized, prepare db queries $strReq = 'INSERT INTO ' . $core->prefix . 'setting' . ' (setting_id,setting_ns,setting_value,setting_type,setting_label)' . ' VALUES(\'%s\',\'system\',\'%s\',\'boolean\',\'%s\')'; $core->con->execute(sprintf($strReq, 'no_search', '0', 'Disable internal search system')); } if (version_compare($version, '2.8.2', '<=')) { # Update flie exclusion upload regex $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '/\\.(phps?|pht(ml)?|phl)[0-9]*\$/i' " . " WHERE setting_id = 'media_exclusion' " . " AND setting_ns = 'system' " . " AND (setting_value = '/\\.php[0-9]*\$/i' " . " OR setting_value = '/\\.php\$/i') "; $core->con->execute($strReq); } if (version_compare($version, '2.9', '<=')) { # Some new settings should be initialized, prepare db queries $strReq = 'INSERT INTO ' . $core->prefix . 'setting' . ' (setting_id,setting_ns,setting_value,setting_type,setting_label)' . ' VALUES(\'%s\',\'system\',\'%s\',\'%s\',\'%s\')'; $core->con->execute(sprintf($strReq, 'media_video_width', '400', 'integer', 'Media video insertion width')); $core->con->execute(sprintf($strReq, 'media_video_height', '300', 'integer', 'Media video insertion height')); $core->con->execute(sprintf($strReq, 'media_flash_fallback', '1', 'boolean', 'Flash player fallback for audio and video media')); } $core->setVersion('core', DC_VERSION); $core->blogDefaults(); # Drop content from session table if changes or if needed if ($changes != 0 || $cleanup_sessions) { $core->con->execute('DELETE FROM ' . $core->prefix . 'session '); } # Empty templates cache directory try { $core->emptyTemplatesCache(); } catch (Exception $e) { } return $changes; } catch (Exception $e) { throw new Exception(__('Something went wrong with auto upgrade:') . ' ' . $e->getMessage()); } } # No upgrade? return false; }
public function deleteModule($id, $disabled = false) { if ($disabled) { $p =& $this->disabled; } else { $p =& $this->modules; } if (!isset($p[$id])) { throw new Exception(__('No such module.')); } if (!files::deltree($p[$id]['root'])) { throw new Exception(__('Cannot remove module files')); } }
protected function removeAssetsFiles($sAssetsDir, $aLockedFiles = array()) { $aFiles = files::getDirList($sAssetsDir); foreach ($aFiles['files'] as $sFiles) { if (!in_array($sFiles, $aLockedFiles)) { unlink($sFiles); } } foreach (array_reverse($aFiles['dirs']) as $sDir) { if (!util::dirHasFiles($sDir)) { files::deltree($sDir); } } return true; }
/** * Suppression d'un utilisateur. * * @param $id * @return boolean */ public function deleteUser($id) { $rsUser = $this->getUsers(array('id' => $id)); if ($rsUser->isEmpty()) { $this->error->set(sprintf(__('m_users_error_user_%s_not_exists'), $id)); return false; } # si on veut supprimer un super-admin alors il faut vérifier qu'il y en as d'autres if ($rsUser->group_id == oktAuth::superadmin_group_id) { $iCountSudo = $this->getUsers(array('group_id' => oktAuth::superadmin_group_id), true); if ($iCountSudo < 2) { $this->error->set(__('m_users_error_cannot_remove_last_super_administrator')); return false; } } # si on veut supprimer un admin alors il faut vérifier qu'il y en as d'autres if ($rsUser->group_id == oktAuth::admin_group_id) { $iCountAdmin = $this->getUsers(array('group_id' => oktAuth::admin_group_id), true); if ($iCountAdmin < 2) { $this->error->set(__('m_users_error_cannot_remove_last_administrator')); return false; } } $sQuery = 'DELETE FROM ' . $this->t_users . ' ' . 'WHERE id=' . (int) $id; if (!$this->db->execute($sQuery)) { return false; } $this->db->optimize($this->t_users); # delete user custom fields if ($this->config->enable_custom_fields) { $this->fields->delUserValue($id); } # delete user directory $user_dir = $this->upload_dir . $id . '/'; if (files::isDeletable($user_dir)) { files::deltree($user_dir); } return true; }
header('Location: tools.php?p=toolsmng'); exit; } } } # Changement de status d'un plugin $switch = !empty($_GET['switch']) ? $_GET['switch'] : ''; if ($is_writable && $switch != '' && in_array($switch, array_keys($plugins_list)) && $switch != 'toolsmng') { $plugins->switchStatus($switch); header('Location: tools.php?p=toolsmng'); exit; } # Suppression d'un thème $delete = !empty($_GET['delete']) ? $_GET['delete'] : ''; if ($is_writable && $delete != '' && in_array($delete, array_keys($plugins_list)) && $delete != 'toolsmng') { files::deltree($plugins_root . '/' . $delete); header('Location: tools.php?p=toolsmng'); exit; } if ($err != '') { buffer::str('<div class="erreur"><p><strong>' . __('Error(s)') . ' :</strong></p>' . $err . '</div>'); } buffer::str('<h2>' . __('Plugins manager') . '</h2>' . '<h3>' . __('Install a plugin') . '</h3>'); if (!$is_writable) { buffer::str('<p>' . sprintf(__('The folder %s is not writable, please check its permissions.'), DC_ECRIRE . '/tools/') . '</p>'); } else { buffer::str('<form action="tools.php" method="get">' . '<p><label for="tool_url">' . __('Please give the URL (http or ftp) of the plugin\'s file') . ' :</label>' . form::field('tool_url', 50, '', $tool_url) . '</p>' . '<p><input type="submit" class="submit" value="' . __('install') . '" />' . '<input type="hidden" name="p" value="toolsmng" /></p>' . '</form>'); } buffer::str('<p><a href="http://www.wikini.net">' . __('Install new plugins') . '</a></p>'); # Traduction des plugins foreach ($plugins_list as $k => $v) {
} } /* Traitements ------------------------------------------------------------*/ /* Affichage ------------------------------------------------------------*/ # En-tête $title = __('i_end_' . $_SESSION['okt_install_process_type'] . '_title'); require OKT_INSTAL_DIR . '/header.php'; ?> <p><?php _e('i_end_' . $_SESSION['okt_install_process_type'] . '_congrat'); ?> </p> <p><?php printf(__('i_end_connect'), './../' . OKT_ADMIN_DIR . '/' . OKT_ADMIN_LOGIN_PAGE . '?user_id=' . $user . '&user_pwd=' . $password); ?> </p> <?php # Pied de page require OKT_INSTAL_DIR . '/footer.php'; # destroy session data $_SESSION = array(); session_destroy(); if (defined('OKT_ENVIRONMENT') && OKT_ENVIRONMENT == 'prod') { @files::deltree(OKT_INSTAL_DIR, true); }
/** * Supprime les fichiers cache public d'Okatea * * @return void */ public static function deleteOktPublicCacheFiles($bForce = false) { $aCacheFiles = self::getOktPublicCacheFiles($bForce); foreach ($aCacheFiles as $file) { if (is_dir(OKT_PUBLIC_PATH . '/cache/' . $file)) { files::deltree(OKT_PUBLIC_PATH . '/cache/' . $file); } else { unlink(OKT_PUBLIC_PATH . '/cache/' . $file); } } }
message_die(GENERAL_MESSAGE, $message); exit; } break; case 'supprime': // on veut supprimer son mod if (!$plugins->supprime($titre, $id_mod)) { $message = $lang['mod_non_supprime'] . '<br /><br />'; $message .= sprintf($lang['Click_return_areabb_mods'], '<a href="' . append_sid('admin_areabb_mods.' . $phpEx) . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); exit; } // On vire le dossier du site load_function('lib.files'); $mod = new files(); $mod->deltree(CHEMIN_MODS . $titre); break; } // -------------------------------------------------------------------------------------------- // RECUPERATION des mods déjà installés et NON installés // $sql = 'SELECT id_mod, nom FROM ' . AREABB_MODS . ' ORDER BY nom ASC'; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Impossible d'afficher la liste des blocs", '', __LINE__, __FILE__, $sql); } $listes_mods = array(); $liste_id = array(); while ($row = $db->sql_fetchrow($result)) { $listes_mods[] = $row['nom'];
} $iItemId = $okt->galleries->items->addItem($okt->galleries->items->openItemCursor(array('gallery_id' => $iGalleryId, 'active' => 1)), $aItemLocalesData); $sDestination = $okt->galleries->upload_dir . '/img/items/' . $iItemId . '/1.' . $sFileExtension; files::makeDir(dirname($sDestination), true); $oZip->unzip($sFileName, $sDestination); $aNewImagesInfos = $okt->galleries->items->getImageUploadInstance()->buildImagesInfos($iItemId, array(1 => basename($sDestination))); if (isset($aNewImagesInfos[1])) { $aNewItemImages = $aNewImagesInfos[1]; $aNewItemImages['original_name'] = utf8_encode(basename($sFileName)); } else { $aNewItemImages = array(); } $okt->galleries->items->updImages($iItemId, $aNewItemImages); } $oZip->close(); files::deltree($sTempDir); } catch (Exception $e) { $okt->error->set($e->getMessage()); } if ($okt->error->isEmpty()) { $okt->galleries->items->regenMinImages($iGalleryId); $okt->redirect('module.php?m=galleries&action=items&gallery_id=' . $iGalleryId); } } /* Affichage ----------------------------------------------------------*/ $okt->page->addButton('galleriesBtSt', array('permission' => true, 'title' => __('c_c_action_Go_back'), 'url' => $iGalleryId ? 'module.php?m=galleries&action=items&gallery_id=' . $iGalleryId : 'module.php?m=galleries&action=index', 'ui-icon' => 'arrowreturnthick-1-w'), 'before'); $okt->page->addGlobalTitle(__('m_galleries_zip_main_title')); # Récupération de la liste complète des galeries $rsGalleries = $okt->galleries->tree->getGalleries(array('language' => $okt->user->language, 'active' => 2)); # Lang switcher
/** Empty templates cache directory */ public function emptyTemplatesCache() { if (is_dir(DC_TPL_CACHE . '/cbtpl')) { files::deltree(DC_TPL_CACHE . '/cbtpl'); } }
* @addtogroup Okatea * */ # Accès direct interdit if (!defined('ON_CONFIGURATION_MODULE')) { die; } # Suppression d'un fichier cache if (!empty($_GET['cache_file']) && in_array($_GET['cache_file'], $aCacheFiles)) { if (is_dir(OKT_CACHE_PATH . '/' . $_GET['cache_file'])) { files::deltree(OKT_CACHE_PATH . '/' . $_GET['cache_file']); } else { unlink(OKT_CACHE_PATH . '/' . $_GET['cache_file']); } $okt->redirect('configuration.php?action=tools&file_deleted=1'); } # Suppression d'un fichier cache public if (!empty($_GET['public_cache_file']) && in_array($_GET['public_cache_file'], $aPublicCacheFiles)) { if (is_dir(OKT_PUBLIC_PATH . '/cache/' . $_GET['public_cache_file'])) { files::deltree(OKT_PUBLIC_PATH . '/cache/' . $_GET['public_cache_file']); } else { unlink(OKT_PUBLIC_PATH . '/cache/' . $_GET['public_cache_file']); } $okt->redirect('configuration.php?action=tools&file_deleted=1'); } # Suppression des fichiers cache if (!empty($_GET['all_cache_file'])) { util::deleteOktCacheFiles(); util::deleteOktPublicCacheFiles(); $okt->redirect('configuration.php?action=tools&files_deleted=1'); }
function dc_lang_install($file) { $zip = new fileUnzip($file); $zip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|Thumbs\\.db)(/|$)#'); if (!preg_match('/^[a-z]{2,3}(-[a-z]{2})?$/', $zip->getRootDir())) { throw new Exception(__('Invalid language zip file.')); } if ($zip->isEmpty() || !$zip->hasFile($zip->getRootDir() . '/main.po')) { throw new Exception(__('The zip file does not appear to be a valid Dotclear language pack.')); } $target = dirname($file); $destination = $target . '/' . $zip->getRootDir(); $res = 1; if (is_dir($destination)) { if (!files::deltree($destination)) { throw new Exception(__('An error occurred during language upgrade.')); } $res = 2; } $zip->unzipAll($target); return $res; }
echo $oInstallModule->checklist->getLegend(); echo '</div>'; if (file_exists($oInstallModule->root() . '/_install/tpl/') || file_exists($oInstallModule->root() . '/_install/common/') || file_exists($oInstallModule->root() . '/_install/public/')) { $next_url = 'configuration.php?action=modules&compare=' . $oInstallModule->id(); } else { $next_url = 'configuration.php?action=modules'; } echo '<p class="ui-helper-clearfix"><a class="button" ' . 'href="' . $next_url . '">' . __('Continue') . '</a></p>'; # Pied-de-page require OKT_ADMIN_FOOTER_FILE; # log admin $okt->logAdmin->critical(array('code' => 21, 'message' => $_GET['update'])); exit; } else { if (!empty($_GET['delete']) && array_key_exists($_GET['delete'], $aUninstalledModules)) { if (files::deltree($okt->modules->path . '/' . $_GET['delete'])) { $okt->page->flashMessages->addSuccess(__('c_a_modules_successfully_deleted')); $okt->redirect('configuration.php?action=modules'); } else { $okt->error->set(__('c_a_modules_not_deleted.')); } } else { if (!empty($_GET['enable']) && array_key_exists($_GET['enable'], $aInstalledModules)) { $okt->modules->enableModule($_GET['enable']); # vidange du cache util::deleteOktCacheFiles(); # log admin $okt->logAdmin->warning(array('code' => 30, 'message' => $_GET['enable'])); $okt->redirect('configuration.php?action=modules&enabled=1'); } else { if (!empty($_GET['disable']) && array_key_exists($_GET['disable'], $aInstalledModules)) {