$v)
{
if ($v['default'])
{
$system['defaultLanguage'] = $v['prefix'];
if (!isset($system['language']))
{
$system['language'] = $v['prefix'];
setcookie('language', $system['language'], (time() + 2592000), '/');
}
break;
}
}
if (!in_array($system['module'], $allowedModules))
{
if ($system['module'] == '') {
$system['module'] = 'main';
} else {
$system['module'] = 'content';
}
}
$lang = array();
include_once $system['basePath'].'includes'.DS.'languages'.DS.$system['language'].'.php';
require $system['basePath'].'includes'.DS.'smarty'.DS.'Smarty.class.php';
$smarty = new Smarty;
$smarty->template_dir = $system['basePath'].'includes'.DS.'templates';
$smarty->compile_dir = $system['basePath'].'includes'.DS.'templates_c';
$smarty->use_sub_dirs = false;
$smarty->register_function('showBanner', 'showBanner');
$smarty->register_function('showMenu', 'showMenu');
$smarty->register_function('showPoll', 'showPoll');
$loginType = 'site';
require_once $system['basePath'].'includes'.DS.'login.php';
$sitename = $system['sitename'];
$headMetaKeys = $system['metaKeys'];
$headMetaDescription = $system['metaDescription'];
$smarty->assign('sitename', $sitename);
$smarty->assign('headMetaKeys', $headMetaKeys);
$smarty->assign('headMetaDescription', $headMetaDescription);
//statistics
if ($system['statisticsEnabled'])
{
$ip = ip2long(getenv('REMOTE_ADDR'));
$referer = addslashes(urldecode(getenv('HTTP_REFERER')));
$useragent = addslashes(getenv('HTTP_USER_AGENT'));
$date = date('Y-m-d H:i:s');
$date2 = date('Y-m-d', strtotime($date));
$db->query("SELECT `date` FROM `".PREFIX."statistics` WHERE `date`='".$date2."'");
if ($db->numRows()) {
$db->query("UPDATE `".PREFIX."statistics` SET `hits`=`hits`+1 WHERE `date`='".$date2."'");
} else {
$db->query("INSERT INTO `".PREFIX."statistics` SET `date`='".$date2."', `hosts`='0', `hits`='1'");
}
$db->query("SELECT `ip` FROM `".PREFIX."statistics_ip` WHERE `ip`='".$ip."' AND `date`>='".date('Y-m-d 00:00:00', strtotime($date))."' AND `date`<='".date('Y-m-d 23:59:59', strtotime($date))."'");
if (!$db->numRows())
{
$db->query("INSERT INTO `".PREFIX."statistics_ip` SET `ip`='".$ip."', `date`='".$date."', `useragent`='".$useragent."', `referer`='".$referer."'");
$db->query("UPDATE `".PREFIX."statistics` SET `hosts`=`hosts`+1 WHERE `date`='".$date2."'");
}
}
$lang['copyright'] = sprintf($lang['copyright'], date('Y'));
$smarty->assign('system', $system);
$smarty->assign('lang', $lang);
$smarty->assign('module', $system['module']);
$BANNERS = array();
// last comments
$sql = "SELECT c.`id`, c.`userId`, c.`author`, c.`text`, a.`url`, a.`title`, ct.`url` AS `categoryUrl` "
. "FROM `".PREFIX."comments` AS c, `".PREFIX."articles` AS a LEFT JOIN `".PREFIX."categories` AS ct ON ct.`id`=a.`categoryId` "
. "WHERE c.`deleted`='0' AND c.`articleId`=a.`id` AND a.`language`='".$system['language']."' AND a.`published`='1' "
. "ORDER BY c.`date` DESC LIMIT 10";
$db->query($sql);
$lastComments = $db->getAssocList();
foreach ($lastComments as $k=>$v)
{
if ($lastComments[$k]['categoryUrl'] != '') {
$lastComments[$k]['url'] = $lastComments[$k]['categoryUrl'].'/'.$lastComments[$k]['url'];
}
if (String::strlen($lastComments[$k]['text']) > 100)
{
$lastComments[$k]['text'] = String::substr($lastComments[$k]['text'], 0, 97);
$tmpMore = true;
} else {
$tmpMore = false;
}
$lastComments[$k]['text'] = iconv('utf-8', 'windows-1251', $lastComments[$k]['text']);
$lastComments[$k]['text'] = preg_replace('/([^\s]{20})[^\s]+/', '', $lastComments[$k]['text']);
$lastComments[$k]['text'] = iconv('windows-1251', 'utf-8', $lastComments[$k]['text']);
if ($tmpMore) {
$lastComments[$k]['text'] .= '...';
}
}
$smarty->assign('lastComments', $lastComments);
// guest
$guest = array();
$guest['published'] = 0;
if (file_exists($system['basePath'].'images'.DS.'guest'.DS.'published.txt')) {
$guest['published'] = file_get_contents($system['basePath'].'images'.DS.'guest'.DS.'published.txt');
}
if (file_exists($system['basePath'].'images'.DS.'guest'.DS.'text.txt')) {
$guest['text'] = file_get_contents($system['basePath'].'images'.DS.'guest'.DS.'text.txt');
}
$smarty->assign('guest', $guest);
$sql = "SELECT a.`id`, a.`title`, a.`question`, COUNT(c.`id`) AS `commentsCount` FROM `".PREFIX."salon` AS a "
. "LEFT JOIN `".PREFIX."salon_comments` AS c ON (c.`articleId`=a.`id` AND c.`deleted`='0') "
. "WHERE a.`published`='1' GROUP BY a.`id` ORDER BY a.`date` DESC LIMIT 2";
$db->query($sql);
$salonLastArticles = $db->getAssocList();
foreach ($salonLastArticles as $k=>$v)
{
if (String::strlen($salonLastArticles[$k]['question']) > 200) {
$salonLastArticles[$k]['question'] = String::substr($salonLastArticles[$k]['question'], 0, 197).'...';
}
}
$smarty->assign('salonLastArticles', $salonLastArticles);
/*
// ����� �������
$sql = "SELECT a.`id`, a.`title`, a.`question`, COUNT(c.`id`) AS `commentsCount`, MAX(c.`date`) AS `maxDate` "
. "FROM `".PREFIX."peoplehelp` AS a "
. "LEFT JOIN `".PREFIX."peoplehelp_comments` AS c ON (c.`articleId`=a.`id` AND c.`deleted`='0') "
. "WHERE a.`recommend`='0' GROUP BY a.`id` ORDER BY `maxDate` DESC LIMIT 3";
$db->query($sql);
$peoplehelpLastArticles = $db->getAssocList();
foreach ($peoplehelpLastArticles as $k=>$v)
{
if (String::strlen($peoplehelpLastArticles[$k]['question']) > 200) {
$peoplehelpLastArticles[$k]['question'] = String::substr($peoplehelpLastArticles[$k]['question'], 0, 197).'...';
}
}
$smarty->assign('peoplehelpLastArticles', $peoplehelpLastArticles);
*/
// �����������
$sql = "SELECT a.`id`, a.`title`, a.`question`, COUNT(c.`id`) AS `commentsCount`, MAX(c.`date`) AS `maxDate` "
. "FROM `".PREFIX."peoplehelp` AS a "
. "LEFT JOIN `".PREFIX."peoplehelp_comments` AS c ON (c.`articleId`=a.`id` AND c.`deleted`='0') "
. "WHERE a.`recommend`='1' GROUP BY a.`id` ORDER BY `maxDate` DESC LIMIT 2";
$db->query($sql);
$peoplehelpRecommendLastArticles = $db->getAssocList();
foreach ($peoplehelpRecommendLastArticles as $k=>$v)
{
if (String::strlen($peoplehelpRecommendLastArticles[$k]['question']) > 200) {
$peoplehelpRecommendLastArticles[$k]['question'] = String::substr($peoplehelpRecommendLastArticles[$k]['question'], 0, 197).'...';
}
}
$smarty->assign('peoplehelpRecommendLastArticles', $peoplehelpRecommendLastArticles);
// konkurs winner this month
$sql = "SELECT k.`id`, k.`title` FROM `".PREFIX."konkurs_winners` AS kw, `".PREFIX."konkurs` AS k "
. "WHERE k.`id`=kw.`photoId` ORDER BY kw.`date` DESC LIMIT 1";
$db->query($sql);
if ($konkursWinnerThisMonth = $db->getAssoc())
{
if (file_exists($system['basePath'].'images'.DS.'konkurs'.DS.'3'.DS.$konkursWinnerThisMonth['id'].'.jpg'))
{
$imgInfo = getimagesize($system['basePath'].'images'.DS.'konkurs'.DS.'3'.DS.$konkursWinnerThisMonth['id'].'.jpg');
$konkursWinnerThisMonth['width'] = $imgInfo[0];
$konkursWinnerThisMonth['height'] = $imgInfo[1];
$konkursWinnerThisMonth['wh'] = $imgInfo[3];
}
$konkursWinnerThisMonth['width'] = '';
$konkursWinnerThisMonth['height'] = '';
$konkursWinnerThisMonth['wh'] = '';
}
$smarty->assign('konkursWinnerThisMonth', $konkursWinnerThisMonth);
// konkurs rand photo
$stat = @stat(__FILE__);
if (empty($stat) || !is_array($stat)) $stat = array(php_uname());
mt_srand(crc32(microtime().implode('|', $stat)));
$db->query("SELECT COUNT(`id`) AS `count` FROM `".PREFIX."konkurs` WHERE `approved`='1'");
$row = $db->getAssoc();
$tmp = mt_rand(0, $row['count']);
$db->query("SELECT `id`, `title` FROM `".PREFIX."konkurs` WHERE `approved`='1' LIMIT ".$tmp.",1");
if ($konkursRandPhoto = $db->getAssoc())
{
$imgInfo = getimagesize($system['basePath'].'images'.DS.'konkurs'.DS.'3'.DS.$konkursRandPhoto['id'].'.jpg');
$konkursRandPhoto['width'] = $imgInfo[0];
$konkursRandPhoto['height'] = $imgInfo[1];
$konkursRandPhoto['wh'] = $imgInfo[3];
}
$smarty->assign('konkursRandPhoto', $konkursRandPhoto);
$include = $system['basePath'].'includes'.DS.'modules'.DS.$system['module'].'.php';
if (file_exists($include)) {
include $include;
} else {
include $system['basePath'].'includes'.DS.'modules'.DS.'main.php';
}