|
|
| version 1.21, 2003/11/03 11:22:06 | version 1.24.2.1, 2005/12/08 10:02:45 |
|---|---|
| Line 1 | Line 1 |
| @USE | @USE |
| common/lib.p | lib.p |
| common/layout.p | layout.p |
| common/implode.p | implode.p |
| date/dtf.p | dtf.p |
| mysql.p | mysql.p |
| #rotabanner.p | |
| ########################################################################### | |
| ################################################################################################# | |
| @auto[] | @auto[] |
| $now[^date::now[]] | $MAIN:pSQL[^mysql::init[$SQL.connect-string; |
| $.is_debug(1) | |
| # id 404 : | $.cache_dir[/../data/cache] |
| $MAIN:error404ObjectId(23) | ]] |
| # id , : | |
| $MAIN:siteDataObjectId(21) | |
| # id | |
| $MAIN:faq_category_root_id(3) | |
| $MAIN:pSQL[^mysql::init[$SQL.connect-string;^if(^env:QUERY_STRING.pos[mode=debug] >= 0){debug}{500}]] | |
| ^detectBrowser[] | ^detectBrowser[] |
| # | # эта табличка нужна для очистки всякой фигни от ентитей/тегов |
| $MAIN:objIdNews(1) | |
| # / | |
| $repl[^table::create{a b | $repl[^table::create{a b |
|  ^; |  ^; |
| &hellip^; ... | &hellip^; ... |
| &rdquo^; " | &rdquo^; ^taint["] |
| &ldquo^; " | &ldquo^; ^taint["] |
| »^; " | »^; ^taint["] |
| «^; " | «^; ^taint["] |
| &mdash^; - | &mdash^; - |
| &ndash^; - | &ndash^; - |
| №^; | №^; № |
| &bull^; }] | &bull^; }] |
| $MAIN:user_images_dir[/i/users] | $SECTIONS[ |
| $.banner_old[ | |
| $.image_path[/i/banners_old] | |
| ] | |
| $.banner[ | |
| $.image_path[/i/banners] | |
| ] | |
| ] | |
| #end @auto[] | #end @auto[] |
| ################################################################################################# | ########################################################################### |
| @error404[][err_lang] | @error404[] |
| #$response:status[404] | |
| ^location[/404/] | ^location[/404/] |
| #end @error404[] | #end @error404[] |
| ################################################################################################# | ########################################################################### |
| @pageHeader[header] | @postprocess[body][repl] |
| $header | $result[$body] |
| #end @pageHeader[] | ^if(def $result && $result is "string"){ |
| ^if($MAIN:browser eq "nn" && $MAIN:browser_ver < 5){ | |
| $repl[^table::create{a b | |
| ################################################################################################# | |
| @pageFooter[] | |
| footer | |
| #end @pageFooter[] | |
| ################################################################################################# | |
| @body[content] | |
| <body bgcolor="#F4F4F4" text="#000000" link="#0000C4" alink="#0000C4" vlink="#073683" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" rightmargin="0" onLoad="init()"> | |
| $content | |
| </body> | |
| #end @body[] | |
| ################################################################################################# | |
| @html[header;content] | |
| <!-- Copyright (c) Art. Lebedev Studio | http://www.design.ru/ --> | |
| <html> | |
| <head> | |
| <base target="_top"> | |
| <link rel="stylesheet" type="text/css" href="/main.css"></link> | |
| <title>AB.LV^if(def $header){ | ^taint[as-is][$header] }</title> | |
| </head> | |
| ^body{ | |
| <table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#ffffff"> | |
| ^pageHeader[] | |
| $content | |
| ^pageFooter[] | |
| </table> | |
| } | |
| <html> | |
| #end @html[] | |
| ################################################################################################# | |
| @main[] | |
| ^pSQL.server{ | |
| <html> | |
| <head> | |
| ^if(def $prepare){^prepare[]} | |
| </head> | |
| ^body{^content[]} | |
| </html> | |
| } | |
| # @main[] | |
| ################################################################################################# | |
| @postprocess[body][repl;tmp] | |
| ^if($body is file){ | |
| $body}{ | |
| ^if(def $body){ | |
| ^if($MAIN:browser eq "nn" && $MAIN:browser_ver < 5){ | |
| $repl[^table::create{a b | |
| &hellip^; …^; | &hellip^; …^; |
| &rdquo^; ”^; | &rdquo^; ”^; |
| &ldquo^; “^; | &ldquo^; “^; |
| &mdash^; —^; | &mdash^; —^; |
| &ndash^; –^; | &ndash^; –^; |
| &bull^; •^;}] | &bull^; •^;}] |
| $result[^body.replace[$repl]] | $result[^result.replace[$repl]] |
| }{ | } |
| $result[$body] | |
| } | |
| $not_optimized_space[^taint[as-is][ ]] | |
| $not_optimized_tab[^taint[as-is][^#09]] | |
| $not_optimized_enter[^taint[as-is][^#0A]] | |
| $result[^result.match[][g]{$not_optimized_space}] | |
| $result[^result.match[][g]{$not_optimized_tab}] | |
| $result[^result.match[][g]{$not_optimized_enter}] | |
| }{ | |
| $result[] | |
| } | |
| } | |
| ^getStat[] | |
| ^rusage[] | |
| # , outdated, ... | |
| # ^printOutdatedMacro[] | |
| #end @postprocess[body] | |
| ^rem{ *** это инициализация банеров *** } | |
| # $banner[^rotabanner::init[название проекта;банер по умолчанию]] | |
| ^rem{ *** обрабатываем [parser]код[/parser] *** } | |
| # $result[^result.match[\[(parser)\](.+?)\[/\1\]][g]{^taint[as-is][^process{$match.2}]}] | |
| ^if(^result.pos[one-random]){ | |
| $result[^result.match[<(one-random)>(.+?)</\1>][g]{$_items[^match.2.match[<(random-item)>(.+?)</\1>][g]]^_items.offset(^math:random(^_items.count[]))$_items.2}] | |
| } | |
| ################################################################################################# | ^rem{ *** если отдаем страничку яндексу, то меняем &^; на &, а то у него крышу сносит *** } |
| @rusage[msg][rusage] | ^if(^env:HTTP_USER_AGENT.match[yandex][i]){ |
| ^if(!in "/admin/"){ | $result[^result.match[&^;][g]{&}] |
| $rusage[$status:rusage] | } |
| $now[^date::now[]] | |
| $s[[^now.sql-string[]] $rusage.utime $rusage.maxrss [$status:memory.used/$status:memory.free/$status:memory.since_compact/$status:memory.process] $env:REMOTE_ADDR $request:uri^if(def $msg){ $msg}^#0A] | $repl[^table::create{a b |
| ^s.save[append;/../data/rusage.log] | <br></br> <br /> |
| ></img> /> | |
| }] | |
| $result[^if(${response:content-type.value} eq "text/html"){<?xml version="1.0" encoding="$response:charset"?>}^result.replace[$repl]] | |
| } | } |
| #end @rusage[] | |
| # получаем статистику по sql запросам | |
| ^getSQLStat[] | |
| # вызываем rusage, который напишет в log столько страничка генерилась и сколько отожрала памяти | |
| ^rusage[] | |
| #end @postprocess[] | |
| ################################################################################################# | |
| # , $MAIN:pSQL | ########################################################################### |
| @getStat[] | @rusage[msg][now;s] |
| ^if(def $MAIN:pSQL && $MAIN:pSQL.debug){ | ^if(1 || !in "/admin/"){ |
| $result[^MAIN:pSQL.getStatistics[/../data/sql.txt]] | $now[^date::now[]] |
| }{ | $s[[^now.sql-string[]] $status:rusage.utime $status:rusage.maxrss [$status:memory.used/$status:memory.free/$status:memory.ever_allocated_since_compact/$status:memory.ever_allocated_since_start] $env:REMOTE_ADDR $request:uri^if(def $msg){ $msg}^#0A] |
| $result[] | ^s.save[append;/../data/rusage.log] |
| } | } |
| #end @stat[] | #end @rusage[] |
| ################################################################################################# | ########################################################################### |
| # | # этот метод выведет статистику, собранную объектом $MAIN:pSQL |
| @getComments[f][file;fd;t;comments] | @getSQLStat[] |
| $file[^if(def $f){$f}{/../data/classes/engine.p}] | ^if(def $MAIN:pSQL && !in "/admin/"){ |
| ^if(-f $file){ | ^if(def $form:mode && ^form:tables.mode.locate[field;debug]){ |
| $fd[^file::load[text;$file]] | ^rem{ *** если пусканули с ?mode=debug то получаем и сохраняем информацию обо всех запросах на странице *** } |
| ^MAIN:pSQL.print_statistic[$.file[/../data/sql.txt]] | |
| $t[$fd.text] | }{ |
| $t[^t.match[^^##[^^#]*^$][mg]{}] | ^rem{ *** а по умолчанию в лог пишем только информацию о проблемных страницах *** } |
| $t[^t.match[(\n){3,}][g]{${match.1}$match.1}] | ^MAIN:pSQL.print_statistic[ |
| $comments[^t.match[(#{5,}\n#\s.*?\n@.+?\^])][g]] | $.file[/../data/sql.log] |
| $.debug_time_limit(500) | |
| $result[^taint[as-is][^comments.menu{$comments.1^#0A^#0A^#0A}]] | $.debug_queries_limit(25) |
| $.debug_result_limit(3000) | |
| ] | |
| } | |
| } | } |
| #end @getComments[] | #end @getSQLStat[] |
| ################################################################################################# | |
| @log404[][str] | |
| $str[^now.sql-string[] $request:uri $env:HTTP_REFERER $env:REMOTE_ADDR^#0A] | |
| ^str.save[append;/../data/missing_url.txt] | |
| #end @log404[] | |