^use[/include/classes/index/index.p] ### FORM PARAMS HASH ### $sParam[^form:param.trim[both;/]] $form[ $.tables[^hash::create[]] ] $tParam[^sParam.split[/]] ^if(def $tParam.piece){ ^tParam.menu{ $pair[^tParam.piece.split[-]] $param[$pair.piece] ^pair.offset(1) $value[$pair.piece] ^if($form.tables.[$param] is table){ ^rem{ #do nothing } }{ $form.tables.[$param][^table::create{field^#0A$form.[$param]}] } ^form.tables.[$param].append{$value} $form.[$param][$value] } } ### DEBUG SWITCH ### ^if($form:nameless eq 'debug'){ ^if($cookie:debug){ $cookie:debug[] }{ $cookie:debug(1) } $response:location[./] } ^if(def $cookie:debug){ } ### CURRENT PAGE ### $request[^index:parseRequest[$form:request]] $uri[$request.uri] ^if(def $request.lang){ $lang[$request.lang] }{ $lang[$config.site.defaultLang] } $form.page[$request.page] $langID[^sql:string{ SELECT id FROM $tbl WHERE parent_id = $config.site.langs_id && uriTitle = '$lang' }] ^if(def $request.cat){ $formCatSplit[^request.cat.split[-]] ^formCatSplit.offset(-1) ^if(^formCatSplit.piece.int(0)){ $isCatExists(^sql:int{ SELECT id FROM ${tbl}_categories WHERE uri = '$request.cat' }) ^if(!$isCatExists){ $uri[${uri}$request.cat/] } }{ $uri[${uri}$request.cat/] } } $page[^sql:table{ SELECT id, parent_id, IF( module = 'catalogMsSql' && method = 'item', ( SELECT pageTitle FROM ${tbl}_prod_translations WHERE prodID = ${tbl}.id && langID = $langID LIMIT 1 ), pageTitle ) AS pageTitle, IF( windowTitle != '', windowTitle, IF( module = 'catalogMsSql' && method = 'item', ( SELECT pageTitle FROM ${tbl}_prod_translations WHERE prodID = ${tbl}.id && langID = $langID LIMIT 1 ), pageTitle ) ) AS windowTitle, module, method, results, template, keywords, description, IF( module = 'catalogMsSql' && method = 'item', ( SELECT text FROM ${tbl}_prod_translations WHERE prodID = ${tbl}.id && langID = $langID LIMIT 1 ), text ) AS text, clearCache, showSub, comments FROM $tbl WHERE uri = '$uri' && lang = '^if(^uri.left(9) eq '/katalog/'){uk}{$lang}' && ( visible = '1' # || (module = 'catalogMsSql' && method = 'item') ) && parentInvisible != '1' }[ $.limit(1) ]] ^if($uri eq '/katalog/' && $lang eq 'ru'){ $page.windowTitle[^sql:string{ SELECT windowTitle FROM $tbl WHERE uri = '/katalog/' && lang = 'ru' }] $page.description[^sql:string{ SELECT description FROM $tbl WHERE uri = '/katalog/' && lang = 'ru' }] } ^if($page && !def $page.pageTitle){ $page.pageTitle[^sql:string{ SELECT pageTitle FROM ${tbl}_prod_translations WHERE prodID = $page.id && langID = ^if($langID == 3){75731}{3} }] $page.windowTitle[$page.pageTitle] } $langs[^sql:table{ SELECT id, pageTitle, uriTitle FROM $tbl WHERE parent_id = '$config.site.langs_id' && visible = '1' && type = 'l' ORDER BY order_id }] ^if(def $page.template){ ### CACHE $cacheKey[${request:uri}${cookie:[sort-$page.module]}${cookie:[results-$page.module]}${cookie:currency}] $cacheFile[/data/cache/$page.id/^math:md5[$cacheKey]] ^if($env:REQUEST_METHOD eq 'POST' || $cookie:debug || $form:nameless eq 'nocache'){ $cacheTime(0) }{ $cacheTime($config.site.cacheTime) } ^if($page.clearCache == 1){ ^cache[$cacheFile] ^sql:void{UPDATE $tbl SET clearCache = '0' WHERE id = '$page.id' LIMIT 1} } ### TEMPLATE $jTemplateCode{ ^if($langs > 1 && !def $request.lang){ # $response:status(301) # $response:location[^langPrefix[^untaint{$request:uri}]] # $index:neededRedirects.lang[$config.site.defaultLang] } ^if($langs > 1){ $translList[^getTranslList[]] } $markList[^getMarkList[]] $path[^getPath[$page.parent_id]] ^use[/include/templates/$page.template/template.p] ^template:show[] } ^try{ ^cache[$cacheFile]($cacheTime){ $jTemplateCode } }{ ^if(^exception.comment.pos[cache_put failed] >=0){ $exception.handled(1) $jTemplateCode } } ### VISIT COUNTER ^use[/include/classes/counter.p] ^file:lock[/include/counter.lock]{ ^counter:setHits[$page.id] ^counter:setHosts[] } }{ $isUriExists(^sql:int{ SELECT id FROM $tbl WHERE uri = '$uri' }) # ^if( # $langs > 1 # && def $form:lang # && $isUriExists # ){ # $response:status(301) # $response:location[http://$env:SERVER_NAME/$lang/] # $index:neededRedirects.lang[$lang] # }{ $response:status(404) $404[^file::load[text;/404.html]] ^process{^untaint{$404.text}} # } } ^index:redirects[]