예제 #1
0
파일: index.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $ou = SJB_UserManager::getOnlineUsers();
     $onlineUsers = array();
     $totalOnlineUsers = 0;
     $userGroups = SJB_UserGroupManager::createTemplateStructureForUserGroups();
     foreach ($userGroups as $userGroup) {
         $onlineUsers[$userGroup["id"]]["count"] = 0;
         $onlineUsers[$userGroup["id"]]["caption"] = $userGroup["caption"];
     }
     foreach ($ou as $value) {
         $onlineUsers[$value["type"]]["count"]++;
         $totalOnlineUsers++;
     }
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme);
     // FLAGGED LISTINGS
     $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $totalFlagsNum = array();
     foreach ($allListingTypes as $type) {
         $totalFlagsNum[$type['id']] = SJB_ListingManager::getFlagsNumberByListingTypeSID($type['sid'], $filter = null, $groupByListingSID = true);
     }
     $files = $this->getCssFiles($themePath);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('totalFlagsNum', $totalFlagsNum);
     $tp->assign('usersInfo', SJB_UserManager::getUsersInfo());
     $tp->assign('groupsInfo', SJB_UserManager::getGroupsInfo());
     $tp->assign('listingsInfo', SJB_ListingManager::getListingsInfo());
     $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo());
     $tp->assign('invoicesInfo', SJB_InvoiceManager::getInvoicesInfo());
     $tp->assign('unpaidInvoices', SJB_InvoiceManager::getTotalUnpaidInvoices());
     $tp->assign('totalInvoices', SJB_InvoiceManager::getTotalInvoices());
     $i18n = SJB_I18N::getInstance();
     $lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
     $tp->assign("today", strftime($lang['date_format'], time()));
     // ранее были данные за период: месяц (последние 30 дней), неделя (последние 7 дней)
     // теперь - текущий месяц и текущая неделя
     $currMonth = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), 1, date("Y")));
     $currWeek = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), date("d") - date("N") + 1, date("Y")));
     $tp->assign("weekAgo", $currWeek);
     $tp->assign("monthAgo", $currMonth);
     $tp->assign('onlineUsers', $onlineUsers);
     $tp->assign('totalOnlineUsers', $totalOnlineUsers);
     if (count($files) > 0) {
         $tp->assign("file", $files[0]);
     }
     $tp->display("index.tpl");
 }
예제 #2
0
 /**
  * @param $listingSID
  * @return mixed
  * @throws Exception
  */
 public function postListing($listingSID)
 {
     $listing = SJB_ListingManager::getObjectBySID($listingSID);
     if (!$listing instanceof SJB_Listing) {
         $params = array($listingSID);
         $message = 'Listing #$param_0 does not exist in system';
         throw new SJB_FeedException($message, $params);
     }
     $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing);
     $listingUrl = SJB_ListingManager::getListingUrlBySID($listingSID);
     $link = " {$listingUrl} {$this->feedInfo['hash_tags']}";
     $userInfo = SJB_Array::get($listingInfo, 'user');
     $this->tp->assign('post_template', $this->feedInfo['post_template']);
     $this->tp->assign('listing', $listingInfo);
     $this->tp->assign('user', $userInfo);
     $text = $this->tp->fetch($this->template);
     $picture = $userInfo['Logo']['file_url'] == null ? SJB_System::getSystemSettings('SITE_URL') . '/' . SJB_TemplatePathManager::getAbsoluteImagePath(SJB_TemplateSupplier::getUserCurrentTheme(), 'main', 'logo.png') : $userInfo['Logo']['file_url'];
     return $this->postToWall($listingSID, $text . $link, $listingUrl, $picture);
 }
