/** * Underscored and lowercased class name of an object, of the form "my.mamespace.my_class" * @param object|string $object * @return string */ function underscore($object) { return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', canonical($object))); }
function C14NGeneral($element, $exclusive = FALSE, $withcomments = FALSE) { /* IF PHP 5.2+ then use built in canonical functionality */ $php_version = explode('.', PHP_VERSION); if ($php_version[0] > 5 || $php_version[0] == 5 && $php_version[1] >= 2) { return $element->C14N($exclusive, $withcomments); } /* Must be element or document */ if (!$element instanceof DOMElement && !$element instanceof DOMDocument) { return NULL; } /* Currently only exclusive XML is supported */ if ($exclusive == FALSE) { throw new Exception("Only exclusive canonicalization is supported in this version of PHP"); } $copyDoc = new DOMDocument(); canonical($copyDoc, $element, $withcomments); return $copyDoc->saveXML($copyDoc->documentElement, LIBXML_NOEMPTYTAG); }
foreach ($languages as $language_id => $language_code) { $sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/category', 'category_id=' . $category->category_id)), '0.9', 'daily', $category->date_modified); } } } // Generate product links $statement = $db->query('SELECT `product_id`, `date_modified` FROM `product` WHERE `status` = 1'); if ($statement->rowCount()) { foreach ($statement->fetchAll() as $product) { foreach ($languages as $language_id => $language_code) { $sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/product', 'product_id=' . $product->product_id)), '0.8', 'weekly', $product->date_modified); } } } // Generate tag links $statement = $db->query('SELECT `td`.`name`, (SELECT MAX(`p`.`date_modified`) FROM `product` AS `p` JOIN `product_to_tag` AS `p2t` ON (`p2t`.`product_id` = `p`.`product_id`) WHERE `p`.`status` = 1 AND `p2t`.`tag_id` = `td`.`tag_id`) AS `date_modified` FROM `tag_description` AS `td` HAVING `date_modified` IS NOT NULL'); if ($statement->rowCount()) { foreach ($statement->fetchAll() as $search) { foreach ($languages as $language_id => $language_code) { $sitemap->addItem(canonical($language_id, $language_code, $url->link('catalog/search', 'q=' . rawurlencode($search->name))), '0.7', 'weekly', $search->date_modified); } } } // Save sitemap $sitemap->createSitemapIndex(URL_BASE);
/** * Canonical class name of an object, of the form "My.Namespace.MyClass" * @param object|string $object * @return string */ public static function canonical($object) { return canonical($object); }
/** * Метод, предназанченный для сборки всей страницы в единое целое. * * @param int $id идентификатор документа * @param int $rub_id идентификатор рубрики */ function coreSiteFetch($id, $rub_id = '') { global $AVE_DB; // Если происходит вызов модуля, получаем соответствующие мета-теги и получаем шаблон модуля if (!empty($_REQUEST['module'])) { $out = $this->_coreModuleMetatagsFetch(); $out = $this->_coreDocumentTemplateGet('', '', $this->_coreModuleTemplateGet()); } else { if (!isset($this->curentdoc->Id) && !$this->_coreCurrentDocumentFetch($id, UGROUP)) { // Определяем документ с 404 ошиюкой, в случае, если документ не найден if ($this->_corePageNotFoundFetch(PAGE_NOT_FOUND_ID, UGROUP)) { $_REQUEST['id'] = $_GET['id'] = $id = PAGE_NOT_FOUND_ID; } } // проверяем параметры публикации документа if (!$this->_coreDocumentIsPublished()) { $this->_coreErrorPage404(); } // Определяем права доступа к документам рубрики define('RUB_ID', !empty($rub_id) ? $rub_id : $this->curentdoc->rubric_id); $this->_coreRubricPermissionFetch(RUB_ID); if (!(isset($_SESSION[RUB_ID . '_docread']) && $_SESSION[RUB_ID . '_docread'] == 1 || isset($_SESSION[RUB_ID . '_alles']) && $_SESSION[RUB_ID . '_alles'] == 1)) { // читать запрещено - извлекаем ругательство и отдаём вместо контента $main_content = get_settings('message_forbidden'); } else { if (isset($_REQUEST['print']) && $_REQUEST['print'] == 1) { // увеличиваем счетчик версий для печати $AVE_DB->Query("\n\t\t\t\t\t\tUPDATE " . PREFIX . "_documents\n\t\t\t\t\t\tSET document_count_print = document_count_print+1\n\t\t\t\t\t\tWHERE Id = '" . $id . "'\n\t\t\t\t\t"); } else { if (!isset($_SESSION['doc_view'][$id])) { // увеличиваем счетчик просмотров (1 раз в пределах сессии) $AVE_DB->Query("\n\t\t\t\t\t\t\tUPDATE " . PREFIX . "_documents\n\t\t\t\t\t\t\tSET document_count_view = document_count_view+1\n\t\t\t\t\t\t\tWHERE Id = '" . $id . "'\n\t\t\t\t\t\t"); $_SESSION['doc_view'][$id] = time(); } $curdate = mktime(0, 0, 0, date("m"), date("d"), date("Y")); if (!isset($_SESSION['doc_view_dayly[' . $curdate . '][' . $id . ']'])) { // и подневный счетчик просмотров тоже увеличиваем $curdate = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $AVE_DB->Query("\n UPDATE\n " . PREFIX . "_view_count\n SET\n count = count + 1\n WHERE\n document_id = '" . $id . "' AND\n day_id = '" . $curdate . "'\n "); if (!$AVE_DB->_handle->affected_rows) { $AVE_DB->Query("\n INSERT INTO " . PREFIX . "_view_count (\n document_id,\n day_id,\n count\n )\n VALUES (\n '" . $id . "', '" . $curdate . "', '1'\n )\n "); } $_SESSION['doc_view_dayly[' . $curdate . '][' . $id . ']'] = time(); } } if (CACHE_DOC_TPL && empty($_POST) && !(isset($_SESSION['user_adminmode']) && $_SESSION['user_adminmode'] == 1)) { // кэширование разрешено // извлекаем скомпилированный шаблон документа из кэша $main_content = $AVE_DB->Query("\n\t\t\t\t\t\tSELECT compiled\n\t\t\t\t\t\tFROM " . PREFIX . "_rubric_template_cache\n\t\t\t\t\t\tWHERE hash = '" . $this->_get_cache_hash() . "'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t")->GetCell(); } else { // кэширование запрещено $main_content = false; } if (empty($main_content)) { // кэш пустой или отключен, извлекаем и компилируем шаблон if (!empty($this->curentdoc->rubric_template)) { $rubTmpl = $this->curentdoc->rubric_template; } else { $rubTmpl = $AVE_DB->Query("\n\t\t\t\t\t\t\tSELECT rubric_template\n\t\t\t\t\t\t\tFROM " . PREFIX . "_rubrics\n\t\t\t\t\t\t\tWHERE Id = '" . RUB_ID . "'\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t")->GetCell(); } $rubTmpl = trim($rubTmpl); if (empty($rubTmpl)) { // не задан шаблон рубрики $main_content = $this->_rubric_template_empty; } else { // парсим теги полей в шаблоне документа $main_content = preg_replace_callback('/\\[tag:fld:([a-zA-Z0-9-_]+)\\]/', 'document_get_field', $rubTmpl); $main_content = preg_replace_callback('/\\[tag:([r|c|f|t]\\d+x\\d+r*):(.+?)]/', 'callback_make_thumbnail', $main_content); // удаляем ошибочные теги полей $main_content = preg_replace('/\\[tag:fld:\\d*\\]/', '', $main_content); if (CACHE_DOC_TPL && empty($_POST) && !(isset($_SESSION['user_adminmode']) && $_SESSION['user_adminmode'] == 1)) { // кэширование разрешено // сохраняем скомпилированный шаблон в кэш $AVE_DB->Query("\n\t\t\t\t\t\t\t\tINSERT " . PREFIX . "_rubric_template_cache\n\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\thash = '" . $this->_get_cache_hash() . "',\n\t\t\t\t\t\t\t\t\trub_id = '" . RUB_ID . "',\n\t\t\t\t\t\t\t\t\tgrp_id = '" . UGROUP . "',\n\t\t\t\t\t\t\t\t\tdoc_id = '" . $id . "',\n\t\t\t\t\t\t\t\t\tcompiled = '" . addslashes($main_content) . "'\n\t\t\t\t\t\t\t"); } } } $main_content = preg_replace('/\\[tag:date:([a-zA-Z0-9-]+)\\]/e', "RusDate(date('\$1', " . $this->curentdoc->document_published . "))", $main_content); $main_content = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $this->curentdoc->document_published)), $main_content); $main_content = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $this->curentdoc->document_published)), $main_content); $main_content = str_replace('[tag:docauthorid]', $this->curentdoc->document_author_id, $main_content); $main_content = str_replace('[tag:docauthor]', get_username_by_id($this->curentdoc->document_author_id), $main_content); } $out = str_replace('[tag:maincontent]', $main_content, $this->_coreDocumentTemplateGet(RUB_ID)); } // /вывод документа //Работа с условиями /* $out = preg_replace('/\[tag:if_exp:?(.*)\]/u', '<?php $my_exp000=true; $my_exp0001=\'$my_exp000=\'. str_replace(\'#var#\',\'$\',<<<BLOCK $1; BLOCK ); @eval($my_exp0001); if($my_exp000==true) { ?>', $out); $out = str_replace('[tag:if_exp_else]', '<?php }else{ ?>', $out); $out = str_replace('[tag:/if_exp]', '<?php } ?>', $out); */ // Тут мы вводим в хеадер иньекцию скриптов. if (defined('RUB_ID')) { $rubheader = $AVE_DB->Query("\n\t\t\t\t\t\t\tSELECT rubric_header_template\n\t\t\t\t\t\t\tFROM " . PREFIX . "_rubrics\n\t\t\t\t\t\t\tWHERE Id = '" . RUB_ID . "'\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t", CACHE_LIFETIME)->GetCell(); $out = str_replace('[tag:rubheader]', $rubheader . '[tag:rubheader]', $out); } $out = preg_replace('/\\[tag:rfld:([a-zA-Z0-9-_]+)]\\[(more|esc|img|[0-9-]+)]/e', "request_get_document_field(\"\$1\", {$id}, \"\$2\")", $out); // Если в запросе пришел параметр print, т.е. страница для печати, парсим контент, который обрамлен // тегами только для печати if (isset($_REQUEST['print']) && $_REQUEST['print'] == 1) { $out = str_replace(array('[tag:if_print]', '[/tag:if_print]'), '', $out); $out = preg_replace('/\\[tag:if_notprint\\](.*?)\\[\\/tag:if_notprint\\]/si', '', $out); } else { // В противном случае наоборот, парсим только тот контент, который предназначен НЕ для печати $out = preg_replace('/\\[tag:if_print\\](.*?)\\[\\/tag:if_print\\]/si', '', $out); $out = str_replace(array('[tag:if_notprint]', '[/tag:if_notprint]'), '', $out); } // получаем из шаблона системный тег, определяющий название темы дизайна $match = ''; preg_match('/\\[tag:theme:(\\w+)]/', $out, $match); define('THEME_FOLDER', empty($match[1]) ? DEFAULT_THEME_FOLDER : $match[1]); $out = preg_replace('/\\[tag:theme:(.*?)]/', '', $out); // парсим теги модулей $out = $this->coreModuleTagParse($out); if (isset($_REQUEST['module']) && !(isset($this->install_modules[$_REQUEST['module']]) && '1' == $this->install_modules[$_REQUEST['module']]->ModuleStatus)) { display_notice($this->_module_error); } // парсим теги системных блоков $out = preg_replace_callback('/\\[tag:sysblock:([0-9-]+)\\]/', 'parse_sysblock', $out); // парсим теги системы внутренних запросов $out = preg_replace_callback('/\\[tag:request:(\\d+)\\]/', 'request_parse', $out); // парсим теги навигации $out = preg_replace_callback('/\\[tag:navigation:(\\d+):?([0-9,]*)\\]/', 'parse_navigation', $out); // парсим теги скрытого текста $out = parse_hide($out); // парсим остальные теги основного шаблона $search = array('[tag:mediapath]', '[tag:path]', '[tag:sitename]', '[tag:document]', '[tag:alias]', '[tag:home]', '[tag:robots]', '[tag:canonical]', '[tag:docid]', '[tag:breadcrumb]'); $replace = array(ABS_PATH . 'templates/' . THEME_FOLDER . '/', ABS_PATH, htmlspecialchars(get_settings('site_name'), ENT_QUOTES), get_redirect_link('print'), @$this->curentdoc->document_alias, get_home_link(), isset($this->curentdoc->document_meta_robots) ? $this->curentdoc->document_meta_robots : '', canonical($_SERVER['REQUEST_URI']), isset($this->curentdoc->Id) ? $this->curentdoc->Id : '', get_breadcrumb()); if (defined('MODULE_CONTENT')) { // парсинг тегов при выводе из модуля $search[] = '[tag:maincontent]'; $replace[] = MODULE_CONTENT; $search[] = '[tag:title]'; $replace[] = htmlspecialchars(defined('MODULE_SITE') ? MODULE_SITE : '', ENT_QUOTES); $search[] = '[tag:description]'; $replace[] = htmlspecialchars(defined('MODULE_DESCRIPTION') ? MODULE_DESCRIPTION : '', ENT_QUOTES); $search[] = '[tag:keywords]'; $replace[] = htmlspecialchars(defined('MODULE_KEYWORDS') ? MODULE_KEYWORDS : '', ENT_QUOTES); } else { $search[] = '[tag:keywords]'; $replace[] = isset($this->curentdoc->document_meta_keywords) ? htmlspecialchars($this->curentdoc->document_meta_keywords, ENT_QUOTES) : ''; $search[] = '[tag:description]'; $replace[] = isset($this->curentdoc->document_meta_description) ? htmlspecialchars($this->curentdoc->document_meta_description, ENT_QUOTES) : ''; $search[] = '[tag:title]'; $replace[] = htmlspecialchars(pretty_chars($this->curentdoc->document_title), ENT_QUOTES); } $search[] = '[tag:maincontent]'; $replace[] = ''; $search[] = '[tag:printlink]'; $replace[] = get_print_link(); $search[] = '[tag:version]'; $replace[] = APP_INFO; $search[] = '[tag:docviews]'; $replace[] = isset($this->curentdoc->document_count_view) ? $this->curentdoc->document_count_view : ''; // парсим тизер документа $out = preg_replace('/\\[tag:teaser:(\\d+)\\]/e', "showteaser(\$1)", $out); if (defined('RUB_ID')) { $out = preg_replace('/\\[tag:docauthoravatar:(\\d+)\\]/e', "getAvatar(" . intval($this->curentdoc->document_author_id) . ",\"\$1\")", $out); } if (defined('RUB_ID')) { $out = preg_replace('/\\[tag:lang:([a-zA-Z0-9-_]+)\\]/', '<?php if($AVE_Core->curentdoc->document_lang=="$1") { ?>', $out); } else { $out = preg_replace('/\\[tag:lang:([a-zA-Z0-9-_]+)\\]/', '<?php if($_SESSION["user_language"]=="$1") { ?>', $out); } $out = str_replace('[tag:/lang]', '<?php } ?>', $out); // парсим остальные теги основного шаблона $out = str_replace($search, $replace, $out); unset($search, $replace); // парсим теги для combine.php $out = preg_replace_callback('/\\[tag:(css|js):([^ :\\/]+):?(\\S+)*\\]/', array($this, '_parse_combine'), $out); // ЧПУ $out = rewrite_link($out); echo $out; }
$fotos = nggdb::find_images_in_list($pids, false, 'DESC'); if (empty($fotos)) { header('Location: /tags.php'); } //页面title $page_title = empty($_GET['tag']) ? $cfg['sitename'] : $_GET['tag']; $title = $page_title . $cfg['sitetitle']; } else { header('Location: /tags.php'); } //输出keywords $keywords = $_GET['tag'] . ',' . $cfg['keywords']; //输出description $description = $cfg['description']; //输出canonical $canonical = canonical($tag->term_id, $tag->slug); require_once './inc/html/head.html'; ?> <div id='main'> <?php foreach ($fotos as $foto) { ?> <a href="/foto/<?php echo $foto->pid; ?> .html"><img src="<?php echo fotourl($foto->thumbURL); ?> " alt="<?php echo fotourl($foto->alttext); ?>
$key_arr = array(); foreach ($tags as $tag) { $key_arr[] = $tag->slug; $keywords = implode(',', $key_arr); } } else { $keywords = $cfg['keywords']; } //输出keywords $keywords = $foto->name . ',' . $keywords; //输出页面description $description = empty($foto->description) ? $cfg['description'] : $foto->description; //输出$title,$canonical $page_title = empty($foto->alttext) ? $cfg['sitename'] : $foto->alttext; $title = $page_title . $cfg['sitetitle']; $canonical = canonical($foto->pid); require_once './inc/html/head.html'; ?> <div id='main'> <p><img title="<?php echo $foto->alttext; ?> " src="<?php echo $foto_url; ?> " alt="<?php echo $foto->alttext; ?> " /></p> <a href="/foto/<?php
<?php session_start(); $cfg['siteurl'] = 'http://foto.tfbj.cc/'; $cfg['baseurl'] = 'http://stat001.tfbj.cc/'; $cfg['trueurl'] = 'http://foto.tfbj.cc/wp-content/gallery/'; $cfg['sitename'] = 'FOTO'; $cfg['sitetitle'] = " | foto my life | foto your life | foto everyone's life"; $cfg['description'] = 'To find all beautiful things | colorful world,young body,pure desire,real dream,crazy movement'; $cfg['keywords'] = 'photo,graphic,shot,polaroid,camera,perfect,gorgeous,picture,nice,sex,babes'; $canonical = canonical(); //处理图片url 隐藏真实地址 function fotourl($url) { global $cfg; return str_replace($cfg['trueurl'], $cfg['baseurl'], $url); } //生成canonical标签内容 function canonical($id = 0, $slug = '') { global $cfg; switch ($_SERVER['SCRIPT_NAME']) { case '/foto.php': return $cfg['siteurl'] . 'foto/' . $id . '.html'; break; case '/tag.php': return $cfg['siteurl'] . 'tag/' . $id . '-' . $slug . '.html'; break; default: return $cfg['siteurl'] . substr($_SERVER['SCRIPT_NAME'], 1); }
function PDQ_Solve($meth) { global $DEBUG, $method, $streams, $nodes; // extern int //global $centers_declared, $streams_declared; // extern int global $job; // extern JOB_TYPE * global $node; // extern NODE_TYPE * global $s1, $s2, $s3, $s4; // extern char[] global $sumD; // extern double $k = 0; // int $c = 0; // int $should_be_class = 0; // int $demand = 0.0; // double $maxD = 0.0; // double $p = "PDQ_Solve()"; // char * if ($DEBUG) { debug($p, "Entering"); } /* There'd better be a job[0] or you're in trouble !!! */ $method = $meth; switch ($method) { case EXACT: if ($job[0]->network != CLOSED) { /* bail ! */ typetostr($s2, $job[0]->network); typetostr($s3, $method); $s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3); errmsg($p, $s1); } switch ($job[0]->should_be_class) { case TERM: case BATCH: exact(); break; default: break; } break; case APPROX: if ($job[0]->network != CLOSED) { /* bail ! */ typetostr($s2, $job[0]->network); typetostr($s3, $method); $s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3); errmsg($p, $s1); } switch ($job[0]->should_be_class) { case TERM: case BATCH: approx(); break; default: break; } break; case CANON: if ($job[0]->network != OPEN) { /* bail out ! */ typetostr($s2, $job[0]->network); typetostr($s3, $method); $s1 = sprintf("Network should_be_class \"%s\" is incompatible with \"%s\" method", $s2, $s3); errmsg($p, $s1); } canonical(); break; default: typetostr($s3, $method); $s1 = sprintf("Unknown method \"%s\"", $s3); errmsg($p, $s1); break; } /* Now compute bounds */ for ($c = 0; $c < $streams; $c++) { $sumD = 0.0; $maxD = 0.0; $should_be_class = $job[$c]->should_be_class; for ($k = 0; $k < $nodes; $k++) { $demand = $node[$k]->demand[$c]; if ($node[$k]->sched == ISRV && $job[$c]->network == CLOSED) { $demand /= $should_be_class == TERM ? $job[$c]->term->pop : $job[$c]->batch->pop; } if ($maxD < $demand) { $maxD = $demand; } $sumD += $node[$k]->demand[$c]; } /* Over k */ switch ($should_be_class) { case TERM: $job[$c]->term->sys->maxN = ($sumD + $job[$c]->term->think) / $maxD; $job[$c]->term->sys->maxTP = 1.0 / $maxD; $job[$c]->term->sys->minRT = $sumD; if ($sumD == 0) { getjob_name($s1, $c); $s2 = sprintf("Sum of demands is zero for workload \"%s\"", $s1); errmsg($p, $s2); } break; case BATCH: $job[$c]->batch->sys->maxN = $sumD / $maxD; $job[$c]->batch->sys->maxTP = 1.0 / $maxD; $job[$c]->batch->sys->minRT = $sumD; if ($sumD == 0) { getjob_name($s1, $c); $s2 = sprintf("Sum of demands is zero for workload \"%s\"", $s1); errmsg($p, $s2); } break; case TRANS: $job[$c]->trans->sys->maxTP = 1.0 / $maxD; $job[$c]->trans->sys->minRT = $sumD; if ($sumD == 0) { getjob_name($s1, $c); $s2 = sprintf("Sum of demands is zero for workload \"%s\"", $s1); errmsg($p, $s2); } break; default: break; } } /* Over c */ if ($DEBUG) { debug($p, "Exiting"); } }