Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // Author: $Author: cms $
- // Revision: $Revision: 1.72 $
- // Date: $Date: 2005/07/06 15:45:06 $
- /* Apache in cgi mode bugaround */
- if (isset($_GET["template"])&&$_GET["template"]=="error404"){
- $_tmp=parse_url($_SERVER["REQUEST_URI"]);
- if (isset($_tmp["path"])){
- $pathinfo=pathinfo($_tmp["path"]);
- if(isset($pathinfo["extension"]) && ($pathinfo["extension"]!="css" && $pathinfo["extension"]!="js" && $pathinfo["extension"]!="gif" && $pathinfo["extension"]!="png" && $pathinfo["extension"]!="jpg" && $pathinfo["extension"]!="htm" && $pathinfo["extension"]!="html")){
- die("File does not exist: ".@$_SERVER["REQUEST_URI"]);
- }
- }
- }
- $GLOBALS["site_mode"]=1;
- if (isset($_SERVER["HTTP_HOST"])&&$_SERVER["HTTP_HOST"]=="dev.loc")
- $GLOBALS["dev_flag"]=1;
- else
- $GLOBALS["dev_flag"]=0;
- preg_match('/(.*)\?(.*)$/i',$_SERVER["REQUEST_URI"],$matches);
- $password_protected=0;
- if (isset($matches[1]))
- $_SERVER["PHP_SELF"]=$matches[1];
- else
- $_SERVER["PHP_SELF"]=$_SERVER["REQUEST_URI"];
- $cms_ns=0;$id=0;
- $found_handler="";
- require_once('cms/.include/config.php');
- if(isset($GLOBALS["cms"]["config"]["msg_files_encoding"]["convert_from"])
- && isset($GLOBALS["cms"]["config"]["msg_files_encoding"]["convert_to"])
- && $GLOBALS["cms"]["config"]["msg_files_encoding"]["convert_to"]
- && $GLOBALS["cms"]["config"]["msg_files_encoding"]["convert_from"]
- ){
- header("Content-Type: text/html; charset=".$GLOBALS["cms"]["config"]["msg_files_encoding"]["convert_to"]);
- }
- /*
- if(!isset($GLOBALS["cms"]["config"]["site"]["send_errors"]) || $GLOBALS["cms"]["config"]["site"]["send_errors"]==1){
- $old_error_handler = set_error_handler("error_handler");
- }
- */
- require_once('cms/.libs/'.$GLOBALS["cms"]["config"]["sql"]["dbtype"].'.php');
- db_connect();
- require_once('cms/.libs/common.php');
- $_SERVER['REMOTE_ADDR'] = $GLOBALS["cms_common"]->get_real_ip();
- $GLOBALS["cms_common"]->load_modifiers("header_codes.lst");
- $GLOBALS["rewrite_mode"]=0;
- $GLOBALS["relative_path"]="../";
- /*if(empty($_SERVER['PATH_INFO']) && !empty($_SERVER['REDIRECT_URL'])){
- $_SERVER['PATH_INFO'] = $_SERVER['REDIRECT_URL'];
- parse_str(parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY),$_GET);
- }*/
- if (!isset($GLOBALS["wrapper"])){
- if (isset($GLOBALS["cms"]["config"]["site"]["rewrite_urls"]) && $GLOBALS["cms"]["config"]["site"]["rewrite_urls"]==1){
- $GLOBALS["rewrite_mode"]=1;
- $temp=explode("/",$_SERVER["SCRIPT_NAME"]);
- unset($temp[count($temp)-1]);
- $_SERVER["SCRIPT_NAME"]=implode("/",$temp);
- if (!isset($_SERVER["PATH_INFO"])){
- if(isset($_SERVER["ORIG_PATH_INFO"]))
- $_SERVER["PATH_INFO"]=$_SERVER["ORIG_PATH_INFO"];
- //elseif(isset($_SERVER["REDIRECT_URL"])){
- //$_SERVER["PATH_INFO"]=$_SERVER["REDIRECT_URL"];
- else{
- if(!empty($_SERVER['REDIRECT_URL']))
- $_SERVER["PATH_INFO"]=$_SERVER['REDIRECT_URL'];
- else
- $_SERVER["PATH_INFO"]=$_SERVER['REQUEST_URI'];
- }
- }
- if (isset($_SERVER["PATH_INFO"])){
- $GLOBALS["requested_page"]=$_SERVER["PATH_INFO"];
- if(preg_match("@^/site\.php(/.*)$@Uism",$GLOBALS["requested_page"],$temp)){
- $GLOBALS["requested_page"]=$temp[1];
- }
- if (isset($_GET["template"]) && $_GET["template"]=="error404"){
- if (isset($_SERVER["REQUEST_URI"]) && $_SERVER["REQUEST_URI"])
- $GLOBALS["requested_page"]=$_SERVER["REQUEST_URI"];
- }
- if (substr($GLOBALS["requested_page"],0,1)=="/")
- $GLOBALS["requested_page"]=substr($GLOBALS["requested_page"],1,strlen($GLOBALS["requested_page"])-1);
- if(isset($_GET["template"])&& $_GET["template"]=="error404"){
- $requested_page_depth=0;
- $GLOBALS["relative_path"]="";
- }elseif (isset($_SERVER["REDIRECT_STATUS"]) && $_SERVER["REDIRECT_STATUS"]==404){
- if ($str=@strstr($_SERVER["REQUEST_URI"],($_SERVER["SCRIPT_NAME"]?$_SERVER["SCRIPT_NAME"]:"/"))){
- $temp=(substr($str,strlen($_SERVER["SCRIPT_NAME"])));
- if (substr($temp,0,1)=="/"){
- $temp=substr($temp,1,strlen($temp)-1);
- }
- }else{
- $temp=$_SERVER["REQUEST_URI"];
- if (substr($temp,0,1)=="/")
- $temp=substr($temp,1,strlen($temp)-1);
- }
- $temp=explode("/",$temp);
- $requested_page_depth=count($temp)-1;
- $GLOBALS["relative_path"]=str_repeat("../",$requested_page_depth);
- }else{
- $temp=explode("/",$GLOBALS["requested_page"]);
- $requested_page_depth=count($temp)-1;
- $GLOBALS["relative_path"]=str_repeat("../",$requested_page_depth);
- }
- require_once ("cms/.libs/pages.php");
- $cms_pages = new cms_pages;
- //if (trim($GLOBALS["requested_page"])){
- $temp=explode("/",$_SERVER["REQUEST_URI"]);
- for($i=0;$i<=$requested_page_depth;$i++){
- unset($temp[count($temp)-1]);
- }
- $GLOBALS["requested_path"]=implode("/",$temp);
- if (($temp[count($temp)-1]=="site" || $temp[count($temp)-1]=="site.php") && !preg_match("/forum_..\.php/",$GLOBALS["requested_page"])){
- unset($temp[count($temp)-1]);
- preg_match('/page([0-9]+).*\.html/',$GLOBALS["requested_page"],$matches);
- $alias=0;
- if (isset($matches[1])){
- $alias=$cms_pages->get_page_alias($matches[1]);
- }
- if ($alias)
- $redirected_page=implode("/",$temp)."/".$alias;
- else
- $redirected_page=implode("/",$temp)."/".$GLOBALS["requested_page"];
- header("HTTP/1.1 301 Moved Permanently");
- header("Location:".$redirected_page);
- exit();
- }
- //}
- if ($GLOBALS["requested_page"]){
- if (isset($_GET["template"]) && $_GET["template"]=="error404"){
- $_req_path=$GLOBALS["requested_path"];
- if (substr($_req_path,0,1)=="/")
- $_req_path=substr($_req_path,1);
- $_req_page=$GLOBALS["requested_page"];
- if (substr($_req_page,0,1)=="/")
- $_req_page=substr($_req_page,1);
- if (strpos($_req_page,$_req_path."/")===0){
- $GLOBALS["requested_page"]=substr($_req_page,strlen($_req_path."/"));
- }
- }
- if (!isset($GLOBALS["cms"]["config"]["site"]["url_handlers"]))
- $handlers=array("site");
- else
- $handlers=explode(",",$GLOBALS["cms"]["config"]["site"]["url_handlers"]);
- if (!in_array("site",$handlers))
- $handlers[]="site";
- if (is_array($handlers)){
- foreach ($handlers as $handler){
- if ($handler=="site"){
- $alias_id=$cms_pages->check_page_alias($GLOBALS["requested_page"]);
- if ($alias_id && isset($_GET["template"]) && $_GET["template"]=="error404"){
- unset($_GET["template"]);
- }
- break;
- }else{
- if (is_file(".plugins/$handler/site/main.php")){
- require_once(".plugins/$handler/site/main.php");
- $class_name=$handler."_site";
- $handler_class=new $class_name;
- if (method_exists($handler_class,"check_url_handler") && $handler_class->check_url_handler($GLOBALS["requested_page"])){
- $found_handler=$handler_class;
- $alias_id=0;
- break;
- }
- }
- }
- }
- }
- if (isset($alias_id)&&$alias_id){
- $id=$alias_id;
- }elseif(!is_object($found_handler)){
- preg_match('/^\/page([0-9]+).*\.html/',$_SERVER["PATH_INFO"],$matches);
- if (isset($matches[1]))
- $id=$matches[1];
- else
- $id=-1;
- }
- }else{
- $id=0;
- }
- }
- //$_SERVER["REQUEST_URI"]=$_SERVER["REDIRECT_URL"];
- }else{
- preg_match('/(.*\/)site.*\/page([0-9]+).*\.html/',$_SERVER["REQUEST_URI"],$matches);
- @$id=$matches[2];
- $GLOBALS["requested_path"]=preg_replace("/site(\.php)?$/i","",$_SERVER["SCRIPT_NAME"]);
- }
- }else{
- if (isset($GLOBALS["cms"]["config"]["site"]["rewrite_urls"]) && $GLOBALS["cms"]["config"]["site"]["rewrite_urls"]==1){
- $GLOBALS["rewrite_mode"]=1;
- }
- }
- if (!isset($GLOBALS["cms"]["config"]["site"]["site_relative_url"])){
- $GLOBALS["cms"]["config"]["site"]["site_relative_url"]="/";
- }
- if (!isset($GLOBALS["wrapper"])){
- if (!$GLOBALS["cms"]["config"]["site"]["site_relative_url"])
- $GLOBALS["cms"]["config"]["site"]["site_relative_url"]="/";
- if (substr($GLOBALS["cms"]["config"]["site"]["site_relative_url"],strlen($GLOBALS["cms"]["config"]["site"]["site_relative_url"])-1)!="/")
- $GLOBALS["cms"]["config"]["site"]["site_relative_url"].="/";
- if (isset($GLOBALS["requested_path"])&&(!isset($_GET["template"])||$_GET["template"]!="error404")){
- if ($GLOBALS["requested_path"]."/"!=$GLOBALS["cms"]["config"]["site"]["site_relative_url"]){
- $GLOBALS["cms_common"]->http_redirect($GLOBALS["cms"]["config"]["site"]["site_relative_url"].$GLOBALS["requested_page"].(isset($_SERVER["QUERY_STRING"])&&$_SERVER["QUERY_STRING"]?"?".$_SERVER["QUERY_STRING"]:""));
- exit;
- }
- }else{
- $GLOBALS["requested_path"]=$GLOBALS["cms"]["config"]["site"]["site_relative_url"];
- }
- }else{
- $GLOBALS["requested_path"]=$GLOBALS["cms"]["config"]["site"]["site_relative_url"];
- }
- /*@$GLOBALS["MAIN_URL"]=$matches[1];
- if (!$GLOBALS["MAIN_URL"])
- $GLOBALS["MAIN_URL"]=$_SERVER["REQUEST_URI"];*/
- include('cms/.libs/sessions_mysql.php'); // Session SQL module
- if(isset($_SERVER["HTTP_USER_AGENT"])&&!preg_match("|StackRambler|i",$_SERVER["HTTP_USER_AGENT"])){
- session_name ("SESSID");
- session_start();
- session_set_cookie_params (0); // creating SESSID
- }
- $cms_common->get_transit_query_string();
- require_once('cms/.libs/pages.php');
- if(!isset($GLOBALS["wrapper"])){
- if(isset($_SESSION["page_authorized"])&&$_SESSION["page_authorized"]){
- if (isset($_GET["action"]) && $_GET["action"]=="logout"){
- unset($_SESSION["page_authorized"]);
- header("HTTP/1.1 302 Found");
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- }
- if (isset($_SESSION["page_bad_authorized"]))
- unset($_SESSION["page_bad_authorized"]);
- if (isset($_SESSION["page_bad_password"]) && !(isset($_GET["action"]) && $_GET["action"]=="password_reminder"))
- unset($_SESSION["page_bad_password"]);
- if (isset($_SESSION["page_bad_auth"]))
- unset($_SESSION["page_bad_auth"]);
- if (isset($_SESSION["page_bad_active"]))
- unset($_SESSION["page_bad_active"]);
- if (isset($_POST["action"]) && $_POST["action"]=="page_authorization"){
- if(isset($_POST["register"])||isset($_POST["register_x"])){
- if(isset($GLOBALS["cms"]["config"]["site"]["register_packet_id"]) && $GLOBALS["cms"]["config"]["site"]["register_packet_id"]){
- $query="select id from pages where nested=0 and lang='{$_POST["lang"]}' and parent='{$GLOBALS["cms"]["config"]["site"]["register_packet_id"]}'";
- $_row=db_fetch_assoc(db_query($query));
- if(isset($_row["id"])){
- $GLOBALS["lang"]=$_POST["lang"];
- header("HTTP/1.1 302 Found");
- header("Location: ".$GLOBALS["relative_path"].$GLOBALS["cms_common"]->createsitelink(array("page"=>$_row["id"])));
- exit;
- }
- }elseif (isset($GLOBALS["cms"]["config"]["site"]["register_url"]) && $GLOBALS["cms"]["config"]["site"]["register_url"]){
- header("HTTP/1.1 302 Found");
- header("Location: ".$GLOBALS["cms"]["config"]["site"]["register_url"]);
- exit;
- }
- }
- if (trim($_POST["page_password"]) && trim($_POST["page_login"]) && !(isset($_POST["register"])||isset($_POST["register_x"]))){
- $query="select level,md5pass,email,active,ipaddresses,login,info,name from users where login='".trim($_POST["page_login"])."' limit 1";
- $result=db_query($query);
- $auth_row=db_fetch_assoc($result);
- if (db_affected_rows()>0){
- if ($auth_row["level"]==3 && isset($auth_row["active"])&&!$auth_row["active"]){
- $_SESSION["page_bad_authorized"]=1;
- //$_SESSION["page_bad_password"]=stripslashes($_POST["page_login"]);
- //$_SESSION["page_bad_email"]=$auth_row["email"];
- $_SESSION["page_bad_active"]=1;
- }elseif ($auth_row["md5pass"]==md5(trim($_POST["page_password"]))){
- if ($auth_row["ipaddresses"]){
- require_once("cms/.libs/login.php");
- $login_class= new cms_login();
- if($login_class->is_good_ip($auth_row["ipaddresses"])){
- $_SESSION["page_authorized"]=1;
- }else{
- $_SESSION["page_bad_authorized"]=1;
- $_SESSION["page_bad_ip"]=1;
- }
- unset($login_class);
- }else{
- $_SESSION["page_authorized"]=1;
- $_SESSION["auth_row"]=$auth_row;
- }
- }elseif ($auth_row["level"]==3){
- $_SESSION["page_bad_authorized"]=1;
- $_SESSION["page_bad_password"]=stripslashes($_POST["page_login"]);
- $_SESSION["page_bad_email"]=$auth_row["email"];
- }
- }else{
- $_SESSION["page_bad_authorized"]=1;
- }
- }else{
- $_SESSION["page_bad_authorized"]=1;
- }
- }
- }
- if (isset($_COOKIE["site_edit_mode"]) && $_COOKIE["site_edit_mode"]==1){
- $GLOBALS["cms"]["config"]["site"]["enable_cache"]=0;// disable cache
- $_SESSION["site_edit_mode"]=1;
- }
- $site_name="";
- if (isset($GLOBALS["cms"]["config"]["site"]["multi_site"]) && $GLOBALS["cms"]["config"]["site"]["multi_site"]==1){
- list($site_name)=db_fetch_row(db_query("select name from cms_sites where domain='{$_SERVER["HTTP_HOST"]}'"));
- }elseif ($cms_common->getsitevar("site")!=FALSE){
- $result=db_query("SELECT db,langs from cms_sites WHERE name='".$cms_common->getsitevar("site")."'");
- list($site_name)=db_fetch_row($result);
- }
- $result=db_query("SELECT db,langs from cms_sites WHERE name='".($site_name?$site_name:"default")."'");
- if (db_affected_rows()==0) die("Unknown site"); // uknown site.
- list($site,$langs)=db_fetch_row($result);
- db_select_db($site);
- if(!isset($langs))
- {
- list($langs)=db_fetch_row(db_query("SELECT langs from ".$GLOBALS["cms"]["config"]["sql"]["database"].".cms_sites WHERE name='default'"));
- }
- $lngarray=explode(";",$langs);
- foreach ($lngarray as $v)
- {
- $GLOBALS["cms"]["sitelangs"][]=substr($v,0,2);
- $GLOBALS["cms"]["startpage"][substr($v,0,2)]=substr($v,3);
- }
- unset($langs);
- if(!isset($GLOBALS["wrapper"])){
- if (($id==-1 || $id==0) && !is_object($found_handler))
- {
- if ($id==-1){
- if (isset($GLOBALS["requested_page"])&&is_file($GLOBALS["requested_page"])){
- ob_start();
- @include($GLOBALS["requested_page"]);
- $content = ob_get_contents();
- ob_end_clean();
- echo $content;
- exit();
- }elseif(isset($GLOBALS["no_page_specified"]) && $GLOBALS["no_page_specified"]==1){
- if(!(substr($lngarray[0],3)==0 || substr($lngarray[0],3)==""))
- $id=substr($lngarray[0],3);
- }
- if ($id==-1)
- $_GET["template"]="error404";
- }
- /*if(isset($_GET["template"]) && $_GET["template"]=="error404"){
- $request=(isset($_GET["request"])?$_GET["request"]:$_SERVER["PHP_SELF"]);
- $template="?template=error404&request=".$request.($_SERVER["QUERY_STRING"]?"&".$_SERVER["QUERY_STRING"]:"");
- }else{
- $template=($_SERVER["QUERY_STRING"]?"?".$_SERVER["QUERY_STRING"]:"");
- }*/
- if (isset($_GET["lang"])){
- if(!isset($GLOBALS["cms"]["startpage"][$_GET["lang"]])) die("Default page is not assigned :(");
- //if(isset($GLOBALS["no_page_specified"]) && $GLOBALS["no_page_specified"]==1){
- $id=$GLOBALS["cms"]["startpage"][$_GET["lang"]];
- //}else{
- //$GLOBALS["cms_common"]->http_redirect($_SERVER["SCRIPT_NAME"].'/page'.$GLOBALS["cms"]["startpage"][$_GET["lang"]].'.html'.$template);
- //exit;
- //}
- }else{
- if(substr($lngarray[0],3)==0 || substr($lngarray[0],3)=="") die("Default page is not assigned :(");
- //if(isset($GLOBALS["no_page_specified"]) && $GLOBALS["no_page_specified"]==1){
- $id=substr($lngarray[0],3);
- //}else{
- $id=substr($lngarray[0],3);
- //$GLOBALS["cms_common"]->http_redirect($_SERVER["SCRIPT_NAME"].'/page'.substr($lngarray[0],3).'.html'.$template);
- //exit;
- //}
- }
- }
- if (isset($_GET['plugin']))
- $plugin=$_GET['plugin'];
- elseif(isset($_POST['plugin']))
- $plugin=$_POST['plugin'];
- if(isset($_GET["mode"]) && $_GET["mode"]=="setflash"){
- $_SESSION["flash"]["version"]=$_GET["version"];
- $GLOBALS["cms_common"]->http_redirect($_SERVER["PHP_SELF"]);
- }
- if (isset($GLOBALS["cms"]["config"]["site"]["flashdetect"]) && $GLOBALS["cms"]["config"]["site"]["flashdetect"]==1 && !isset($_SESSION["flash"]["version"])
- && !isset($_GET["flash"])){
- //echo $cms_common->detectflash();
- //exit;
- }
- $site_closed=0;
- $site_closed_packet_id=0;
- if (file_exists(".plugins/site_closer/cms/main.php")){
- $query="select * from pl_site_closer";
- $res=db_query($query);
- $tmp_row=db_fetch_assoc($res);
- $site_closed=$tmp_row["closed"];
- $site_closed_packet_id=$tmp_row["packet_id"];
- }
- if ((isset($plugin) || is_object($found_handler)) && !$site_closed){
- $id=0;$text="";
- if (!(isset($GLOBALS["lang"])&&$GLOBALS["lang"]))
- $lang=@$_REQUEST["lang"];
- else
- $lang=$GLOBALS["lang"];
- if (isset($lang) && is_file("language/".$lang."/msg.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- }
- else die("can`t load lang resources");
- if (is_file("language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/common.php");
- require_once($encoded_msg_file);
- }
- if (isset($lang) && is_file("local/language/".$lang."/msg.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- }
- if (is_file("local/language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/common.php");
- require_once($encoded_msg_file);
- }
- if (!is_object($found_handler)){
- require_once(".plugins/{$plugin}/site/main.php");
- eval('$init=new '.$plugin.'_site;');
- }else{
- $init=$found_handler;
- }
- $params=array();
- if (is_object($found_handler)){
- unset($params);
- $params["requested_page"]=$GLOBALS["requested_page"];
- }
- $content=$init->ProcessCommand("show_block",$params);
- $text=$content["text"];
- if(isset($content["headers"][1]))
- $content["headers"]["item_name"]=$content["headers"][1];
- if(isset($content["headers"][0]))
- $content["headers"]["item_parents"]=$content["headers"][0];
- //$menu["top1i"]=$menu["top1"]=(isset($content["headers"][0])?$content["headers"][0]:"");
- //$menu["top2"]=(isset($content["headers"][1])?$content["headers"][1]:"");
- $menu["bottom"]=" ";
- unset($init);
- }
- else{
- $query="SELECT packets.type,pages.lang,pages.parent,packets.template,packets.id as pack_id,packets.protected,packets.copy_packet_id,packets.redirect,packets.disable_cache FROM packets,pages WHERE pages.nested=0 and pages.id='".$id."' AND pages.parent=packets.id";
- $result=db_query($query);
- if(db_affected_rows()==0) {
- if($GLOBALS["cms"]["config"]["cms"]["enable_acl"]==1){
- // trying to find it in the drafts
- $query="SELECT parent_page from cms_pages_drafts where id='$id'";
- $result=db_query($query);
- if (db_affected_rows()==0){
- $GLOBALS["cms_common"]->http_redirect('page0.html?'.($_SERVER["QUERY_STRING"]?$_SERVER["QUERY_STRING"]."&":"").'template=error404&request='.rawurlencode($_SERVER["PHP_SELF"]));
- }
- $GLOBALS["cms"]["config"]["site"]["enable_cache"]=0;// disable cache
- list($new_id)=db_fetch_row($result);
- $query="SELECT packets.type,pages.lang,pages.parent,packets.template,packets.id as pack_id,packets.protected,packets.copy_packet_id,packets.redirect,packets.disable_cache FROM packets,pages WHERE pages.id='".$new_id."' AND pages.parent=packets.id";
- $result=db_query($query);
- }else{
- if ($id!=substr($lngarray[0],3)){
- $GLOBALS["cms_common"]->http_redirect('page0.html?'.($_SERVER["QUERY_STRING"]?$_SERVER["QUERY_STRING"]."&":"").'template=error404&request='.rawurlencode($_SERVER["PHP_SELF"]));
- }
- }
- }
- $packet_data=db_fetch_assoc($result);
- list($type,$lang,$parentid,$tpl_id,$pack_id,$password_protected,$copy_packet_id)=array(
- isset($packet_data["type"])?$packet_data["type"]:"",
- isset($packet_data["lang"])?$packet_data["lang"]:"",
- isset($packet_data["parent"])?$packet_data["parent"]:"",
- isset($packet_data["template"])?$packet_data["template"]:"",
- isset($packet_data["pack_id"])?$packet_data["pack_id"]:"",
- isset($packet_data["protected"])?$packet_data["protected"]:"",
- isset($packet_data["copy_packet_id"])?$packet_data["copy_packet_id"]:"",
- isset($packet_data["redirect"])?$packet_data["redirect"]:"",
- );
- $page_removed=false;
- if (db_affected_rows()==0){
- $page_removed=true;
- }
- if($page_removed && $id==substr($lngarray[0],3)){
- if(isset($lngarray[0]))
- $lang=substr($lngarray[0],0,2);
- }
- if ($copy_packet_id){
- $query="select packets.type,pages.id from pages left join packets on (pages.parent=packets.id) where parent='$copy_packet_id' and lang='$lang'";
- $res=db_query($query);
- list($original_type,$original_page_id)=db_fetch_row($res);
- if (isset($packet_data["redirect"])&&$packet_data["redirect"]){
- $GLOBALS["cms_common"]->http_redirect($GLOBALS["relative_path"].$cms_common->createsitelink(array("page"=>$original_page_id)));
- exit;
- }
- }
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- if (is_file("language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/common.php");
- require_once($encoded_msg_file);
- }
- if (is_file("local/language/".$lang."/msg.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- }
- if (is_file("local/language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/common.php");
- require_once($encoded_msg_file);
- }
- if($page_removed && $id==substr($lngarray[0],3)){
- $content['text']=$msg["default_page_does_not_exist"];
- }
- if($site_closed){
- if(!isset($_GET["template"]) || $_GET["template"]!="constr"){
- $GLOBALS["cms_common"]->http_redirect($GLOBALS["relative_path"].'page0.html?'.($_SERVER["QUERY_STRING"]?$_SERVER["QUERY_STRING"]."&":"").'template=constr');
- exit;
- }else{
- if ($site_closed_packet_id==0){
- $content['text']=$msg["site_closed"];
- $page_removed=true;
- }else{
- $query="select id from pages where parent='{$site_closed_packet_id}' and lang='$lang'";
- $res=db_query($query);
- $tmp_row=db_fetch_assoc($res);
- if(db_affected_rows()==0){
- $page_removed=true;
- $content['text']=$msg["site_closed"];
- }else{
- $id=$tmp_row["id"];
- $page_removed=false;
- $query="SELECT packets.type,pages.lang,pages.parent,packets.template,packets.id as pack_id,packets.protected,packets.copy_packet_id FROM packets,pages WHERE pages.id='".$id."' AND pages.parent=packets.id";
- $result=db_query($query);
- list($type,$lang,$parentid,$tpl_id,$pack_id,$password_protected,$copy_packet_id)=db_fetch_row($result);
- }
- }
- }
- }
- if (!$page_removed){
- // fwrite ( int fp, string string [, int length])
- if ($GLOBALS["rewrite_mode"]==0){
- if (substr($_SERVER["PHP_SELF"],strlen($_SERVER["PHP_SELF"])-6,6)==".html/"){
- $GLOBALS["cms_common"]->http_redirect(substr($_SERVER["PHP_SELF"],0,strlen($_SERVER["PHP_SELF"])-1).(isset($_SERVER["QUERY_STRING"])&&trim($_SERVER["QUERY_STRING"])?"?".$_SERVER["QUERY_STRING"]:""));
- exit;
- }
- $fname=str_replace(array("*","?","\\","/",".."),"",substr(strrchr($_SERVER["PHP_SELF"], "/"), 1));
- if (!$fname)
- $fname="{$id}.html";
- }else{
- $fname=$GLOBALS["requested_page"];
- }
- $query="SELECT max(mtime) from pages where id=$id or parent='".$copy_packet_id."'";
- list($mtime)=db_fetch_row(db_query($query));
- if (isset($packet_data["disable_cache"])&&$packet_data["disable_cache"]==1){
- $GLOBALS["cms"]["config"]["site"]["enable_cache"]=0;
- }
- require_once(".plugins/".($copy_packet_id?$original_type:$type)."/site/main.php");
- eval('$init=new '.($copy_packet_id?$original_type:$type).'_site;');
- if ($GLOBALS["cms"]["config"]["site"]["enable_cache"]==0) $nocache=1;
- else $nocache=0;
- if ($_SERVER["QUERY_STRING"]!="" || $_SERVER["REQUEST_METHOD"]!="GET" || $mtime==1) $nocache=1;
- if(false /*$password_protected==1 && (!isset($_SESSION["page_authorized"])||$_SESSION["page_authorized"]!=1)*/){
- if (isset($_GET["action"]) && $_GET["action"]=="password_reminder"){
- require_once("cms/.libs/db_common.php");
- require_once("cms/.libs/mail.php");
- $db_common=new db_common();
- $new_pass=$cms_common->genpassword(8);
- $sql=$db_common->make_update_sql("users",array(
- "md5pass"=>$new_pass,
- ),array("login"=>$_SESSION["page_bad_password"]),
- array("md5pass"=>"md5"));
- db_query($sql);
- $cms_common->mail_to($_SESSION["page_bad_email"],$msg["remind_password_request"],"Login: ".$_SESSION["page_bad_password"]."\nPassword: $new_pass",array(),array("from"=>$GLOBALS["cms"]["config"]["site"]["admin_email"]));
- $GLOBALS["cms_common"]->http_redirect($_SERVER["PHP_SELF"]."?action=reminded");
- }elseif (isset($_GET["action"]) && $_GET["action"]=="reminded"){
- $content['text']='<p class="content-text">'.$msg["remind_password_text"].'</p>';
- $content['text'].='<p class="content-text"><a href="'.$_SERVER["PHP_SELF"].'">'.$msg["sign_in"].'</a></p>';
- }elseif (isset($_GET["action"]) && $_GET["action"]=="user_registered"){
- $content['text']='<p class="content-text">'.$msg["user_registered"].'</p>';
- }else{
- if (!(isset($_POST["register"])||isset($_POST["register_x"]))){
- $content['text']='<br><form name="page" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
- if (isset($_SESSION["page_bad_authorized"]) && $_SESSION["page_bad_authorized"]==1 && !isset($_POST["register_sign_in"])){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["authorization_error"].'!</span></p>';
- }
- //if (isset($GLOBALS["cms"]["config"]["site"]["register_url"]) && $GLOBALS["cms"]["config"]["site"]["register_url"]){
- if ($register_btn=glob("pics/auth/{$GLOBALS["lang"]}/register.*")){
- $register_text='<input type="image" name="register" value="'.$GLOBALS["msg"]["register"].'" src="'.$register_btn[0].'" id="btn-register" onMouseOver="SwapImage(\'btn-register\',1)" onMouseOut="SwapImage(\'btn-register\',0)">';
- //print_r($register_btn);die();
- }elseif($register_btn=glob("pics/auth/register.*")){
- $register_text='<input type="image" name="register" value="'.$GLOBALS["msg"]["register"].'" src="'.$register_btn[0].'" id="btn-register" onMouseOver="SwapImage(\'btn-register\',1)" onMouseOut="SwapImage(\'btn-register\',0)">';
- }else{
- $register_text='<input type="submit" name="register" value="'.$GLOBALS["msg"]["register"].'">';
- }
- //}
- $content['text'].='<center>';
- if (isset($_SESSION["page_bad_password"]) && $_SESSION["page_bad_password"]){
- $content['text'].='<p align="center"><span class="form-error">'.$GLOBALS["msg"]["invalid_password"].'</span></p>';
- }
- if (isset($_SESSION["page_bad_active"]) && $_SESSION["page_bad_active"]){
- $content['text'].='<p align="center"><span class="form-error">'.$GLOBALS["msg"]["login_is_not_active"].'</span></p>';
- }
- if (isset($_SESSION["page_bad_ip"]) && $_SESSION["page_bad_ip"]){
- $content['text'].='<p align="center"><span class="form-error">'.$GLOBALS["msg"]["bad_ip"].'</span></p>';
- }
- $content['text'].='<p class="content-text">'.$msg["authorization_required"].'.</p><br>';
- if ($sign_in_btn=glob("pics/auth/{$GLOBALS["lang"]}/login.*")){
- $sign_in_text='<input type="image" name="sign-in" value="'.$GLOBALS["msg"]["sign_in"].'" src="'.$sign_in_btn[0].'" id="btn-sign-in" onMouseOver="SwapImage(\'btn-sign-in\',1)" onMouseOut="SwapImage(\'btn-sign-in\',0)">';
- //print_r($register_btn);die();
- }elseif($sign_in_btn=glob("pics/auth/login.*")){
- $sign_in_text='<input type="image" name="sign-in" value="'.$GLOBALS["msg"]["sign_in"].'" src="'.$sign_in_btn[0].'" id="btn-sign-in" onMouseOver="SwapImage(\'btn-sign-in\',1)" onMouseOut="SwapImage(\'btn-sign-in\',0)">';
- }else{
- $sign_in_text='<input type="submit" name="sign-in" value="'.$GLOBALS["msg"]["sign_in"].'">';
- }
- $content['text'].='<table cellpadding="3" cellspacing="1" border="0" >';
- $content['text'].='<tr><td class="content-text">'.$msg["your_login"].':</td><td><input name="page_login" value="'.(isset($_POST["page_login"])?$_POST["page_login"]:"").'"></td></tr>';
- $content['text'].='<tr><td class="content-text">'.$msg["your_password"].':</td><td><input type="password" name="page_password"></td></tr>';
- $content['text'].='<tr><td align="center" colspan="2"><input type="hidden" name="action" value="page_authorization">'.$sign_in_text.' '.(isset($register_text)&&$register_text?$register_text:"").'</td></tr>';
- $content['text'].='</table></form>';
- if (isset($_POST["action"]) && $_POST["action"]=="page_authorization" && isset($_SESSION["page_bad_password"]) && $_SESSION["page_bad_password"]){
- $content['text'].='<p><a class="content-link" href="'.$_SERVER["PHP_SELF"].'?action=password_reminder&login='.$_SESSION["page_bad_password"].'">'.$GLOBALS["msg"]["remind_password"].'</a></p>';
- }
- $content['text'].='</center>';
- }else{
- $content['text']='';
- if(isset($_POST["action"]) && $_POST["action"]=="user_registration"){
- if (!isset($_POST["desired_login"]) || !$_POST["desired_login"]){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["enter_desired_login"].'!</span></p>';
- }elseif(!preg_replace("@[^a-zA-Z0-9_]@","",trim($_POST["desired_login"]))){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["invalid_desired_login"].'!</span></p>';
- }elseif(isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1&&(!isset($_POST["name"]) || !$_POST["name"])){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["enter_name"].'!</span></p>';
- }elseif(!isset($_POST["email"]) || !$_POST["email"]){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["enter_email"].'!</span></p>';
- }elseif(!$cms_common->valid_email($_POST["email"])){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["email_invalid"].'!</span></p>';
- }elseif(isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1&&(!isset($_POST["company"]) || !$_POST["company"])){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["enter_company"].'!</span></p>';
- }else{
- $query="select * from users where login = '".trim($_POST["desired_login"])."' or (level=3 and email='".trim($_POST["email"])."')";
- $res=db_query($query);
- if (db_affected_rows()>0){
- $_row=db_fetch_assoc($res);
- if ($_row["email"]==trim($_POST["email"])){
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["email_exists"].'!</span></p>';
- }else{
- $content['text'].='<p class="content-text" align="center"><span class="form-error">'.$msg["login_exists"].'!</span></p>';
- }
- }else{
- require_once("cms/.libs/db_common.php");
- require_once("cms/.libs/mail.php");
- $db_common=new db_common();
- $new_pass=$cms_common->genpassword(8);
- $sql=$db_common->make_insert_sql("users",array(
- "login"=>$_POST["desired_login"],
- "md5pass"=>$new_pass,
- "name"=>(isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1?$_POST["name"]:""),
- "email"=>$_POST["email"],
- "info"=>(isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1?$_POST["company"]:""),
- "level"=>3,
- "lang"=>$GLOBALS["lang"],
- "active"=>1 /*(isset($GLOBALS["cms"]["config"]["site"]["registration_approve_required"])&&$GLOBALS["cms"]["config"]["site"]["registration_approve_required"]==1?0:1)*/
- ),
- array("md5pass"=>"md5"));
- db_query($sql);
- $user_id=db_insert_id();
- if(isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1)
- $msg["registration_mail_message"]=str_replace("<!--%name%-->",stripslashes($_POST["name"]),$msg["registration_mail_message"]);
- $msg["registration_mail_message"]=str_replace("<!--%login%-->",stripslashes($_POST["desired_login"]),$msg["registration_mail_message"]);
- $msg["registration_mail_message"]=str_replace("<!--%password%-->",$new_pass,$msg["registration_mail_message"]);
- $cms_common->mail_to($_POST["email"],$msg["registration_on_site"]." ".$GLOBALS["main_title"],$msg["registration_mail_message"],array(),array("from"=>$GLOBALS["cms"]["config"]["site"]["admin_email"]));
- $ip=$GLOBALS["cms_common"]->get_real_ip();
- if ($ip!=trim($_SERVER["REMOTE_ADDR"])){
- $proxy_ip=$_SERVER["REMOTE_ADDR"];
- $ip.="\nProxy IP: ".$proxy_ip;
- }
- $msg["registration_admin_message"]=str_replace("<!--%REFERER%-->",(isset($_SESSION["HTTP_REFERERS"])?implode(",\n",is_array($_SESSION["HTTP_REFERERS"])?$_SESSION["HTTP_REFERERS"]:array($_SESSION["HTTP_REFERERS"])):""),$msg["registration_admin_message"]);
- $msg["registration_admin_message"]=str_replace("<!--%IP%-->",@gethostbyaddr(stripslashes($ip)),$msg["registration_admin_message"]);
- if (isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1)
- $msg["registration_admin_message"]=str_replace("<!--%name%-->",stripslashes($_POST["name"]),$msg["registration_admin_message"]);
- $msg["registration_admin_message"]=str_replace("<!--%login%-->",stripslashes($_POST["desired_login"]),$msg["registration_admin_message"]);
- $msg["registration_admin_message"]=str_replace("<!--%password%-->",$new_pass,$msg["registration_admin_message"]);
- if (isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1)
- $msg["registration_admin_message"]=str_replace("<!--%company%-->",$_POST["company"],$msg["registration_admin_message"]);
- $msg["registration_admin_message"]=str_replace("<!--%email%-->",$_POST["email"],$msg["registration_admin_message"]);
- if (isset($GLOBALS["cms"]["config"]["site"]["registration_approve_required"])&&$GLOBALS["cms"]["config"]["site"]["registration_approve_required"]==1){
- $msg["registration_admin_message"]=str_replace("<!--%approve_link%-->","https://{$_SERVER["HTTP_HOST"]}".(isset($GLOBALS["requested_path"])?$GLOBALS["requested_path"]:"")."/cms/index.php?mode=settings&plugin=web_users&action=approve&user_id={$user_id}",$msg["registration_admin_message"]);
- $msg["registration_admin_message"]=str_replace("<!--%delete_link%-->","https://{$_SERVER["HTTP_HOST"]}".(isset($GLOBALS["requested_path"])?$GLOBALS["requested_path"]:"")."/cms/index.php?mode=settings&plugin=web_users&action=delete&user_id={$user_id}",$msg["registration_admin_message"]);
- }
- $cms_common->mail_to($GLOBALS["cms"]["config"]["site"]["admin_email"],$msg["registration_on_site"]." ".$GLOBALS["main_title"],$msg["registration_admin_message"],array(),array("from"=>$GLOBALS["cms"]["config"]["site"]["admin_email"]));
- $GLOBALS["cms_common"]->http_redirect($_SERVER["PHP_SELF"]."?action=user_registered");
- }
- }
- }
- $GLOBALS["cms_common"]->include_template_files(array(
- array(
- "type"=>"script",
- "src"=>"cms/js/site_js/tooltip.js",
- "dst"=>"jscripts/cms_tooltip.js",
- ),
- array(
- "type"=>"css",
- "src"=>"cms/styles/site_css/tooltip.css",
- "dst"=>"styles/cms_tooltip.css",
- ),
- ));
- $content['text'].=$msg["register_form_top_msg"];
- $content['text'].='<br><form name="page" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
- $content['text'].='<center><table cellpadding="3" cellspacing="1" border="0" >';
- $content['text'].='<tr><td class="content-text">'.$msg["desired_login"].$GLOBALS["cms_common"]->add_tooltip_code($msg["allowed_characters"],"this",1).' <span class="req">*</span>:</td><td><input name="desired_login" value="'.(isset($_POST["desired_login"])?htmlspecialchars(stripslashes($_POST["desired_login"])):"").'"></td></tr>';
- if (isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1)
- $content['text'].='<tr><td class="content-text">'.$msg["name"].' <span class="req">*</span>:</td><td><input name="name" value="'.(isset($_POST["name"])?htmlspecialchars(stripslashes($_POST["name"])):"").'"></td></tr>';
- $content['text'].='<tr><td class="content-text">'.site_mes("E-mail").' <span class="req">*</span>:</td><td><input name="email" value="'.(isset($_POST["email"])?htmlspecialchars(stripslashes($_POST["email"])):"").'"></td></tr>';
- if (isset($GLOBALS["cms"]["config"]["site"]["complex_registration"])&&$GLOBALS["cms"]["config"]["site"]["complex_registration"]==1)
- $content['text'].='<tr><td class="content-text">'.$msg["company"].' <span class="req">*</span>:</td><td><input name="company" value="'.(isset($_POST["company"])?htmlspecialchars(stripslashes($_POST["company"])):"").'"></td></tr>';
- if ($register_btn=glob("pics/auth/{$GLOBALS["lang"]}/register.*")){
- $register_btn_html=' src="'.$register_btn[0].'" id="btn-register" onMouseOver="SwapImage(\'btn-register\',1)" onMouseOut="SwapImage(\'btn-register\',0)"';
- }elseif($register_btn=glob("pics/auth/register.*")){
- $register_btn_html=' src="'.$register_btn[0].'" id="btn-register" onMouseOver="SwapImage(\'btn-register\',1)" onMouseOut="SwapImage(\'btn-register\',0)"';
- }else{
- $register_btn_html="";
- }
- if ($sign_in_btn=glob("pics/auth/{$GLOBALS["lang"]}/login.*")){
- $register_signin_btn_html=' src="'.$sign_in_btn[0].'" id="btn-sign-in" onMouseOver="SwapImage(\'btn-sign-in\',1)" onMouseOut="SwapImage(\'btn-sign-in\',0)"';
- }elseif($sign_in_btn=glob("pics/auth/login.*")){
- $register_signin_btn_html=' src="'.$sign_in_btn[0].'" id="btn-sign-in" onMouseOver="SwapImage(\'btn-sign-in\',1)" onMouseOut="SwapImage(\'btn-sign-in\',0)"';
- }else{
- $register_signin_btn_html="";
- }
- $content['text'].='<tr><td align="center" colspan="2"><input type="hidden" name="action" value="user_registration"><input '.($register_btn_html?'type="image"':'type="submit"').' name="register" value="'.$msg["register"].'"'.$register_btn_html.'> <!-- <input '.($register_signin_btn_html?'type="image"':'type="submit"').' name="register_sign_in" value="'.$msg["sign_in"].'"'.$register_signin_btn_html.'">--></td></tr>';
- $content['text'].='</table></form>';
- $content['text'].='</center>';
- $content['text'].=$msg["register_form_bottom_msg"];
- }
- }
- }elseif($nocache==0 && is_file("cache/".md5(($site_name?$site_name."/":"")."$fname")) && $mtime-filemtime("cache/".md5(($site_name?$site_name."/":"")."$fname"))<2) { /* bug around for dos like FS */
- $loaded_from_cache=true;
- $text=file_get_contents("cache/".md5(($site_name?$site_name."/":"")."$fname"));
- $content['text']=$text;
- }else{
- $text=$init->ProcessCommand(($copy_packet_id && $original_page_id!=$id?$original_page_id:$id),"show_page");
- if (is_file(".plugins/auto_updater/cms/auto_updater_class.php")){//auto update
- if (preg_match("<%.*?%>",$text)){
- require_once(".plugins/auto_updater/cms/auto_updater_class.php");
- $text=$auto_updater_class->replace_codes($id,$text);
- }
- }
- $content['text']=$text;
- if ($nocache==0 && !(isset($_SESSION["site_edit_mode"])&&$_SESSION["site_edit_mode"]==1)) {
- if ($mtime==0) {$mtime=time();db_query("UPDATE pages set mtime=$mtime where id=$id");}; // old base fix
- if (file_exists("cache/".md5(($site_name?$site_name."/":"")."$fname"))){
- @unlink("cache/".md5(($site_name?$site_name."/":"")."$fname"));
- }
- $fp=fopen("cache/".md5(($site_name?$site_name."/":"")."$fname"),"w+");
- fwrite($fp,$text);
- fclose($fp);
- touch("cache/".md5(($site_name?$site_name."/":"")."$fname"),$mtime);
- }
- }
- $page_keywords=db_fetch_assoc($cms_common->get_page_meta(array("page"=>(isset($original_page_id)&&$original_page_id!=$id?$original_page_id:$id))));
- }
- }
- }else{ //end of !isset($GLOBALS["wrapper"])
- if (isset($GLOBALS["wrapper"]["lang"])){
- $lang=$GLOBALS["wrapper"]["lang"];
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- if (is_file("language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("language/common.php");
- require_once($encoded_msg_file);
- }
- if (is_file("local/language/".$lang."/msg.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/".$lang."/msg.php");
- require_once($encoded_msg_file);
- }
- if (is_file("local/language/common.php")){
- $encoded_msg_file=$cms_common->get_encoded_msg_file("local/language/common.php");
- require_once($encoded_msg_file);
- }
- }
- $content["text"]=isset($GLOBALS["wrapper"]["content"])?$GLOBALS["wrapper"]["content"]:"";
- $GLOBALS["lang"]=isset($GLOBALS["wrapper"]["lang"])?$GLOBALS["wrapper"]["lang"]:(isset($GLOBALS["cms"]["sitelangs"][0])?$GLOBALS["cms"]["sitelangs"][0]:"");
- }
- if (!isset($GLOBALS["wrapper"])){
- if(isset($_GET["mode"]) && $_GET["mode"]=="sendfile" && (!$password_protected || isset($_SESSION["page_authorized"]) && $_SESSION["page_authorized"]==1)){
- if(!$password_protected){
- $cms_common->SendFile($_GET["fileid"]); exit;
- }
- $file_data=$cms_common->GetFile($_GET["fileid"]);
- $query="select parent from pages where id='{$GLOBALS["id"]}'";
- $_res=db_query($query);
- $_row=db_fetch_assoc($_res);
- $query="select id from pages where parent='{$_row["parent"]}'";
- $_res=db_query($query);
- while($_row=db_fetch_assoc($_res)){
- $_ids[]=$_row["id"];
- }
- if (in_array($file_data[3],$_ids)){
- $cms_common->SendFile($_GET["fileid"]); exit;
- }
- }
- /* Process possible automatic values */
- if (isset($GLOBALS["cms"]["config"]["site"]["custom_automatic_values"]) && $GLOBALS["cms"]["config"]["site"]["custom_automatic_values"]){
- preg_match_all("/(<|<)%=(\w+?)::(.+?)%(>|>)/",$content["text"],$matches,PREG_SET_ORDER);
- if (count($matches)>0){
- foreach ($matches as $match){
- if (isset($match[2]) && isset($match[3])){
- if (is_file("./.plugins/".trim($match[2])."/site/main.php")){
- require_once("./.plugins/".trim($match[2])."/site/main.php");
- $module= trim($match[2])."_site";
- $init = new $module;
- if (method_exists($init,"get_code_value")){
- $text=$init->get_code_value(array("match"=>$match[3],"page_id"=>$id));
- }else{
- $text="";
- }
- $content["text"]=str_replace($match[0],$text,$content["text"]);
- }
- }
- }
- }
- }
- /* Process possible automatic values end */
- /* correct path to local images */
- if (isset($content["text"])){
- $content["text"]=str_replace("https://".$_SERVER["HTTP_HOST"].$GLOBALS["requested_path"]."/images/","../images/",$content["text"]);
- preg_match_all('/<img([^>]+)src="(\.\.\/)?([^>"\']+)"([^>]*)>/msi',$content["text"],$matches,PREG_SET_ORDER);
- foreach($matches as $match){
- if (isset($match[3])){
- if (is_file($match[3])){
- //$imageinfo=getimagesize("images/".$match[2].".swf");
- $content["text"]=str_replace($match[0],'<img'.$match[1].'src="'.$GLOBALS["relative_path"].$match[3].'"'.$match[4].'>',$content["text"]);
- }
- }
- //die();
- }
- //$content["text"]=$text;
- }
- /* correct path to local images end*/
- }
- if ((!isset($GLOBALS["cms"]["config"]["site"]["hide_signed_in_panel"])||!$GLOBALS["cms"]["config"]["site"]["hide_signed_in_panel"]) && isset($_SESSION["page_authorized"])&&$_SESSION["page_authorized"] && isset($_SESSION["auth_row"])){
- if (!isset($_GET['template'])||$_GET['template']!="popup")
- $content['text']='<p align="right">'."{$_SESSION["auth_row"]["login"]}".' [<a href="'.$_SERVER["PHP_SELF"].'?action=logout">'.$GLOBALS["msg"]["Logout"].'</a>]</p>'.$content['text'];
- }
- if(isset($plugin_folder) && is_file($plugin_folder."template.tpl")){
- ob_start();
- include($plugin_folder."template.tpl");
- $content['text']=ob_get_contents();
- ob_clean();
- }
- /* new template implementation */
- if(isset($_GET['template'])){
- $template_name=$_GET['template'];
- $query="select * from pl_template where template='$template_name'";
- $row=db_fetch_assoc(db_query($query));
- $tpl_id=$row['id'];
- }else{
- if (!isset($tpl_id)||!$tpl_id){
- $tpl_id=0;
- if (isset($GLOBALS["cms"]["config"]["site"]["menu_templates_enable"]) && $GLOBALS["cms"]["config"]["site"]["menu_templates_enable"]){
- $query="SELECT masterdiv FROM pages WHERE id=$id";
- $res=db_query($query);
- list($master_div)=db_fetch_row($res);
- if ($master_div>0)
- $query="select menu.template_id,menu.parent_id from menu where menu='$master_div'";
- else
- $query="select menu.template_id,menu.parent_id from menu where pageid='$id'";
- $res=db_query($query);
- $row=db_fetch_assoc($res);
- /*$menu_template_id=$row["template_id"];
- $menu_parent=$row["parent"];*/
- while(!$row["template_id"] && $row["parent_id"]){
- $query="select menu.template_id,menu.parent_id from menu where id='{$row["parent_id"]}'";
- $res=db_query($query);
- $row=db_fetch_assoc($res);
- /*$menu_template_id=$row["template_id"];
- $menu_parent=$row["parent"];*/
- }
- if ($row["template_id"]){
- $tpl_id=$row["template_id"];
- }
- }
- }
- $query="select * from pl_template where id='$tpl_id'";
- $row=db_fetch_assoc(db_query($query));
- $GLOBALS["template_instance_name"]=$row["name"];
- $tpl_id=$row['id'];
- $template_name=$row['template'];
- }
- if (isset($GLOBALS["wrapper"])){
- if(isset($GLOBALS["wrapper"]["template_name"])){
- $query="select * from pl_template where name='{$GLOBALS["wrapper"]["template_name"]}'";
- $row=db_fetch_assoc(db_query($query));
- if (isset($row["id"])){
- $GLOBALS["template_instance_name"]=$row["name"];
- $tpl_id=$row['id'];
- $template_name=$row['template'];
- }
- }
- }
- if(!isset($GLOBALS["template_instance_name"])){
- $GLOBALS["template_instance_name"]=isset($template_name)?$template_name:"";
- }
- if (!isset($GLOBALS["startpage_settings"])){
- if($template_name!="error404" && isset($GLOBALS["cms"]["startpage"][$GLOBALS["lang"]]) && $GLOBALS["cms"]["startpage"][$GLOBALS["lang"]]==$GLOBALS["id"])
- $GLOBALS["startpage_settings"]=1;
- else
- $GLOBALS["startpage_settings"]=0;
- }
- if (!isset($GLOBALS["wrapper"]) && $template_name!="error404"){
- if (!(isset($loaded_from_cache)&&$loaded_from_cache)){
- $GLOBALS["content"]["text"]=$GLOBALS["cms_common"]->load_modifiers("rules.lst",$GLOBALS["content"]["text"]);
- }
- }
- if (!file_exists(".include/templates/".$template_name."/template.php")){
- if ($template_name=="error404"){
- $loaded_from_cache=false;
- if (isset($GLOBALS["error404_text"]))
- $content['text']=$GLOBALS["error404_text"];
- else
- $content['text']='
- <p><SPAN class="error">Error 404</SPAN> - <b>the page cannot be found</b></p>
- '.(isset($_GET["request"])
- ?'<p><a class="content-link" href="'.$_GET["request"].'">'.$_GET["request"].'</a>'
- :''
- ).'
- <br>
- The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.<br>
- <br>Please try the following:<ul>
- <li>If you typed the page address in the Address bar, make sure that it is spelled correctly.
- </li><li>Open the <a class="content-link" href="../'.$cms_common->createsitelink(array("page"=>$GLOBALS["cms"]["startpage"][$GLOBALS["lang"]])).'" target="_top">'.$GLOBALS["cms"]["startpage"][$GLOBALS["lang"]].".html".'</a> home page, and then look for links to the information you want.
- </li><li>Click the <a class="content-link" href="javascript:history.back(1)">Back</a>, button to try another link.
- </li>
- ';
- }
- if ($template_name!="popup"){
- $template_name="default";
- $tpl_id=0;
- }
- }
- if(isset($GLOBALS["original_type"])){
- $plugin_type=$GLOBALS["original_type"];
- }elseif(isset($GLOBALS["type"])){
- $plugin_type=$GLOBALS["type"];
- }elseif(isset($GLOBALS["plugin"])){
- $plugin_type=$GLOBALS["plugin"];
- }elseif(is_object($found_handler)){
- $plugin_type=$handler;
- }
- if(isset($plugin_type)){
- $GLOBALS["cms_common"]->include_template_files(
- array(
- array(
- "src"=>".plugins/{$plugin_type}/site/style.css",
- "dst"=>"styles/{$plugin_type}.css",
- "type"=>"css",
- )
- )
- );
- }
- require_once("cms/.libs/template.php");
- $tpl_class = new cms_template($template_name);
- if (!isset($_GET['plugin'])){
- /* TODO: if (!isset($content["headers"]["item_name"]) && isset($page_keywords["meta_name"]) && $page_keywords["meta_name"]){
- $content["headers"]["item_name"]=stripslashes($page_keywords["meta_name"]);
- $tpl_class->content=$content;
- }*/
- /*$menus_count=isset($GLOBALS["cms"]["config"]["site"]["menus"])?$GLOBALS["cms"]["config"]["site"]["menus"]:1;
- for ($i=1;$i<=$menus_count;$i++){
- if (!isset($menu["top1"]) || !$menu["top1"] || $menu["top1"]==" ")
- $menu["top1"]=strip_tags($tpl_class->show_block("menu".($i==1?"":$i)."::item_parents",$id));
- if (!isset($menu["top2"]) || !$menu["top2"] || $menu["top2"]==" ")
- $menu["top2"]=$tpl_class->show_block("menu".($i==1?"":$i)."::item_name",$id);
- }
- if (!$menu["top2"])
- $menu["top2"]=$menu["top1"];*/
- }else{
- //$menu["top1"]=(isset($content["headers"][1]))?$content["headers"][1]:"";
- //$menu["top2"]=$content["headers"][0];
- }
- /*
- if ($template_name=="popup"){
- include(".include/header.php");
- if (is_file(".include/popup_header.php")){
- include(".include/popup_header.php");
- }
- echo $content['text'];
- if (is_file(".include/popup_footer.php")){
- include(".include/popup_footer.php");
- }
- include(".include/footer.php");
- exit();
- }
- */
- if ($template_name=="print"){
- $GLOBALS["template_include_files"]["css"]["print.css"]="";
- }
- if (isset($content))
- $tpl_class->content=$content;
- if (!isset($pack_id))
- $pack_id=0;
- if (method_exists($cms_common,"get_fav_blocks")){
- $menu_favblocks=$cms_common->get_menu_fav_blocks($GLOBALS["id"]);
- if ($menu_favblocks["top"])
- $tpl_class->content["text"]=$menu_favblocks["top"].$tpl_class->content["text"];
- if ($menu_favblocks["bottom"])
- $tpl_class->content["text"]=$tpl_class->content["text"].$menu_favblocks["bottom"];
- }
- $text=$tpl_class->load_template($tpl_id,$template_name,$id,$pack_id,$row["parent_id"]);
- if (file_exists(".include/templates/".$template_name."/header.php")){
- include(".include/templates/".$template_name."/header.php");
- }else
- include(".include/header.php");
- //****** webstat ******
- if (file_exists(".plugins/webstat/cms/webstat.class.php")){
- chdir("cms");
- if(is_file("../.plugins/webstat/settings.ini")) {
- $GLOBALS["plugins"]["webstat"]["settings"]=parse_ini_file("../.plugins/webstat/settings.ini", TRUE);
- }else{
- $GLOBALS["plugins"]["webstat"]["settings"]["visitor_timeout"]=30;
- $GLOBALS["plugins"]["webstat"]["settings"]["db_table_prefix"]="pl_webstat";
- $GLOBALS["plugins"]["webstat"]["settings"]["country_ip_file"]=".plugins/webstat/data/ip-to-country.csv";
- $GLOBALS["plugins"]["webstat"]["settings"]["query_string"]="mode=settings&plugin=webstat";
- }
- $GLOBALS["plugins"]["webstat"]["settings"]["page_name"]=isset($menu["top2"])?$menu["top2"]:"";
- require_once("../.plugins/webstat/cms/webstat.class.php");
- $webstat = new webstat_class("track",$GLOBALS["plugins"]["webstat"]["settings"]);
- chdir("../");
- unset($webstat);
- }
- //****** webstat ******
- echo preg_replace(array('/^( |\t)+/m'),"",$text);
- if (file_exists(".include/templates/".$template_name."/footer.php"))
- include(".include/templates/".$template_name."/footer.php");
- else
- include(".include/footer.php");
- function error_handler($errno, $errmsg, $filename, $linenum, $vars) {
- if($errno == E_STRICT) return;
- if(defined('E_DEPRECATED') && $errno == E_DEPRECATED) return;
- $subject='Error on the site: '.$_SERVER["HTTP_HOST"];
- $mailtext=$subject.'
- ����: '.date("F j, Y, g:i a").'
- ����� ������: '.$errno.'
- ���������: '.stripslashes($errmsg).'
- � �����: '.stripslashes($filename).'
- ����� ������: '.stripslashes($linenum).'
- ��������: https://'.$_SERVER["HTTP_HOST"]."/".$_SERVER["PHP_SELF"].(isset($_SERVER["QUERY_STRING"])?"?".$_SERVER["QUERY_STRING"]:"").'
- '.(isset($_POST) && is_array($_POST)?"POST=".print_r($_POST,1):"").'
- '.("_SERVER=".print_r($_SERVER,1)).'
- ';
- $headers = 'MIME-Version: 1.0' . "\n";
- $headers .= 'Content-type: text/plain; charset=windows-1251' . "\n";
- //$headers .= 'To: Jens <jkuest@gmail.com>' . "\n";
- mail("jkuest@gmail.com",$subject,$mailtext,$headers);
- if (!isset($GLOBALS["cms"]["config"]["site"]["show_errors"])||$GLOBALS["cms"]["config"]["site"]["show_errors"]==1)
- return false;
- //print $errmsg." in $filename:$linenum\n";
- return true;
- /*$fp=fopen("./log.txt","a+");
- fputs($fp,$mailtext."\n");
- fclose($fp);*/
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement