* @copyright 2006, Cataev Oleg Alexandrovich * @license * @version * @link * путь по сайту для index.php от 26 июля 2006 * ****************************************************************************/ function getPath($httpID,$cpu) { $Item=false; $pathArray=array(); $flag=true; $parentID=$httpID; #echo "

path

"; //данные о главной странице $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['documetHomeAttr'],NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['documetHomeAttr'],NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['_httpLang'],NORMAL); $GLOBALS['DB']->execute("SELECT sections.ID,Head As caption,StructID,cpu FROM sections, structure WHERE sections.StructID=structure.ID AND structure.Attr&?=? AND langID=? AND Translated=1"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) //собственно путь while (true) { $row=threadUserContent($parentID,$GLOBALS['_httpLang']); if (is_array($row)) { $cpu=$row['cpu']; $pathArrayValue=($parentID==$httpID)?false:create_user_url($GLOBALS['_httpLangL'],$cpu); if ($row['ParentID']!==0) { $pathArray[$row['head']]=$pathArrayValue; $parentID=$row['ParentID']; if ($GLOBALS['back_url']==false) $GLOBALS['back_url']=$pathArrayValue; } else { $pathArray[$row['head']]=$pathArrayValue; if ($GLOBALS['back_url']==false) $GLOBALS['back_url']=$pathArrayValue; break; } } else { break; } } if (isset($rootTitle)) { $pathArray[$rootTitle]=$rootURL; } $pathArray=array_reverse($pathArray); #if (sizeof($pathArray)>2) #{ $Item=getXMLUserPath($pathArray); #} unset($pathArray); #echo "

END PATH

"; return $Item; } function threadUserContent($id,$langID) { $GLOBALS['DB']->addParam(adNumeric,$langID,NORMAL); $GLOBALS['DB']->addParam(adNumeric,$id,NORMAL); $GLOBALS['DB']->execute("SELECT structure.ID,structure.ParentID,sections.Head, cpu FROM structure,sections WHERE (sections.StructID=structure.ID AND sections.LangID=? AND sections.StructID=? AND Translated=1)"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { $row=$GLOBALS['DB']->getRecords(); $ret=array('ParentID'=>$row['ParentID'],'head'=>$row['Head'],'cpu'=>$row['cpu']); unset($row); } else { unset($ret); $ret=false; } return $ret; } ?> * @copyright 2006, Cataev Oleg Alexandrovich * @license * @version * @link * контент для index.php от 26 июля 2006 * 21 ноя 2006 - включаем человеческую поддержку чпу и выносим языки наружу * ****************************************************************************/ function getForms($row) { $curr_lang=$GLOBALS['_httpLang']; //три буквы языка $sendmail_info=$GLOBALS['_httpLangL']."_sendmail_info"; $contact_person=$GLOBALS['_httpLangL']."_contact_person"; $contact_phone=$GLOBALS['_httpLangL']."_contact_phone"; $contact_email=$GLOBALS['_httpLangL']."_contact_email"; $contact_message=$GLOBALS['_httpLangL']."_contact_message"; $contact_send=$GLOBALS['_httpLangL']."_contact_send"; $contact_reset=$GLOBALS['_httpLangL']."_contact_reset"; $SendMail=$GLOBALS['XML']->createElement("SendMailForm"); if (is_array($row)) { if ($row['Attr'] & $GLOBALS['documentSendMail']) { //форма обратной связи $SendMail->setAttribute("form","yes"); $SendMail->setAttribute("sendmail_info",c($GLOBALS[$sendmail_info])); $SendMail->setAttribute("form_action",c($GLOBALS['cfg']['Server']['wwwroot']."/forms.php")); $SendMail->setAttribute("faction","sendmail"); $SendMail->setAttribute("contact_person",c($GLOBALS[$contact_person])); $SendMail->setAttribute("contact_phone",c($GLOBALS[$contact_phone])); $SendMail->setAttribute("contact_email",c($GLOBALS[$contact_email])); $SendMail->setAttribute("contact_message",c($GLOBALS[$contact_message])); $SendMail->setAttribute("contact_send",c($GLOBALS[$contact_send])); $SendMail->setAttribute("contact_reset",c($GLOBALS[$contact_reset])); # мы запомнили данные if (isset($_SESSION['formperson'])) { $SendMail->setAttribute("formperson", c($_SESSION['formperson'])); } if (isset($_SESSION['formphone'])) { $SendMail->setAttribute("formphone", c($_SESSION['formphone'])); } if (isset($_SESSION['formemail'])) { $SendMail->setAttribute("formemail", c($_SESSION['formemail'])); } if (isset($_SESSION['forminfo'])) { $SendMail->setAttribute("forminfo", c($_SESSION['forminfo'])); } } } return Array($SendMail); } function getSection($httpID, $StructID, $attr=0, $topcpu="") { $Item=false; //отображаем содержимое $Item=$GLOBALS['XML']->createElement("ContentList"); $GLOBALS['DB']->addParam(adNumeric, $StructID,NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['_httpLang'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, ($GLOBALS['_httpPage']-1)*$GLOBALS['cfg']['docsPerPage'], SMALL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['cfg']['docsPerPage'], SMALL); $simpleAnonceFlag = false; if ($attr & $GLOBALS['SimpleAnonce']) { $Item->setAttribute('listview', 'yes'); $simpleAnonceFlag = true; } else { $Item->setAttribute('listview', 'no'); } // собираем запрос $query = " SELECT SQL_CALC_FOUND_ROWS structure.ID, sections.Head as caption, sections.Translated, SDate, Descr as `text`, structure.SortOrder, structure.Attr AS Attr, FolderDoc, Icon as icon, sections.ftxt, extlink, cpu, title, metadescr, metakey, cheader, informers, price, price2, code FROM sections, structure WHERE sections.StructID=structure.ID AND structure.ParentID=? AND structure.Attr&?=? AND sections.LangID=? AND Translated=1 "; if (($attr & $GLOBALS['sectionNewsAttr'])) { $Item->setAttribute("news","yes"); $GLOBALS['Root']->setAttribute("news","yes"); $GLOBALS['news_flag']=true; $query.=" ORDER BY sections.SDate DESC, FolderDoc ASC LIMIT ?,?"; } else { $query.=" ORDER BY structure.SortOrder ASC LIMIT ?,?"; } $GLOBALS['DB']->execute($query); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows)) { while ($row=$GLOBALS['DB']->getRecords()) { if ($row['icon']=="") { $row['icon'] = $GLOBALS['cfg']['Server']['wwwroot'] . "/xsl/img/noimg.jpg"; } if (""!==$row['cheader']) { $row['caption'] = $row['cheader']; } if (""!==$row['extlink']) { $url=$row['extlink']; } else { $url=create_user_url($GLOBALS['_httpLangL'], $row['cpu']); } if (!$simpleAnonceFlag) { $row['text'] = $row['text']; } if (0==$row['FolderDoc']) { $SubItem=createNode("SectionShort", $row); } else { if ($row['price']>0) { $row['price'] = $row['price'] * $GLOBALS['_curs']; $row['price'] = number_format($row['price'], 2, ',', ' '); } if ($row['price2']>0) { $row['price2'] = $row['price2'] * $GLOBALS['_curs']; $row['price2'] = number_format($row['price2'], 2, ',', ' '); } $SubItem=createNode("DocumentShort", $row); /* это предмет который можно добавить в корзину */ if (($row['Attr'] & $GLOBALS['documentProduct']) && ($row['price']>0)) { $SubItem->setAttribute("product", "yes"); $cart_url=$GLOBALS['cfg']['Server']['wwwroot']."/index.php?lang=".$GLOBALS['_httpLangL']."&apage=add2cart&catid=".$row['ID']; $SubItem->setAttribute("cartlink",c($cart_url)); if ($row['Attr'] & $GLOBALS['nalichieAttr'] ) { $SubItem->setAttribute("nalichie","yes"); } } /* */ } $SubItem->setAttribute("link",c($url)); $d=dateFromBase($row['SDate']); $d=date($GLOBALS['_date_fotmat'],mktime($d['hour'],$d['minute'],$d['second'],$d['month'],$d['day'],$d['year'])); $SubItem->setAttribute("SDate",$d); $filename =_pathTrans($row['icon']); $pathinfo = pathinfo($filename); if (isset($pathinfo['extension'])) { $SubItem->setAttribute('type', $pathinfo['extension']); } if ($row['Attr'] & 64) { $SubItem->setAttribute("newwind","1"); } $Item->appendChild($SubItem); unset($SubItem); } # строим навигацию по страницам $GLOBALS['DB']->execute("SELECT FOUND_ROWS() as numrows"); if (!$GLOBALS['DB']->err && $GLOBALS['DB']->n_rows>0) { $row=$GLOBALS['DB']->getRecords(); $numrows = $row['numrows']; } if ($numrows > $GLOBALS['cfg']['docsPerPage']) { $numPages=ceil($numrows/$GLOBALS['cfg']['docsPerPage']); $PagesItem=getXMLUserPages($numPages, $GLOBALS['_httpPage'], $GLOBALS['cp1']); if (is_object($PagesItem)) { $GLOBALS['Root']->appendChild($PagesItem); unset($PagesItem); } } } else { // нет такой страницы ? _throw(1404,1); } return $Item; } function getContent($httpID,$httpLang,$httpPage=1) { $Item=false; $GLOBALS['DB']->addParam(adNumeric,$httpID,NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric,$httpLang,NORMAL); $GLOBALS['DB']->execute("SELECT sections.ID, Head as caption, Icon As icon, structure.ID, StructID, SDate, Text as text, Descr as description, FolderDoc, structure.Attr, sections.ftxt, cpu, title, price, price2, metadescr, metakey, cheader, informers, code FROM sections, structure WHERE sections.StructID=structure.ID AND structure.ID=? AND structure.Attr&?=? AND LangID=? AND Translated=1"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { $row=$GLOBALS['DB']->getRecords(); if (""!==$row['cheader']) { $row['caption'] = $row['cheader']; } $GLOBALS['Root']->setAttribute("ContentHeader",c($row['caption'])); if (0==$row['FolderDoc']) { //это раздел $Item=getSection($httpID,$row['StructID'],$row['Attr'],$row['cpu']); if (false!==$Item) $GLOBALS['Root']->setAttribute("contentlisttext",c($row['text'])); $Item->setAttribute("caption", c($row['caption'])); $Item->setAttribute("icon", $row['icon']); $Item->setAttribute("informers", c($row['informers'])); } else { //это документ $nodeName = "Document"; $url=create_user_url($GLOBALS['_httpLangL'],$row['cpu'],$GLOBALS['_httpPage']); $d=dateFromBase($row['SDate']); $row['SDate']=date($GLOBALS['_date_fotmat'],mktime($d['hour'],$d['minute'],$d['second'],$d['month'],$d['day'],$d['year'])); if ($row['price']>0) { $row['price'] = $row['price'] * $GLOBALS['_curs']; $row['price'] = number_format($row['price'], 2, ',', ' '); } if ($row['price2']>0) { $row['price2'] = $row['price2'] * $GLOBALS['_curs']; $row['price2'] = number_format($row['price2'], 2, ',', ' '); } $Item=createNode($nodeName,$row); $Item->setAttribute("form_action",c($GLOBALS['cfg']['Server']['wwwroot']."/forms.php")); if ($row['Attr'] & $GLOBALS['documetHomeAttr']) { $GLOBALS['Root']->setAttribute("mainpage","yes"); } /* это предмет который можно добавить в корзину */ if ($row['Attr'] & $GLOBALS['documentProduct']) { $Item->setAttribute("product", "yes"); $cart_url=$GLOBALS['cfg']['Server']['wwwroot']."/index.php?lang=".$GLOBALS['_httpLangL']."&apage=add2cart&catid=".$row['ID']; $Item->setAttribute("cartlink",c($cart_url)); if ($row['Attr'] & $GLOBALS['nalichieAttr'] ) { $Item->setAttribute("nalichie","yes"); } } /* */ $Item->setAttribute("link",c($url)); $forms=getForms($row); foreach ($forms as $key=>$value) { $Item->appendChild($value); } unset($forms); $GLOBALS['DB']->addParam(adNumeric,$httpID,NORMAL); $GLOBALS['DB']->execute("select galery_structure.id, galery_structure.icon_url, galery_structure.image_url, galery_structure.caption from galery_structure where galery_structure.struct_id=? "); $GLOBALS['DB']->clearParams(); if (!$GLOBALS['DB']->err && $GLOBALS['DB']->n_rows>0) { $Galery=$GLOBALS['XML']->createElement("Galery"); $rows=$GLOBALS['DB']->getAllRecords(); $Galery->setAttribute("image", urldecode(strtolower($rows[0]['image_url']))); $Galery->setAttribute("caption", c($rows[0]['caption'])); //$rows=array_shorten($rows); foreach ($rows as $key=>$value) { $SubItem=$GLOBALS['XML']->createElement("GaleryItem"); $SubItem->setAttribute("xml:id", $value['id']); $SubItem->setAttribute("gal_struct_id", $value['id']); $value['icon_url'] = urldecode(strtolower($value['icon_url'])); $value['image_url'] = urldecode(strtolower($value['image_url'])); $SubItem->setAttribute("icon_url", $value['icon_url']); $SubItem->setAttribute("image_url", $value['image_url']); $SubItem->setAttribute("caption", c($value['caption'])); $Galery->appendChild($SubItem); unset($SubItem); } $Item->appendChild($Galery); unset($Galery); } } if (is_object($Item)) { $Item->setAttribute("metadescr", c($row['metadescr'])); $Item->setAttribute("metakey", c($row['metakey'])); $Item->setAttribute("title", c($row['title'])); } } else { // нет такой страницы ? _throw(1404,1); } return($Item); } function getTypeContentHeader($type_id, $lang_id) { $return = false; $GLOBALS['DB']->addParam(adNumeric, $type_id, BIG); $GLOBALS['DB']->addParam(adNumeric, $lang_id, BIG); $GLOBALS['DB']->execute("SELECT caption FROM types WHERE struct_id=? AND lang_id=? AND translated=1"); $GLOBALS['DB']->clearParams(); if (!$GLOBALS['DB']->err && $GLOBALS['DB']->n_rows>0) { $row=$GLOBALS['DB']->getRecords(); $return = $row['caption']; } return $return; } function getTypeContent($type_id, $lang_id, $page=0) { $Item = false; $db = $GLOBALS['DB']; $xml = $GLOBALS['XML']; //отображаем содержимое $Item = $xml->createElement("ContentList"); $db->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $db->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $db->addParam(adNumeric, $GLOBALS['_httpLang'], NORMAL); $db->addParam(adNumeric, $type_id, NORMAL); $db->addParam(adNumeric, ($GLOBALS['_httpPage']-1)*$GLOBALS['cfg']['docsPerPage'], SMALL); $db->addParam(adNumeric, $GLOBALS['cfg']['docsPerPage'], SMALL); $query = " SELECT SQL_CALC_FOUND_ROWS structure.ID, sections.Head as caption, sections.Translated, SDate, Descr as `text`, structure.SortOrder, structure.Attr AS Attr, FolderDoc, Icon as icon, sections.ftxt, extlink, cpu, title, metadescr, metakey FROM sections, structure, types_rel WHERE sections.StructID=structure.ID AND structure.Attr&?=? AND sections.LangID=? AND Translated=1 AND types_rel.id_typestruct = ? AND types_rel.id_struct=structure.ID ORDER BY structure.ParentID, structure.SortOrder LIMIT ?,?"; $db->execute($query); $db->clearParams(); if ((!$db->err) && ($db->n_rows)) { while ($row=$db->getRecords()) { if ($row['icon']=="") { $row['icon'] = $GLOBALS['cfg']['Server']['wwwroot'] . "/xsl/img/noimg.jpg"; } if (""!==$row['extlink']) { $url=$row['extlink']; } else { $url=create_user_url($GLOBALS['_httpLangL'], $row['cpu']); } if (!$simpleAnonceFlag) { $row['text'] = $row['text']; } /* */ if ($row['price']>0) { $row['price'] = $row['price'] * $GLOBALS['_curs']; $row['price'] = number_format($row['price'], 2, ',', ' '); } if ($row['price2']>0) { $row['price2'] = $row['price2'] * $GLOBALS['_curs']; $row['price2'] = number_format($row['price2'], 2, ',', ' '); } /* */ $SubItem=createNode("DocumentShort", $row); /* это предмет который можно добавить в корзину */ if (($row['Attr'] & $GLOBALS['documentProduct']) && ($row['price']>0)) { $SubItem->setAttribute("product", "yes"); $cart_url=$GLOBALS['cfg']['Server']['wwwroot']."/index.php?lang=".$GLOBALS['_httpLangL']."&apage=add2cart&catid=".$row['ID']; $SubItem->setAttribute("cartlink",c($cart_url)); if ($row['Attr'] & $GLOBALS['nalichieAttr'] ) { $SubItem->setAttribute("nalichie","yes"); } } /* */ $SubItem->setAttribute("link",c($url)); $d=dateFromBase($row['SDate']); $d=date($GLOBALS['_date_fotmat'],mktime($d['hour'],$d['minute'],$d['second'],$d['month'],$d['day'],$d['year'])); $SubItem->setAttribute("SDate",$d); $filename =_pathTrans($row['icon']); $pathinfo = pathinfo($filename); if (isset($pathinfo['extension'])) { $SubItem->setAttribute('type', $pathinfo['extension']); } if ($row['Attr'] & 64) { $SubItem->setAttribute("newwind","1"); } $Item->appendChild($SubItem); unset($SubItem); } # строим навигацию по страницам /* */ $db->execute("SELECT FOUND_ROWS() as numrows"); if (!$db->err && $db->n_rows>0) { $row=$db->getRecords(); $numrows = $row['numrows']; } if ($numrows > $GLOBALS['cfg']['docsPerPage']) { $numPages=ceil($numrows/$GLOBALS['cfg']['docsPerPage']); $PagesItem=getXMLUserPages($numPages, $GLOBALS['_httpPage'], "/index.php?type=".$type_id); if (is_object($PagesItem)) { $GLOBALS['Root']->appendChild($PagesItem); unset($PagesItem); } } /* */ } else { // нет такой страницы ? _throw(1404,1); } return $Item; }