예제 #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme);
     $files = $this->getCssFiles($themePath);
     $tp->assign("action", SJB_Request::getVar("action"));
     switch (SJB_Request::getVar("action")) {
         case "save":
             if (SJB_System::getSystemSettings("isDemo")) {
                 $tp->assign('ERROR', "NOT_ALLOWED_IN_DEMO");
             } else {
                 $fp = fopen($_REQUEST["file"], "w");
                 fwrite($fp, $_REQUEST["file_content"]);
                 fclose($fp);
             }
         case "edit":
             $tp->assign("file_content", file_get_contents($_REQUEST["file"]));
             $tp->assign("cssFile", $_REQUEST["file"]);
             break;
     }
     $tp->assign("files", $files);
     $tp->display("edit_css.tpl");
 }
예제 #4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $tp->assign('theme', $theme);
     $errors = array();
     $message = '';
     $alternativeText = SJB_Request::getVar('logoAlternativeText', '');
     switch (SJB_Request::getVar('action', '')) {
         case 'save':
             if (isset($_FILES['logo']['error'])) {
                 if ($_FILES['logo']['error'] == UPLOAD_ERR_OK) {
                     if (SJB_System::getSystemSettings('isDemo')) {
                         $errors[] = 'NOT_ALLOWED_IN_DEMO';
                     } else {
                         $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme);
                         if (move_uploaded_file($_FILES['logo']['tmp_name'], "{$themePath}main/images/logo.png")) {
                             $message = 'Logo has been uploaded successfully';
                         }
                     }
                 } else {
                     switch ($_FILES['logo']['error']) {
                         case UPLOAD_ERR_INI_SIZE:
                             $errors[] = 'File size exceeds system limit. Please check the file size limits on your hosting or upload another file.';
                             break;
                         case UPLOAD_ERR_FORM_SIZE:
                             $errors[] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
                             break;
                         case UPLOAD_ERR_PARTIAL:
                             $errors[] = 'The uploaded file was only partially uploaded';
                             break;
                         case UPLOAD_ERR_NO_FILE:
                             // Разрешим изменять текст без аплоада лого
                             break;
                         case UPLOAD_ERR_NO_TMP_DIR:
                             $errors[] = 'Missing a temporary folder';
                             break;
                         case UPLOAD_ERR_CANT_WRITE:
                             $errors[] = 'Failed to write file to disk';
                             break;
                         default:
                             $errors[] = 'File upload error';
                     }
                     if ($alternativeText == SJB_Settings::getSettingByName('logoAlternativeText')) {
                         $errors[] = 'Upload a logo or enter alternative text';
                     }
                 }
             }
             if (SJB_Settings::getSettingByName('logoAlternativeText') === false) {
                 SJB_Settings::addSetting('logoAlternativeText', $alternativeText);
             } else {
                 if ($alternativeText != SJB_Settings::getSettingByName('logoAlternativeText')) {
                     SJB_Settings::updateSetting('logoAlternativeText', $alternativeText);
                     if (!$message) {
                         $message = 'Alternative text has been updated successfully';
                     } else {
                         $message = 'Logo and Alternative text has been uploaded successfully';
                     }
                 }
             }
             break;
     }
     $tp->assign('errors', $errors);
     $tp->assign('message', $message);
     $tp->assign('uploadMaxFilesize', SJB_UploadFileManager::getIniUploadMaxFilesize());
     $tp->assign('logoAlternativeText', SJB_Request::getVar('logoAlternativeText', SJB_Settings::getSettingByName('logoAlternativeText')));
     $tp->display('upload_logo.tpl');
 }
