function textile($text, $lite = '') { if (get_magic_quotes_gpc() == 1) { $text = stripslashes($text); } $text = incomingEntities($text); $text = encodeEntities($text); $text = fixEntities($text); $text = cleanWhiteSpace($text); $text = getRefs($text); $text = noTextile($text); $text = image($text); $text = links($text); $text = span($text); $text = superscript($text); $text = footnoteRef($text); $text = code($text); $text = glyphs($text); $text = retrieve($text); if ($lite == '') { $text = lists($text); $text = table($text); $text = block($text); } /* clean up <notextile> */ $text = preg_replace('/<\\/?notextile>/', "", $text); /* turn the temp char back to an ampersand entity */ $text = str_replace("x%x%", "&", $text); $text = str_replace("<br />", "<br />\n", $text); return trim($text); }
function cronNotify() { global $evtList; //initialize $todayT = time() + 43200; //today 12:00 $todayD00 = date("Y-m-d", $todayT); //today $todayD30 = date("Y-m-d", $todayT + 2592000); //today + 30 days $sentTo = ''; //set filter $filter = 'notify >= 0'; //retrieve and process events retrieve($todayD00, $todayD30, '', $filter); if ($evtList) { foreach ($evtList as $date => &$events) { $daysDue = round((mktime(12, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)) - $todayT) / 86400); foreach ($events as $evt) { if (($daysDue == $evt['rem'] or $date == $todayD00) and $evt['mde'] <= 1 and $evt['rml']) { //due and mail addresses to notify $sentTo .= notify($evt, $date, $daysDue) . "\n"; //send reminder email } } } } return $sentTo; }
/** * reminder post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Reminder * @author Henry Ruhs */ function reminder_post() { $emailValidator = new Redaxscript\Validator\Email(); $captchaValidator = new Redaxscript\Validator\Captcha(); /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/reminder'] == 'visited') { $email = clean($_POST['email'], 3); $task = $_POST['task']; $solution = $_POST['solution']; } /* validate post */ if ($email == '') { $error = l('email_empty'); } else { if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) { $error = l('email_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) { $error = l('captcha_incorrect'); } else { if (retrieve('id', 'users', 'email', $email) == '') { $error = l('email_unknown'); } else { /* query users */ $query = 'SELECT id, user, password FROM ' . PREFIX . 'users WHERE email = \'' . $email . '\' && status = 1'; $result = mysql_query($query); if ($result) { while ($r = mysql_fetch_assoc($result)) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } /* send reminder information */ $passwordResetRoute = ROOT . '/' . REWRITE_ROUTE . 'password_reset/' . $id . '/' . $password; $passwordResetLink = anchor_element('external', '', '', $passwordResetRoute, $passwordResetRoute); $toArray = array(s('author') => s('email')); $fromArray = array($name => $email); $subject = l('reminder'); $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password_reset') . l('colon') . '</strong> ' . $passwordResetLink); /* mailer object */ $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray); $mailer->send(); } } } } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } notification(l('error_occurred'), $error, l('back'), 'reminder'); } else { notification(l('operation_completed'), l('reminder_sent'), l('login'), 'login'); } $_SESSION[ROOT . '/reminder'] = ''; }
public function get_content() { global $LANG; load_module_lang('search'); $search = retrieve(REQUEST, 'q', ''); $tpl = new FileTemplate('search/search_mini.tpl'); $tpl->put_all(array('TEXT_SEARCHED' => !empty($search) ? stripslashes(retrieve(REQUEST, 'q', '')) : '', 'WARNING_LENGTH_STRING_SEARCH' => addslashes($LANG['warning_length_string_searched']), 'L_SEARCH' => $LANG['search'], 'U_FORM_VALID' => url(TPL_PATH_TO_ROOT . '/search/search.php#results'), 'L_ADVANCED_SEARCH' => $LANG['advanced_search'], 'U_ADVANCED_SEARCH' => url(TPL_PATH_TO_ROOT . '/search/search.php'))); return $tpl; }
function search_mini($position, $block) { global $LANG; load_module_lang('search'); $search = retrieve(REQUEST, 'q', ''); $tpl = new Template('search/search_mini.tpl'); import('core/menu_service'); MenuService::assign_positions_conditions($tpl, $block); $tpl->assign_vars(array('TITLE_SEARCH' => TITLE, 'SEARCH' => $LANG['title_search'], 'TEXT_SEARCHED' => !empty($search) ? stripslashes(retrieve(REQUEST, 'q', '')) : $LANG['search'] . '...', 'WARNING_LENGTH_STRING_SEARCH' => addslashes($LANG['warning_length_string_searched']), 'L_SEARCH' => $LANG['search'], 'U_FORM_VALID' => url(TPL_PATH_TO_ROOT . '/search/search.php#results'), 'L_ADVANCED_SEARCH' => $LANG['advanced_search'], 'U_ADVANCED_SEARCH' => url(TPL_PATH_TO_ROOT . '/search/search.php'))); return $tpl->parse(TEMPLATE_STRING_MODE); }
function handler($errstr, $errno, $errline = '', $errfile = '', $tpl_cond = '', $archive = false, $stop = true) { global $LANG; $_err_stop = retrieve(GET, '_err_stop', false); if (!empty($errstr)) { switch ($errno) { case E_TOKEN: $this->_error_log($errfile, $errline, $errno, $errstr, $archive); break; case E_USER_REDIRECT: $this->_error_log($errfile, $errline, $errno, $errstr, $archive); if (!$_err_stop) { redirect($this->redirect . '/member/error' . url('.php?e=' . $errstr . '&_err_stop=1')); } else { die($errstr); } break; case E_USER_SUCCESS: $errstr = sprintf($LANG['error_success'], $errstr, '', ''); $this->template->assign_vars(array('C_ERROR_HANDLER' . strtoupper($tpl_cond) => true, 'ERRORH_IMG' => 'success', 'ERRORH_CLASS' => 'error_success', 'L_ERRORH' => $errstr)); break; case E_USER_NOTICE: case E_NOTICE: $errstr = sprintf($LANG['error_notice_tiny'], $errstr, '', ''); $this->template->assign_vars(array('C_ERROR_HANDLER' . strtoupper($tpl_cond) => true, 'ERRORH_IMG' => 'notice', 'ERRORH_CLASS' => 'error_notice', 'L_ERRORH' => $errstr)); break; case E_USER_WARNING: case E_WARNING: $errstr = sprintf($LANG['error_warning_tiny'], $errstr, '', ''); $this->template->assign_vars(array('C_ERROR_HANDLER' . strtoupper($tpl_cond) => true, 'ERRORH_IMG' => 'important', 'ERRORH_CLASS' => 'error_warning', 'L_ERRORH' => $errstr)); break; case E_USER_ERROR: case E_ERROR: $error_id = $this->_error_log($errfile, $errline, $errno, $errstr, true); if ($stop) { if (!$_err_stop) { header('Location:' . $this->redirect . '/member/fatal.php?error=' . $error_id . '&_err_stop=1'); exit; } else { die($errstr); } } } if ($this->personal_tpl) { $this->set_default_template(); } if ($archive) { return $this->_error_log($errfile, $errline, $errno, $errstr, $archive); } return true; } }
function dir_list($path, $exts = '', $list = array()) { $path = dir_path($path); $files = glob($path . '*'); foreach ($files as $v) { if (!$exts || preg_match("/\\.({$exts})/i", $v)) { $list[] = retrieve($v); if (is_dir($v)) { $list = dir_list($v, $exts, $list); } } } return $list; }
function is_valid() { global $Sql; if (!$this->is_available()) { return true; } $get_code = retrieve(POST, 'verif_code' . $this->instance, '', TSTRING_UNCHANGE); $user_id = substr(strhash(USER_IP), 0, 13) . $this->instance; $captcha = $Sql->query_array(DB_TABLE_VERIF_CODE, 'code', 'difficulty', "WHERE user_id = '" . $user_id . "'", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_VERIF_CODE . " WHERE user_id = '" . $user_id . "'", __LINE__, __FILE__); if (!empty($captcha['code']) && $captcha['code'] == $get_code && $captcha['difficulty'] == $this->difficulty) { return true; } else { return false; } }
function get_categ($id) { $q3 = "select id,name from res_partner where id = {$id}"; $a3 = retrieve($q3); $q = "select * from res_partner_category_rel where partner_id = {$id}"; $a = retrieve($q); $c = []; $i = 0; foreach ($a as $v) { $cat = $v['category_id']; $q2 = "select id,name from res_partner_category where id = {$cat}"; $a2 = retrieve($q2); if ($i == 0) { $cstr = $a2[0]['name']; } else { $cstr .= ' / ' . $a2[0]['name']; } $i++; } return $cstr; }
function build_menu_from_form(&$elements_ids, $level = 0) { $menu = null; $menu_element_id = $elements_ids['id']; $menu_name = retrieve(POST, 'menu_element_' . $menu_element_id . '_name', '', TSTRING_UNCHANGE); $menu_url = retrieve(POST, 'menu_element_' . $menu_element_id . '_url', ''); $menu_image = retrieve(POST, 'menu_element_' . $menu_element_id . '_image', ''); $array_size = count($elements_ids); if ($array_size == 1 && $level > 0) { $menu = new LinksMenuLink($menu_name, $menu_url, $menu_image); } else { $menu = new LinksMenu($menu_name, $menu_url, $menu_image); unset($elements_ids['id']); $array_size = count($elements_ids); for ($i = 0; $i < $array_size; $i++) { $menu->add(build_menu_from_form($elements_ids[$i], $level + 1)); } } $menu->set_auth(Authorizations::build_auth_array_from_form(AUTH_MENUS, 'menu_element_' . $menu_element_id . '_auth')); return $menu; }
function build_menu_from_form($elements_ids, $level = 0) { $menu = null; $menu_element_id = $elements_ids['id']; $menu_name = retrieve(POST, 'menu_element_' . $menu_element_id . '_name', '', TSTRING_UNCHANGE); $menu_url = retrieve(POST, 'menu_element_' . $menu_element_id . '_url', ''); $menu_image = retrieve(POST, 'menu_element_' . $menu_element_id . '_image', ''); $array_size = count($elements_ids); if ($array_size == 1 && $level > 0) { // If it's a menu, there's only one element; $menu = new LinksMenuLink($menu_name, $menu_url, $menu_image); } else { $menu = new LinksMenu($menu_name, $menu_url, $menu_image); // We unset the id key of the array unset($elements_ids['id']); $array_size = count($elements_ids); for ($i = 0; $i < $array_size; $i++) { // We build all its children and add it to its father $menu->add(build_menu_from_form($elements_ids[$i], $level + 1)); } } $menu->set_auth(Authorizations::build_auth_array_from_form(Menu::MENU_AUTH_BIT, 'menu_element_' . $menu_element_id . '_auth')); return $menu; }
function DataRetrieveHandler() { global $l; $l = new llog(); global $generalAuthKey; if (authorized($generalAuthKey)) { $l->a("Started DataRetrieveHandler<br>"); $status = 0; $insertion = retrieve($_REQUEST['id']); //print_r($insertion); $status = $insertion['status']; $csum = Csum_import($insertion['csum']); if (check($status, true)) { echo $csum->len . '|' . $csum->md5 . '|' . $csum->sha . '|' . $csum->s512 . '|' . $insertion['data']; } } }
<?php require_once '../kernel/begin.php'; load_module_lang('wiki'); define('TITLE', $LANG['wiki'] . ' - ' . $LANG['wiki_search']); $bread_crumb_key = 'wiki_search'; require_once '../wiki/wiki_bread_crumb.php'; require_once '../kernel/header.php'; if (!$User->check_level(MEMBER_LEVEL)) { $Errorh->handler('e_auth', E_USER_REDIRECT); } $search_string = retrieve(GET, 'search', ''); $where_search = retrieve(GET, 'where', ''); $where_search = !(empty($where_search) || $where_search == 'contents') ? 'contents' : 'title'; $page = retrieve(GET, 'page', 1); $page = $page <= 0 ? 1 : $page; $Template->set_filenames(array('wiki_search' => 'wiki/search.tpl')); $Template->assign_vars(array('L_SEARCH' => $LANG['wiki_search'], 'L_KEY_WORDS' => $LANG['wiki_search_key_words'], 'TARGET' => url('search.php?token=' . $Session->get_token()), 'KEY_WORDS' => $search_string, 'L_SEARCH_RESULT' => $LANG['wiki_search_result'], 'ARTICLE_TITLE' => $LANG['title'], 'RELEVANCE' => $LANG['wiki_search_relevance'], 'SELECTED_TITLE' => $where_search == 'title' ? 'checked="checked"' : '', 'SELECTED_CONTENTS' => $where_search != 'title' ? 'checked="checked"' : '', 'L_TITLE' => $LANG['title'], 'L_CONTENTS' => $LANG['content'])); if (!empty($search_string)) { $title_search = "SELECT title, encoded_title, MATCH(title) AGAINST('" . $search_string . "') AS relevance\n\t\tFROM " . PREFIX . "wiki_articles\n\t\tWHERE MATCH(title) AGAINST('" . $search_string . "') \n\t\tORDER BY relevance DESC"; $contents_search = "SELECT a.title, a.encoded_title, MATCH(c.content) AGAINST('" . $search_string . "') AS relevance\n\t\tFROM " . PREFIX . "wiki_articles a\n\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id\n\t\tWHERE MATCH(c.content) AGAINST('" . $search_string . "') \n\t\tORDER BY relevance DESC"; $query = $where_search == 'title' ? $title_search : $contents_search; $query_rows = $where_search == 'title' ? "SELECT COUNT(*) FROM " . PREFIX . "wiki_articles WHERE MATCH(title) AGAINST('" . $search_string . "')" : "SELECT COUNT(*) \t\tFROM " . PREFIX . "wiki_articles a\n\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id\n\t\tWHERE MATCH(c.content) AGAINST('" . $search_string . "')"; $result = $Sql->query_while($query, __LINE__, __FILE__); $num_rows = $Sql->num_rows($result, $query_rows, __LINE__, __FILE__); import('util/pagination'); $Pagination = new Pagination(); $pages_links = $Pagination->display('search' . url('.php?search=' . $search_string . '&where=' . $where_search . '&page=%d'), $num_rows, 'page', 10, 3); if ($num_rows > 0) { $Template->assign_block_vars('search_result', array('PAGES' => !empty($pages_links) ? $pages_links : ' ')); } else {
include_once '../forum/forum.class.php'; $Forumfct = new Forum(); $Forumfct->Unlock_topic($idt_get); redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $idt_get, '-' . $idt_get . $rewrited_title . '.php', '&')); } } else { $Errorh->handler('e_auth', E_USER_REDIRECT); } } else { $Errorh->handler('e_auth', E_USER_REDIRECT); } } elseif (!empty($track) && $User->check_level(MEMBER_LEVEL)) { $Forumfct->Track_topic($track); redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $track, '-' . $track . '.php', '&') . '#go_bottom'); } elseif (!empty($untrack) && $User->check_level(MEMBER_LEVEL)) { $tracking_type = retrieve(GET, 'trt', 0); $Forumfct->Untrack_topic($untrack, $tracking_type); redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $untrack, '-' . $untrack . '.php', '&') . '#go_bottom'); } elseif (!empty($track_pm) && $User->check_level(MEMBER_LEVEL)) { include_once '../forum/forum.class.php'; $Forumfct = new Forum(); $Forumfct->Track_topic($track_pm, FORUM_PM_TRACKING); redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $track_pm, '-' . $track_pm . '.php', '&') . '#go_bottom'); } elseif (!empty($untrack_pm) && $User->check_level(MEMBER_LEVEL)) { include_once '../forum/forum.class.php'; $Forumfct = new Forum(); $Forumfct->Untrack_topic($untrack_pm, FORUM_PM_TRACKING); redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $untrack_pm, '-' . $untrack_pm . '.php', '&') . '#go_bottom'); } elseif (!empty($track_mail) && $User->check_level(MEMBER_LEVEL)) { include_once '../forum/forum.class.php'; $Forumfct = new Forum();
<?php define('NO_SESSION_LOCATION', true); require_once '../kernel/begin.php'; require_once '../kernel/header_no_display.php'; if ($User->check_level(ADMIN_LEVEL)) { require_once 'media_cats.class.php'; $media_categories = new MediaCats(); $id_up = retrieve(GET, 'id_up', 0); $id_down = retrieve(GET, 'id_down', 0); $id_show = retrieve(GET, 'show', 0); $id_hide = retrieve(GET, 'hide', 0); $cat_to_del = retrieve(GET, 'del', 0); $result = false; if ($id_up > 0) { $result = $media_categories->move($id_up, MOVE_CATEGORY_UP); } elseif ($id_down > 0) { $result = $media_categories->move($id_down, MOVE_CATEGORY_DOWN); } elseif ($id_show > 0) { $result = $media_categories->change_visibility($id_show, CAT_VISIBLE, LOAD_CACHE); } elseif ($id_hide > 0) { $result = $media_categories->change_visibility($id_hide, CAT_UNVISIBLE, LOAD_CACHE); } if ($result) { $cat_config = array('xmlhttprequest_file' => 'xmlhttprequest_cats.php', 'administration_file_name' => 'admin_media_cats.php', 'url' => array('unrewrited' => 'media.php?id=%d', 'rewrited' => 'media-%d+%s.php')); $media_categories->set_display_config($cat_config); $Cache->load('media', RELOAD_CACHE); echo $media_categories->build_administration_interface(AJAX_MODE); } } require_once '../kernel/footer_no_display.php';
private function build_view() { global $LANG, $Bread_crumb; load_module_lang('gallery'); $g_idpics = retrieve(GET, 'id', 0); $g_views = retrieve(GET, 'views', false); $g_notes = retrieve(GET, 'notes', false); $g_sort = retrieve(GET, 'sort', ''); $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : ''; //Récupération du mode d'ordonnement. if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) { $g_type = $array_match[1]; $g_mode = $array_match[2]; } else { list($g_type, $g_mode) = array('date', 'desc'); } $comments_topic = new GalleryCommentsTopic(); $config = GalleryConfig::load(); $category = $this->get_category(); $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()); $authorized_categories = GalleryService::get_authorized_categories($category->get_id()); $Gallery = new Gallery(); $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id())); $total_cat = count($categories); //On crée une pagination si le nombre de catégories est trop important. $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?p=%d&cat=' . $category->get_id() . '&id=' . $g_idpics . '&' . $g_sort)); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } //Colonnes des catégories. $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $column_width_cats = floor(100 / $nbr_column_cats); //Colonnes des images. $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics; $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1; $column_width_pics = floor(100 / $nbr_column_pics); $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL); $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation(); $module_data_path = $this->tpl->get_pictures_data_path(); $rewrite_title = Url::encode_rewrite($category->get_name()); ##### Catégorie disponibles ##### $nbr_cat_displayed = 0; if ($total_cat > 0 && empty($g_idpics)) { $this->tpl->put('C_GALLERY_CATS', true); $j = 0; $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*, (SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND aprob = 1 ) AS nbr_pics FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats WHERE id_parent = :id_category AND id IN :authorized_categories ORDER BY id_parent, c_order LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { $category_image = new Url($row['image']); $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name']))); $nbr_cat_displayed++; } $result->dispose(); } $category_description = FormatingHelper::second_parse($category->get_description()); $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s'])); ##### Affichage des photos ##### if ($nbr_pics > 0) { switch ($g_type) { case 'name': $sort_type = 'g.name'; break; case 'date': $sort_type = 'g.timestamp'; break; case 'views': $sort_type = 'g.views'; break; case 'notes': $sort_type = 'notes.average_notes'; break; case 'com': $sort_type = 'com.number_comments'; break; default: $sort_type = 'g.timestamp'; } switch ($g_mode) { case 'desc': $sort_mode = 'DESC'; break; case 'asc': $sort_mode = 'ASC'; break; default: $sort_mode = 'DESC'; } $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode; if ($g_views) { $g_sql_sort = ' ORDER BY g.views DESC'; } elseif ($g_notes) { $g_sql_sort = ' ORDER BY notes.average_notes DESC'; } $this->tpl->put('C_GALLERY_PICS', true); //Affichage d'une photo demandée. if (!empty($g_idpics)) { $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics)); if (!empty($info_pics['id'])) { $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php')); //Affichage miniatures. $id_previous = 0; $id_next = 0; $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2); //Nombres de photos de chaque côté de la miniature de la photo affichée. $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before); list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after); $array_pics = array(); $array_js = 'var array_pics = new Array();'; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature //Affichage de la liste des miniatures sous l'image. $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>'; if ($row['id'] == $g_idpics) { $reach_pics_pos = true; $pos_pics = $i; } else { if (!$reach_pics_pos) { $thumbnails_before++; $id_previous = $row['id']; } else { $thumbnails_after++; if (empty($id_next)) { $id_next = $row['id']; } } } $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n"; $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n"; $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n"; $i++; } $result->dispose(); $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); if ($activ_note) { //Affichage notation. $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_id_in_module($info_pics['id']); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_number_notes($info_pics['number_notes']); $notation->set_average_notes($info_pics['average_notes']); $notation->set_user_already_noted(!empty($info_pics['note'])); } if ($thumbnails_before < $nbr_pics_display_before) { $end_thumbnails += $nbr_pics_display_before - $thumbnails_before; } if ($thumbnails_after < $nbr_pics_display_after) { $start_thumbnails += $nbr_pics_display_after - $thumbnails_after; } $html_protected_name = $info_pics['name']; $comments_topic->set_id_in_module($info_pics['id']); $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0')); //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']); //Affichage de l'image et de ses informations. $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&cat=' . $info_pics['idcat'])); //Affichage de la liste des miniatures sous l'image. $i = 0; foreach ($array_pics as $pics) { if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) { $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics)); } $i++; } //Commentaires if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) { $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } } } else { $sort = retrieve(GET, 'sort', ''); //On crée une pagination si le nombre de photos est trop important. $page = AppContext::get_request()->get_getint('pp', 1); $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&sort=' . $sort : '') . '&cat=' . $category->get_id())); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views'])); $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); $j = 0; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature $onclick = ''; //Affichage de l'image en grand. if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) { $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name'])); } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) { $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;'; $display_link = ''; } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) { $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\');return false;'; $display_link = ''; } else { $onclick = true; $display_link = url('gallery.php?cat=' . $row['idcat'] . '&id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max'; } //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($row['id']); $notation->set_number_notes($row['number_notes']); $notation->set_average_notes($row['average_notes']); $notation->set_user_already_noted(!empty($row['note'])); $group_color = User::get_group_color($row['groups'], $row['level']); $comments_topic->set_id_in_module($row['id']); $html_protected_name = $row['name']; $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list')); } $result->dispose(); //Création des cellules du tableau si besoin est. while (!is_int($j / $nbr_column_pics)) { $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%"> </td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : '')); } } } }
<?php require_once '../kernel/begin.php'; load_module_lang('wiki'); include '../wiki/wiki_functions.php'; $article_id = retrieve(GET, 'id', 0); if ($article_id > 0) { $result = $Sql->query_while("SELECT a.id, a.is_cat, a.hits, a.redirect, a.id_cat, a.title, a.encoded_title, a.is_cat, a.defined_status, a.nbr_com, f.id AS id_favorite, a.undefined_status, a.auth, c.menu, c.content\n\tFROM " . PREFIX . "wiki_articles a\n\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\n\tLEFT JOIN " . PREFIX . "wiki_favorites f ON f.id_article = a.id\n\tWHERE a.id = '" . $article_id . "'\n\tGROUP BY a.id", __LINE__, __FILE__); $num_rows = $Sql->num_rows($result, "SELECT COUNT(*) FROM " . PREFIX . "wiki_articles WHERE id = '" . $article_id . "'", __LINE__, __FILE__); $article_infos = $Sql->fetch_assoc($result); $Sql->query_close($result); if (!empty($article_infos['redirect'])) { $id_redirection = $article_infos['id']; $result = $Sql->query_while("SELECT a.id, a.is_cat, a.hits, a.redirect, a.id_cat, a.title, a.encoded_title, a.is_cat, a.nbr_com, a.defined_status, f.id AS id_favorite, a.undefined_status, a.auth, c.menu, c.content\n\t\tFROM " . PREFIX . "wiki_articles a\n\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\n\t\tLEFT JOIN " . PREFIX . "wiki_favorites f ON f.id_article = a.id\n\t\tWHERE a.id = '" . $article_infos['redirect'] . "'\n\t\tGROUP BY a.id", __LINE__, __FILE__); $article_infos = $Sql->fetch_assoc($result); $Sql->query_close($result); } } if (empty($article_infos['id'])) { exit; } require_once PATH_TO_ROOT . '/kernel/header_no_display.php'; $template = new Template('framework/content/print.tpl'); $template->assign_vars(array('PAGE_TITLE' => $article_infos['title'] . (!empty($_WIKI_CONFIG['wiki_name']) ? $_WIKI_CONFIG['wiki_name'] : $LANG['wiki']), 'TITLE' => $article_infos['title'], 'L_XML_LANGUAGE' => $LANG['xml_lang'], 'CONTENT' => second_parse($article_infos['content']))); $template->parse(); require_once PATH_TO_ROOT . '/kernel/footer_no_display.php';
require_once '../admin/admin_header.php'; import('members/uploads'); $Uploads = new Uploads(); $folder = retrieve(GET, 'f', 0); $folder_member = retrieve(GET, 'fm', 0); $parent_folder = retrieve(GET, 'fup', 0); $home_folder = !empty($_GET['root']) ? true : false; $del_folder = retrieve(GET, 'delf', 0); $empty_folder = retrieve(GET, 'eptf', 0); $del_file = retrieve(GET, 'del', 0); $get_error = retrieve(GET, 'error', ''); $get_l_error = retrieve(GET, 'erroru', ''); $show_member = !empty($_GET['showm']) ? true : false; $move_folder = retrieve(GET, 'movefd', 0); $move_file = retrieve(GET, 'movefi', 0); $to = retrieve(POST, 'new_cat', -1); if (isset($_GET['fup'])) { $parent_folder = $Sql->query_array(PREFIX . "upload_cat", "id_parent", "user_id", "WHERE id = '" . $parent_folder . "'", __LINE__, __FILE__); if (!empty($folder_member)) { redirect(HOST . DIR . '/admin/admin_files.php?showm=1'); } elseif ($parent_folder['user_id'] != -1 && empty($parent_folder['id_parent'])) { redirect(HOST . DIR . '/admin/admin_files.php?fm=' . $parent_folder['user_id']); } else { redirect(HOST . DIR . '/admin/admin_files.php?f=' . $parent_folder['id_parent']); } } elseif ($home_folder) { redirect(HOST . DIR . '/admin/admin_files.php'); } elseif (!empty($_FILES['upload_file']['name']) && isset($_GET['f'])) { @clearstatcache(); $dir = '../upload/'; if (!is_writable($dir)) {
<?php //include serverinfo include "../php/servinfo.php"; include "../php/dbfunctions.php"; if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; $args = $_POST['args']; switch ($action) { // ---------------- RETRIEVE AND SUBMIT EXPENSE SUBMISSIONS case 'retrieve': if (argsLen($args, 1)) { retrieve($args[0]); } else { incorrect(); } break; case 'submit': if (argsLen($args, 7)) { submit($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]); } else { incorrect(); } break; // ----------------- GET EMPLOYEE INFORMATION // ----------------- GET EMPLOYEE INFORMATION case 'getPhone': if (argsLen($args, 1)) { getPhone($args[0]); } else { incorrect();
$editor->set_identifier('contents'); $tpl->put_all(array('KERNEL_EDITOR' => $editor->display(), 'L_ALERT' => $LANG['alert_topic'], 'L_ALERT_EXPLAIN' => $LANG['alert_modo_explain'], 'L_ALERT_TITLE' => $LANG['alert_title'], 'L_ALERT_CONTENTS' => $LANG['alert_contents'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_REQUIRE_TEXT' => $LANG['require_text'], 'L_REQUIRE_TITLE' => $LANG['require_title'])); $tpl->assign_block_vars('alert_form', array('TITLE' => $topic_name, 'U_TOPIC' => 'topic' . url('.php?id=' . $alert, '-' . $alert . '-' . Url::encode_rewrite($topic_name) . '.php'), 'ID_ALERT' => $alert)); } else { $tpl->put_all(array('L_ALERT' => $LANG['alert_topic'], 'L_BACK_TOPIC' => $LANG['alert_back'], 'URL_TOPIC' => 'topic' . url('.php?id=' . $alert, '-' . $alert . '-' . Url::encode_rewrite($topic_name) . '.php'))); $tpl->assign_block_vars('alert_confirm', array('MSG' => $LANG['alert_topic_already_done'])); } } //Si on enregistre une alerte if (!empty($alert_post)) { $tpl->put_all(array('L_ALERT' => $LANG['alert_topic'], 'L_BACK_TOPIC' => $LANG['alert_back'], 'URL_TOPIC' => 'topic' . url('.php?id=' . $alert_post, '-' . $alert_post . '-' . Url::encode_rewrite($topic_name) . '.php'))); //On vérifie qu'une alerte sur le même sujet n'ait pas été postée $nbr_alert = PersistenceContext::get_querier()->count(PREFIX . 'forum_alerts', 'WHERE idtopic=:idtopic AND status = 0', array('idtopic' => $alert_post)); if (empty($nbr_alert)) { $alert_title = retrieve(POST, 'title', ''); $alert_contents = retrieve(POST, 'contents', '', TSTRING_PARSE); //Instanciation de la class du forum. $Forumfct = new Forum(); $Forumfct->Alert_topic($alert_post, $alert_title, $alert_contents); $tpl->assign_block_vars('alert_confirm', array('MSG' => str_replace('%title', $topic_name, $LANG['alert_success']))); } else { $tpl->assign_block_vars('alert_confirm', array('MSG' => $LANG['alert_topic_already_done'])); } } //Listes les utilisateurs en lignes. list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script LIKE '/forum/%'"); $vars_tpl = array('FORUM_NAME' => $config->get_forum_name() . ' : ' . $LANG['alert_topic'], 'DESC' => $topic['subtitle'], 'C_USER_CONNECTED' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'TOTAL_ONLINE' => $total_online, 'USERS_ONLINE' => $total_online - $total_visit == 0 ? '<em>' . $LANG['no_member_online'] . '</em>' : $users_list, 'ADMIN' => $total_admin, 'MODO' => $total_modo, 'MEMBER' => $total_member, 'GUEST' => $total_visit, 'U_FORUM_CAT' => '<a href="forum' . url('.php?id=' . $topic['idcat'], '-' . $topic['idcat'] . '.php') . '">' . $category->get_name() . '</a>', 'U_TITLE_T' => '<a href="topic' . url('.php?id=' . $topic_id, '-' . $topic_id . '.php') . '">' . stripslashes($topic['title']) . '</a>', 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_SUBMIT' => $LANG['submit'], 'L_PREVIEW' => $LANG['preview'], 'L_RESET' => $LANG['reset'], 'L_USER' => $total_online > 1 ? $LANG['user_s'] : $LANG['user'], 'L_ADMIN' => $total_admin > 1 ? $LANG['admin_s'] : $LANG['admin'], 'L_MODO' => $total_modo > 1 ? $LANG['modo_s'] : $LANG['modo'], 'L_MEMBER' => $total_member > 1 ? $LANG['member_s'] : $LANG['member'], 'L_GUEST' => $total_visit > 1 ? $LANG['guest_s'] : $LANG['guest'], 'L_AND' => $LANG['and'], 'L_ONLINE' => strtolower($LANG['online'])); $tpl->put_all($vars_tpl); $tpl_top->put_all($vars_tpl); $tpl_bottom->put_all($vars_tpl); $tpl->put('forum_top', $tpl_top);
define('ALTERNATIVE_CSS', 'wiki'); $bread_crumb_key = 'wiki_post'; require_once '../wiki/wiki_bread_crumb.php'; $is_cat = retrieve(POST, 'is_cat', false) ? 1 : 0; $is_cat_get = retrieve(GET, 'type', '') == 'cat' ? 1 : 0; $is_cat = $is_cat > 0 ? $is_cat : $is_cat_get; $id_edit = retrieve(POST, 'id_edit', 0); $title = retrieve(POST, 'title', ''); $encoded_title = retrieve(GET, 'title', ''); $contents = wiki_parse(retrieve(POST, 'contents', '', TSTRING_AS_RECEIVED)); $contents_preview = htmlspecialchars(retrieve(POST, 'contents', '', TSTRING_UNCHANGE), ENT_COMPAT, 'ISO-8859-1'); $id_cat = retrieve(GET, 'id_parent', 0); $new_id_cat = retrieve(POST, 'id_cat', 0); $id_cat = $id_cat > 0 ? $id_cat : $new_id_cat; $preview = !empty($_POST['preview']) ? true : false; $id_edit_get = retrieve(GET, 'id', 0); $id_edit = $id_edit > 0 ? $id_edit : $id_edit_get; require_once '../kernel/header.php'; $error = ''; if (!empty($contents)) { include_once '../wiki/wiki_functions.php'; $menu = ''; if (preg_match('`[\\-]{2,6}`isU', $contents)) { $menu_list = wiki_explode_menu($contents); $menu = wiki_display_menu($menu_list); } if ($preview) { $Template->assign_block_vars('preview', array('CONTENTS' => second_parse(wiki_no_rewrite(stripslashes($contents))), 'TITLE' => stripslashes($title))); if (!empty($menu)) { $Template->assign_block_vars('preview.menu', array('MENU' => $menu)); }
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ require_once '../kernel/begin.php'; require_once 'pages_defines.php'; //Titre de l'article à afficher en version imprimable $encoded_title = retrieve(GET, 'title', '', TSTRING); $pages_config = PagesConfig::load(); if (!empty($encoded_title)) { try { $page_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'pages', array('id', 'title', 'auth', 'is_cat', 'id_cat', 'hits', 'count_hits', 'activ_com', 'redirect', 'contents'), 'WHERE encoded_title = :encoded_title', array('encoded_title' => $encoded_title)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $num_rows = !empty($page_infos['title']) ? 1 : 0; if ($page_infos['redirect'] > 0) { $redirect_title = stripslashes($page_infos['title']); $redirect_id = $page_infos['id']; try { $page_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'pages', array('id', 'title', 'auth', 'is_cat', 'id_cat', 'hits', 'count_hits', 'activ_com', 'redirect', 'contents'), 'WHERE id = :id', array('id' => $page_infos['redirect'])); } catch (RowNotFoundException $e) {
$title = retrieve(POST, 'title', ''); $subtitle = retrieve(POST, 'desc', ''); $contents = retrieve(POST, 'contents', '', TSTRING_PARSE); $type = retrieve(POST, 'type', 0); if (!empty($to) && !empty($contents) && !empty($title)) { include_once '../forum/forum.class.php'; $Forumfct = new Forum(); $last_topic_id = $Forumfct->Cut_topic($id_post_msg, $msg['idtopic'], $topic['idcat'], $to, $title, $subtitle, $contents, $type, $msg['user_id'], $topic['last_user_id'], $topic['last_msg_id'], $topic['last_timestamp']); $question = retrieve(POST, 'question', ''); if (!empty($question)) { $poll_type = retrieve(POST, 'poll_type', 0); $poll_type = $poll_type == 0 || $poll_type == 1 ? $poll_type : 0; $answers = array(); $nbr_votes = 0; for ($i = 0; $i < 20; $i++) { $answer = str_replace('|', '', retrieve(POST, 'a' . $i, '')); if (!empty($answer)) { $answers[$i] = $answer; $nbr_votes++; } } $Forumfct->Add_poll($last_topic_id, $question, $answers, $nbr_votes, $poll_type); } redirect(HOST . DIR . '/forum/topic' . url('.php?id=' . $last_topic_id, '-' . $last_topic_id . '.php', '&')); } else { redirect(url(HOST . SCRIPT . '?error=false_t&idm=' . $id_post_msg, '', '&') . '#errorh'); } } else { $Errorh->handler('e_incomplete', E_USER_REDIRECT); } } else {
/** * @desc Retrieves a date entered in a mini calendar. * @param string $calendar_name Name of the calendar (HTML identifier). * @return Date The date of the calendar. */ public static function retrieve_date($calendar_name) { return new Date(retrieve(REQUEST, $calendar_name, '', TSTRING_UNCHANGE)); }
unset($cats[0]); } $current_cat = ''; $nbr_cats = count($cats); $i = 1; foreach ($cats as $key => $value) { $current_cat .= $_WIKI_CATS[$value]['name'] . ($i < $nbr_cats ? ' / ' : ''); $i++; } if ($article_infos['id_cat'] > 0) { $current_cat .= ($nbr_cats > 0 ? ' / ' : '') . $_WIKI_CATS[$article_infos['id_cat']]['name']; } else { $current_cat = $LANG['wiki_no_selected_cat']; } $Template->assign_block_vars('remove', array('L_TITLE' => sprintf($LANG['wiki_remove_this_cat'], $article_infos['title']), 'L_REMOVE_ALL_CONTENTS' => $LANG['wiki_remove_all_contents'], 'L_MOVE_ALL_CONTENTS' => $LANG['wiki_move_all_contents'], 'ID_ARTICLE' => $del_article, 'CATS' => $cat_list, 'CURRENT_CAT' => $current_cat, 'SELECTED_CAT' => $article_infos['id_cat'], 'CAT_0' => $article_infos['id_cat'] == 0 ? 'wiki_selected_cat' : '', 'ID_CAT' => $article_infos['id_cat'])); $error = retrieve(GET, 'error', ''); if ($error == 'e_cat_contains_cat') { $errstr = $LANG['wiki_cat_contains_cat']; } elseif ($error == 'e_not_a_cat') { $errstr = $LANG['wiki_not_a_cat']; } else { $errstr = ''; } if (!empty($errstr)) { $Errorh->handler($errstr, E_USER_WARNING); } } } else { redirect(HOST . DIR . '/wiki/' . url('wiki.php')); } $content_editor = new ContentFormattingFactory(BBCODE_LANGUAGE);
echo "<h4 class='floatC'><a class='noPrint' href='index.php?lc&cD={$sDoLastW}'> ◀ </a>{$header}<a class='noPrint' href='index.php?lc&cD={$sDoNextW}'> ▶ </a></h4>\n"; $cWidth = round(98 / strlen($days), 1) . '%'; /* display day headers */ echo "<div" . ($_SESSION['mobile'] ? '' : " class='scrollBoxHead'") . ">\n"; echo "<table class='grid'>\n\t<tr><th class='tCol'>{$xx['vws_time']}</th>\n"; for ($i = 0; $i < 7; $i++) { $cTime = mktime(12, 0, 0, $m, $sDow + $i, $y); //current time if (strpos($days, date("N", $cTime)) !== false) { $sDate = date("Y-m-d", $cTime); echo "<th class='dCol point' style='width:{$cWidth}' onclick=\"goDay('{$sDate}');\" title=\"{$xx['vws_view_day']}\">" . makeD($sDate, $_SESSION['mobile'] ? 1 : 4, 'xs') . "</th>\n"; } } echo "</tr>\n</table>\n\t</div>"; /* retrieve events */ retrieve($sDayOfWk, $sDoNextW, 'guc'); /* display days */ echo "<div" . ($_SESSION['mobile'] ? '' : " class='scrollBoxWe'") . ">\n"; echo "<table class='grid'>\n\t<tr><td class='tCol tColBg'>\n"; showHours(); echo "</td>\n"; for ($i = 0; $i < 7; $i++) { $cTime = mktime(12, 0, 0, $m, $sDow + $i, $y); //current time $cDate = date("Y-m-d", $cTime); //current date if (strpos($days, date("N", $cTime)) !== false) { $dayBg = ''; $curSeq = 0; if (!empty($evtList[$cDate])) { //check day background should be set
} $menu->set_auth(Authorizations::build_auth_array_from_form(Menu::MENU_AUTH_BIT)); //Filters MenuAdminService::set_retrieved_filters($menu); MenuService::move($menu, $menu->get_block()); MenuService::generate_cache(); AppContext::get_response()->redirect('menus.php#m' . $menu->get_id()); } // Display the Menu administration $edit = !empty($id); include 'lateral_menu.php'; lateral_menu(); $tpl = new FileTemplate('admin/menus/feed.tpl'); $tpl->put_all(array('L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'JL_REQUIRE_NAME' => TextHelper::to_js_string($LANG['require_name']), 'JL_REQUIRE_FEED' => TextHelper::to_js_string($LANG['choose_feed_in_list']), 'JL_REQUIRE_ITEMS_NUMBER' => TextHelper::to_js_string($LANG['require_items_number']), 'L_FEED' => $LANG['feed'], 'L_AVAILABLES_FEEDS' => $LANG['availables_feeds'], 'L_NAME' => $LANG['name'], 'L_STATUS' => $LANG['status'], 'L_HIDDEN_WITH_SMALL_SCREENS' => $LANG['hidden_with_small_screens'], 'L_AUTHS' => $LANG['auths'], 'L_ENABLED' => LangLoader::get_message('enabled', 'common'), 'L_DISABLED' => LangLoader::get_message('disabled', 'common'), 'L_GUEST' => $LANG['guest'], 'L_USER' => $LANG['member'], 'L_MODO' => $LANG['modo'], 'L_ADMIN' => $LANG['admin'], 'L_LOCATION' => $LANG['location'], 'L_ACTION_MENUS' => $edit ? $LANG['menus_edit'] : LangLoader::get_message('add', 'common'), 'L_ACTION' => $edit ? $LANG['update'] : $LANG['submit'], 'L_RESET' => $LANG['reset'], 'ACTION' => 'save')); //Localisation possibles. $block = retrieve(GET, 's', Menu::BLOCK_POSITION__HEADER, TINTEGER); $array_location = array(Menu::BLOCK_POSITION__HEADER => $LANG['menu_header'], Menu::BLOCK_POSITION__SUB_HEADER => $LANG['menu_subheader'], Menu::BLOCK_POSITION__LEFT => $LANG['menu_left'], Menu::BLOCK_POSITION__TOP_CENTRAL => $LANG['menu_top_central'], Menu::BLOCK_POSITION__BOTTOM_CENTRAL => $LANG['menu_bottom_central'], Menu::BLOCK_POSITION__RIGHT => $LANG['menu_right'], Menu::BLOCK_POSITION__TOP_FOOTER => $LANG['menu_top_footer'], Menu::BLOCK_POSITION__FOOTER => $LANG['menu_footer']); $feed_url = ''; if ($edit) { $menu = MenuService::load($id); if (!$menu instanceof FeedMenu) { AppContext::get_response()->redirect('menus.php'); } $block = $menu->get_block(); $feed_url = $menu->get_url(true); $tpl->put_all(array('IDMENU' => $id, 'NAME' => $menu->get_title(), 'ITEMS_NUMBER' => $menu->get_number(), 'AUTH_MENUS' => Authorizations::generate_select(Menu::MENU_AUTH_BIT, $menu->get_auth()), 'C_MENU_HIDDEN_WITH_SMALL_SCREENS' => $menu->is_hidden_with_small_screens(), 'C_ENABLED' => $menu->is_enabled(), 'C_EDIT' => true)); } else { $tpl->put_all(array('C_NEW' => true, 'C_ENABLED' => true, 'ITEMS_NUMBER' => 10, 'AUTH_MENUS' => Authorizations::generate_select(Menu::MENU_AUTH_BIT, array(), array(-1 => true, 0 => true, 1 => true, 2 => true)))); // Create a new generic menu $menu = new FeedMenu('', '', ''); }
function makeFile() { global $ax, $evtList, $set, $fileName, $fileDes, $usrName, $catName, $fromDda, $fromMda, $tillDda, $tillMda; $icsHead = "BEGIN:VCALENDAR\r\n"; $icsHead .= "VERSION:2.0\r\n"; $icsHead .= "METHOD:PUBLISH\r\n"; $icsHead .= "PRODID:- // LuxCal " . LCV . " // {$set['calendarTitle']} // EN\r\n"; $icsHead .= "X-LC-CONTENT:user: "******"all"); $icsHead .= " // cat: " . ($catName != '*' ? $catName : "all"); $icsHead .= " // due: " . ($fromDda ? $fromDda : "begin") . " - " . ($tillDda ? $tillDda : "end"); $icsHead .= " // mod: " . ($fromMda ? $fromMda : "begin") . " - " . ($tillMda ? $tillMda : "end") . "\r\n"; $icsHead .= "X-WR-CALNAME:" . ($fileDes ? htmlspecialchars_decode($fileDes, ENT_QUOTES) : "Events") . "\r\n"; $icsHead .= "X-WR-TIMEZONE:" . date_default_timezone_get() . "\r\n"; $icsHead .= "CALSCALE:GREGORIAN\r\n"; //set event filter $filter = $usrName != '*' ? " AND u.user_name = '{$usrName}'" : ''; if ($catName != '*') { $filter .= " AND c.name = '{$catName}'"; } if ($fromMda) { $filter .= " AND SUBSTR(e.m_datetime,1,10) >= '{$fromMda}'"; } if ($tillMda) { $filter .= " AND SUBSTR(e.m_datetime,1,10) <= '{$tillMda}'"; } //set event date range $sRange = $fromDda ? $fromDda : date('Y-m-d', time() - 31536000); //-1 year $eRange = $tillDda ? $tillDda : date('Y-m-d', time() + 31536000); //+1 year retrieve($sRange, $eRange, '', substr($filter, 5)); //grab events if (count($evtList) == 0) { return $ax['iex_no_events_found']; } $icsBody = ''; $from = array(',', ';', '<br>'); $to = array('\\,', '\\;', '\\n'); $eidDone = array(); //events processed foreach ($evtList as $evtListDate) { foreach ($evtListDate as $evt) { if (!in_array($evt['eid'], $eidDone)) { //event not yet processed $vDescription = str_replace($from, $to, htmlspecialchars_decode(makeE($evt, $set['evtTemplGen'], 'br', '\\n', '345'), ENT_QUOTES)); $vDescription = chunk_split_unicode($vDescription, 72, "\r\n "); //fold to 72 chars line length //compile DTSTART and DTEND values $dateS = str_replace('-', '', $evt['sda']); $dateE = $evt['eda'][0] != '9' ? str_replace('-', '', $evt['eda']) : $dateS; $timeS = str_replace(':', '', $evt['sti']); $timeE = str_replace(':', '', $evt['eti']); if ($timeS == '' and $timeE == '') { //all day $allDay = true; $dateE = date('Ymd', mktime(12, 0, 0, substr($dateE, 4, 2), substr($dateE, 6, 2) + 1, substr($dateE, 0, 4))); //+1 day } else { $allDay = false; $dateS .= 'T' . $timeS . '00'; $dateE .= 'T' . ($timeE ? $timeE . '00' : $timeS . '01'); } //compile RRULE property $rrule = ''; if ($evt['r_t'] == 1) { //every 1|2|3|4 d|w|m|y $rrule .= "FREQ="; switch ($evt['r_p']) { case 1: $rrule .= 'DAILY'; break; case 2: $rrule .= 'WEEKLY'; break; case 3: $rrule .= 'MONTHLY'; break; case 4: $rrule .= 'YEARLY'; } $rrule .= ";INTERVAL=" . $evt['r_i']; } if ($evt['r_t'] == 2) { //every 1|2|3|4|5 m|t|w|t|f|s|s of the month $rrule .= $evt['r_m'] ? "FREQ=YEARLY" : "FREQ=MONTHLY"; $rrule .= ";BYDAY=" . ($evt['r_i'] != 5 ? $evt['r_i'] : '-1'); switch ($evt['r_p']) { case 1: $rrule .= 'MO'; break; case 2: $rrule .= 'TU'; break; case 3: $rrule .= 'WE'; break; case 4: $rrule .= 'TH'; break; case 5: $rrule .= 'FR'; break; case 6: $rrule .= 'SA'; break; case 7: $rrule .= 'SU'; } if ($evt['r_m']) { $rrule .= ";BYMONTH=" . $evt['r_m']; } } if ($evt['r_u'][0] != '9') { $rrule .= ";UNTIL=" . str_replace('-', '', $evt['r_u']) . 'T235900'; } $tStamp = mktime(substr($timeS, 0, 2), substr($timeS, 2, 2), 0, substr($dateS, 4, 2), substr($dateS, 6, 2), substr($dateS, 0, 4)); $icsBody .= "BEGIN:VEVENT\r\n"; $icsBody .= "DTSTAMP:" . gmdate('Ymd\\THis\\Z') . "\r\n"; if ($evt['adt']) { $icsBody .= "CREATED:" . gmdate('Ymd\\THis\\Z', mktime(substr($evt['adt'], 11, 2), substr($evt['adt'], 14, 2), 0, substr($evt['adt'], 5, 2), substr($evt['adt'], 8, 2) + 1, substr($evt['adt'], 0, 4))) . "\r\n"; } if ($evt['mdt']) { $icsBody .= "LAST-MODIFIED:" . gmdate('Ymd\\THis\\Z', mktime(substr($evt['mdt'], 11, 2), substr($evt['mdt'], 14, 2), 0, substr($evt['mdt'], 5, 2), substr($evt['mdt'], 8, 2) + 1, substr($evt['mdt'], 0, 4))) . "\r\n"; } $icsBody .= "UID:" . gmdate("Ymd\\THis\\Z", $tStamp) . trim(substr(iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $evt['tit']), 0, 4)) . "-LuxCal@{$set['calendarUrl']}\r\n"; $icsBody .= "SUMMARY:" . str_replace(",", "\\,", htmlspecialchars_decode($evt['tit'], ENT_QUOTES)) . "\r\n"; if ($vDescription) { $icsBody .= "DESCRIPTION:{$vDescription}\r\n"; } $icsBody .= "CATEGORIES:" . str_replace(",", "\\,", $evt['cnm']) . "\r\n"; if ($evt['ven']) { $icsBody .= "LOCATION:" . str_replace(",", "\\,", htmlspecialchars_decode($evt['ven'], ENT_QUOTES)) . "\r\n"; } if ($rrule) { $icsBody .= "RRULE:{$rrule}\r\n"; } $icsBody .= "DTSTART;" . ($allDay ? "VALUE=DATE" : "TZID=" . date_default_timezone_get()) . ":{$dateS}\r\n"; $icsBody .= "DTEND;" . ($allDay ? "VALUE=DATE" : "TZID=" . date_default_timezone_get()) . ":{$dateE}\r\n"; //+1 ? $icsBody .= "END:VEVENT\r\n"; $eidDone[] = $evt['eid']; //mark as processed } } } $icsTail = "END:VCALENDAR"; //save to iCal file $icalfName = $fileName ? $fileName : $set['calendarTitle']; $icalfName = translit($icalfName, true); if (file_put_contents("./files/{$icalfName}.ics", $icsHead . $icsBody . $icsTail, LOCK_EX) !== false) { $result = $ax['iex_file_created']; } else { $result = $ax['iex_write error']; } return $result; }
$storage = createStorage(createFactory(), $test); $session = retrieve($storage, $test, $sessionId, $averageRetrieve); neighbourhood($session, $averageNeighbourhood); attempt($session, 'ChoiceA', $effectiveAverageAttempt); moveNext($session, $averageNext); persist($storage, $session, $averagePersist); $end = microtime(); unset($session); unset($storage); unset($test); echo "Retrieving session + attempt 3 + persistance (" . spentTime($start, $end, $averageAttempt) . ")\n"; // Retrieving session + make an attemp + persistance. $start = microtime(); $test = loadTestDefinition($averageLoad); $storage = createStorage(createFactory(), $test); $session = retrieve($storage, $test, $sessionId, $averageRetrieve); neighbourhood($session, $averageNeighbourhood); attempt($session, 'ChoiceA', $effectiveAverageAttempt); moveNext($session, $averageNext); persist($storage, $session, $averagePersist); $end = microtime(); unset($session); unset($storage); unset($test); echo "Retrieving session + attempt 4 + persistance (" . spentTime($start, $end, $averageAttempt) . ")\n\n"; echo "Average attempt time = " . array_sum($averageAttempt) / count($averageAttempt) . "\n"; echo "Effective average attempt time = " . array_sum($effectiveAverageAttempt) / count($effectiveAverageAttempt) . "\n"; echo "Retrieve average time = " . array_sum($averageRetrieve) / count($averageRetrieve) . "\n"; echo "Persist average time = " . array_sum($averagePersist) / count($averagePersist) . "\n"; echo "MoveNext average time = " . array_sum($averageNext) / count($averageNext) . "\n"; echo "Load average time = " . array_sum($averageLoad) / count($averageLoad) . "\n";
function searchText() { global $xx, $set, $schText, $eF, $catName, $fromDda, $tillDda; //set event filter $schTextEsc = '%' . mysql_real_escape_string($schText) . '%'; $schTextEsc = str_replace('&', '%', $schTextEsc); //prepare description filter $filter = ''; if ($catName != '*') { $filter .= " AND c.name = '" . mysql_real_escape_string($catName) . "'"; } $filter .= " AND ("; if (in_array(0, $eF) or in_array(1, $eF)) { $filter .= "e.title LIKE '{$schTextEsc}'"; } //Title if (in_array(0, $eF) or in_array(2, $eF)) { $filter .= (substr($filter, -1) == '(' ? '' : ' OR ') . "e.venue LIKE '{$schTextEsc}'"; } //venue if (in_array(0, $eF) or in_array(3, $eF)) { $filter .= (substr($filter, -1) == '(' ? '' : ' OR ') . "e.description LIKE '{$schTextEsc}'"; } //description if (in_array(0, $eF) or in_array(4, $eF)) { $filter .= (substr($filter, -1) == '(' ? '' : ' OR ') . "e.xfield1 LIKE '{$schTextEsc}'"; } //extra field 1 if (in_array(0, $eF) or in_array(5, $eF)) { $filter .= (substr($filter, -1) == '(' ? '' : ' OR ') . "e.xfield2 LIKE '{$schTextEsc}'"; } //extra field 2 $filter = substr($filter, 5) . ")"; //set event date range $sDate = $fromDda ? $fromDda : date('Y-m-d', time() - 31536000); //-1 year $eDate = $tillDda ? $tillDda : date('Y-m-d', time() + 31536000); //+1 year retrieve($sDate, $eDate, '', $filter); //grab events //display header $fields = ''; if (in_array(0, $eF) or in_array(1, $eF)) { $fields = ' + ' . $xx['sch_title']; } foreach (str_split($set['evtTemplGen']) as $fieldNr) { if (strpos('1345', $fieldNr) !== false) { switch ($fieldNr) { case '1': if (in_array(0, $eF) or in_array(2, $eF)) { $fields .= ' + ' . $xx['sch_venue']; } break; case '3': if (in_array(0, $eF) or in_array(3, $eF)) { $fields .= ' + ' . $xx['sch_description']; } break; case '4': if (in_array(0, $eF) or in_array(4, $eF)) { $fields .= ' + ' . ($set['xField1'] ? "{$set['xField1']}" : $xx['sch_extra_field1']); } break; case '5': if (in_array(0, $eF) or in_array(5, $eF)) { $fields .= ' + ' . ($set['xField2'] ? "{$set['xField2']}" : $xx['sch_extra_field2']); } } } } $fields = substr($fields, 3); echo "<div class='subHead'>\n\t\t<form id='event' name='event' action='index.php?lc' method='post'>\n\t\t<input type='hidden' name='schText' value=\"{$schText}\">\n"; foreach ($eF as $key => $value) { echo "<input type='hidden' name='eF[]' value=\"{$value}\">\n"; } echo "<input type='hidden' name='catName' value=\"{$catName}\">\n\t\t<input type='hidden' name='fromDda' value='" . IDtoDD($fromDda) . "'>\n\t\t<input type='hidden' name='tillDda' value='" . IDtoDD($tillDda) . "'>\n\t\t<input class='floatR noPrint' type='submit' name='newSearch' value=\"{$xx['sch_new_search']}\">\n\t\t</form>\n\t\t{$xx['sch_search_text']}: <b>{$schText}</b><br>\n\t\t{$xx['sch_event_fields']}: <b>{$fields}</b><br>\n\t\t{$xx['sch_event_cat']}: <b>" . ($catName != '*' ? $catName : $xx['sch_all_cats']) . "</b><br>\n\t\t{$xx['sch_occurring_between']}: <b>" . makeD($sDate, 2) . " - " . makeD($eDate, 2) . "</b>\n\t\t</div>\n"; }