$value) { $value = $db->safesql($value); $Fields .= "`$key`"; $Values .= "'$value'"; if(($i+1)<=$Count) { $Fields .= ", "; $Values .= ", "; } $i++; } $Fields .= ")"; $Values .= ")"; $Qry .= $Fields." VALUES ".$Values; //echo "".$Qry; $this->query($Qry); } function update( $table, $entries, $where=array()) { global $db; // make where string $WhereList = ""; if(is_array($where)) { $WhereList = " WHERE "; $Count = count($where); $i=1; foreach($where as $key=>$value) { $value = $db->safesql($value); $WhereList .= "`$key` = '$value'"; if(($i+1)<=$Count) { $WhereList .= " AND "; } } } // make query string :) $Qry = "UPDATE $table SET "; $Fields = ""; $Count = count($entries); $i=1; foreach($entries as $key=>$value) { $value = $db->safesql($value); $Fields .= "`$key` = '$value'"; if(($i+1)<=$Count) { $Fields .= ", "; } $i++; } $Qry .= $Fields.$WhereList; $this->query($Qry); } function select($table, $where=array(), $orderby=array(), $limit="", $cols=array()) { global $db; // make cols streen $ColsList = ""; if(!empty($cols)) { $Count = count($cols); $i=1; foreach($cols as $col) { if(strstr($col, "count")) { $ColsList .= "$col"; } else { $ColsList .= "`$col`"; } if(($i+1)<=$Count) { $ColsList .= ", "; } } } else { $ColsList = " * "; } // make where string $WhereList = ""; if(!empty($where)) { $WhereList = " WHERE "; $Count = count($where); $i=1; foreach($where as $key=>$value) { if(is_array($value)) { if(!isset($value['sign'])) { $Cnt = 1; foreach($value as $hrundel) { if(is_array($hrundel)&&isset($hrundel['sign'])&&$hrundel['sign']!="") { $hrundel['value'] = $db->safesql($hrundel['value']); $WhereList .= "`$key` ".$hrundel['sign']." '".$hrundel['value']."'"; $Cnt++; if($Cnt<=count($value)) { $WhereList .= " AND "; } } else { $hrundel = $db->safesql($hrundel); $WhereList .= "`$key` = '$hrundel'"; $Cnt++; if($Cnt<=count($value)) { $WhereList .= " OR "; } } } } else { $value['value'] = $db->safesql($value['value']); $WhereList .= "`$key` ".$value['sign']." '".$value['value']."'"; } } else { $value = $db->safesql($value); $WhereList .= "`$key` = '$value'"; } if(($i+1)<=$Count) { $WhereList .= " AND "; } $i++; } } // make orderby string $OrderByList = ""; if(!empty($orderby)) { $OrderByList = " ORDER BY "; $Count = count($orderby); $i=1; foreach($orderby as $key=>$value) { $OrderByList .= "`$key` $value"; if(($i+1)<=$Count) { $OrderByList .= ", "; } $i++; } } // Limit string $limitStr = ""; if($limit!="") { $limitStr = "LIMIT ".$limit; } $Qry = "SELECT $ColsList FROM $table $WhereList $OrderByList $limitStr"; $result = $this->query($Qry); $RetArr = array(); if(is_array($result)) { $RetArr = $result; } else { while($row = $db->get_row($result)) { $RetArr[] = $row; } } return $RetArr; } function delete($table, $where) { global $db; // make where string $WhereList = ""; if(is_array($where)) { $WhereList = " WHERE "; $Count = count($where); $i=1; foreach($where as $key=>$value) { $value = $db->safesql($value); $WhereList .= "`$key` = '$value'"; if(($i+1)<=$Count) { $WhereList .= " AND "; } } } $Qry = "DELETE FROM $table $WhereList"; $result = $this->query($Qry); } function query($query) { global $db; $this->SqlList[] = $query; // set hook on query // first get table from it $SQLArr = $this->ParseSql($query); $TableText = trim($SQLArr['table']); if(isset($this->DBStorage[''.$TableText.''])) { // ok we have kinds of request now lets try to get elements // first thing is to define subarray of aproprite variables it is restricted by where $result = $this->ArraySQLSearch($SQLArr); if($result!="zooza"&&!empty($result)) { return $result; } } $result = $db->query($query); return $result; } function ProcessQuery($res) { global $db; $RetArr = array(); if(is_array($res)) { $RetArr = $res; } else { while($row = $db->get_row($res)) { $RetArr[] = $row; } } return $RetArr; } // Init functions - функции инициализации модуля function Initiate($title, $filePath, $cnfFile, $cnfArr, $templates=array(), $cnfTxt="", $plugins=array()) { $this->MyConfig = $cnfArr; $this->MyConfigFile = $cnfFile; $this->MyTitle = $title; $this->MyStorage = $filePath; $this->templates = $templates; $this->MyConfigTxt = $cnfTxt; $this->Plugins = $plugins; } function LoadDataClass($title="", $table="", $DbStructure=array(), $tpl=array(), $lang=array(), $FormArr = array(), $CheckDataArr=array(), $BreadCrumbsArr=array(), $LinkinArr=array(), $cacheit=false, $seovar="") { $this->MyClasses[$title]['title'] = $title; $this->MyClasses[$title]['table'] = $table; $this->MyClasses[$title]['db'] = $DbStructure; $this->MyClasses[$title]['tpl'] = $tpl; $this->MyClasses[$title]['lang'] = $lang; $this->MyClasses[$title]['form'] = $FormArr; $this->MyClasses[$title]['fieldcheck'] = $CheckDataArr; $this->MyClasses[$title]['breadcrumbs'] = $BreadCrumbsArr; $this->MyClasses[$title]['links'] = $LinkinArr; $this->MyClasses[$title]['cache'] = $cacheit; $this->MyClasses[$title]['seo'] = $seovar; // check if cache is and load database to an array if($cacheit==true) { // load database $AllItems = $this->GetRecords($title); $this->DBStorage[''.$table.''] = $AllItems; } } function CreatePage($title, $langTitle, $Configs, $TagList, $UserRights, $UrlPath=array(), $tplFile="", $Meta=array()) { $this->MyPages[$title]['lang'] = $langTitle; $this->MyPages[$title]['tags'] = $TagList; $this->MyPages[$title]['rights'] = $UserRights; $this->MyPages[$title]['url'] = $UrlPath; $this->MyPages[$title]['tpl'] = $tplFile; $this->MyPages[$title]['config'] = $Configs; $this->MyPages[$title]['meta'] = $Meta; } function LoadPage($PageTitle, $plugins=array()) { global $metatags; if(isset($this->MyPages[$PageTitle])) { // start loading page if($this->UserCheckRights($this->MyPages[$PageTitle]['rights'])) { $metatags['title'] = $this->MyPages[$PageTitle]['meta']['title']; $metatags['keywords'] = $this->MyPages[$PageTitle]['meta']['keywords']; $metatags['description'] = $this->MyPages[$PageTitle]['meta']['description']; switch($this->MyPages[$PageTitle]['config']['type']) { case "static": // this is a static page which don't need form processing' { $MyTags = array(); foreach($plugins as $key=>$value) { $MyTags = array_merge($MyTags, $this->LoadPlugin($key, $value)); } $MyTags = $this->GenerateTagData($this->MyPages[$PageTitle]['tags']); // $MyTags = array_merge($MyTags, $this->PrepareDbTags($class, "static")); return $this->MakeTemplate($this->MyPages[$PageTitle]['tpl'], $MyTags, "content"); break; } case "form": // this is a form page which needs to have the form processed and reacted { if($_REQUEST['sent']=='yes') { $this->ProcessData($this->MyPages[$PageTitle]); } else { $MyTags = $this->GenerateTagData($this->MyPages[$PageTitle]['tags']); return $this->MakeTemplate($this->MyPages[$PageTitle]['tpl'], $MyTags, "content"); } break; } } } else { return $this->MakeTemplate($this->templates['message'], array("msg"=>$this->GetLangVar("msg_restricted")), "content"); } } } function GenerateTagData($TagArray = array()) { $RetArr = array(); foreach($TagArray as $key=>$value) { $SpecVal = $this->GetTrueValue("", $value); if(is_array($SpecVal)) { foreach($SpecVal as $ert=>$jinx) { $RetArr[$ert] = $jinx; } } else { $RetArr[$key] = $this->GetTrueValue("", $value); } } return $RetArr; } // Show function - функции отображения данных function ShowList($class, $ParamArr=array()) { global $config; $Page = "1"; if(isset($_REQUEST['page'])) { if($_REQUEST['page']!="") { $Page = $_REQUEST['page']; } } $offset = (int)((int)$Page-1)*(int)$this->MyConfig['limitpage']['value']; $Ordering = $ParamArr['order']; $where = $ParamArr['where']; $CountIt = $this->GetCount($class, $where); $limiting = $ParamArr['limit']; if($limiting=="") { if(isset($this->MyConfig['limitpage']['value'])) { $limits = "$offset, ".$this->MyConfig['limitpage']['value']; } else { $limits = "$offset, 10"; } } else { $limits = $limiting; } $Items = $this->GetRecords($class, $where, $Ordering, $limits); // We have our items now we need to build a list if(isset($ParamArr['tpl'])) { $TemplateLoad = $ParamArr['tpl']; } else { $TemplateLoad = $this->MyClasses[$class]['tpl']['item']; } if(isset($ParamArr['tpllist'])) { $TemplateWhole = $ParamArr['tpllist']; } else { $TemplateWhole = $this->MyClasses[$class]['tpl']['list']; } $pager = "1"; if(isset($ParamArr['pager'])) { $pager = $ParamArr['pager']; } $zebra = ""; if(isset($ParamArr['zebra'])) { $zebra = $ParamArr['zebra']; } $MyList = $this->MakeItemList($class, $Items, $CountIt, $TemplateLoad, $pager, $zebra); // Load main template and insert extra tags there if(!file_exists("templates/".$config['skin']."/".$TemplateWhole)) { $BodyOf =file_get_contents($TemplateWhole); } else { $BodyOf =file_get_contents("templates/".$config['skin']."/".$TemplateWhole); } $BodyOf = str_replace("{items}", $MyList, $BodyOf); $TotalPages = ceil((int)$CountIt/$this->MyConfig['limitpage']['value']); if($pager=="1") { if(isset($_GET['page'])) { $Current = $_GET['page']; } else { $Current = "1"; } if($pager!="0") { $PageStr = $this->MakePages($class, $TotalPages, $Current); $BodyOf = str_replace("{pagination}", $PageStr, $BodyOf); } else { $BodyOf = str_replace("{pagination}", "", $BodyOf); } } else { $BodyOf = str_replace("{pagination}", "", $BodyOf); } $BodyOf = str_replace("{item_count}", $CountIt, $BodyOf); return $BodyOf; } // Record functions - функции управления записями function AddRecord($class, $data) { // Get through the record data get fields we have in dbstructure make an array to add and write it $TotalArr = array(); $CheckArr = array(); foreach($this->MyClasses[$class]['db'] as $key=>$value) { if(isset($data[$key])) { $TotalArr[$key] = $data[$key]; // check array forming if($value=="varchar") { $CheckArr[$key] = $data[$key]; } } } // Uniquality check $ResultArr = $this->select($this->MyClasses[$class]['table'], $CheckArr); if(isset($ResultArr[0]["id"])) { return "exists"; } // So we need to add our record into offlin $this->insert($this->MyClasses[$class]['table'], $TotalArr); if($this->MyClasses[$class]['cache']==true) { unset($this->DBStorage[''.$this->MyClasses[$class]['table'].'']); $AllItems = $this->GetRecords(''.$this->MyClasses[$class]['title'].''); $this->DBStorage[''.$this->MyClasses[$class]['table'].''] = $AllItems; } // now lets see our last record ID ;) a little trick from Uncle Boris $ResultArr = $this->select($this->MyClasses[$class]['table'], array(), array("id"=>"DESC"), "", array()); return $ResultArr[0]["id"]; } function EditRecord($class, $id, $data) { // Get through the record data get fields we have in dbstructure make an array to add and write it $TotalArr = array(); foreach($this->MyClasses[$class]['db'] as $key=>$value) { if(isset($data[$key])) { $TotalArr[$key] = $data[$key]; } } $this->update($this->MyClasses[$class]['table'], $TotalArr, array("id"=>$id)); } function DeleteRecord($class, $id) { $this->delete($this->MyClasses[$class]['table'], array("id"=>$id)); } function GetRecord($class, $id) { $where = array("id"=>$id); $Redult = $this->select($this->MyClasses[$class]['table'], $where, array(), "1", array()); return $Redult; } function GetRecords($class, $Data=array(), $OrderBy=array(), $limit="") { if(isset($this->ModerSets[''.$class.''])) { if(!isset($Data['published'])) { $Data['published'] = "1"; } } $Redult = $this->select($this->MyClasses[$class]['table'], $Data, $OrderBy, $limit, array()); return $Redult; } function GetCount($class, $Data=array()) { if(isset($this->ModerSets[''.$class.''])) { if(!isset($Data['published'])) { $Data['published'] = "1"; } } $Redult = $this->select($this->MyClasses[$class]['table'], $Data, array(), "", array("count(`id`)")); return $Redult[0]["count(`id`)"]; } // Show function - функции отображения данных function ShowItemList($class, $ParamArr=array()) { $Page = "1"; if(isset($_REQUEST['page'])) { $Page = $_REQUEST['page']; } if(isset($_REQUEST['moder'])) { $Moder = $_REQUEST['moder']; } $offset = (int)((int)$Page-1)*(int)$this->MyConfig['limitpage']['value']; $Ordering = $ParamArr['order']; $where = $ParamArr['where']; if($Moder=="1") { $where['published'] = "0"; } $CountIt = $this->GetCount($class, $where); $limits = "$offset, ".$this->MyConfig['limitpage']['value']; $Items = $this->GetRecords($class, $where, $Ordering, $limits); if($_GET["mod"]=="shop" && $_GET["class"]=="categories" && $_GET["op"]=="showlist") $Items = $this->GetRecords($class, $where, $Ordering, $CountIt); //echo "
";
			//print_r($Items);	
			//echo "