예제 #5
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $module_name = SJB_Request::getVar('module_name', "", 'GET');
     $template_name = SJB_Request::getVar('template_name', "", 'GET');
     // не работало с юзерской
     if (empty($template_name)) {
         $template_name = SJB_Request::getVar('template_name', '');
     }
     if (empty($module_name)) {
         $module_name = SJB_Request::getVar('module_name', '');
     }
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $template_editor = new SJB_TemplateEditor();
     $simple_view = SJB_Request::getVar('simple_view');
     if (!$template_editor->doesModuleExists($module_name)) {
         $tp->assign('ERROR', "MODULE_DOES_NOT_EXIST");
     } else {
         if (!$template_editor->doesModuleTemplateExists($module_name, $template_name)) {
             $tp->assign('ERROR', "TEMPLATE_DOES_NOT_EXIST");
         } else {
             if (isset($_REQUEST['action'])) {
                 $content = SJB_Request::getVar('template_content');
                 if ($content) {
                     if (SJB_System::getSystemSettings("isDemo")) {
                         $tp->assign('ERROR', 'NOT_ALLOWED_IN_DEMO');
                     } elseif (SJB_System::getIfTrialModeIsOn() && SJB_HelperFunctions::findSmartyRestrictedTagsInContent($tp, $content)) {
                         $tp->assign('ERROR', 'Php tags are not allowed');
                     } else {
                         $result = $template_editor->saveTemplate($template_name, $module_name, $theme, $content);
                         // if ajax request to save
                         if ($simple_view) {
                             if ($result) {
                                 echo '<p class="message">Template saved successfully. </p>';
                             } else {
                                 echo "ERROR WHILE SAVE TEMPLATE";
                             }
                             exit;
                         }
                         if ($_REQUEST['action'] == "save_template") {
                             SJB_HelperFunctions::redirect("?module_name=" . $module_name);
                         }
                     }
                 }
             }
             echo SJB_System::executeFunction('template_manager', 'add_template');
             $modules = $template_editor->getModuleWithTemplatesList();
             $tp->assign('module_name', $module_name);
             $tp->assign('template_name', $template_name);
             $tp->assign('theme', $theme);
             $tp->assign('display_name', $modules[$module_name]['display_name']);
             $tp->assign('template_display_name', $template_name);
             $path_to_template = SJB_TemplatePathManager::getAbsoluteTemplatePath($theme, $module_name, $template_name);
             if (!file_exists($path_to_template)) {
                 $theme = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR');
             }
             if (false === ($template_content = $template_editor->loadTemplate($template_name, $module_name, $theme))) {
                 $tp->assign('ERROR', "CANNOT_FETCH_TEMPLATE");
             } else {
                 if (!$template_editor->isTemplateWriteable($module_name, $theme, $template_name) && !SJB_System::getSystemSettings("isDemo")) {
                     $tp->assign('ERROR', "TEMPLATE_IS_NOT_WRITEABLE");
                 } else {
                     $tp->assign('template_content', $template_content);
                 }
             }
             $list_modules = SJB_System::getModulesUserList();
             $list_functions = array();
             $list_params = array();
             foreach ($list_modules as $module) {
                 $functions = SJB_System::getFunctionsUserList($module);
                 foreach ($functions as $keyF => $func) {
                     $list_functions[$module][$keyF] = $func;
                     $params = SJB_System::getParamsList($module, $func);
                     if (isset($params[0])) {
                         foreach ($params as $keyP => $param) {
                             $list_params[$module][$func][$keyP] = $param;
                         }
                     }
                 }
             }
             $tp->assign('LIST_MODULES', $list_modules);
             $tp->assign('LIST_FUNCTIONS', $list_functions);
             $tp->assign('LIST_PARAMS', $list_params);
         }
     }
     if ($simple_view) {
         $tp->display('edit_template_simple.tpl');
     } else {
         header('X-XSS-Protection: 0');
         $tp->display('edit_template.tpl');
     }
 }
예제 #6
0
 /**
  * create template file by theme, modulename, templatename
  *
  * @param string $theme
  * @param string $module_name
  * @param string $tpl_name
  * @param array $error
  * @return boolean
  */
 function createTemplate($theme, $module_name, $tpl_name, &$error = array())
 {
     $path_to_template = SJB_TemplatePathManager::getAbsoluteTemplatePath($theme, $module_name, $tpl_name);
     if (!is_dir($path_to_template)) {
         SJB_Filesystem::mkpath(dirname($path_to_template));
     }
     if (!file_exists($path_to_template)) {
         return self::createTemplateFile($path_to_template);
     } else {
         $error[] = 'FILE_EXISTS';
     }
     return false;
 }
