Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $id = intval(str_replace('project|','',$row['page_url'])); $_copy[$id] = $row['slider_id']; } foreach ($_copy as $_project_id => $_file_id) { copy( ROOT_PATH . '/i/_projects/index_' . $_file_id . '.jpg' , ROOT_PATH . '/i/projects/teaser_' . $_project_id . '.jpg' ); copy( ROOT_PATH . '/i/_projects/preview_' . $_file_id . '.jpg' , ROOT_PATH . '/i/projects/thumb_' . $_project_id . '.jpg' ); chmod(ROOT_PATH . '/i/projects/thumb_' . $_project_id . '.jpg',0777); chmod(ROOT_PATH . '/i/projects/teaser_' . $_project_id . '.jpg',0777); } exit(); */ function upload_image($_e_file,$_e_save) { global $dbconn; $error = check_upload_error($_e_file); if ($error!=false) { echo ''; exit(); } $_file = ROOT_PATH . $_e_save; if ($_e_save=='/i/slider/slider_') { $sql = 'INSERT INTO im_sliders(slider_type,slider_date) VALUES (0,NOW())'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $_file .= $dbconn->_insertid() . '.png'; } else { if (file_exists($_file)) { rename($_file,str_replace(array('/i/','.jpg','.png'),array('/_i/','-'.date('Y-m-d-H-i-s').'.jpg','-'.date('Y-m-d-H-i-s').'.png'),$_file)); } } /* if (strpos($_file,'/i/u')!==false) { $_file = str_replace('_120','',$_file); move_uploaded_file($_FILES[$_e_file]['tmp_name'], $_file); chmod($_file,0777); exec( 'convert -size 120x120 '. $_file . ' -thumbnail 120x120 ' . $_file . '_120' ); } else { } */ move_uploaded_file($_FILES[$_e_file]['tmp_name'], $_file); chmod($_file,0777); } function check_upload_error($_filename) { $error = false; if(!empty($_FILES[$_filename]['error'])) { switch($_FILES[$_filename]['error']) { case '1': $error = 'Размер файла превышает максимально допустимый'; break; case '2': $error = 'Размер файла превышает максимально допустимый'; break; case '3': $error = 'The uploaded file was only partially uploaded'; break; case '4': $error = 'Не выбран файл для закачки.'; break; case '6': $error = 'Missing a temporary folder'; break; case '7': $error = 'Failed to write file to disk'; break; case '8': $error = 'File upload stopped by extension'; break; } } elseif(empty($_FILES[$_filename]['tmp_name']) || $_FILES[$_filename]['tmp_name'] == 'none') { $error = 'Не выбран файл для закачки'; } return $error; } function echo_banners($_page_url) { global $dbconn, $template; $sql = 'SELECT * FROM im_sliders_pages sp, im_sliders s WHERE page_url = "'. addslashes(stripslashes($_page_url)) .'" AND sp.slider_id = s.slider_id ORDER BY sp_position'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('banner',$row); } } $_site_categories = array( 1 => 'advert', 2 => 'identity', 3 => 'print', 4 => 'interactive', 5 => 'special', ); $_assign = array(); $_error = array(); $_success = false; $_current_lang = (isset($_POST['lang']) && $_POST['lang']=='en/') ? 'en' : 'ru'; if (strpos($_SERVER['REQUEST_URI'],'/en/') === 0) { $r = substr($_SERVER['REQUEST_URI'],3); $_current_lang = "en"; } else $r = $_SERVER['REQUEST_URI']; $sql = 'SELECT * FROM im_texts'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) die("Empty query"); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); if (strpos($row['text_id'],'e_mail_')!==0) { $_assign[$row['text_id']] = str_replace(array("\r\n","\n","\r"),'',($row['text_'.$_current_lang]=="") ? '' : $row['text_'.$_current_lang]); } else { $_assign[$row['text_id']] = $row['text_en']; } } $_assign['lang'] = ($_current_lang=='en') ? 'en/' : ''; $_assign['lang_letters'] = ($_current_lang=='en') ? 'en' : 'ru'; $template->assign_block_vars( (($r!='/') ? 'no' : '') . 'index',array()); $template->assign_block_vars( $_current_lang . 'lang', array('url'=> ( ($_current_lang=='en') ? '' : '/en' ) . $r) ); // Класс пользователей if ((isset($_GET['_fun']) && $user->_fun($_GET['_fun'] ) )) { $template->assign_vars($_assign); $template->allparse(); } $_savetype = (isset($_POST['e_edit'])) ? $_POST['e_edit'] : (isset($_POST['e_save']) ? $_POST['e_save'] : false); if ($_savetype!==false) { if ( (strpos($_savetype,'/i/') === 0) ) { $_form = 'image'; list($_savetype) = explode('?',$_savetype); /* } elseif (strpos($_savetype,'e_poster') === 0) { $_form = 'poster'; } elseif (strpos($_savetype,'e_moderate') === 0) { $_form = 'poster'; } elseif (strpos($_savetype,'e_partner') === 0) { $_form = 'partner'; */ } elseif (strpos($_savetype,'e_sliders') === 0) { $_form = 'sliders'; } elseif (strpos($_savetype,'e_slider') === 0) { $_form = 'slider'; } elseif (strpos($_savetype,'e_user') === 0) { $_form = 'user'; } elseif (strpos($_savetype,'e_news') === 0) { $_form = 'news'; } elseif (strpos($_savetype,'e_brand') === 0) { $_form = 'brand'; } elseif (strpos($_savetype,'e_project') === 0) { $_form = 'project'; } elseif (strpos($_savetype,'e_quote') === 0) { $_form = 'quote'; } elseif (strpos($_savetype,'e_category') === 0) { $_form = 'category'; } elseif (strpos($_savetype,'banners') === 0) { $_form = 'banners'; } elseif ( (strpos($_savetype,'e_title') === 0) || (strpos($_savetype,'e_menu') === 0) || (strpos($_savetype,'e_desc') === 0) || (strpos($_savetype,'e_label') === 0) || (strpos($_savetype,'e_button') === 0) || (strpos($_savetype,'e_string') === 0) ) { $_form = 'text'; $_height = 18; } else { $_form = 'text'; $_height = 300; } if (isset($_POST['e_save'])) { if ( ( $session->user_id ) && ( ($user->is_admin) || ( ($user->is_moderator) && ($_form=='blog') ) ) ) switch ($_form) { case 'image': if ( isset($_POST['e_delete']) && ($_POST['e_delete']==1) ) { if ( (strpos($_POST['e_save'],'/i/slider/slider_')===0) || strpos($_POST['e_save'],'/i/projects/project_')===0 ) { $_file = ROOT_PATH . $_POST['e_save']; rename($_file,str_replace(array('/i/','.jpg','.png'),array('/_i/','-'.date('Y-m-d-H-i-s').'.jpg','-'.date('Y-m-d-H-i-s').'.png'),$_file)); $sql = 'DELETE FROM im_sliders WHERE slider_id = ' . intval(str_replace(array('/i/slider/slider_','/i/projects/project_','.png','.jpg'),'',$_POST['e_save'])); $result = $dbconn->Execute($sql); if ($result === false) die("Unable to delete file.
".$dbconn->ErrorMsg()); $sql = 'DELETE FROM im_sliders_pages WHERE slider_id = ' . intval(str_replace(array('/i/slider/slider_','/i/projects/project_','.png','.jpg'),'',$_POST['e_save'])); $result = $dbconn->Execute($sql); if ($result === false) die("Unable to delete file.
".$dbconn->ErrorMsg()); echo ''; exit(); } } else { upload_image('e_file',$_POST['e_save']); if ($_POST['e_save']=='/i/slider/slider_') { echo ''; } else { echo ''; } } exit(); break; case 'slider': $_project_id = (isset($_POST['project_id'])) ? intval($_POST['project_id']) : 0; if ($_project_id==0) exit(); $error = check_upload_error('project'); if ($error!=false) { echo ''; exit(); } $_file_type = intval($_POST['file_type']); switch ($_file_type) { case 1: @unlink( ROOT_PATH . '/i/projects/teaser_' . $_project_id . '.jpg' ); move_uploaded_file($_FILES['project']['tmp_name'], ROOT_PATH . '/i/projects/teaser_' . $_project_id . '.jpg'); chmod(ROOT_PATH . '/i/projects/teaser_' . $_project_id . '.jpg',0777); break; case 2: @unlink( ROOT_PATH . '/i/projects/thumb_' . $_project_id . '.jpg' ); move_uploaded_file($_FILES['project']['tmp_name'], ROOT_PATH . '/i/projects/thumb_' . $_project_id . '.jpg'); chmod(ROOT_PATH . '/i/projects/thumb_' . $_project_id . '.jpg',0777); break; default: $sql = 'INSERT INTO im_sliders(slider_type,slider_date) VALUES (1,NOW())'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $_new_id = $dbconn->_insertid(); move_uploaded_file($_FILES['project']['tmp_name'], ROOT_PATH . '/i/projects/project_' . $_new_id . '.jpg'); chmod(ROOT_PATH . '/i/projects/project_' . $_new_id . '.jpg',0777); $sql = 'INSERT INTO im_sliders_pages(slider_id,page_url) VALUES ('. $_new_id .',"project|'. intval($_project_id) .'")'; $result = $dbconn->Execute($sql); break; } echo ''; break; case 'banners': $_page = explode('banners|',$_POST['e_save']); if (!isset($_page[1])) exit(); parse_str($_POST['e_text'], $_banners); $sql = 'DELETE FROM im_sliders_pages WHERE page_url = "'. addslashes(stripslashes($_page[1])) .'" '; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); if (is_array($_banners['selected'])) foreach ($_banners['selected'] as $_id) { $_id = trim($_id); if ($_id==0) continue; $sql = 'INSERT INTO im_sliders_pages(slider_id,page_url) VALUES('. $_id .',"'. addslashes(stripslashes($_page[1])) .'")'; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); } echo 'system:reload'; exit(); break; case 'sliders': $_project_id = explode('sliders|',$_POST['e_save']); $_project_id = isset($_project_id[1]) ? intval($_project_id[1]) : 0; if ($_project_id==0) exit(); parse_str($_POST['e_text'], $_banners); $sql = 'DELETE FROM im_sliders_pages WHERE page_url = "project|'. $_project_id .'" '; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); if (is_array($_banners['selected'])) foreach ($_banners['selected'] as $_id) { $_id = trim($_id); if ($_id==0) continue; $sql = 'INSERT INTO im_sliders_pages(slider_id,page_url) VALUES('. $_id .',"project|'. $_project_id .'")'; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); } echo 'system:reload'; exit(); break; case 'news': $_id = intval($_POST['event_id']); if (isset($_POST['e_delete']) && $_POST['e_delete']==1) { $sql = 'DELETE FROM im_events WHERE event_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } if ($_id==0) upload_image('img','/i/events/event_9999.jpg'); $sql = ( ($_id==0) ? ' INSERT INTO im_events SET ' : ' UPDATE im_events SET ' ) . ' event_name_ru = "'. addslashes(stripslashes($_POST['event']['name_ru'])) .'", event_name_en = "'. addslashes(stripslashes($_POST['event']['name_en'])) .'", event_text_ru = "'. addslashes(stripslashes($_POST['event']['text_ru'])) .'", event_text_en = "'. addslashes(stripslashes($_POST['event']['text_en'])) .'", event_date = "'. implode('-',array_reverse(explode('.',$_POST['event']['date']))) .'" ' . ( ($_id==0) ? '' : ' WHERE event_id = ' . $_id ); $result = $dbconn->Execute($sql); if ($_id==0) { rename(ROOT_PATH . '/i/events/event_9999.jpg',ROOT_PATH . '/i/events/event_'. $dbconn->_insertid() .'.jpg'); chmod(ROOT_PATH . '/i/events/event_'. $dbconn->_insertid() .'.jpg',0777); } echo ''; exit(); break; case 'brand': $_id = intval($_POST['brand_id']); if (isset($_POST['e_delete']) && $_POST['e_delete']==1) { $sql = 'DELETE FROM im_brands WHERE brand_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } $sql = ( ($_id==0) ? ' INSERT INTO im_brands SET ' : ' UPDATE im_brands SET ' ) . ' brand_name_ru = "'. addslashes(stripslashes($_POST['brand']['name_ru'])) .'", brand_name_en = "'. addslashes(stripslashes($_POST['brand']['name_en'])) .'", brand_industry_ru = "'. addslashes(stripslashes($_POST['brand']['industry_ru'])) .'", brand_industry_en = "'. addslashes(stripslashes($_POST['brand']['industry_en'])) .'", brand_description_ru = "'. addslashes(stripslashes($_POST['brand']['description_ru'])) .'", brand_description_en = "'. addslashes(stripslashes($_POST['brand']['description_en'])) .'", brand_url = "'. addslashes(stripslashes($_POST['brand']['url'])) .'" ' . ( ($_id==0) ? '' : ' WHERE brand_id = ' . $_id ); $result = $dbconn->Execute($sql); echo ''; exit(); break; case 'project': $_id = intval($_POST['project_id']); if (isset($_POST['e_delete']) && $_POST['e_delete']==1) { $sql = 'DELETE FROM im_projects WHERE project_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } $sql = ( ($_id==0) ? ' INSERT INTO im_projects SET ' : ' UPDATE im_projects SET ' ) . ' project_name_ru = "'. addslashes(stripslashes($_POST['project']['name_ru'])) .'", project_name_en = "'. addslashes(stripslashes($_POST['project']['name_en'])) .'", project_text_ru = "'. addslashes(stripslashes($_POST['project']['text_ru'])) .'", project_text_en = "'. addslashes(stripslashes($_POST['project']['text_en'])) .'", project_context_ru = "'. addslashes(stripslashes($_POST['project']['context_ru'])) .'", project_context_en = "'. addslashes(stripslashes($_POST['project']['context_en'])) .'", project_task_ru = "'. addslashes(stripslashes($_POST['project']['task_ru'])) .'", project_task_en = "'. addslashes(stripslashes($_POST['project']['task_en'])) .'", project_solution_ru = "'. addslashes(stripslashes($_POST['project']['solution_ru'])) .'", project_solution_en = "'. addslashes(stripslashes($_POST['project']['solution_en'])) .'", project_top = '. ( ( isset($_POST['project']['top']) && ($_POST['project']['top']==1) ) ? 1 : 0 ) .', project_date = "'. implode('-',array_reverse(explode('.',$_POST['project']['date']))) .'", brand_id = ' . intval($_POST['project']['brand_id']) . ' ' . ( ($_id==0) ? '' : ' WHERE project_id = ' . $_id ); $result = $dbconn->Execute($sql); echo ''; exit(); break; case 'quote': $_id = intval($_POST['project_id']); if ($_id==0) exit(); $sql = 'UPDATE im_projects SET project_quote_ru = "'. addslashes(stripslashes($_POST['project']['quote_ru'])) .'", project_quote_en = "'. addslashes(stripslashes($_POST['project']['quote_en'])) .'", project_author_ru = "'. addslashes(stripslashes($_POST['project']['author_ru'])) .'", project_author_en = "'. addslashes(stripslashes($_POST['project']['author_en'])) .'" WHERE project_id = ' . $_id; $result = $dbconn->Execute($sql); echo ''; exit(); break; case 'category': $_id = intval($_POST['project_id']); if ($_id==0) exit(); $sql = 'DELETE FROM im_projects_categories WHERE project_id = ' . $_id; $result = $dbconn->Execute($sql); if (isset($_POST['categories']) && sizeof($_POST['categories'])) { $_categories = array(); foreach ($_POST['categories'] as $_category_id) { $_category_id = intval($_category_id); if (($_category_id!=0) && isset($_site_categories[$_category_id])) $_categories[] = $_category_id; } if (sizeof($_categories)) { $sql = 'INSERT INTO im_projects_categories(project_id,category_id) VALUES ('. $_id . ',' . implode('),(' . $_id . ',',$_categories) .')'; $result = $dbconn->Execute($sql); } } echo ''; exit(); break; /* case 'user': $_id = intval($_POST['user_id']); if (isset($_POST['e_delete']) && $_POST['e_delete']==1) { $sql = 'UPDATE fw_users SET user_active = 0 WHERE user_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } if ($_id!=0) { $sql = 'UPDATE fw_users SET username = "'. addslashes(stripslashes($_POST['e_name'])) .'", user_office = "'. addslashes(stripslashes($_POST['e_office'])) .'", user_email = "'. addslashes(stripslashes($_POST['e_email'])) .'", user_interest = "'. addslashes(stripslashes($_POST['e_interest'])) .'", user_level = "'. intval($_POST['e_level']) .'" WHERE user_id = ' . $_id; $result = $dbconn->Execute($sql); echo ''; exit(); } if ($user->registration_submit()) { $sql = 'UPDATE fw_users SET user_active = 1 WHERE user_id = ' . $user->_['user_id']; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } if (isset($user->error_text['error_username'])) { echo ''; } elseif (isset($user->error_text['error_email'])) { echo ''; } echo ''; exit(); break; case 'poster': if ($_POST['e_save']=='e_poster') { $_id = intval($_POST['poster_id']); $sql = 'UPDATE im_posters SET poster_firstname = "'. addslashes(stripslashes($_POST['e_firstname'])) .'", poster_lastname = "'. addslashes(stripslashes($_POST['e_lastname'])) .'", poster_country = "'. addslashes(stripslashes($_POST['e_country'])) .'", poster_city = "'. addslashes(stripslashes($_POST['e_city'])) .'", poster_url = "'. addslashes(stripslashes($_POST['e_url'])) .'", poster_desc = "'. addslashes(stripslashes($_POST['e_desc'])) .'", poster_address = "'. addslashes(stripslashes($_POST['e_address'])) .'", poster_telephone = "'. addslashes(stripslashes($_POST['e_telephone'])) .'", poster_email = "'. addslashes(stripslashes($_POST['e_email'])) .'", poster_author_type = '. intval($_POST['e_author_type']) .', poster_status = '. intval($_POST['e_status']) .' WHERE poster_id = ' . $_id; $result = $dbconn->Execute($sql); echo ''; exit(); } else { $_id = intval($_POST['poster_id']); $_POST['e_status'] = intval($_POST['e_status']); $error = false; switch ($_POST['e_status']) { case 1: $error = check_upload_error('preview'); if ($error!=false) { $_error[] = 'e_text_uploaddesc'; } else { $_preview = ROOT_PATH . 'i/p/' . $_id; move_uploaded_file( $_FILES['preview']['tmp_name'], $_preview ); $_file = $_FILES['preview']['name']; if (file_exists($_preview)) { chmod($_preview ,0777); exec( 'convert -size 300x293 '. $_preview . ' -thumbnail 300x293 ' . $_preview . '_300' ); exec( 'convert -size 88x86 '. $_preview . ' -thumbnail 88x86 ' . $_preview . '_88' ); } } $_mailtext = $_assign['e_mail_text_approve']; break; case 3: $_mailtext = $_assign['e_mail_text_decline']; break; } if ($error==false) { $sql = 'UPDATE im_posters SET poster_firstname = "'. addslashes(stripslashes($_POST['e_firstname'])) .'", poster_lastname = "'. addslashes(stripslashes($_POST['e_lastname'])) .'", poster_country = "'. addslashes(stripslashes($_POST['e_country'])) .'", poster_city = "'. addslashes(stripslashes($_POST['e_city'])) .'", poster_url = "'. addslashes(stripslashes($_POST['e_url'])) .'", poster_desc = "'. addslashes(stripslashes($_POST['e_desc'])) .'", poster_author_type = '. intval($_POST['e_author_type']) .', poster_status = '. intval($_POST['e_status']) .' WHERE poster_id = ' . $_id; $result = $dbconn->Execute($sql); $sql = 'SELECT * FROM im_posters WHERE poster_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { die('No poster'); } else { $row = $result->GetRowAssoc(false); } mail( $row['poster_email'], '=?UTF-8?B?'.base64_encode( 'Your artwork on SweetContent.ru' ).'?=', str_replace( array( '{username}', '{decline}', '{url}', "\r\n", "\r", ), array( $row['poster_firstname'].' '.$row['poster_lastname'], $_POST['e_decline'], 'http://sweetcontent.ru/poster/'.$row['poster_id'].'/'.$row['poster_firstname'].$row['poster_lastname'].'/', "\n", "\n", ),$_mailtext), implode("\n",$headers) ); echo ''; } else { echo ''; } exit(); } break; case 'partner': $_id = intval($_POST['partner_id']); if (isset($_POST['e_delete']) && $_POST['e_delete']==1) { $sql = 'DELETE FROM im_partners WHERE partner_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die('Databse error'); echo ''; exit(); } if ($_id==0) { upload_image('e_logo','/i/l/999'); upload_image('e_gray','/i/l/999_g'); } $sql = ( ($_id==0) ? ' INSERT INTO im_partners SET ' : ' UPDATE im_partners SET ' ) . ' partner_url = "'. addslashes(stripslashes($_POST['e_url'])) .'", partner_text_en = "'. addslashes(stripslashes($_POST['e_text_en'])) .'", partner_text_ru = "'. addslashes(stripslashes($_POST['e_text_ru'])) .'" ' . ( ($_id==0) ? '' : ' WHERE partner_id = ' . $_id ); $result = $dbconn->Execute($sql); if ($_id==0) { $_id = $dbconn->_insertid(); rename(ROOT_PATH . 'i/l/999', ROOT_PATH . 'i/l/' . $_id); rename(ROOT_PATH . 'i/l/999_g', ROOT_PATH . 'i/l/' . $_id.'_g'); } echo ''; exit(); break; */ case 'text': default: $sql = 'UPDATE im_texts SET text_'. $_POST['e_lang'] .' = "'. addslashes(stripslashes($_POST['e_text'])) .'" WHERE text_id = "'. $_POST['e_save'] .'"'; $result = $dbconn->Execute($sql); echo "ok"; exit(); break; } else { echo ''; exit(); } } if ( isset($_POST['e_edit']) ) { if ( ( $session->user_id ) && ( ($user->is_admin) || ( ($user->is_moderator) && ($_form=='blog') ) ) ) switch ($_form) { case 'banners': $_page = parse_url($_SERVER['HTTP_REFERER']); if ($_page==false) exit(); $_page['path'] = str_replace('/en/','/',$_page['path']); if ( (strpos($_page['path'],'/work/brands/')===0) && ($_page['path']!='/work/brands/') ) $_page['path'] = 'brand'; elseif ( (strpos($_page['path'],'/work/')===0) && ($_page['path']!='/work/') ) $_page['path'] = '/work/category/'; $_sliders = $_sliders_selected = array(); $sql = 'SELECT * FROM im_sliders_pages WHERE page_url = "' . addslashes(stripslashes($_page['path'])) . '" ORDER BY sp_position'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_sliders[$row['slider_id']] = false; $_sliders_selected[$row['slider_id']] = true; } $sql = 'SELECT * FROM im_sliders WHERE slider_type=0 ORDER BY slider_type, slider_id'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_sliders[$row['slider_id']] = $row; } foreach ($_sliders as $row) { if ($row===false) continue; $template->assign_block_vars('slider' . (isset($_sliders_selected[$row['slider_id']]) ? '_selected' : '') ,array_merge($row,array( 'slider_date' => date('d.m.Y',strtotime($row['slider_date'])), ))); } $template->assign_vars(array( 'e_save' => 'banners|'.$_page['path'], )); break; case 'sliders': $_id = intval(str_replace('e_sliders_','',$_POST['e_edit'])); if ($_id==0) exit(); $sql = 'SELECT * FROM im_sliders_pages sp, im_sliders s WHERE sp.slider_id = s.slider_id AND page_url = "project|' . $_id . '" ORDER BY sp_position'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('slider' ,array_merge($row,array( 'slider_date' => date('d.m.Y',strtotime($row['slider_date'])), ))); } $template->assign_vars(array( 'e_save' => 'e_sliders|'.$_id, )); break; case 'image': switch ($_savetype) { case '/i/slider/slider_': $_form_title = 'Добавление банера'; $_form_help = 'Изображение должно быть в формате png и иметь линейные размеры 700*301'; break; default: $_form_title = 'Редактирование изображения ' . $_savetype.''; $_form_help = ''; break; } if ( ( (strpos($_savetype,'/i/slider/slider_')===0) && strpos($_savetype,'.png')!=false ) || (strpos($_savetype,'/i/projects/project_')===0) ) { $template->assign_block_vars('delete',array()); } $template->assign_vars(array( 'text_id' => $_savetype, 'form_title' => $_form_title, 'form_help' => $_form_help, )); break; case 'slider': $_id = intval(str_replace('e_slider_','',$_POST['e_edit'])); if ($_id==0) exit(); $template->assign_vars(array( 'project_id' => $_id, 'preview' => file_exists( ROOT_PATH . '/i/projects/thumb_' . $_id . '.jpg' ) ? 'уже загружено' : 'отсутствует', 'teaser' => file_exists( ROOT_PATH . '/i/projects/teaser_' . $_id . '.jpg' ) ? 'уже загружено' : 'отсутствует', )); break; case 'news': $_id = intval(str_replace('e_news_','',$_POST['e_edit'])); if ($_id!=0) { $sql = 'SELECT * FROM im_events WHERE event_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $row = array('event_id' => 0, 'event_date' => date('Y-m-d') ); } else { $row = $result->GetRowAssoc(false); $template->assign_block_vars('delete',array()); } } else $row = array('event_id' => 0, 'event_date' => date('Y-m-d') ); if ($row['event_id'] == 0) { $template->assign_block_vars('preview_image',array()); } else { $row['event_name_ru'] = str_replace('"','"',$row['event_name_ru']); $row['event_name_en'] = str_replace('"','"',$row['event_name_en']); } $row['event_date'] = date('d.m.Y',strtotime($row['event_date'])); $template->assign_vars($row); $template->assign_vars(array( 'form_title' => ( ($row['event_id']==0) ? 'Добавление' : 'Редактирование' ) . ' события', )); break; case 'brand': $_id = intval(str_replace('e_brand_','',$_POST['e_edit'])); if ($_id!=0) { $sql = 'SELECT * FROM im_brands WHERE brand_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $row['blog_id'] = 0; } else { $row = $result->GetRowAssoc(false); $template->assign_block_vars('delete',array()); } } else $row = array('brand_id' => 0, 'brand_url' => 'http://'); $template->assign_vars($row); $template->assign_vars(array( 'form_title' => ( ($row['brand_id']==0) ? 'Добавление' : 'Редактирование' ) . ' бренда', )); break; case 'project': case 'quote': $_id = intval(str_replace('e_'.$_form.'_','',$_POST['e_edit'])); if ($_id!=0) { $sql = 'SELECT * FROM im_projects WHERE project_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $row = array('project_id' => 0, 'brand_id' => 0, 'project_top' => 0, 'project_date' => date('Y-m-d')); } else { $row = $result->GetRowAssoc(false); $template->assign_block_vars('delete',array()); } } else { $row = array('project_id' => 0, 'brand_id' => 0, 'project_top' => 0, 'project_date' => date('Y-m-d')); if (strpos($_SERVER['HTTP_REFERER'],'/work/brands/')!==false) { list(,$row['brand_id']) = explode('/work/brands/',$_SERVER['HTTP_REFERER']); list($row['brand_id']) = explode('/',$row['brand_id']); list($row['brand_id']) = explode('-',$row['brand_id']); $row['brand_id'] = intval($row['brand_id']); } } $row['project_date'] = date('d.m.Y',strtotime($row['project_date'])); $row['project_name_ru'] = str_replace('"','"',$row['project_name_ru']); $row['project_name_en'] = str_replace('"','"',$row['project_name_en']); $template->assign_vars($row); $sql = 'SELECT *, brand_name_'.$_current_lang.' as brand_name, brand_description_'.$_current_lang.' as brand_description FROM im_brands ORDER BY brand_name'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $brand = $result->GetRowAssoc(false); $template->assign_block_vars('brand',array_merge($brand,array( 'brand_selected' => ($brand['brand_id']==$row['brand_id']) ? 'selected="selected"' : '', ))); } $template->assign_vars(array( 'form_title' => ( ($row['project_id']==0) ? 'Добавление' : 'Редактирование' ) . ( ($_form=='project') ? ' проекта' : ' цитаты' ) , 'project_top_checked' => ($row['project_top']==1) ? 'checked="checked"' : '', )); break; case 'category': $_id = intval(str_replace('e_category_','',$_POST['e_edit'])); if ($_id==0) exit(); $_project_categories = array(); $sql = 'SELECT * FROM im_projects_categories WHERE project_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_project_categories[$row['category_id']] = true; } foreach ($_site_categories as $_category_id => $_category_name) { $template->assign_block_vars('category',array( 'category_id' => $_category_id, 'category_name' => isset($_assign['e_menu_work_'.$_category_name]) ? $_assign['e_menu_work_'.$_category_name] : 'No text ('. $_category_name .')', 'category_checked' => (isset($_project_categories[$_category_id])) ? 'checked="checked"' : '', )); } $_assign['project_id'] = $_id; $template->assign_vars($_assign); break; /* case 'blog': $_id = intval(str_replace('e_blog_','',$_POST['e_edit'])); $sql = 'SELECT * FROM im_blogs WHERE blog_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $row['blog_id'] = 0; } else { $row = $result->GetRowAssoc(false); } if ($row['blog_id']!=0) $template->assign_block_vars('delete',array()); $template->assign_vars($row); $template->assign_vars(array( 'text_id' => $_savetype, 'form_title' => 'ЗАПИСЬ В БЛОГЕ', )); break; */ case 'user': $_id = intval(str_replace('e_user_','',$_POST['e_edit'])); $sql = 'SELECT * FROM fw_users WHERE user_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $_form = 'reg'; } else { $row = $result->GetRowAssoc(false); $row['user_level_' . $row['user_level']] = 'selected'; $template->assign_vars($row); $template->assign_block_vars('delete',array()); } $template->assign_vars(array( 'text_id' => $_savetype, 'form_title' => 'Пользователь', )); break; /* case 'poster': $_id = intval(str_replace(array('e_poster_','e_moderate_'),'',$_POST['e_edit'])); $sql = 'SELECT * FROM im_posters WHERE poster_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { die('No poster found'); } else { $row = $result->GetRowAssoc(false); $row['poster_status_' . $row['poster_status']] = 'selected'; $row['poster_author_type_' . $row['poster_author_type']] = 'selected'; } $template->assign_vars($row); $template->assign_vars(array( 'text_id' => $_savetype, 'form_title' => 'РЕДАКТИРОВАНИЕ ПОСТЕРА', )); if (strpos($_savetype,'e_moderate') === 0) { $template->assign_block_vars( ( ($row['poster_userpic']==1) ? '' : 'no' ) . 'userpic',array()); if ($row['poster_type']==1) { $template->assign_block_vars( 'type1',array('size'=>round(filesize( ROOT_PATH . '_i/source_' . $row['poster_id'])/1024/10.24)/100)); } elseif ($row['poster_type']==2) { $template->assign_block_vars( 'type2',array()); } $_form = 'moderate'; } break; */ case 'partner': $_id = intval(str_replace('e_partner_','',$_POST['e_edit'])); $sql = 'SELECT * FROM im_partners WHERE partner_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $template->assign_block_vars('add',array()); } else { $row = $result->GetRowAssoc(false); $template->assign_vars($row); $template->assign_block_vars('delete',array()); } $template->assign_vars(array( 'text_id' => $_savetype, 'form_title' => 'ПАРТНЕР', )); break; case 'text': default: $sql = 'SELECT text_'. $_POST['e_lang'] .' as text FROM im_texts WHERE text_id = "'. $_POST['e_edit'] .'"'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { $sql = 'INSERT INTO im_texts SET text_id = "'. $_POST['e_edit'] .'"'; $result = $dbconn->Execute($sql); $row['text'] = ''; } else { $row = $result->GetRowAssoc(false); } $template->assign_vars(array( 'lang' => $_current_lang, 'text' => $row['text'], 'text_id' => $_savetype, 'form_title' => 'Редактирование ' .$_savetype.'_'.$_POST['e_lang'].'', 'height' => $_height )); break; } else { $_form = 'deny'; } $template->set_filenames(array('body'=>'edit.'.$_form.'.tpl')); $template->allparse(); } } if (isset($_POST['upload']) && is_array($_POST['upload']) ) { /* $_upload_type = intval($_POST['upload']['upload_type']); if ( ($_upload_type==3) && ($session->user_id==false) ) { $_error[] = 'e_text_uploaddesc'; } if (!sizeof($_error)) { $sql = 'INSERT INTO im_posters SET poster_status = -1'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $_id = $dbconn->_insertid(); } $_file = false; $_userpic = false; $error = check_upload_error('userpic'); if ($error!=false) { // $_error[] = 'e_deim_userpic'; } else { $_userpic = ROOT_PATH . 'i/u/a_' . $_id; move_uploaded_file($_FILES['userpic']['tmp_name'],$_userpic ); chmod($_userpic,0777); if (!file_exists($_userpic)) $_userpic = false; } if (!sizeof($_error)) switch ($_upload_type) { case 1: $error = check_upload_error('work'); if ($error!=false) { $_error[] = 'e_text_uploaddesc'; } else { move_uploaded_file($_FILES['work']['tmp_name'], ROOT_PATH . '_i/source_' . $_id); $_file = $_FILES['work']['name']; chmod( ROOT_PATH . '_i/source_' . $_id,0777); } break; case 2: $_file = $_POST['upload']['link']; break; case 3: $error = check_upload_error('preview'); if ($error!=false) { $_error[] = 'e_text_uploaddesc'; } else { $_preview = ROOT_PATH . 'i/p/' . $_id; move_uploaded_file( $_FILES['preview']['tmp_name'], $_preview ); $_file = $_FILES['preview']['name']; if (file_exists($_preview)) { chmod($_preview ,0777); exec( 'convert -size 300x293 '. $_preview . ' -thumbnail 300x293 ' . $_preview . '_300' ); exec( 'convert -size 88x86 '. $_preview . ' -thumbnail 88x86 ' . $_preview . '_88' ); } } break; } if ($_userpic!=false) { exec( 'convert -size 120x120 '. $_userpic . ' -thumbnail 120x120 ' . $_userpic . '_120' ); } if (sizeof($_error)==0) { $_set = array(); foreach (array( 'filename', 'firstname', 'lastname', 'country', 'city', 'address', 'telephone', 'url', 'email', 'desc', ) as $_field) { if (isset($_POST['upload'][$_field])) $_set[] = 'poster_'.$_field.' = "' . addslashes(stripslashes($_POST['upload'][$_field])) . '"'; } $sql = 'UPDATE im_posters SET poster_status = '. ( ($_upload_type==3) ? 1 : 0 ) .', poster_author_type = '. ( ($_upload_type==3) ? 1 : 0 ) .', poster_type = '. $_upload_type .', poster_filename = "'. addslashes($_file) .'", poster_userpic = '. ($_userpic ? 1 : 0) .', poster_date = NOW() '. ( sizeof($_set) ? ',' . implode(', ',$_set) : '' ) . ' WHERE poster_id = ' . $_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); foreach (array('merlinni@sweetcontent.ru','tobe@ya.ru') as $_email) mail( $_email, '=?UTF-8?B?'.base64_encode( 'New artwork on SweetContent.ru' ).'?=', str_replace( array( "\r\n", "\r", ), array( "\n", "\n", ),$_assign['e_mail_newartwork']), implode("\n",$headers) ); } else { // $sql = 'DELETE FROM ' // $result = $dbconn->Execute($sql); // if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); } // $_error = array('0'); if (sizeof($_error)) { foreach ($_POST['upload'] as $_key => $_value) { $_assign['upload_'.$_key] = $_value; } } else { $_success = true; $_assign['e_text_joinsuccess'] = str_replace(array( '{firstname}', '{lastname}', ),array( $_POST['upload']['firstname'], $_POST['upload']['lastname'] ),$_assign['e_text_joinsuccess']); } */ } if (strpos($r,'/posters/')===0) { /* $_order = explode('/',$r); $_page = (isset($_order[3])) ? intval($_order[3]) : 1; $_page = ($_page < 1) ? 1 : $_page; $_order = (isset($_order[2])) ? $_order[2] : ''; $_per_page = 8; switch ($_order) { case 'by-votes': case 'by-date': case 'by-views': case 'by-comments': break; default: $_order = 'by-date'; break; } $_assign['s_menu_' . str_replace('by-','',$_order)] = ' class="current"'; $_assign['style_' . str_replace('by-','',$_order)] = ' class="b"'; $r = '/posters/'; */ } elseif (strpos($r,'/poster/')===0) { $_poster_id = explode('/',$r); $_poster_id = intval((isset($_poster_id[2])) ? $_poster_id[2] : 0); $r = '/poster/'; } /* if (!$user->is_admin) { header('HTTP/1.1 404 Not Found'); exit(); } */ $_current_category = 0; if ((strpos($r,'/work/brands/')===0) && ($r!='/work/brands/')) { list(,$o) = explode('/work/brands/',$r); list($o) = explode('/',$o); list($o) = explode('-',$o); $o = intval($o); if ($o!=0) $r = 'brand'; } elseif ((strpos($r,'/work/')===0) && ($r!='/work/')) { list(,$o) = explode('/work/',$r); list($o) = explode('/',$o); list($o) = explode('-',$o); $_check_category = array_flip($_site_categories); if (isset($_check_category[$o])) { $_current_category = $_check_category[$o]; $r = '/work/category/'; } else { $o = intval($o); if ($o!=0) $r = 'project'; } } switch ($r) { case '/texts/': if (!$user->is_admin) { header('HTTP/1.1 404 Not Found'); exit(); } $sql = 'SELECT * FROM im_texts WHERE text_id LIKE "e_%" ORDER BY text_id'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $row['text'] = $_assign[$row['text_id']]; $template->assign_block_vars('texts',$row); } $_assign['title'] = 'Text editor'; $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'admin.texts.tpl','footer'=>'usr.footer.tpl')); break; case '/config/': case '/files/': if (!$user->is_admin) { header('HTTP/1.1 404 Not Found'); exit(); } if (isset($_POST['config'])) { $_update = array(); foreach ($_POST['config'] as $_key => $_value) { $_value = ( strpos($_key,'int') != false ) ? intval($_value) : trim(addslashes(stripslashes($_value))); $_key = trim(addslashes(stripslashes($_key))); $sql = 'DELETE FROM im_texts WHERE text_id = "'. $_key .'"'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $sql = 'INSERT INTO im_texts (text_id,text_en,text_ru) VALUES( "'. $_key .'", "'. $_value .'", "'. $_value .'")'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); } } $sql = 'SELECT * FROM im_texts WHERE text_id LIKE "config%"'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_assign[$row['text_id']] = $row['text_en']; $_assign[$row['text_id'].'_'.$row['text_en']] = 'selected="selected"'; } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'admin.config.tpl','footer'=>'usr.footer.tpl')); break; case '/banners/': if (!$user->is_admin) { header('HTTP/1.1 404 Not Found'); exit(); } $_sliders = array(); $sql = 'SELECT * FROM im_sliders WHERE slider_type=0 ORDER BY slider_type, slider_id'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_sliders[$row['slider_id']] = array_merge($row,array( 'slider_date' => date('d.m.Y',strtotime($row['slider_date'])), 'slider_use' => 0, )); } $sql = 'SELECT * FROM im_sliders_pages'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); if (isset($_sliders[$row['slider_id']])) $_sliders[$row['slider_id']]['slider_use']++; } foreach ($_sliders as $row) { $template->assign_block_vars('slider',array_merge($row,array( 'slider_use' => ($row['slider_use']==0) ? 'не иcпользуется' : ' на ' . $row['slider_use'] . ' ' . say($row['slider_use'],'странице','страницах','страницах'), ))); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'admin.banners.tpl','footer'=>'usr.footer.tpl')); break; case '/posters/': /* $sql = 'SELECT COUNT(*) as cnt FROM im_posters WHERE poster_status = 1'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $row = $result->GetRowAssoc(false); if ( ($_page-1) * $_per_page > $row['cnt']) { header('Location: /'. $_assign['lang'] .'posters/'); exit(); } $_assign['pagination'] = pagination( '/' . $_assign['lang'] . 'posters/'.$_order.'/{page}/',$_page,$row['cnt'],$_per_page); $sql = 'SELECT * FROM im_posters WHERE poster_status = 1 ORDER BY '.str_replace('by-','poster_',$_order).' DESC LIMIT ' . ( ($_page-1) * $_per_page) . ', ' .$_per_page ; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $row['poster_date'] = date(($_current_lang=='ru') ? 'd/m/y' : 'm/d/y',strtotime($row['poster_date'])); $row['poster_color'] = ($row['poster_author_type']==1) ? 'g' : 'w'; $template->assign_block_vars('posters',$row); } $_assign['s_menu_posters'] = ' class="current"'; $_assign['title'] = ucwords(strtolower($_assign['e_menu_posters'])) . ' »'; $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'posters.tpl','footer'=>'usr.footer.tpl')); */ break; case '/poster/': /* $sql = 'SELECT * FROM im_posters WHERE poster_id = ' . $_poster_id . ' AND poster_status = 1'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { header('Location: /'. $_assign['lang'] .'posters/'); exit(); } $row = $result->GetRowAssoc(false); $row['poster_date'] = date(($_current_lang=='ru') ? 'd/m/y' : 'm/d/y',strtotime($row['poster_date'])); $template->assign_vars($row); $_assign['s_menu_posters'] = ' class="second"'; $_assign['title'] = ucwords(strtolower($row['poster_firstname'] . ' ' . $row['poster_lastname'] )) . ' » ' . ucwords(strtolower($_assign['e_menu_posters'])) . ' »'; $template->assign_block_vars('meta_description',array('content'=>str_replace('"','"',$row['poster_desc']))); $template->assign_block_vars('meta_image',array('content'=>'http://sweetcontent.ru/i/p/'.$row['poster_id'])); $sql = 'SELECT * FROM im_votes WHERE user_ip = "'. $_SERVER['REMOTE_ADDR'] .'" AND poster_id = ' . $_poster_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) $template->assign_block_vars('like',array()); $sql = 'UPDATE im_posters SET poster_views = poster_views+1 WHERE poster_id = ' . $_poster_id; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); $sql = 'SELECT * FROM im_posters WHERE poster_status = 1 AND poster_id !='. $_poster_id .' ORDER BY RAND() LIMIT 3'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_selected[] = $row['poster_id']; $template->assign_block_vars('posters',$row); } $sql = 'SELECT * FROM im_comments WHERE poster_id = ' . $_poster_id . ' AND comment_show!=2 ORDER BY comment_date '; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if (!$result->EOF) $template->assign_block_vars('hascomments',array()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $row['comment_date'] = date(($_current_lang=='ru') ? 'd/m/y' : 'm/d/y',strtotime($row['comment_date'])); $template->assign_block_vars('comments',$row); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'poster.tpl','footer'=>'usr.footer.tpl')); */ break; case '/join/success/': case '/join/': $_assign['s_menu_join'] = ' class="current"'; $_assign['title'] = ucwords(strtolower($_assign['e_menu_join'])) . ' »'; $template->assign_block_vars(($_success) ? 'success' : 'join',array()); if (!$_success && sizeof($_error)) { foreach ($_error as $id) $template->assign_block_vars('join.error',array('id'=>$id)); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'join.tpl','footer'=>'usr.footer.tpl')); break; case '/agency/': echo_banners($r); $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'agency.tpl','footer'=>'usr.footer.tpl')); break; case '/agency/news/': echo_banners($r); $sql = 'SELECT *, event_name_'.$_current_lang.' as event_name, event_text_'.$_current_lang.' as event_text FROM im_events WHERE 1 ORDER BY event_date DESC, event_id ASC LIMIT 5'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('event',array_merge($row,array( 'event_date' => $_assign['z_month_' . date('m',strtotime($row['event_date']))] . ' ' . date('Y',strtotime($row['event_date'])), ))); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'news.tpl','footer'=>'usr.footer.tpl')); break; case '/agency/carriers/': echo_banners($r); $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'carriers.tpl','footer'=>'usr.footer.tpl')); break; case '/services/': echo_banners($r); $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'services.tpl','footer'=>'usr.footer.tpl')); break; case '/contacts/': $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'contacts.tpl','footer'=>'usr.footer.tpl')); break; case 'brand': echo_banners($r); $sql = 'SELECT *, brand_name_'.$_current_lang.' as brand_name, brand_description_'.$_current_lang.' as brand_description FROM im_brands WHERE brand_id = ' . $o; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { header('HTTP/1.1 404 Not Found'); exit(); } $row = $result->GetRowAssoc(false); $_current_url = '/' . $_assign['lang'] . 'work/brands/' . $row['brand_id'] . '-' . translit(strip_tags($row['brand_name'])) . '.html'; if ($_SERVER['REQUEST_URI']!=$_current_url) { header('Location: ' . $_current_url); exit(); } $template->assign_vars($row); $_projects = array(); $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text FROM im_projects WHERE brand_id = '. $o .' ORDER BY project_date'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('project',array_merge($row,array( 'project_image' => file_exists( ROOT_PATH . '/i/projects/thumb_' . $row['project_id'] . '.jpg' ) ? '/i/projects/thumb_' . $row['project_id'] . '.jpg' : '/i/none.gif', 'project_date' => $_assign['z_month_' . date('m',strtotime($row['project_date']))] . ' ' . date('Y',strtotime($row['project_date'])), 'project_link' => '/' . $_assign['lang'] . 'work/' . $row['project_id'] . '-' . translit(strip_tags($row['project_name'])) . '.html', ))); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'brand.tpl','footer'=>'usr.footer.tpl')); break; case 'project': echo_banners('project|'.$o); $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text, project_context_'.$_current_lang.' as project_context, project_task_'.$_current_lang.' as project_task, project_solution_'.$_current_lang.' as project_solution, project_quote_'.$_current_lang.' as project_quote, project_author_'.$_current_lang.' as project_author, brand_name_'.$_current_lang.' as brand_name, brand_description_'.$_current_lang.' as brand_description, brand_industry_'.$_current_lang.' as brand_industry FROM im_brands b, im_projects p WHERE project_id = ' . $o . ' AND p.brand_id = b.brand_id '; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); if ($result->EOF) { header('HTTP/1.1 404 Not Found'); exit(); } $row = $result->GetRowAssoc(false); $_current_url = '/' . $_assign['lang'] . 'work/' . $row['project_id'] . '-' . translit(strip_tags($row['project_name'])) . '.html'; if ($_SERVER['REQUEST_URI']!=$_current_url) { header('Location: ' . $_current_url); exit(); } $row = array_merge($row,array( 'project_name' => strip_tags($row['project_name']), 'brand_link' => '/' . $_assign['lang'] . 'work/brands/' . $row['brand_id'] . '-' . translit(strip_tags($row['brand_name'])) . '.html', 'brand_url_show' => str_replace('http://','',$row['brand_url']), )); $template->assign_vars($row); foreach (array( 'brand_url', 'brand_description', 'project_context', 'project_task', 'project_solution', 'project_quote', 'project_author', ) as $_text_type) { if ($row[$_text_type]!='' && $row[$_text_type]!='http://') $template->assign_block_vars('show_'.$_text_type,array()); } $_categories = array(); $sql = 'SELECT * FROM im_projects_categories WHERE project_id = ' . $row['project_id']; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_categories[$row['category_id']] = TRUE; } if (sizeof($_categories)) { $template->assign_block_vars('categories',array()); foreach ($_site_categories as $_category_id => $_category_name) { if (isset($_categories[$_category_id])) $template->assign_block_vars('categories.category',array( 'category_name' => $_category_name, 'category_title' => isset($_assign['e_menu_work_'.$_category_name]) ? $_assign['e_menu_work_'.$_category_name] : '', )); } } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'project.tpl','footer'=>'usr.footer.tpl')); break; case '/work/category/': if (!isset($_current_category) || ($_current_category==0) || !isset($_site_categories[$_current_category]) ) { header('HTTP/1.1 404 Not Found'); exit(); } $_assign['category_name'] = $_assign['e_menu_work_' . $_site_categories[$_current_category]]; case '/work/': echo_banners($r); $_projects = array(); if ($r=='/work/') { $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text, brand_name_'.$_current_lang.' as brand_name FROM im_projects p, im_brands b WHERE p.brand_id = b.brand_id ORDER BY project_date DESC, project_id ASC LIMIT 30'; } else { $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text, brand_name_'.$_current_lang.' as brand_name FROM im_projects p, im_brands b, im_projects_categories pc WHERE p.brand_id = b.brand_id AND pc.project_id = p.project_id AND pc.category_id = '. $_current_category .' ORDER BY project_date DESC, p.project_id ASC'; } $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('project',array_merge($row,array( 'project_date' => $_assign['z_month_' . date('m',strtotime($row['project_date']))] . ' ' . date('Y',strtotime($row['project_date'])), 'project_link' => '/' . $_assign['lang'] . 'work/' . $row['project_id'] . '-' . translit(strip_tags($row['project_name'])) . '.html', 'project_image' => file_exists( ROOT_PATH . '/i/projects/thumb_' . $row['project_id'] . '.jpg' ) ? '/i/projects/thumb_' . $row['project_id'] . '.jpg' : '/i/none.gif', ))); } $template->assign_block_vars( ($r=='/work/') ? 'work' : 'category' , array() ); $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'work.tpl','footer'=>'usr.footer.tpl')); break; case '/work/brands/': echo_banners($r); $sql = 'SELECT *, brand_name_'.$_current_lang.' as brand_name, brand_description_'.$_current_lang.' as brand_description FROM im_brands ORDER BY brand_name'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('brand',array_merge($row,array( 'brand_link' => '/' . $_assign['lang'] . 'work/brands/' . $row['brand_id'] . '-' . translit(strip_tags($row['brand_name'])) . '.html', ))); } $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'brands.tpl','footer'=>'usr.footer.tpl')); break; /* case '/contacts/': $sql = 'SELECT * FROM fw_users WHERE user_active=1 ORDER BY username'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); list($row['name']) = explode(' ',$row['username']); $row['userpic'] = ($row['user_userpic_default']) ? 'http://u.poloski.ru/' . $row['user_userpic_default'] : '/i/userpic.png'; $template->assign_block_vars('users',$row); } $_assign['title'] = $_assign['e_menu_contacts']; $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'contacts.tpl','footer'=>'usr.footer.tpl')); break; */ default: if ($r!='/') { header('Location: /'); exit(); } $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text FROM im_projects WHERE project_top = 1 ORDER BY project_date DESC, project_id ASC'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); if (!file_exists( ROOT_PATH . '/i/projects/teaser_' . $row['project_id'] . '.jpg' )) continue; $template->assign_block_vars('project',array_merge($row,array( 'project_date' => $_assign['z_month_' . date('m',strtotime($row['project_date']))] . ' ' . date('Y',strtotime($row['project_date'])), 'project_link' => '/' . $_assign['lang'] . 'work/' . $row['project_id'] . '-' . translit(strip_tags($row['project_name'])) . '.html', 'project_image' => '/i/projects/teaser_' . $row['project_id'] . '.jpg', ))); } $sql = 'SELECT *, event_name_'.$_current_lang.' as event_name, event_text_'.$_current_lang.' as event_text FROM im_events WHERE 1 ORDER BY event_date DESC, event_id ASC LIMIT ' . $_assign['config_int_events_count']; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $template->assign_block_vars('event',array_merge($row,array( 'event_date' => $_assign['z_month_' . date('m',strtotime($row['event_date']))] . ' ' . date('Y',strtotime($row['event_date'])), ))); } $_project_count = 0; $sql = 'SELECT *, project_name_'.$_current_lang.' as project_name, project_text_'.$_current_lang.' as project_text FROM im_projects WHERE project_top = 0 ORDER BY project_date DESC, project_id ASC LIMIT 30'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); if (!file_exists( ROOT_PATH . '/i/projects/thumb_' . $row['project_id'] . '.jpg' )) continue; $template->assign_block_vars('newproject',array_merge($row,array( 'project_date' => $_assign['z_month_' . date('m',strtotime($row['project_date']))] . ' ' . date('Y',strtotime($row['project_date'])), 'project_link' => '/' . $_assign['lang'] . 'work/' . $row['project_id'] . '-' . translit(strip_tags($row['project_name'])) . '.html', 'project_image' => '/i/projects/thumb_' . $row['project_id'] . '.jpg', ))); if ( ($_project_count++) >= ($_assign['config_int_newprojects_count']-1) ) break; } $_selected = array(); $_assign['title'] = ''; $template->set_filenames(array('header'=>'usr.header.tpl','body'=>'index.tpl','footer'=>'usr.footer.tpl')); break; } if ($session->user_id) { if ($user->is_moderator || $user->is_admin) $template->assign_block_vars('editor',array()); if ( ($r=='/join/') && ($user->is_admin)) $template->assign_block_vars( ( ($_success) ? 'success' : 'join') . '.admin',array()); if ($user->is_admin) { } } $_categories_count = array(); $sql = 'SELECT category_id, COUNT(*) as cnt FROM im_projects p, im_projects_categories pc WHERE p.project_id = pc.project_id GROUP BY pc.category_id'; $result = $dbconn->Execute($sql); if ($result === false) die("Unable to read object property.
".$dbconn->ErrorMsg()); for(;!$result->EOF;$result->MoveNext() ) { $row = $result->GetRowAssoc(false); $_categories_count[$row['category_id']] = $row['cnt']; } $_assign[str_replace('/','',$r).'_class'] = 'class="active"'; $_temp_active = explode('/',$r); if (isset($_temp_active[1])) $_assign[$_temp_active[1].'_fclass'] = 'class="active"'; foreach ($_site_categories as $_category_id => $_category_name) { if (!isset($_categories_count[$_category_id])) continue; $template->assign_block_vars('menu',array( 'menu_name' => $_category_name, 'menu_title' => isset($_assign['e_menu_work_'.$_category_name]) ? $_assign['e_menu_work_'.$_category_name] : '', 'menu_class' => ( isset($_current_category) && ($_current_category==$_category_id) ) ? 'class="active"' : '', )); } $_assign['config_int_opacity1'] = $_assign['config_int_opacity']/100; $template->assign_vars($_assign); $template->allparse(); ?>