"; $pager = "1"; if(isset($ParamArr['pager'])) { $pager = $ParamArr['pager']; } // We have our items now we need to build a list if(isset($ParamArr['tpl']['item'])) { $TplItem = $ParamArr['tpl']['item']; } else { $TplItem = $this->MyClasses[$class]['tpl']['item']; } //echo $class; $MyList = $this->MakeItemList($class, $Items, $CountIt, $TplItem); //print_r($MyList); if(isset($ParamArr['tpl']['list'])) { $TplList = $ParamArr['tpl']['list']; } else { $TplList = $this->MyClasses[$class]['tpl']['list']; } $TotalPages = ceil((int)$CountIt/$this->MyConfig['limitpage']['value']); if($pager=="1") { if(isset($_GET['page'])) { $Current = $_GET['page']; } else { $Current = "1"; } if($pager!="0") { $PageStr = $this->MakePages($class, $TotalPages, $Current); } else { $PageStr = ""; } } else { $PageStr = ""; } if($_GET["mod"]=="shop" && $_GET["class"]=="categories" && $_GET["op"]=="showlist") $PageStr="Страниц: 1"; $SetArr = array("items_all"=>$MyList, "pagination"=>$PageStr, "item_count"=>$CountIt); if(isset($ParamArr['extra'])) { $SetArr = array_merge($SetArr, $ParamArr['extra']); } //print_r($SetArr); return $this->MakeTemplate($TplList, $SetArr, "content"); } function ShowItem($class, $ParamArr = array()) { // Shows one particular record global $member_id, $metatags; if(isset($_GET['id'])&&$_GET['id']!="") { $IId = $_GET['id']; $Items = $this->GetRecord($class, $IId); } else { $MesData = "Неправильный запрос вы будете перенаправлены на главну страницу
GetLinkTag("main")."\">На главную"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } $CurItem = $Items[0]; if(isset($CurItem['id'])&&$CurItem['id']!="") { } else { $MesData = "Неправильный запрос вы будете перенаправлены на главну страницу
GetLinkTag("main")."\">На главную"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } $metatags['title'] = $CurItem['title']." :: ".$this->MyConfig['title']['value']; if(isset($CurItem['description'])) { $metatags['description'] = $CurItem['description']; } $ArrVar = array(); $ArrVar['breadcrumbs'] = $this->GenerateCrumbs($class, $CurItem); //$ArrVar = $this->ShowComments($CurItem); foreach($CurItem as $key=>$value) { $CurItem[$key] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]); $CurItem[$key."_raw"] = $value; if($this->MyClasses[$class]['db'][$key]=="img") { $CurItem["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); $CurItem["".$key."_thumb_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb_raw"); $CurItem["".$key."_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_raw"); $CurItem["".$key."_complete"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"); } if($this->MyClasses[$class]['db'][$key]=="unlimg") { $CurItem["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); $CurItem["".$key."_complete"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"); } if($this->MyClasses[$class]['db'][$key]=="multifield") { $ArrFields = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]); foreach($ArrFields as $gre=>$fee) { $CurItem["".$gre.""] = $fee; } } } if(isset($this->MyClasses[$class]['commcl'])&&$this->MyClasses[$class]['commcl']!="") { if(isset($CurItem['commpub'])&&$CurItem['commpub']==$this->GetLangVar("checkbox_yes")) { $CurItem['comments'] = $this->ShowComments($class, $CurItem['id']); } else { $CurItem['comments'] = ""; } } else { $CurItem['comments'] = ""; } if($member_id['user_group']=="1") { $CurItem["adm_links"] = "GetLink($class, "edit", array("id"=>$IId))."\">".$this->GetLangVar("Edit")." | GetLink($class, "delete", array("id"=>$IId))."\">".$this->GetLangVar("Delete").""; if(isset($this->ModerSets[''.$class.''])) { // moderation links go here if($CurItem['published']=="1") { $CurItem["adm_links"] .= " | GetLink($class, "unpublish", array("id"=>$IId))."\">".$this->GetLangVar("unpubl").""; } else { $CurItem["adm_links"] .= " | GetLink($class, "publish", array("id"=>$IId))."\">".$this->GetLangVar("publ").""; } } } else { $CurItem["adm_links"] = ""; } $ArrVar = array_merge($ArrVar, $CurItem); $PlugDataArr = array(); foreach($this->Plugins as $key=>$value) { $PlugDataArr = $this->LoadPlugin($key, "ShowFull", $ArrVar); } $ArrVar = array_merge($ArrVar, $PlugDataArr); if(isset($ParamArr['tpl'])) { $TemplateLoad = $ParamArr['tpl']; } else { $TemplateLoad = $this->MyClasses[$class]['tpl']['full']; } //$ArrVar = array_merge($ArrVar, $this->GetAdminLinks($class, "ShowItem")); return $this->MakeTemplate($TemplateLoad, $ArrVar, "content"); } function ShowItemPrint($class, $ParamArr = array()) { // Shows one particular record global $member_id, $metatags; if(isset($_GET['id'])) { $IId = $_GET['id']; $Items = $this->GetRecord($class, $IId); } else { $MesData = "Неправильный запрос вы будете перенаправлены на главну страницу
GetLinkTag("main")."\">На главную"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } $CurItem = $Items[0]; $metatags['title'] = $CurItem['title']." :: ".$this->MyConfig['title']['value']; if(isset($CurItem['description'])) { $metatags['description'] = $CurItem['description']; } $ArrVar = array(); $ArrVar['breadcrumbs'] = $this->GenerateCrumbs($class, $CurItem); //$ArrVar = $this->ShowComments($CurItem); foreach($CurItem as $key=>$value) { $CurItem[$key] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]); if($this->MyClasses[$class]['db'][$key]=="img") { $CurItem["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); $CurItem["".$key."_thumb_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb_raw"); $CurItem["".$key."_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_raw"); $CurItem["".$key."_complete"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"); } if($this->MyClasses[$class]['db'][$key]=="unlimg") { $CurItem["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); $CurItem["".$key."_complete"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"); } } if(isset($this->MyClasses[$class]['commcl'])&&$this->MyClasses[$class]['commcl']!="") { $CurItem['comments'] = $this->ShowComments($class, $CurItem['id']); } else { $CurItem['comments'] = ""; } if($member_id['user_group']=="1") { $CurItem["adm_links"] = "GetLink($class, "edit", array("id"=>$IId))."\">".$this->GetLangVar("Edit")." | GetLink($class, "delete", array("id"=>$IId))."\">".$this->GetLangVar("Delete").""; if(isset($this->ModerSets[''.$class.''])) { // moderation links go here if($CurItem['published']=="1") { $CurItem["adm_links"] .= " | GetLink($class, "unpublish", array("id"=>$IId))."\">".$this->GetLangVar("unpubl").""; } else { $CurItem["adm_links"] .= " | GetLink($class, "publish", array("id"=>$IId))."\">".$this->GetLangVar("publ").""; } } } else { $CurItem["adm_links"] = ""; } $ArrVar = array_merge($ArrVar, $CurItem); $PlugDataArr = array(); foreach($this->Plugins as $key=>$value) { $PlugDataArr = $this->LoadPlugin($key, "ShowFull", $ArrVar); } $ArrVar = array_merge($ArrVar, $PlugDataArr); if(isset($ParamArr['tpl'])) { $TemplateLoad = $ParamArr['tpl']; } else { //$TemplateLoad = $this->MyClasses[$class]['tpl']['full']; $TemplateLoad = "templates/artprint.tpl";//$this->MyClasses[$class]['tpl']['fullprint']; } //$ArrVar = array_merge($ArrVar, $this->GetAdminLinks($class, "ShowItem")); return $this->MakeTemplate($TemplateLoad, $ArrVar, "content", true); } function AddItem($class) { global $metatags, $lang, $config; if(isset($_GET['action'])) { $action = $_GET['action']; } else { $action = ""; } if ($action != "add") { // Make form link more universal if ($config['allow_alt_url'] == "yes"&&!strstr($this->selfURL(), '=')) { $FormLink = $this->selfURL()."/add"; } else { $FormLink = $this->selfURL()."&action=add"; } $ArrVar = array("form"=>"
", "/form"=>"
", "input_submit"=>""); $ArrVar = array_merge($ArrVar, $this->GenerateAddFields($class)); $metatags['title'] = "Добавление ".$this->GetLangVar($class)." :: ".$this->MyConfig['title']['value']; // Now as we have our add fields /*foreach($this->MyClasses[$class]['form'] as $key=>$value) { / here we may define title and description for fields and specify certain fields to display }*/ $PlugDataArr = array(); foreach($this->Plugins as $key=>$value) { $PlugDataArr = $this->LoadPlugin($key, "AddItem", $ArrVar); } $ArrVar = array_merge($ArrVar, $PlugDataArr); return $this->MakeTemplate($this->MyClasses[$class]['tpl']['add'], $ArrVar, "content"); } else { $VarData = $this->ProcessData($class, "add"); if(!is_array($VarData)||!isset($VarData['id'])||$VarData['id']=="") { $MesData = $VarData."
Назад"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } else { $MesData = $this->GetLangVar("msg_".$class."_add"); $MesData .= "
Назад "; if(is_array($this->MyClasses[$class]['links']['list'])) { if ($config['allow_alt_url'] == "yes") { $LinkStr = $this->MyClasses[$class]['links']['list']['sef']; } else { $LinkStr = $this->MyClasses[$class]['links']['list']['std']; } } else { $LinkStr = $this->GetLink($class, "itemshow", array("id"=>$VarData['id'])); } foreach($VarData['data'] as $yel=>$rel) { $LinkStr = str_replace("{".$yel."}", $rel, $LinkStr); } $MesData .= " | Просмотреть"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } } } function EditItem($class) { global $metatags; if($this->UserCheckRights("admin")) { $action = $_GET['action']; if ($action !== "edit") { if(!isset($_GET['id'])||$_GET['id']=="") { $MesData = "Неправильный запрос вы будете перенаправлены на главну страницу
GetLinkTag("main")."\">На главную"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } // Make form link more universal if ($config['allow_alt_url'] == "yes") { $FormLink = $this->selfURL()."/edit"; } else { $FormLink = $this->selfURL()."&action=edit"; } $metatags['title'] = "Изменение ".$this->GetLangVar($class)." :: ".$this->MyConfig['title']['value']; $ArrVar = array("form"=>"
", "/form"=>"
", "input_submit"=>""); $ArrVar = array_merge($ArrVar, $this->GenerateEditFields($class, $_GET['id'])); ///$ArrVar = $this->GenerateEditFields(); $PlugDataArr = array(); foreach($this->Plugins as $key=>$value) { $PlugDataArr = $this->LoadPlugin($key, "EditItem", $ArrVar); } $ArrVar = array_merge($ArrVar, $PlugDataArr); return $this->MakeTemplate($this->MyClasses[$class]['tpl']['edit'], $ArrVar, "content"); } else { $VarData = $this->ProcessData($class, "edit", $_GET['id']); if(!isset($VarData['id'])||$VarData['id']=="") { $MesData = "
Назад"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } else { $MesData = $this->GetLangVar("msg_".$class."_edit"); $MesData .= "
Назад "; if(is_array($this->MyClasses[$class]['links']['list'])) { if ($config['allow_alt_url'] == "yes") { $LinkStr = $this->MyClasses[$class]['links']['list']['sef']; } else { $LinkStr = $this->MyClasses[$class]['links']['list']['std']; } } else { $LinkStr = $this->GetLink($class, "itemshow", array("id"=>$VarData['id'])); } if(is_array($VarData['data'])) { foreach($VarData['data'] as $yel=>$rel) { $LinkStr = str_replace("{".$yel."}", $rel, $LinkStr); } } $MesData .= " | Просмотреть"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } // header ("Location: ".$this->GetLink($class, "showlist")); } } else { return $this->MakeTemplate($this->templates['message'], array("msg"=>$this->GetLangVar("msg_restricted")), "content"); } } function DeleteItem($class) { global $metatags; if($this->UserCheckRights("admin")) { $action = $_GET['action']; if ($action !== "delete") { if(!isset($_GET['id'])||$_GET['id']=="") { $MesData = "Неправильный запрос вы будете перенаправлены на главну страницу
GetLinkTag("main")."\">На главную"; return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } // Make form link more universal if ($config['allow_alt_url'] == "yes") { $FormLink = $this->selfURL()."/delete"; } else { $FormLink = $this->selfURL()."&action=delete"; } $metatags['title'] = "Удаление ".$this->GetLangVar($class)." :: ".$this->MyConfig['title']['value']; $ArrVar = array("form"=>"
", "/form"=>"
", "input_submit"=>""); $ArrVar = array_merge($ArrVar, $this->GenerateDeleteFields($class, $_GET['id'])); return $this->MakeTemplate($this->MyClasses[$class]['tpl']['delete'], $ArrVar, "content"); } else { $VarData = $this->ProcessData($class, "delete", $_GET['id']); $MesData = $this->GetLangVar("msg_".$class."_del"); if(is_array($this->MyClasses[$class]['links']['list'])) { if ($config['allow_alt_url'] == "yes") { $LinkStr = $this->MyClasses[$class]['links']['list']['sef']; } else { $LinkStr = $this->MyClasses[$class]['links']['list']['std']; } foreach($VarData['data'] as $yel=>$rel) { $LinkStr = str_replace("{".$yel."}", $rel, $LinkStr); } $MesData .= "
Просмотреть"; } else { $MesData .= "
GetLink($class, "showlist")."\">Просмотреть"; } return $this->MakeTemplate($this->templates['message'], array("msg"=>$MesData), "content"); } } else { return $this->MakeTemplate($this->templates['message'], array("msg"=>$this->GetLangVar("msg_restricted")), "content"); } } function MakeTemplate($template, $data, $block, $notMain=false) { global $tpl; if(!empty($tpl)&&$notMain==false) { $tpl->load_template($template); if(is_array($data)) { foreach($data as $key=>$value) { $tpl->set("{".$key."}", stripslashes($value)); if(stripslashes($value)==""||stripslashes($value)=="0") { $tpl->set_block("'\\[".$key."\\](.*?)\\[/".$key."\\]'si",""); } else { $tpl->set_block("'\\[".$key."\\](.*?)\\[/".$key."\\]'si","\\1"); } } } $tpl->compile($block); $tpl->clear(); } else { return $this->MakeStTemplate($template, $data); } } function MakeStTemplate($template, $data) { global $config; // Get template fileg if(!file_exists("templates/".$config['skin']."/".$template)) { $LeftItem =file_get_contents($template); } else { $LeftItem =file_get_contents("templates/".$config['skin']."/".$template); } if(is_array($data)) { foreach($data as $key=>$value) { $LeftItem = str_replace("{".$key."}", $value, $LeftItem); if(stripslashes($value)==""||stripslashes($value)=="0") { $IntStart = strpos($LeftItem, "[".$key."]"); $IntEdn = strpos($LeftItem, "[/".$key."]"); $ToRemove = substr($LeftItem, $IntStart, $IntEdn-$IntStart); $ToRemove .= "[/".$key."]"; $LeftItem = str_replace($ToRemove, "", $LeftItem); } else { $LeftItem = str_replace("[".$key."]", "", $LeftItem); $LeftItem = str_replace("[/".$key."]", "", $LeftItem); } } } return $LeftItem; } function translitIt($str) { $tr = array( "А"=>"a","Б"=>"b","В"=>"v","Г"=>"g", "Д"=>"d","Е"=>"e","Ж"=>"j","З"=>"z","И"=>"i", "Й"=>"y","К"=>"k","Л"=>"l","М"=>"m","Н"=>"n", "О"=>"o","П"=>"p","Р"=>"r","С"=>"s","Т"=>"t", "У"=>"u","Ф"=>"f","Х"=>"h","Ц"=>"ts","Ч"=>"ch", "Ш"=>"sh","Щ"=>"sch","Ъ"=>"","Ы"=>"yi","Ь"=>"", "Э"=>"e","Ю"=>"yu","Я"=>"ya","а"=>"a","б"=>"b", "в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j", "з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l", "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r", "с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h", "ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"y", "ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya", " "=> "_", "."=> "", "/"=> "_" ); return strtr($str,$tr); } function MakeItemList($class, $items, $total, $tpl, $pager="1", $zebra="") { global $config, $member_id; // Get template fileg if(!file_exists("templates/".$config['skin']."/".$tpl)) { $LeftItem =file_get_contents($tpl); } else { $LeftItem =file_get_contents("templates/".$config['skin']."/".$tpl); } $TotalList = ""; $TotalPages = ceil((int)$total/$this->MyConfig['limitpage']['value']); if(count($items)>0) { $Cnt = 0; foreach($items as $row) { if(!is_array($row)) { continue; } // first make all the db aware tags $TplChange = $LeftItem; //print_r($TplChange); // Now load plugin functions for this function and get extra tgs and changes if($_GET["op"]=="category" and $row["maindata"]!="") $TplChange = str_replace("{addinfo}", "", $TplChange); foreach($this->Plugins as $key=>$value) { $TplChange = $this->LoadPlugin($key, "MakeItemList", array("text" => $TplChange, "row"=>$row)); } foreach($row as $key=>$value) { //check value with it's type $TplChange = str_replace("{".$key."}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]), $TplChange); $TplChange = str_replace("{".$key."_raw}", $value, $TplChange); //print_r($TplChange); if(stripslashes($value)==""||stripslashes($value)=="0") { $TplChange = preg_replace("'\\[".$key."\\](.*?)\\[/".$key."\\]'si", "", $TplChange); } else { $TplChange = preg_replace("'\\[".$key."\\](.*?)\\[/".$key."\\]'si","\\1", $TplChange); } if($this->MyClasses[$class]['db'][$key]=="img") { $TplChange = str_replace("{".$key."_thumb}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"), $TplChange); $TplChange = str_replace("{".$key."_thumb_raw}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb_raw"), $TplChange); $TplChange = str_replace("{".$key."_raw}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_raw"), $TplChange); $TplChange = str_replace("{".$key."_complete}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"), $TplChange); } if($this->MyClasses[$class]['db'][$key]=="unlimg") { $TplChange = str_replace("{".$key."_thumb}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"), $TplChange); $TplChange = str_replace("{".$key."_complete}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"), $TplChange); } if($this->MyClasses[$class]['db'][$key]=="multifield") { $ArrFields = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]); foreach($ArrFields as $gre=>$fee) { $TplChange = str_replace("{".$gre."}", $fee, $TplChange); } } } //$url = urldecode($this->GetLink($class, "itemshow", array("id"=>$row['id']))); //$url = $this->translitIt($url); //echo $url; // and load url and other non db records ///if (preg_match('/[^A-Za-z0-9_\-]/', $url)) { //$urlstr = $this->translitIt($this->GetLink($class, "itemshow", array("id"=>$row['id']))); ///urlstr = preg_replace('/[^A-Za-z0-9_\-]/', '', $urlstr);} //echo $this->GetLink($class, "itemshow", array("id"=>$row['id'])); //print_r($TplChange); $TplChange = str_replace("{link}", "GetLink($class, "itemshow", array("id"=>$row['id']))."\">", $TplChange); $TplChange = str_replace("{/link}", "", $TplChange); if($row["maindata"]=="") $TplChange = str_replace("{mfield_maindata_text_shortinfo}", "", $TplChange); if($member_id['user_group']=="1") { $AdmLinksStr = "GetLink($class, "edit", array("id"=>$row['id']))."\">".$this->GetLangVar("Edit")." | GetLink($class, "delete", array("id"=>$row['id']))."\">".$this->GetLangVar("Delete").""; if(isset($this->ModerSets[''.$class.''])) { // moderation links go here if($row['published']=="1") { $AdmLinksStr .= " | GetLink($class, "unpublish", array("id"=>$row['id']))."\">".$this->GetLangVar("unpubl").""; } else { $AdmLinksStr .= " | GetLink($class, "publish", array("id"=>$row['id']))."\">".$this->GetLangVar("publ").""; } } $TplChange = str_replace("{adm_links}", $AdmLinksStr, $TplChange); } else { $TplChange = str_replace("{adm_links}", "", $TplChange); } // zebra fearue if($zebra!="") { if($Cnt % 2==0) { $TplChange = str_replace("{zebr_cl}", $zebra, $TplChange); } else { $TplChange = str_replace("{zebr_cl}", "", $TplChange); } } // - цена $TotalList .= $TplChange; // add admin links $Cnt++; } } else { $TotalList = $this->GetLangVar("msg_record_none"); } //print_r($TotalList); /*echo "


"; echo "mod - ".$_GET["mod"]."
"; echo "categories - ".$_GET["categories"]."
"; echo "op - ".$_GET["op"]."
"; echo "


"; */ // echo "
";
			///print_r($items);
			//	echo "
"; /*print_r($TotalList); echo "


";*/ if($_GET["mod"]=="shop" && $_GET["op"]=="showlist" && $_GET["class"]=="multifields") { $TotalList=""; $TotalList=""; $TotalList.=""; for($i=0;$iРедактировать"; $TotalList.=""; } $TotalList.="
"; $TotalList.="id"; $TotalList.=""; $TotalList.="Имя поля"; $TotalList.=""; $TotalList.="Название"; $TotalList.=""; $TotalList.="Редактировать"; $TotalList.=""; $TotalList.="Удалить"; $TotalList.="
"; $TotalList.="Удалить"; $TotalList.="
"; } if($_GET["mod"]=="shop" && $_GET["op"]=="showlist" && $_GET["class"]=="orders") { $TotalList=""; $TotalList=""; for($i=0;$iЗаказ выполнен"; $TotalList.=""; $TotalList.="
"; $TotalList.=" "; $TotalList.=""; } $TotalList.=""; } if($_GET["mod"]=="shop" && $_GET["op"]=="showlist" && $_GET["class"]=="products") { $TotalList=""; $TotalList=" "; for($i=0;$iРедактировать"; $TotalList.=""; } } if($_GET["mod"]=="shop" && $_GET["op"]=="showlist" && $_GET["class"]=="categories") { $TotalList=""; $TotalList="
id Наименование Артикул Тайтл Цена Редактировать Удалить
"; $TotalList.="Удалить"; $TotalList.="
"; for($i=0;$iРедактировать"; $TotalList.=""; for($j=$i+1;$jРедактировать"; $TotalList.=""; } } } } $TotalList.="
id Категория Родительская категория Описание Редактировать Удалить
"; $TotalList.="Удалить"; $TotalList.="
"; $TotalList.="Удалить"; $TotalList.="
"; } return $TotalList; } function MakeItemPage($class, $items, $tpl) { global $config; // Get template fileg if(!file_exists("templates/".$config['skin']."/".$tpl)) { $TplChange =file_get_contents($tpl); } else { $TplChange =file_get_contents("templates/".$config['skin']."/".$tpl); } foreach($items as $key=>$value) { if(isset($this->MyClasses[$class]['db'][$key])) { $TplChange = str_replace("{".$key."}", $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]), $TplChange); } else { $TplChange = str_replace("{".$key."}", $value, $TplChange); } } return $TplChange; } function GetTrueValue($value, $type="") { // here go special functions if(strstr($type, "Class:")) { // we have class invokation function, lets break it into pieces $Parts = explode(":", $type); $ClassTitle = $Parts[1]; $Function = $Parts[2]; $Params = ""; if(strstr($Function, '(')==true) { $OldFunc = $Function; $Function = substr($Function, 0, strpos($Function, "(")); $Params = substr($OldFunc, strpos($OldFunc, "(")+1); $Params = substr($Params, 0, strlen($Params)-1); } if($Params!="") { eval("\$ParamArr = ".$Params.";"); } if($Function=="ItemSelect") { $SomeRet = $this->ItemSelectGet($ClassTitle, $value); return $SomeRet; } // as we know what we need lets invoke that function of the class if($Function!="") { eval("\$SomeRet = \$this->".$Function."(\$ClassTitle, \$ParamArr);"); return $SomeRet; } else { return false; } } else if(strstr($type, "Plugin:")) { $Parts = explode(":", $type); $ClassTitle = $Parts[1]; $Function = $Parts[2]; $RetData = $this->LoadPlugin($ClassTitle, $Function, array("value"=>$value, "mode"=>"data")); return $RetData; } else if(strstr($type, "Select:")) { $Parts = explode(":", $type); $SelectTitle = $Parts[1]; $Function = $Parts[2]; $RetVar = $this->GetSelectListItem($SelectTitle, $value); return $RetVar; } else if(strstr($type, "Raw:")) { $Parts = explode(":", $type); $SelectTitle = $Parts[1]; return $Parts[1]; } else { // if it's a banal string do it switch($type) { case "varchar": { return $this->GetSimpleData($value); break; } case "text": { return $this->GetTextData($value); break; } case "decimal": { return $this->GetDecimalData($value); break; } case "datetime": { return $this->GetDateTime($value, "Y-m-d G:i:s"); break; } case "date": { return $this->GetDateTime($value, "Y-m-d"); break; } case "unlimg": { return $this->GetUnlImg($value); break; } case "unlimg_thumb": { return $this->GetUnlImgThumb($value); break; } case "unlimg_complete": { return $this->GetUnlImgThumb($value, "complete"); break; } case "file": { return $this->GetFile($value); break; } case "img": { return $this->GetImg($value); break; } case "img_thumb": { return $this->GetImgThumb($value); break; } case "img_thumb_raw": { return $this->GetImgThumb($value, "raw"); break; } case "img_complete": { return $this->GetImgThumb($value, "complete"); break; } case "img_raw": { return $this->GetImg($value, "raw"); break; } case "checkbox": { return $this->GetCheckBox($value); break; } case "multifield": { return $this->GetMultifield($value); break; } default: { return $value; } } } } function GetCheckBox($value) { if($value=="1") { return $this->GetLangVar("checkbox_yes"); } else { return $this->GetLangVar("checkbox_no"); } } function GetMultifield($value) { // here we need to analyze our string, form an array with fields and return it $ValsArr = explode("|::|", $value); $RetArr = array(); foreach($ValsArr as $field) { if($field!="") { $DataField = explode("|++|", $field); $FTitle = $DataField[0]; // field title $FTtype = $DataField[1]; // field type $FValue = $DataField[2]; // field value $FinalVal = $this->GetTrueValue($FValue, $FTtype); $RetArr[''.$FTitle.''] = $FinalVal; } } return $RetArr; } function GetSimpleData($value) { return $value; } function GetTextData($value) { // replace \n to
$value = str_replace("\n", "
", $value); $value = stripslashes($value); return $value; } function GetDecimalData($value) { // replace \n to
$value = str_replace(".00", "", $value); // Now insert spaces into value $ToDot = $value; if(strstr($value, ".")) { $ToDot = substr($value, 0, strpos($value, ".")); } if(strlen($ToDot)>3) { $Intrer = strlen($ToDot)-1; $Cnt = 1; $FinalStr = ""; for($i=$Intrer; $i>=0; $i--) { $FinalStr = $ToDot[$i].$FinalStr; if($Cnt==3) { $FinalStr = " ".$FinalStr; $Cnt = 1; } else { $Cnt++; } } $value = $FinalStr; } return $value; } function GetDateTime($value, $format) { $TimeStr = strtotime($value); return date($format, $TimeStr); } function GetFile($value, $type="") { if($value=="") { return ""; } else { return $this->MyStorage."files/".$value; } } function GetImg($value, $type="") { if($value=="") { return ""; } else { if($type=="raw") { return $this->MyStorage."images/".$value; } else { return "MyStorage."images/".$value."\">"; } } } function GetImgThumb($value, $type="") { if($value=="") { return ""; } else { $ImgParts = explode("/", $value); if($type=="raw") { return $this->MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]; } else if($type=="complete") { return "MyStorage."images/".$value."\" onClick=\"return hs.expand(this)\">MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">"; } else { return "MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">"; } } } function GetUnlImg($value, $type="complete") { if($value=="") { $RetStr =array(); if($type=="complete") { return "MyStorage."images/no_full_photo.gif\">"; } else { $RetStr[] = "MyStorage."images/no_photo.gif\">"; } return $RetStr; } else { $ImgArr = explode(":|:", $value); $RetStr = array(); $Cnt = "0"; foreach($ImgArr as $img) { $ImgParts = explode("/", $img); if($type=="raw") { $RetStr[] = $this->MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]; } else if($type=="complete") { if($Cnt=="0") { $ImgExer = explode(".", $ImgParts[2]); $ImgParts[2] = $ImgExer[0]."_ext_".$this->MyConfig['multiimg_width']['value'].".".$ImgExer[1]; $RetStr[] = "
MyStorage."images/".$img."\" onClick=\"return hs.expand(this)\">MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">
"; } else { $RetStr[] = "MyStorage."images/".$img."\" onClick=\"return hs.expand(this)\">MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">"; } } else { $RetStr[] = "MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">"; } $Cnt++; } $RetFuck = implode(" ", $RetStr); return $RetFuck; } } function GetUnlImgThumb($value, $type="") { if($value=="") { return "MyStorage."images/no_photo.gif\">"; } else { $ImgArr = explode(":|:", $value); $value = $ImgArr[0]; $ImgParts = explode("/", $value); if($type=="raw") { return $this->MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]; } else if($type=="complete") { $ImgExer = explode(".", $ImgParts[2]); $ImgParts[2] = $ImgExer[0]."_ext_".$this->MyConfig['multiimg_width']['value'].".".$ImgExer[1]; return "
MyStorage."images/".$ImgArr[0]."\" onClick=\"return hs.expand(this)\">MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">
"; } else { return "MyStorage."images/".$ImgParts[0]."/".$ImgParts[1]."/thumb/".$ImgParts[2]."\">"; } } } function MakePages($class, $TotalPages, $CurPage, $kind="teams") { global $config; // count our pages $TotalPagesS = ceil(((int)$TotalPages/(int)$this->MyConfig['limitpage']['value'])); // Get page styling $BodyOf =file_get_contents("templates/".$config['skin']."/".$this->MyClasses[$class]['tpl']['pager']); // get template parts $ItemTpl = $this->GetBetween("[item]", "[/item]", $BodyOf); $SelTpl = $this->GetBetween("[sel]", "[/sel]", $BodyOf); $BodyTpl = $this->GetBetween("[body]", "[/body]", $BodyOf); if((int)$TotalPages>1) { $CurPage = (int)$CurPage-1; } else { $CurPage = '0'; } $CurOffset = (int)$CurPage*(int)$this->MyConfig['limitpage']['value']; // теперь сделаем массив наших страничек $PagesArr = array(); for($k=1; $k<=(int)$TotalPages; $k++) { $PagesArr[] = $k; } $PageStr = ""; foreach($PagesArr as $page) { if((int)$page==(int)$CurPage+1) { $PageStr .= str_replace("{page}", $page, $SelTpl); } else { $rsTpl = $ItemTpl; $rsTpl = str_replace("{page}", $page, $rsTpl); $pageArr = array(); // get all GET vars and add page foreach($_GET as $reso=>$kolu) { if($reso!="do"&&$reso!="class"&&$reso!="page"&&$reso!="op") { $pageArr[''.$reso.''] = $kolu; } } $pageArr['page'] = $page; $rsTpl = str_replace("{link}", $this->GetLink($_GET['class'], $_GET['op'], $pageArr), $rsTpl); $PageStr .= $rsTpl; } } if($PageStr!="") { $PageStr = str_replace("{pages}", $PageStr, $BodyTpl); } return $PageStr; } // Get admin settings function AdminPage() { // } function GetAdminLinks($class, $params) { global $config; if($this->UserCheckRights("admin")) { // we need to get all the classes and adding links to them $LinkTags['adm_cfg_lnk'] = "".$this->GetLangVar("CfgAdmin").""; // Now get each class and build class blocks foreach($this->MyClasses as $MyClass) { // Block consists of Add|ShowList links of the class $ClassBlock = $MyClass['lang']['title'].": "; $ClassBlock .= "".$this->GetLangVar("AddLink")." | "; $ClassBlock .= "".$this->GetLangVar("ShowList").""; if(isset($this->ModerSets[''.$MyClass['title'].''])) { $ClassBlock .= " | "1", "moder"=>"1")).">".$this->GetLangVar("ModerList").""; } $ClassBlock .= "
"; $LinkTags['class_block'] .= $ClassBlock; } //echo "Админ | Круто |"; } else { $LinkTags['adm_cfg_lnk'] = ""; $LinkTags['class_block'] = ""; } $RetStr = $this->MakeItemPage("base", $LinkTags, $this->templates['cfg_lnk']); return $RetStr; } function PrepareDbTags($class, $type="static", $id="") { global $config, $lang; $RetArr = array(); switch($type) { case "static": { $ItemData = $this->GetRecord($class, $id); $ItemData = $ItemData[0]; foreach($ItemData as $key=>$value) { $RetArr["".$key.""] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]); if($this->MyClasses[$class]['db'][$key]=="img") { $RetArr["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); $RetArr["".$key."_thumb_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb_raw"); $RetArr["".$key."_raw"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_raw"); $RetArr["".$key."_complete"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_complete"); } if($this->MyClasses[$class]['db'][$key]=="unlimg") { $RetArr["".$key."_thumb"] = $this->GetTrueValue($value, $this->MyClasses[$class]['db'][$key]."_thumb"); } } break; } case "form": { if($id=="") { $ItemData = array(); } else { $ItemData = $this->GetRecord($class, $id); } if(isset($ItemData[0])) { $ItemData = $ItemData[0]; } // For comments implementation if($class=="comments") { if(!isset($ItemData['autor'])||$ItemData['autor']=="") { global $member_id; $ItemData['autor'] = $member_id['name']; $ItemData['email'] = $member_id['email']; } } foreach($this->MyClasses[$class]['db'] as $key=>$value) { if(isset($ItemData[$key])) { $dataval = $ItemData[$key]; } else { $dataval = ""; } $NecVal = $this->GetFormValue($key, $dataval, $value); if($NecVal!="") { $RetArr["input_".$key.""] = $NecVal; } } // and extra data // captcha! if (($this->MyConfig['captcha']['value']==1)&&(in_array($class, $this->CaptchaList)==true)) { $path = parse_url($config['http_home_url']); $CaptArr["captcha"] = "\"{$lang['sec_image']}\"
{$lang['reload_code']}
"; $CaptArr["captcha"] .= << function reload () { var rndval = new Date().getTime(); document.getElementById('dle-captcha').innerHTML = '
{$lang['reload_code']}'; }; HTML; $RetArr["captcha"] = $this->MakeItemPage($class, $CaptArr, $this->templates['captcha']); } else { $RetArr["captcha"] = ""; } break; } } return $RetArr; } function GetFormValue($title, $value, $type="") { // here go special functions if(strstr($type, "Class:")) { // we have class invokation function, lets break it into pieces $Parts = explode(":", $type); $ClassTitle = $Parts[1]; $Function = $Parts[2]; $Params = ""; if(strstr($Function, '(')==true) { $OldFunc = $Function; $Function = substr($Function, 0, strpos($Function, "(")); $Params = substr($OldFunc, strpos($OldFunc, "(")+1); $Params = substr($Params, 0, strlen($Params)-1); } if($Params!="") { eval("\$ParamArr = ".$Params.";"); } if($Function=="ItemSelect") { eval("\$Somewhat = \$this->".$Function."(\$ClassTitle, \$title, \$value);"); return $Somewhat; } // as we know what we need lets invoke that function of the class if($Function!="") { if($ParamArr!="") { eval("\$Somewhat = \$this->".$Function."(\$ClassTitle, \$ParamArr);"); } else { eval("\$Somewhat = \$this->".$Function."(\$ClassTitle, \"\");"); } return $Somewhat; } else { return false; } } else if(strstr($type, "Plugin:")) { $Parts = explode(":", $type); $ClassTitle = $Parts[1]; $Function = $Parts[2]; return $this->LoadPlugin($ClassTitle, $Function, array("value"=>$value, "mode"=>"form")); } else if(strstr($type, "RSelect:")) { $Parts = explode(":", $type); $SelectTitle = $Parts[1]; $Function = $Parts[2]; return $this->GetRSelectList($SelectTitle, $title, $value); } else if(strstr($type, "MSelect:")) { $Parts = explode(":", $type); $SelectTitle = $Parts[1]; $Function = $Parts[2]; return $this->GetMSelectList($SelectTitle, $title, $value); } else if(strstr($type, "Select:")) { $Parts = explode(":", $type); $SelectTitle = $Parts[1]; $Function = $Parts[2]; return $this->GetSelectList($SelectTitle, $title, $value); } else { // if it's a banal string do it switch($type) { case "varchar": { return $this->GetInputField($title, $value); break; } case "decimal": { $value = str_replace(".00", "", $value); $value = str_replace(" ", "", $value); return $this->GetInputField($title, $value); break; } case "text": { return $this->GetTextarea($title, $value); break; } case "bigtext": { return $this->GetBigTextarea($title, $value); break; } case "datetime": { return $this->GetDateTimeField($title, $value, "Y-m-d G:i:s"); break; } case "date": { return $this->GetDateField($title, $value, "Y-m-d"); break; } case "img": { return $this->GetImgField($title, $value); break; } case "file": { return $this->GetFileField($title, $value); break; } case "unlimg": { return $this->GetUnlimImgField($title, $value); break; } case "range": { return $this->GetRangeField($title, $value); } case "checkbox": { return $this->GetCheckBoxField($title, $value); } case "multifield": { return $this->GetMultiFieldField($title, $value); } default: { } } } } // Field making functions function GetInputField($title, $value) { return ""; } function GetMultiFieldField($title, $value) { global $config; if($value=="") { $value = $this->MultiFields[''.$title.'']; } $RetStr = ""; // Get templae for item $TemplateWhole = $this->templates['formitem']; if(!file_exists("templates/".$config['skin']."/".$TemplateWhole)) { $ItemTpl =file_get_contents($TemplateWhole); } else { $ItemTpl =file_get_contents("templates/".$config['skin']."/".$TemplateWhole); } // get list of fields for current item $MyFields = $this->GetRecords("multifields", array("ftitle"=>$title)); $grArr = array(); foreach($MyFields as $field) { $grArr[''.$field['title'].''] = $field; } $ValsArr = explode("|::|", $value); $RetArr = array(); foreach($ValsArr as $field) { $RfStr = $ItemTpl; $DataField = explode("|++|", $field); $FTitle = $DataField[0]; // field title $FTtype = $DataField[1]; // field type $FValue = $DataField[2]; // field value $FormCode = $this->GetFormValue($FTitle, $FValue, $FTtype); $RfStr = str_replace("{field}", $FormCode, $RfStr); $RgTitle = substr($FTitle, strripos($FTitle, "_")+1); if(is_array($grArr[''.$RgTitle.''])) { $RfStr = str_replace("{lang_title}", $grArr[''.$RgTitle.'']['langtitle'], $RfStr); $RetStr .= $RfStr; } } return $RetStr; } // here we need to analyze our string, form an array with fields and return it function GetCheckBoxField($title, $value) { $AddStr = ""; if($value=="1") { $AddStr = "checked"; } return ""; } function GetTextarea($title, $value) { include_once ENGINE_DIR.'/classes/parse.class.php'; $parse = new ParseFilter(Array(), Array(), 1, 1); if(in_array($title, $this->BBParsed)) { $value = $parse->decodeBBCodes($value, true, "yes"); } return ""; } function GetBigTextarea($title, $value) { return ""; } function GetDateTimeField($title, $value) { global $lang; // Fucking checkboxes $CheckBoxes = ""; $Rien = false; if($value=="") { $Rien = true; $value = date("Y-m-d G:i"); } if($Rien == true) { $CheckBoxes = '  '.$lang['edit_jdate'].'[?]'; } else { $CheckBoxes = '  '.$lang['edit_ecal'].'  '.$lang['edit_jdate'].'[?]'; } $CheckBoxes = ""; return ' '.$CheckBoxes.' '; /* return "\"Календарь\" ";*/ } function GetDateField($title, $value) { return "\"Календарь\" "; } function GetImgField($title, $value) { $RetStr = ""; if($value!="") { $RetStr .= $this->GetImgThumb($value); $RetStr .= " Удалить?"; } $RetStr .= "
"; return $RetStr; } function GetFileField($title, $value) { $RetStr = ""; if($value!="") { // Get file name and size $RetStr .= "Текущий файл"; $RetStr .= " Удалить?"; } $RetStr .= "
"; return $RetStr; } function GetUnlimImgField($title, $value) { $RetStr = " "; if($value!="") { $RetStr .= "
"; // get all images and make a list of iamges $ImagesArr = explode(":|:", $value); $frt = 0; foreach($ImagesArr as $imgthumb) { $RetStr .= $this->GetImgThumb($imgthumb); $RetStr .= " Удалить?
"; $frt++; } $RetStr .= "
"; $RetStr .= ""; } $RetStr .= "
"; $RetStr .= "
"; $RetStr .= "
"; $RetStr .= "
GetLangVar("addimgfield")."\" onClick=\"javascript:AddField{$title}();return false;\">"; return $RetStr; } function ProcessData($class, $type, $id="") { global $member_id, $db, $member_db; // get each post element and make up input $DataArr = array(); include_once ENGINE_DIR.'/classes/parse.class.php'; $parse = new ParseFilter(Array(), Array(), 1, 1); foreach($_POST as $key=>$value) { // make up an array of items to do with records if(isset($this->MyClasses[$class]['db'][$key])) { // if we haveplugin item than get it's value by plugin if(strstr($this->MyClasses[$class]['db'][$key], "Plugin")) { $Parts = explode(":", $this->MyClasses[$class]['db'][$key]); $ClassTitle = $Parts[1]; $Function = $Parts[2]; $RetData = $this->LoadPlugin($ClassTitle, $Function, array("value"=>$value, "mode"=>"data")); if(is_array($RetData)) { $DataArr = array_merge($DataArr, $RetData); } } else if($this->MyClasses[$class]['db'][$key]=="decimal") { $value = str_replace(",", ".", $value); $value = str_replace(" ", "", $value); $value = str_replace(".00", "", $value); $DataArr[$key] = $value; } else if(strstr($this->MyClasses[$class]['db'][$key], "MSelect")) { $DataArr[$key] = json_encode($value); } else if(in_array($key, $this->BBParsed)) { $DataArr[$key] = $parse->BB_Parse($value); } else { $DataArr[$key] = $value; } } else if(strstr($key, "mfield_")) { // we have a mulifield $RealKeyArr = str_replace("mfield_", "", $key); $FieldTitle = substr($RealKeyArr, 0, strpos($RealKeyArr, "_")); $RealKeyArr = str_replace($FieldTitle."_", "", $RealKeyArr); $TypeField = substr($RealKeyArr, 0, strpos($RealKeyArr, "_")); $ClearTile = substr($RealKeyArr, 0, strripos($key, "_")+1); // now make final string $StrField = $key."|++|".$TypeField."|++|".$value."|::|"; /* echo $StrField; $dbserver="localhost"; $dbname="testing"; $dbuser="testing"; $dbpass="alltesting"; $chandle = mysql_connect($dbserver, $dbuser, $dbpass) or die("Connection Failure to Database"); mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser); $result = mysql_query('SELECT id FROM dle_shop WHERE artikul='.$_POST["artikul"]); $row = mysql_fetch_assoc($result); echo $row["id"]."
"; //print_r($_POST["artikul"]); echo $_POST["mfield_maindata_text_shortinfo"];*/ if(!isset($DataArr[$FieldTitle])) { $DataArr[''.$FieldTitle.''] = $StrField; } else { $DataArr[''.$FieldTitle.''] .= $StrField; } } } foreach($_FILES as $key=>$value) { if($this->MyClasses[$class]['db'][$key]=="img") { if((int)$value['size']>1024*(int)$this->MyConfig['max_img_size']['value']) { return "Размер загружаемой картинки (".$value['name'].") превышает допустимый размер файла"; } } } if($type!="delete") { // check thr e fileds $CheckRes = $this->FieldsCheck($class, $DataArr); if($CheckRes!="") { return $CheckRes; } } if($type=="add"||$type=="edit") { foreach($this->MyClasses[$class]['db'] as $key=>$value) { if(!isset($DataArr[$key])) { if($this->MyClasses[$class]['db'][$key]=="checkbox") { if(isset($_POST[$key])&&$_POST[$key]!="") { $DataArr[$key] = "1"; } else { $DataArr[$key] = "0"; } } } } } if($type=="add") { // Now add fields which are not in the foreach($this->MyClasses[$class]['db'] as $key=>$value) { if(!isset($DataArr[$key])) { switch($this->MyClasses[$class]['db'][$key]) { case "CurrentUser": { if(isset($member_db[10])&&$member_db[10]!="") { } else { $member_db[10] = $member_id['user_id']; } $DataArr[$key] = $member_db[10]; break; } case "date": { $DataArr[$key] = date("Y-m-d H:i:s"); break; } case "ip": { $DataArr[$key] = $_SERVER['REMOTE_ADDR']; break; } } } } } if($type=="delete") { $SetDataArr = $this->GetRecord($class, $id); $SetDataArr = $SetDataArr[0]; } switch($type) { case "add": { $id = $this->AddRecord($class, $DataArr); break; } case "edit": { $this->EditRecord($class, $id, $DataArr); break; } case "delete": { $this->DeleteRecord($class, $id); break; } } if($type!="delete") { $SetDataArr = $this->GetRecord($class, $id); $SetDataArr = $SetDataArr[0]; } if($id=="exists") { return $this->GetLangVar("msg_record_exists"); } if($type!="delete") { foreach($_FILES as $key=>$value) { // make up an array of items to do with records if(isset($this->MyClasses[$class]['db'][$key])) { $TmpImg = $this->MakeProcessor($class, $key, $value, $id, $_POST); if($TmpImg!="") { $DataArr[$key] = $TmpImg; } else { // we need to check delete flag, if it is there, add empty string and del the file if($_POST[$key."_deleteimg"]) { // delet $DataArr[$key] = ""; $this->DeleteFile($class, $key, $id); } if($this->MyClasses[$class]['db'][$key]=="unlimg") { $DataArr[$key] = $TmpImg; } } // search for deleting checkpoints } } $this->EditRecord($class, $id, $DataArr); } // if isset ID - get it $RetArr = array( "id" => $id, "data" => $SetDataArr ); return $RetArr; } function IfUserAllowed($rights) { if($rights['allowed'] == "all") { return true; } } function ShowSearchForm() { return ""; } function AddLink($tag, $url, $sefurl, $rights) { $this->MyLinks[$tag]['url'] = $url; $this->MyLinks[$tag]['sefurl'] = $sefurl; $this->MyLinks[$tag]['rights'] = $rights; } function GetLinkTag($tag) { global $config; if ($config['allow_alt_url'] == "yes") { return $this->MyLinks[$tag]['sefurl']; } else { return $this->MyLinks[$tag]['url']; } } function GetLink($class, $type, $data=array(), $kind="") { global $config; if($kind=="") { if(strstr($_SERVER['REQUEST_URI'], $config['admin_path'])) { $kind="admin"; } else { $kind="index"; } } if ($config['allow_alt_url'] == "yes") { if($kind=="admin") { $RetStr = "/".$config['admin_path']."?mod=".$this->MyTitle."&class=$class&op=$type"; foreach($data as $key=>$value) { if($value!="") { $RetStr .= "&$key=$value"; } } } else { $RetStr = "/".$this->MyTitle; if($class!="") { $RetStr .= "/$class"; } if($type!="") { $RetStr .= "/$type"; } if(is_array($data)) { foreach($data as $key=>$value) { if($this->MyClasses[$class]['seo']!="") { if($key=="id") { if($type=="itemshow") { // Get record data $UnsereItem = $this->GetRecord($class, $value); $UnsereItem = $UnsereItem[0]; $SEOString = $this->MyClasses[$class]['seo']; if(is_array($UnsereItem)) { foreach($UnsereItem as $rey=>$ralit) { $SEOString = str_replace('{'.$rey.'}', $this->GetTrueValue($ralit, $this->MyClasses[$class]['db'][$rey]), $SEOString); } } $value = $value."-".urlencode($SEOString); } } } if($value!=""||$value=="0") { $RetStr .= "/$value"; } } } } } else { if($kind=="admin") { $RetStr = "/".$config['admin_path']."?mod=".$this->MyTitle."&class=$class&op=$type"; } else { $RetStr = "/index.php?do=".$this->MyTitle."&class=$class&op=$type"; } //if we have our data array, simply add it next foreach($data as $key=>$value) { $RetStr .= "&$key=$value"; } } return $RetStr; } // admin page functions function AdminShowConfig() { global $lang, $db; // Now process data if it was sent if($_GET['action']=="save") { $content = "MyConfig as $key=>$value) { if(!isset($_POST[''.$key.''])) { $_POST[''.$key.''] = ""; } } foreach($_POST as $key=>$value) { if(isset($this->MyConfig[$key]['value'])) { if(is_array($value)) { $value = json_encode($value); } else { $value = $db->safesql($value); } // if we have such config make a string with it $content .= "\$".$this->MyConfigTxt."['".$key."'] = array(\"value\"=>'".$db->safesql($value)."', \"type\"=>\"".$this->MyConfig[$key]['type']."\", \"title\"=>\"".$this->MyConfig[$key]['title']."\", \"descr\"=>\"".$this->MyConfig[$key]['descr']."\");\n\n"; } } $content .= "?>"; $filename = $this->MyConfigFile; if ($file = fopen($filename, "w")) { fwrite($file, $content); fclose($file); } else { echo "не удалось записать"; // exit(); } header ("Location: ".$this->GetLinkTag("adm_cfg_lnk")); } else { if ($config['allow_alt_url'] == "yes"&&!strstr($this->selfURL(), '=')) { $FormLink = $this->selfURL()."/save"; } else { $FormLink = $this->selfURL()."&action=save"; } // at first load basic template for admin config $CfgPage = <<< HTML
HTML; // Now lets make the list of items foreach($this->MyConfig as $key=>$value) { switch($value['type']) { case "varchar": { $CfgPage .= <<< HTML HTML; break; } case "text": { $value['value'] = stripslashes(stripslashes(stripslashes($value['value']))); $CfgPage .= <<< HTML HTML; break; } case "yesno": { $CfgPage .= <<< HTML HTML; break; } default: { if(strstr($value['type'], "MSelect") == true) { // Make and show the list $CfgPage .= <<< HTML HTML; } else if(strstr($value['type'], "Select") == true) { // Make and show the list $CfgPage .= <<< HTML HTML; } } } $CfgPage .= <<< HTML HTML; } $CfgPage .= <<< HTML
{$value['title']}:
{$value['descr']}
{$value['title']}:
{$value['descr']}
{$value['title']}
{$value['descr']}
HTML; $CfgPage .= $this->makeDropDown(array("1" => "Да", "0" => "Нет"), "$key", "{$value['value']}"); $CfgPage .= <<< HTML
{$value['title']}
{$value['descr']}
HTML; $LstParts = explode(":", $value['type']); $ListTitle = $LstParts[1]; $CfgPage .= $this->GetMSelectList($ListTitle, "$key", "{$value['value']}"); $CfgPage .= <<< HTML
{$value['title']}
{$value['descr']}
HTML; $LstParts = explode(":", $value['type']); $ListTitle = $LstParts[1]; $CfgPage .= $this->GetSelectList($ListTitle, "$key", "{$value['value']}"); $CfgPage .= <<< HTML



HTML; return $CfgPage; } return $CfgPage; } function AdminShowItemList($class, $ParamArr) { } function makeDropDown($options, $name, $selected) { $output = "\r\n"; foreach ($options as $value => $description) { $output .= "