예제 #7
0
 /**
  * Returns image URI of specified module
  *
  * @param string $image_name Image name
  * @return string Image URI
  */
 function getModuleImageURI($image_name)
 {
     return SJB_System::getSystemSettings('SITE_URL') . "/" . SJB_TemplatePathManager::getAbsoluteImagePath(self::$theme, $this->module_name, $image_name);
 }
예제 #8
0
 public function execute()
 {
     // таблица с данными xml-feeds
     $feedsTable = 'listing_feeds';
     $action = SJB_Request::getVar('action', '');
     $feedId = SJB_Request::getVar('feedId', null);
     $feedsArray = SJB_DB::query("SELECT f.*, f.count as count_listings, l.sid as typeId, l.id as type FROM {$feedsTable} as f LEFT JOIN `listing_types` as l ON (l.sid=f.type) ORDER BY f.sid");
     $listingTypes = SJB_DB::query("SELECT * FROM `listing_types`");
     $siteURL = SJB_System::getSystemSettings('SITE_URL');
     $tmp = strrchr(SJB_System::getSystemSettings('SITE_URL'), "/");
     $siteURL = str_replace($tmp, "", $siteURL);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('listingTypes', $listingTypes);
     // данные для создания файлов-шаблонов для feed
     $module = SJB_System::getModuleManager()->getCurrentModuleAndFunction();
     $templatePath = SJB_TemplatePathManager::getAbsoluteTemplatesPath();
     $filePath = $templatePath . "_system/" . $module[0] . "/";
     switch ($action) {
         case 'add':
             // если была отправка формы
             if (isset($_REQUEST['addFeed']) && $_REQUEST['addFeed'] != '') {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 // создадим шаблон для нового feed
                 $feed_template = preg_replace("/^feed_|\\.tpl\$/", "", $feed_template);
                 $feed_template = "feed_" . $feed_template . ".tpl";
                 $filePath = $filePath . $feed_template;
                 $fileSystem = new SJB_Filesystem();
                 if (!file_exists($filePath)) {
                     $fileSystem->createFile($filePath);
                 } else {
                     $errors[] = array('code' => 'FILE_ALREADY_EXISTS', 'message' => "Template '{$filePath}' already exists!");
                     $tp->assign('feed', array('name' => $feed_name, 'template' => $feed_template, 'description' => $feed_desc, 'type' => $typeId, 'count_listings' => $count_listings, 'mime_type' => $feed_mimetype));
                     $tp->assign('errors', $errors);
                     $tp->display("add_listing_feed.tpl");
                     break;
                 }
                 SJB_DB::queryExec("INSERT INTO {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             }
             $tp->display("add_listing_feed.tpl");
             break;
         case 'edit':
             // если была отправка формы редактирования элемента
             if ($form_submitted = SJB_Request::getVar('submit')) {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $feedId = $_REQUEST['feedId'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 SJB_DB::queryExec("UPDATE {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s WHERE `sid`=?n LIMIT 1", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype, $feedId);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 if ($form_submitted == 'save_info') {
                     SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
                 }
             }
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings  FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $tp->assign("feed", $feed);
             $tp->display("edit_listing_feed.tpl");
             break;
         case 'delete':
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $filePath = $filePath . $feed['template'];
             $fileSystem = new SJB_Filesystem();
             if (file_exists($filePath)) {
                 $fileSystem->deleteFile($filePath);
             } else {
                 $errors[] = array('code' => 'FILE_NOT_EXISTS', 'message' => "Template for " . $feed['name'] . ": '{$filePath}' not exists!");
             }
             SJB_DB::queryExec("DELETE FROM {$feedsTable} WHERE `sid`=?n LIMIT 1", $feedId);
             $site_url = SJB_System::getSystemSettings("SITE_URL");
             SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             break;
     }
     if ($action == '') {
         $tp->assign('siteURL', $siteURL);
         $tp->assign('feeds', $feedsArray);
         $tp->display('listing_feeds.tpl');
     }
 }