^sql{ $uri[^if(def $form:uri){$form:uri}{/}] $lang[^if(def $form:lang){$form:lang}{^config:get[site;default_lang]}] $page[^table::sql{SELECT id,parent_id,full_title,short_title,module,method,results,template,keywords,description FROM ^config:get[sql;table] WHERE uri='$uri' AND lang='$lang'}[ $.limit(1) ]] ^if(def $page.template){ ^path[$page.parent_id] ^if($form:nameless eq 'print' && -f '/include/templates/print_page.p'){ ^use[/include/templates/print_page.p] }{ ^use[/include/templates/$page.template] } ^if($env:REQUEST_METHOD eq 'POST' || $env:REMOTE_ADDR eq '127.0.0.1' || $form:nameless eq 'nocache'){ $cacheTime(0) }{ $cacheTime(600) } ^cache[/content/cache/$page.id/^math:md5[$request:uri]]($cacheTime){ ^template:show[] } ##################################### # Счетчики ##################################### ### hits total ^void:sql{UPDATE ^config:get[sql;table] SET visits=visits+1 WHERE uri='$uri' AND lang='$lang'} ^if(!def $counter){ $counter[^hashfile::open[/include/counter/counter]] } $reset_counter_date[^date::create($date.year;$date.month;^eval($date.day+1))] ### hits today $counter.hits_today[ $.value[^eval($counter.hits_today+1)] $.expires[$reset_counter_date] ] ^if(!def $cookie:unique_host){ ### hosts total $counter.hosts_total[^eval($counter.hosts_total+1)] ^counter.hosts_total.save[/include/counter/counter.txt] ### hosts today $counter.hosts_today[ $.value[^eval($counter.hosts_today+1)] $.expires[$reset_counter_date] ] $cookie:unique_host[ $.value[1] $.expires[$reset_counter_date] ] } ##################################### # Конец счетчикам ##################################### }{ ##################################### # СТРАНИЦА НЕ СУЩЕСТВУЕТ ##################################### ^if(^request:uri.right(1) ne '/'){ $response:location[http://${env:SERVER_NAME}$request:uri/] }{ ^if(def $form:lang){ $response:location[http://$env:SERVER_NAME/$form:lang/] }{ $response:status(404)