function clear_cache($module_id = false) { import('io/filesystem/folder'); $folder = new Folder(FEEDS_PATH, OPEN_NOW); $files = null; if ($module_id !== false) { $files = $folder->get_files('`' . $module_id . '_.*`'); } else { $files = $folder->get_files(); } foreach ($files as $file) { $file->delete(); } }
private function delete_files(Folder $folder, $regex = '') { $files_to_delete = $folder->get_files($regex, true); foreach ($files_to_delete as $file) { $file->delete(); } }
public static function load_distribution_properties($prefered_lang) { global $DISTRIBUTION_MODULES; //If the distribution properties exist in the prefered language if (is_file('distribution/' . $prefered_lang . '.php')) { //We load them include 'distribution/' . $prefered_lang . '.php'; } else { //We try to load another lang $distribution_folder = new Folder('distribution'); $distribution_files = $distribution_folder->get_files('`distribution_[a-z_-]+\\.php`i'); if (count($distribution_files) > 0) { include 'distribution/distribution_' . $distribution_files[0]->get_name() . '.php'; } else { //We couldn't load anything, we just have to define them to default values //Name of the distribution (localized) define('DISTRIBUTION_NAME', 'Default distribution'); //Description of the distribution (localized) define('DISTRIBUTION_DESCRIPTION', 'This distribution is the default distribution. You will manage to install PHPBoost with the default configuration but it will install only the kernel without any module.'); //Distribution default theme define('DISTRIBUTION_THEME', 'base'); //Home page define('DISTRIBUTION_START_PAGE', UserUrlBuilder::home()->rel()); //Can people register? define('DISTRIBUTION_ENABLE_USER', false); //Debug mode? define('DISTRIBUTION_ENABLE_DEBUG_MODE', true); //Enable bench? define('DISTRIBUTION_ENABLE_BENCH', false); //Modules list $DISTRIBUTION_MODULES = array(); } } }
function list_tu_recursive($directory, $recursive = false) { $files = array(); $folder = new Folder($directory); foreach ($folder->get_files('`^.+Test\\.php$`') as $file) { $files[] = preg_replace('`^[\\./]*kernel/`', '', $file->get_path()); } if ($recursive) { foreach ($folder->get_folders() as $folder) { $files = array_merge($files, list_tu_recursive($folder->get_path(), true)); } } return $files; }
function change_day() { global $Sql, $CONFIG_USER; #######Taches de maintenance####### $yesterday_timestamp = time() - 86400; $Sql->query_inject("INSERT INTO " . DB_TABLE_STATS . " (stats_year, stats_month, stats_day, nbr, pages, pages_detail) VALUES ('" . gmdate_format('Y', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', '" . gmdate_format('m', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', '" . gmdate_format('d', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', 0, 0, '')", __LINE__, __FILE__); $last_stats = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "stats"); #######Statistiques####### $Sql->query_inject("UPDATE " . DB_TABLE_STATS_REFERER . " SET yesterday_visit = today_visit", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_STATS_REFERER . " SET today_visit = 0, nbr_day = nbr_day + 1", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_STATS_REFERER . " WHERE last_update < '" . (time() - 604800) . "'", __LINE__, __FILE__); $pages_displayed = pages_displayed(); import('io/filesystem/file'); $pages_file = new File(PATH_TO_ROOT . '/cache/pages.txt'); $pages_file->delete(); $total_visit = $Sql->query("SELECT total FROM " . DB_TABLE_VISIT_COUNTER . " WHERE id = 1", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_VISIT_COUNTER . " WHERE id <> 1", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_VISIT_COUNTER . " SET time = '" . gmdate_format('Y-m-d', time(), TIMEZONE_SYSTEM) . "', total = 1 WHERE id = 1", __LINE__, __FILE__); $Sql->query_inject("INSERT INTO " . DB_TABLE_VISIT_COUNTER . " (ip, time, total) VALUES('" . USER_IP . "', '" . gmdate_format('Y-m-d', time(), TIMEZONE_SYSTEM) . "', '0')", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_STATS . " SET nbr = '" . $total_visit . "', pages = '" . array_sum($pages_displayed) . "', pages_detail = '" . addslashes(serialize($pages_displayed)) . "' WHERE id = '" . $last_stats . "'", __LINE__, __FILE__); Session::garbage_collector(); import('io/filesystem/folder'); $week = 3600 * 24 * 7; $cache_image_folder_path = new Folder(PATH_TO_ROOT . '/images/maths/'); foreach ($cache_image_folder_path->get_files('`\\.png$`') as $image) { if (time() - $image->get_last_modification_date() > $week) { $image->delete(); } } import('modules/modules_discovery_service'); $modules_loader = new ModulesDiscoveryService(); $modules = $modules_loader->get_available_modules('on_changeday'); foreach ($modules as $module) { if ($module->is_enabled()) { $module->functionality('on_changeday'); } } $CONFIG_USER['delay_unactiv_max'] = $CONFIG_USER['delay_unactiv_max'] * 3600 * 24; if (!empty($CONFIG_USER['delay_unactiv_max']) && $CONFIG_USER['activ_mbr'] != 2) { $Sql->query_inject("DELETE FROM " . DB_TABLE_MEMBER . " WHERE timestamp < '" . (time() - $CONFIG_USER['delay_unactiv_max']) . "' AND user_aprob = 0", __LINE__, __FILE__); } if ($CONFIG_USER['verif_code'] == '1') { $Sql->query_inject("DELETE FROM " . DB_TABLE_VERIF_CODE . " WHERE timestamp < '" . (time() - 3600 * 24) . "'", __LINE__, __FILE__); } import('core/updates'); new Updates(); }
private function list_files($theme_selected) { $files = array(); $files[] = new FormFieldSelectChoiceOption('--', ''); $folder = new Folder(PATH_TO_ROOT . $this->templates_path . $theme_selected . $this->tpl_files_path); foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption($file->get_name(), $file->get_name_without_extension()); } foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $id => $module) { $folder = new Folder(PATH_TO_ROOT . '/' . $module->get_id() . '/templates'); if ($folder->exists()) { foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('module', 'admin-modules-common') . ' ' . ModulesManager::get_module($module->get_id())->get_configuration()->get_name() . ' : ' . $file->get_name(), $module->get_id() . '/' . $file->get_name_without_extension()); } } } $folder = new Folder(PATH_TO_ROOT . '/user/templates'); if ($folder->exists()) { foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('users', 'user-common') . ' : ' . $file->get_name(), 'user/' . $file->get_name_without_extension()); } } return $files; }
/** * @desc Clear the cache of the specified module_id. * @param mixed $module_id the module module_id or false. If false, * Clear all feeds data from the cache * @static */ public static function clear_cache($module_id = false) { $folder = new Folder(FEEDS_PATH); $files = null; if ($module_id !== false) { // Clear only this module cache $files = $folder->get_files('`' . $module_id . '_.*`'); foreach ($files as $file) { $file->delete(); } } else { // Clear the whole cache AppContext::get_cache_service()->clear_syndication_cache(); } }
define('DIR', str_replace('/install/install.php', '', $server_path)); define('SID', ''); $step = retrieve(GET, 'step', 1, TUNSIGNED_INT); $step = $step > STEPS_NUMBER ? 1 : $step; $lang = retrieve(GET, 'lang', DEFAULT_LANGUAGE); if (!@(include_once 'lang/' . $lang . '/install_' . $lang . '.php')) { include_once 'lang/' . DEFAULT_LANGUAGE . '/install_' . DEFAULT_LANGUAGE . '.php'; $lang = DEFAULT_LANGUAGE; } @(include_once '../lang/' . $lang . '/errors.php'); if (is_file('distribution/distribution_' . $lang . '.php')) { include 'distribution/distribution_' . $lang . '.php'; } else { import('io/filesystem/folder'); $distribution_folder = new Folder('distribution'); $distribution_files = $distribution_folder->get_files('`distribution_[a-z_-]+\\.php`i'); if (count($distribution_files) > 0) { include 'distribution/distribution_' . $distribution_files[0]->get_name() . '.php'; } else { define('DISTRIBUTION_NAME', 'Default distribution'); define('DISTRIBUTION_DESCRIPTION', 'This distribution is the default distribution. You will manage to install PHPBoost with the default configuration but it will install only the kernel without any module.'); define('DISTRIBUTION_THEME', 'base'); define('DISTRIBUTION_START_PAGE', '/member/member.php'); define('DISTRIBUTION_ENABLE_USER', false); $DISTRIBUTION_MODULES = array(); } } import('members/user'); $user_data = array('m_user_id' => 1, 'login' => 'login', 'level' => ADMIN_LEVEL, 'user_groups' => '', 'user_lang' => $lang, 'user_theme' => DISTRIBUTION_THEME, 'user_mail' => '', 'user_pm' => 0, 'user_editor' => 'bbcode', 'user_timezone' => 1, 'avatar' => '', 'user_readonly' => 0, 'user_id' => 1, 'session_id' => ''); $user_groups = array(); $User = new User($user_data, $user_groups);
/** * {@inheritdoc} */ public function clear() { $cache_dir = new Folder(PATH_TO_ROOT . '/cache'); $files = $cache_dir->get_files('`^' . $this->prefix . '-.*`'); foreach ($files as $file) { $file->delete(); } }
$Sql->query_close($result); ###### Régénération du cache des rangs ####### $Cache->Generate_file('ranks'); redirect(HOST . SCRIPT); } elseif (!empty($_GET['del']) && !empty($get_id)) { $Sql->query_inject("DELETE FROM " . DB_TABLE_RANKS . " WHERE id = '" . $get_id . "'", __LINE__, __FILE__); ###### Régénération du cache des rangs ####### $Cache->Generate_file('ranks'); redirect(HOST . SCRIPT); } else { $Template->set_filenames(array('admin_ranks' => 'admin/admin_ranks.tpl')); $Template->assign_vars(array('THEME' => get_utheme(), 'L_REQUIRE_RANK_NAME' => $LANG['require_rank_name'], 'L_REQUIRE_NBR_MSG_RANK' => $LANG['require_nbr_msg_rank'], 'L_CONFIRM_DEL_RANK' => $LANG['confirm_del_rank'], 'L_RANKS_MANAGEMENT' => $LANG['rank_management'], 'L_ADD_RANKS' => $LANG['rank_add'], 'L_RANK_NAME' => $LANG['rank_name'], 'L_NBR_MSG' => $LANG['nbr_msg'], 'L_IMG_ASSOC' => $LANG['img_assoc'], 'L_DELETE' => $LANG['delete'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'L_ADD' => $LANG['add'])); import('io/filesystem/folder'); $rank_options_array = array(); $image_folder_path = new Folder(PATH_TO_ROOT . '/templates/' . get_utheme() . '/images/ranks'); foreach ($image_folder_path->get_files('`\\.(png|jpg|bmp|gif)$`i') as $image) { $file = $image->get_name(); $rank_options_array[] = $file; } $result = $Sql->query_while("SELECT id, name, msg, icon, special\n\tFROM " . DB_TABLE_RANKS . " \n\tORDER BY msg", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { if ($row['special'] == 0) { $del = '<a href="admin_ranks.php?del=1&id=' . $row['id'] . '" onclick="javascript:return Confirm();"><img src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/delete.png" alt="" title="" /></a>'; } else { $del = $LANG['special_rank']; } $rank_options = '<option value="">--</option>'; foreach ($rank_options_array as $icon) { $selected = $icon == $row['icon'] ? ' selected="selected"' : ''; $rank_options .= '<option value="' . $icon . '"' . $selected . '>' . $icon . '</option>'; }
function Clear_cache() { import('io/filesystem/folder'); $thumb_folder_path = new Folder('./pics/thumbnails/'); foreach ($thumb_folder_path->get_files('`\\.(png|jpg|bmp|gif)$`i') as $thumbs) { $this->delete_file('./pics/thumbnails/' . $thumbs->get_name()); } }
private static function clear_all_temporary_cache_files() { //We delete all the images generated by the LaTeX formatter $cache_image_folder_path = new Folder(PATH_TO_ROOT . '/images/maths/'); $files = $cache_image_folder_path->get_files('`\\.png$`'); foreach ($files as $image) { if ($image->get_last_modification_date() < self::get_one_week_ago_timestamp()) { $image->delete(); } } }
private static function add_classes($directory, $pattern, $recursive = true) { $files = array(); $folder = new Folder($directory); $relative_path = Path::get_path_from_root($folder->get_path()); $files = $folder->get_files($pattern); foreach ($files as $file) { $filename = $file->get_name(); $classname = $file->get_name_without_extension(); self::$autoload[$classname] = $relative_path . '/' . $filename; } if ($recursive) { $folders = $folder->get_folders('`^[a-z]{1}.*$`i'); foreach ($folders as $a_folder) { if (!in_array($a_folder->get_path_from_root(), self::$exclude_paths) && !in_array($a_folder->get_name(), self::$exclude_folders_names)) { self::add_classes($a_folder->get_path(), $pattern); } } } }
$ckeck_module = $Sql->query("SELECT COUNT(*) FROM " . DB_TABLE_MODULES . " WHERE name = '" . strprotect($module_name) . "'", __LINE__, __FILE__); if (!empty($ckeck_module)) { $info_module = load_ini_file('../' . $module_name . '/lang/', get_ulang()); $previous_version = $Sql->query("SELECT version FROM " . DB_TABLE_MODULES . " WHERE name = '" . strprotect($module_name) . "'", __LINE__, __FILE__); $dir_db_module = get_ulang(); $dir = '../' . $module_name . '/db'; import('io/filesystem/folder'); $folder_path = new Folder($dir . '/' . $dir_db_module); foreach ($folder_path->get_folders('`^[a-z0-9_ -]+$`i') as $dir) { $dir_db_module = $dir->get_name(); break; } $filesupdate = array(); $dir_db = '../' . urldecode($module_name) . '/db/' . $dir_db_module . '/'; $folder_path = new Folder($dir_db); foreach ($folder_path->get_files('`.*\\.(php|sql)$`i') as $files) { $file = $files->get_name(); if (strpos($file, DBTYPE) !== false) { $array_info = explode('_', $file); if (isset($array_info[1]) && version_compare($info_module['version'], $array_info[1], '>=') && version_compare($previous_version, $array_info[1], '<')) { $filesupdate[$array_info[1]] = $file; } } } uksort($filesupdate, 'version_compare'); $_GET['filesupdate_errors'] = false; foreach ($filesupdate as $key => $module_update_name) { if (strpos($module_update_name, '.php') !== false) { @(include_once $dir_db . $module_update_name); } else { $Sql->parse($dir_db . $module_update_name, PREFIX);
private function get_class($directory, $pattern, $type) { $classes = array(); $folder = new Folder($directory); foreach ($folder->get_files($pattern) as $file) { $classes[] = array('name' => $file->get_name_without_extension(), 'type' => $type); } return $classes; }
private function generate_available_smileys_pictures_list() { $smileys_array = $options = array(); $folder_phpboost_smileys = new Folder($this->smileys_path); foreach ($folder_phpboost_smileys->get_files('`\\.(png|jpg|bmp|gif)$`i') as $smileys) { $smileys_array[] = $smileys->get_name(); } if (!$this->smiley['idsmiley']) { $result = PersistenceContext::get_querier()->select("SELECT url_smiley\n\t\t\tFROM " . PREFIX . "smileys"); while ($row = $result->fetch()) { //On recherche les clés correspondante à celles trouvée dans la bdd. $key = array_search($row['url_smiley'], $smileys_array); if ($key !== false) { unset($smileys_array[$key]); } //On supprime ces clés du tableau. } $result->dispose(); $options = array(new FormFieldSelectChoiceOption('--', '')); } foreach ($smileys_array as $smiley) { $options[] = new FormFieldSelectChoiceOption($smiley, $smiley); } return $options; }
$error = !empty($error) ? '?error=' . $error : ''; redirect(HOST . SCRIPT . $error); } else { $Template->set_filenames(array('admin_smileys_add' => 'admin/admin_smileys_add.tpl')); $get_error = retrieve(GET, 'error', ''); $array_error = array('e_upload_invalid_format', 'e_upload_max_weight', 'e_upload_error', 'e_upload_failed_unwritable', 'e_smiley_already_exist'); if (in_array($get_error, $array_error)) { $Errorh->handler($LANG[$get_error], E_USER_WARNING); } if ($get_error == 'incomplete') { $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); } import('io/filesystem/folder'); $smileys_array = array(); $smileys_folder_path = new Folder('../images/smileys'); foreach ($smileys_folder_path->get_files('`\\.(png|jpg|bmp|gif)$`i') as $smileys) { $smileys_array[] = $smileys->get_name(); } $result = $Sql->query_while("SELECT url_smiley\n\tFROM " . PREFIX . "smileys", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $key = array_search($row['url_smiley'], $smileys_array); if ($key !== false) { unset($smileys_array[$key]); } } $Sql->query_close($result); $y = 0; $smiley_options = '<option value="" selected="selected">--</option>'; foreach ($smileys_array as $smiley) { $smiley_options .= '<option value="' . $smiley . '">' . $smiley . '</option>'; }
$cat_list .= '<option value="' . $row['id'] . '"' . $selected . '>' . $margin . ' ' . $row['name'] . '</option>'; $cat_list_unselect .= '<option value="' . $row['id'] . '">' . $margin . ' ' . $row['name'] . '</option>'; } $Sql->query_close($result); if (!empty($add_pic)) { $CAT_GALLERY[0]['name'] = $LANG['root']; $imageup = $Sql->query_array(PREFIX . "gallery", "idcat", "name", "path", "WHERE id = '" . $add_pic . "'", __LINE__, __FILE__); $Template->assign_block_vars('image_up', array('NAME' => $imageup['name'], 'IMG' => '<a href="admin_gallery.php?cat=' . $imageup['idcat'] . '&id=' . $add_pic . '#pics_max"><img src="pics/' . $imageup['path'] . '" alt="" /></a>', 'L_SUCCESS_UPLOAD' => $LANG['success_upload_img'], 'U_CAT' => '<a href="admin_gallery.php?cat=' . $imageup['idcat'] . '">' . $CAT_GALLERY[$imageup['idcat']]['name'] . '</a>')); } $Template->assign_vars(array('WIDTH_MAX' => $CONFIG_GALLERY['width_max'], 'HEIGHT_MAX' => $CONFIG_GALLERY['height_max'], 'WEIGHT_MAX' => $CONFIG_GALLERY['weight_max'], 'AUTH_EXTENSION' => 'JPEG, GIF, PNG', 'CATEGORIES' => $cat_list, 'IMG_HEIGHT_MAX' => $CONFIG_GALLERY['height'] + 10, 'L_GALLERY_MANAGEMENT' => $LANG['gallery_management'], 'L_GALLERY_PICS_ADD' => $LANG['gallery_pics_add'], 'L_GALLERY_CAT_MANAGEMENT' => $LANG['gallery_cats_management'], 'L_GALLERY_CAT_ADD' => $LANG['gallery_cats_add'], 'L_GALLERY_CONFIG' => $LANG['gallery_config'], 'L_ADD_IMG' => $LANG['add_pic'], 'L_WEIGHT_MAX' => $LANG['weight_max'], 'L_HEIGHT_MAX' => $LANG['height_max'], 'L_WIDTH_MAX' => $LANG['width_max'], 'L_UPLOAD_IMG' => $LANG['upload_pics'], 'L_AUTH_EXTENSION' => $LANG['auth_extension'], 'L_CATEGORY' => $LANG['category'], 'L_IMG_DISPO_GALLERY' => $LANG['img_dispo'], 'L_REQUIRE' => $LANG['require'], 'L_SELECT_IMG_ADD' => $LANG['select_img_add'], 'L_NAME' => $LANG['name'], 'L_UNIT_PX' => $LANG['unit_pixels'], 'L_UNIT_KO' => $LANG['unit_kilobytes'], 'L_SELECT' => $LANG['select'], 'L_CAT' => $LANG['categorie'], 'L_DELETE' => $LANG['delete'], 'L_SUBMIT' => $LANG['submit'])); $dir = 'pics/'; if (is_dir($dir)) { import('io/filesystem/folder'); $array_pics = array(); $image_folder_path = new Folder('./pics/'); foreach ($image_folder_path->get_files('`.*\\.(png|jpg|bmp|gif|jpeg|tiff)$`i') as $image) { $array_pics[] = $image->get_name(); } if (is_array($array_pics)) { $result = $Sql->query_while("SELECT path\n\t\t\tFROM " . PREFIX . "gallery", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $key = array_search($row['path'], $array_pics); if ($key !== false) { unset($array_pics[$key]); } } $Sql->query_close($result); $nbr_pics = count($array_pics); $nbr_column_pics = $nbr_pics > $CONFIG_GALLERY['nbr_column'] ? $CONFIG_GALLERY['nbr_column'] : $nbr_pics; $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1; $column_width_pics = floor(100 / $nbr_column_pics);
public function Clear_cache() { //On recupère les dossier des thèmes contenu dans le dossier images/smiley. $thumb_folder_path = new Folder('./pics/thumbnails/'); foreach ($thumb_folder_path->get_files('`\\.(png|jpg|jpeg|bmp|gif)$`i') as $thumbs) { $this->delete_file('./pics/thumbnails/' . $thumbs->get_name()); } }