示例#1
0
 function add()
 {
     if (!$this->haveAccessTo('edit')) {
         return $this->showAccessDenied();
     }
     $nParentID = Func::POSTGET('pid', false, true);
     $aData = array('title' => '', 'pid' => $nParentID, 'keyword' => '', 'keyword' => '', 'menu_link' => '', 'menu_target' => '', 'mkeywords' => '', 'mdescription' => '');
     if (Func::isPostMethod()) {
         Func::setSESSION('pid', $nParentID);
         $sKeyword = Func::POST('keyword', true);
         $sMenuTarget = Func::POST('target');
         if (!in_array($sMenuTarget, array('_self', '_blank'))) {
             $sMenuTarget = '_self';
         }
         $sType = Func::POST('type');
         switch ($sType) {
             case 'menu_type':
                 $sMenuTitle = Func::POST('menu_title4', true);
                 $sMetaKeywords = Func::POST('mkeywords4', true);
                 $sMetaDescription = Func::POST('mdescription4', true);
                 $sMenuLink = '#';
                 break;
             case 'page':
                 $nPageID = Func::POST('page_id', false, true);
                 $aPageInfo = $this->db->one_array('SELECT * FROM ' . TABLE_PAGES . ' WHERE id=' . $nPageID . ' LIMIT 1');
                 if (!$aPageInfo) {
                     $this->adminRedirect(Errors::IMPOSSIBLE);
                 }
                 $sMenuTitle = Func::POST('menu_title3', true);
                 if (!$sMenuTitle) {
                     $sMenuTitle = $aPageInfo['title'];
                 }
                 $sMetaKeywords = $aPageInfo['mkeywords'];
                 $sMetaDescription = $aPageInfo['mdescription'];
                 $sMenuLink = $aPageInfo['filename'] . PAGES_EXTENSION;
                 break;
             case 'link':
             default:
                 $sMenuTitle = Func::POST('menu_title2', true);
                 $sMenuLink = Func::POST('menu_link2', true);
                 $sMetaDescription = Func::POST('mdescription2', true);
                 $sMetaKeywords = Func::POST('mkeywords2', true);
         }
         $_POST['menu_title'] = $sMenuTitle;
         $_POST['menu_link'] = $sMenuLink;
         $_POST['mdescription'] = $sMetaDescription;
         $_POST['mkeywords'] = $sMetaKeywords;
         if (!$sMenuTitle || !trim($sMenuTitle)) {
             $this->errors->set('empty:title');
         }
         if ($this->errors->no()) {
             $nNodeID = $this->tree_insertNode($nParentID);
             $this->addItem($nNodeID, $sMenuTitle, $sKeyword, $sMenuLink, $sMetaKeywords, $sMetaDescription, $sMenuTarget);
             $this->adminRedirect(Errors::SUCCESS);
         }
         $aData = $_POST;
     }
     if (!$nParentID) {
         $nParentID = Func::SESSION('pid');
     }
     //parent options
     $sParentOptions = '';
     $aItems = $this->db->select('SELECT I.menu_title, T.id, T.numlevel, I.keyword FROM ' . TABLE_SITEMAP_TREE . ' T, ' . TABLE_SITEMAP . ' I
                             WHERE T.id=I.node_id AND T.numlevel<=2 
                             ORDER BY T.numleft');
     foreach ($aItems as $v) {
         if (!empty($v['keyword'])) {
             $sParentOptions .= '<option value="' . $v['id'] . '" style="padding-left:' . $v['numlevel'] * 18 . 'px;" 
                                 ' . ($nParentID == $v['id'] ? ' selected' : '') . '>' . $v['menu_title'] . '</option>';
         }
     }
     $this->tplAssign('aData', $aData);
     $this->tplAssign('pid_options', $sParentOptions);
     $this->tplAssign('target_options', $this->getTargetsOptions($this->aTargets, $aData['menu_target']));
     $this->tplAssign('pages_options', func::MakeOptionsListEx($this->db->select('SELECT * FROM ' . TABLE_PAGES), Func::POSTGET('page_id', false, true), 'title', 'id'));
     return $this->tplFetch('admin.add.tpl');
 }
示例#2
0
 function mm_add()
 {
     if (!FORDEV || !$this->security->isSuperAdmin()) {
         return $this->showAccessDenied();
     }
     $aData = array('method' => '', 'title' => '', 'module' => '');
     if (Func::isPostMethod()) {
         $sMethod = Func::POST('method', true);
         $sTitle = Func::POST('title', true);
         $sModule = $this->db->str2sql(Func::POST('module'));
         Func::setSESSION('save_module', $sModule);
         if (!$sMethod) {
             $sMethod = $sModule;
         }
         if (!$sTitle) {
             $sTitle = ucwords($sModule . ' ' . $sMethod);
         }
         //get max module number
         $nNumber = (int) $this->db->one_data('SELECT max(number) FROM ' . TABLE_MODULE_METHODS . " \n                                            WHERE module={$sModule} AND method!={$sModule} ");
         $nNumber++;
         //insert module-method
         $this->db->execute('INSERT INTO ' . TABLE_MODULE_METHODS . " (module, method, title, number)\n                       VALUES ({$sModule}, " . $this->db->str2sql($sMethod) . ', ' . $this->db->str2sql($sTitle) . ", {$nNumber})");
         if ($this->errors->no()) {
             $this->adminRedirect(Errors::SUCCESSFULL, 'mm_listing');
         }
     }
     if (!$aData['module']) {
         $aData['module'] = Func::SESSION('save_module');
     }
     $aModules = CDir::getDirs(PATH_MODULES, false, false, false);
     foreach ($aModules as $k => $v) {
         if ($v[0] != '.' && $v[0] != '_') {
             $aModules[$v] = $v;
         }
         unset($aModules[$k]);
     }
     $this->tplAssign(array('aModules' => $aModules, 'aData' => $aData));
     return $this->tplFetch('admin.mm.create.tpl');
 }
示例#3
0
 function setFORDEV($bEnable = true)
 {
     Func::setSESSION('fordev', $bEnable);
     $_POST['fordev'] = $_GET['fordev'] = $bEnable;
 }
示例#4
0
 function edit()
 {
     if (!$this->haveAccessTo('edit')) {
         return $this->showAccessDenied();
     }
     $nRecordID = Func::POSTGET('rec', false, true);
     if (!$nRecordID) {
         $this->adminRedirect(Errors::IMPOSSIBLE);
     }
     $aData = $this->db->one_array('SELECT * FROM ' . TABLE_BANNERS . ' WHERE id=' . $nRecordID);
     if (empty($aData)) {
         $this->adminRedirect(Errors::IMPOSSIBLE);
     }
     $sPrevPosition = $aData['position'];
     if (bff::$isPost) {
         $this->input->postm(array('position' => TYPE_STR, 'cat' => TYPE_ARRAY_UINT, 'enabled' => TYPE_BOOL, 'banner_type' => TYPE_UINT, 'show_limit' => TYPE_UINT, 'resize_img' => TYPE_BOOL, 'code' => TYPE_STR, 'show_start' => TYPE_STR, 'show_finish' => TYPE_STR, 'clickurl' => TYPE_STR, 'showurl' => TYPE_STR, 'showurl_recursive' => TYPE_BOOL, 'flash_width' => TYPE_UINT, 'flash_height' => TYPE_UINT, 'flash_key' => TYPE_STR, 'title' => TYPE_STR, 'alt' => TYPE_STR, 'description' => TYPE_STR), $aData);
         if (!$aData['position']) {
             $this->errors->set('position');
         }
         /* если при редактировании позиция меняется, проверить новую позицию на возможность ротации */
         if ($aData['position'] != $sPrevPosition) {
             if (!$this->checkRotation($aData['position'])) {
                 $this->errors->set('no_rotation');
             }
         }
         $aData['clickurl'] = preg_replace("[^http://|www\\.|https://|ftp://]", '', $aData['clickurl']);
         $aData['showurl'] = preg_replace("[^http://|www\\.|https://|ftp://]", '', $aData['showurl']);
         $sFlashAddFields = '';
         if ($aData['banner_type'] == BANNERS_TYPE_FLASH) {
             if (!$aData['flash_width'] || !$aData['flash_height']) {
                 $this->errors->set('no_flash_size');
             }
             $sFlashAddFields = 'flash = ' . $this->db->str2sql(serialize(array('width' => $aData['flash_width'], 'height' => $aData['flash_height'], 'key' => $aData['flash_key']))) . ',';
         }
         Func::setSESSION('banner_position', $aData['position']);
         if ($this->errors->no()) {
             $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                         SET clickurl = :clickurl,
                             position = :position,
                             cat = :cat,
                             show_start = :show_start,
                             show_finish = :show_finish,
                             showurl = :showurl,
                             showurl_recursive =' . $aData['showurl_recursive'] . ',
                             enabled =' . $aData['enabled'] . ',
                             banner_type =' . $aData['banner_type'] . ',' . $sFlashAddFields . '
                             show_limit = ' . $aData['show_limit'] . ',
                             title = :title,  alt = :alt, description = :description
                         WHERE id=' . $nRecordID, array(':clickurl' => $aData['clickurl'], ':position' => $aData['position'], ':cat' => join(',', $aData['cat']), ':show_start' => date('Y-m-d H:i', strtotime($aData['show_start'])), ':show_finish' => date('Y-m-d H:i', strtotime($aData['show_finish'])), ':showurl' => $aData['showurl'], ':title' => $aData['title'], ':alt' => $aData['alt'], ':description' => $aData['description']));
             do {
                 if ($aData['banner_type'] == BANNERS_TYPE_IMG) {
                     $oUpload = new Upload('bnrimg', false);
                     if (isset($_FILES['bnrimg']) && $_FILES['bnrimg']['error'] == 4) {
                         break;
                     }
                     $oUpload->checkIsIMG();
                     if ($oUpload->isSuccessfull()) {
                         $this->delImages($nRecordID, array('banner' => $aData['banner']));
                         $aImgInfo = getimagesize($_FILES['bnrimg']['tmp_name']);
                         $sExtension = image_type_to_extension($aImgInfo[2], false);
                         $sFilename = func::generateRandomName(5, true, true) . '.' . $sExtension;
                         $aPositionInfo = $this->positions[$aData['position']];
                         if (!isset($aPositionInfo['height']) || !$aPositionInfo['height']) {
                             $aPositionInfo['height'] = false;
                         }
                         if (!$aData['resize_img']) {
                             $aWorkingImg = array('filename' => BANNERS_PATH . $nRecordID . '_work_' . $sFilename, 'width' => $aImgInfo[0], 'height' => $aImgInfo[1], 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center');
                         } else {
                             $aWorkingImg = array('filename' => BANNERS_PATH . $nRecordID . '_work_' . $sFilename, 'width' => $aPositionInfo['width'], 'height' => $aPositionInfo['height'], 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center');
                         }
                         $aParams = array(array('filename' => BANNERS_PATH . $nRecordID . '_th_' . $sFilename, 'width' => 100, 'height' => false, 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center'), $aWorkingImg ? $aWorkingImg : '');
                         $oThumb = new CThumbnail($_FILES['bnrimg']['tmp_name'], false);
                         $oThumb->save($aParams);
                         $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                                    SET banner=' . $this->db->str2sql($sFilename) . '
                                    WHERE id=' . $nRecordID);
                     }
                 } elseif ($aData['banner_type'] == BANNERS_TYPE_FLASH) {
                     $fUpload = new Upload('flash', false);
                     if (!empty($fUpload->filename)) {
                         $this->delImages($nRecordID, array('banner' => $aData['banner']));
                         $fUpload->save(BANNERS_PATH, $nRecordID . '_src_');
                         $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                                    SET banner=' . $this->db->str2sql($fUpload->getFilename()) . '
                                    WHERE id=' . $nRecordID);
                     }
                 } else {
                     $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                                SET banner=' . $this->db->str2sql($aData['code']) . '
                                WHERE id=' . $nRecordID);
                 }
             } while (false);
             $this->adminRedirect(Errors::SUCCESSFULL);
         }
         $aData['banner'] = $this->db->one_data('SELECT banner FROM ' . TABLE_BANNERS . ' WHERE id=' . $nRecordID);
     }
     $aData['cat'] = explode(',', $aData['cat']);
     if (empty($aData['position'])) {
         $aData['position'] = Func::SESSION('banner_position');
     }
     $aData['width'] = $this->positions[$aData['position']]['width'];
     $aData['height'] = $this->positions[$aData['position']]['height'];
     //prepare link
     $aData['link'] = $this->prepareClickURL($aData['id']);
     //prepare thumbnail path
     $aData['img_small'] = '';
     $aData['img_big'] = '';
     $sFilename = $aData['id'] . '_th_' . $aData['banner'];
     if (file_exists(BANNERS_PATH . $sFilename)) {
         $aData['img_small'] = BANNERS_URL . '/' . $sFilename;
     }
     $sFilename = $aData['id'] . '_work_' . $aData['banner'];
     if (file_exists(BANNERS_PATH . $sFilename)) {
         $aData['img_big'] = BANNERS_URL . '/' . $sFilename;
     }
     $aData['flash'] = unserialize($aData['flash']);
     $aData['resize_img'] = 1;
     $aData['date_min'] = date('Y,n,d', mktime(0, 0, 0, date('n') - 1, date('d'), date('y')));
     $this->includeJS(array('datepicker'));
     $this->tplAssign('aCategories', $this->getBBSCategories($aData['cat'], false));
     $this->tplAssign('aPosOptions', $this->positions);
     $this->tplAssign('aData', $aData);
     return $this->tplFetch('admin.form.tpl');
 }