function getMigration()
 {
     $this->setResultStatus('The transfer was started.');
     mysql_query('SET NAMES utf8', $this->rOldDb);
     $sSql = "SELECT \r\n        \t\t\t`ID` AS `id`, \r\n        \t\t\t`Sender` AS `author_id`, \r\n        \t\t\t`Header` AS `caption`,\r\n        \t\t\t`Text` AS `content`,\r\n        \t\t\t'' AS `uri`,\r\n        \t\t\t'' AS `tags`, \r\n        \t\t\t'3' AS `allow_comment_to`,\r\n        \t\t\t'3' AS `allow_vote_to`,\r\n        \t\t\t`Date` AS `date`,\r\n        \t\t\t`Active` AS `status`,\r\n        \t\t\t'0' AS `rate`,\r\n        \t\t\t'0' AS `rate_count`,\r\n        \t\t\t'0' AS `cmts_count`\r\n        \t\tFROM `Stories`";
     $rResult = mysql_query($sSql, $this->rOldDb);
     $iCount = mysql_num_rows($rResult);
     while ($aFeedback = mysql_fetch_assoc($rResult)) {
         $aFeedback['uri'] = uriGenerate($aFeedback['caption'], $this->oDolModule->_oDb->getPrefix() . 'entries', 'uri');
         $aFeedback['status'] = $aFeedback['status'] == 'on' ? 0 : 1;
         if ($this->exists($aFeedback['id'], $aFeedback['uri'])) {
             $this->setResultStatus('Duplicate data. Feedback with similar info already exists.');
             return MIGRATION_FAILED;
         }
         $sSql = "INSERT INTO `" . $this->oDolModule->_oDb->getPrefix() . "entries` SET";
         foreach ($aFeedback as $sKey => $sValue) {
             $sSql .= " `" . $sKey . "`='" . $this->oMigrationModule->_oDb->escape($sValue) . "',";
         }
         $iResult = (int) $this->oDolModule->_oDb->query(substr($sSql, 0, -1));
         if ($iResult <= 0) {
             $this->setResultStatus('Database error. Cannot insert data in the database.');
             return MIGRATION_FAILED;
         }
     }
     $this->setResultStatus('The transfer was successfully completed. (' . $iCount . ' items)');
     return MIGRATION_SUCCESSFUL;
 }
 function transferContent()
 {
     $sSql = "SELECT \r\n        \t\t\t`ta`.`ArticlesID` AS `id`,\r\n        \t\t\t`ta`.`ownerID` AS `author_id`,\r\n        \t\t\t`ta`.`Title` AS `caption`,\r\n        \t\t\t`ta`.`Text` AS `content`,\r\n        \t\t\t`ta`.`ArticleUri` AS `uri`,\r\n        \t\t\t'' AS `tags`,        \t\t\t\r\n        \t\t\t`tac`.`CategoryName` AS `categories`,\r\n        \t\t\t'0' AS `comment`,\r\n        \t\t\t'0' AS `vote`,\r\n        \t\t\tUNIX_TIMESTAMP(`Date`) AS `date`,\r\n        \t\t\t'0' AS `status`,\r\n        \t\t\t'0' AS `featured`,\r\n        \t\t\t'0' AS `rate`,\r\n        \t\t\t'0' AS `rate_count`,\r\n        \t\t\t'0' AS `view_count`,\r\n        \t\t\t'0' AS `cmts_count`\r\n        \t\tFROM `Articles` AS `ta` \r\n        \t\tLEFT JOIN `ArticlesCategory` AS `tac` ON `ta`.`CategoryID`=`tac`.`CategoryID`\r\n        \t\tORDER BY `Date` ASC";
     $rResult = mysql_query($sSql, $this->rOldDb);
     $iCount = mysql_num_rows($rResult);
     $oCategories = new BxDolCategories();
     while ($aItem = mysql_fetch_assoc($rResult)) {
         $aItem['uri'] = uriGenerate($aItem['caption'], $this->oDolModule->_oDb->getPrefix() . 'entries', 'uri');
         if ($this->existsItem($aItem['id'], $aItem['uri'])) {
             $this->setResultStatus('Duplicate data. Article with similar info already exists.');
             return MIGRATION_FAILED;
         }
         $sSql = "INSERT INTO `" . $this->oDolModule->_oDb->getPrefix() . "entries` SET";
         foreach ($aItem as $sKey => $sValue) {
             $sSql .= " `" . $sKey . "`='" . $this->oMigrationModule->_oDb->escape($sValue) . "',";
         }
         $iResult = (int) $this->oDolModule->_oDb->query(substr($sSql, 0, -1));
         if ($iResult <= 0) {
             $this->setResultStatus('Database error. Cannot insert item in the database.');
             return MIGRATION_FAILED;
         }
         $oCategories->reparseObjTags($this->_sType, $this->oDolModule->_oDb->lastId());
     }
     $this->setResultStatus('The transfer was successfully completed. (' . $iCount . ' items)');
     return MIGRATION_SUCCESSFUL;
 }
 public function performActionAdd()
 {
     $sAction = 'add';
     $aForm = array('form_attrs' => array('id' => 'adm-form-pre-list-create', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_form_pre_lists', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('module' => array('type' => 'hidden', 'name' => 'module', 'value' => BX_DOL_STUDIO_MODULE_CUSTOM, 'db' => array('pass' => 'Xss')), 'use_for_sets' => array('type' => 'hidden', 'name' => 'use_for_sets', 'value' => 1, 'db' => array('pass' => 'Int')), 'title' => array('type' => 'text_translatable', 'name' => 'title', 'caption' => _t('_adm_form_txt_pre_lists_title'), 'info' => _t('_adm_form_dsc_pre_lists_title'), 'value' => '_adm_form_txt_pre_lists', 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'title'), 'error' => _t('_adm_form_err_pre_lists_title'))), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_pre_lists_add')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_form_btn_pre_lists_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         $sLanguage = $oLanguage->getCurrentLangName(false);
         $sKey = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']);
         $sKey = uriGenerate($sKey, 'sys_form_pre_lists', 'key', 'key');
         $iId = (int) $oForm->insert(array('key' => $sKey));
         if ($iId != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_form_err_pre_lists_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-pre-list-create-popup', _t('_adm_form_txt_pre_lists_create_popup'), $this->_oTemplate->parseHtmlByName('form_add_list.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Exemplo n.º 4
0
 public function performActionAdd()
 {
     $sAction = 'add';
     $sFormObject = $this->oModule->_oConfig->getObject('form_nav_menu');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_menu_add');
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $this->fillInSelects($oForm->aInputs);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $sObject = uriGenerate($oForm->getCleanValue('object'), 'sys_objects_menu', 'object', 'object');
         BxDolForm::setSubmittedValue('object', $sObject, $oForm->aFormAttrs['method']);
         if (($iId = (int) $oForm->insert()) != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_nav_err_menus_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-menu-create-popup', _t('_bx_dev_nav_txt_menus_create_popup'), $this->oModule->_oTemplate->parseHtmlByName('nav_add_menu.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 /**
  * Function migrate shared_photos data;
  * 
  * @return : (integer) operation result;
  */
 function getMigration()
 {
     if (!$this->oDolModule) {
         $this->setResultStatus('System error: object  instance is not received');
         return MIGRATION_FAILED;
     }
     // set new status;
     $this->setResultStatus('Shared photos transfer now');
     mysql_query('SET NAMES utf8', $this->rOldDb);
     $sqlQuery = "SELECT * FROM `{$this->aOldTables['main']}` GROUP BY `medID`";
     $rResult = mysql_query($sqlQuery, $this->rOldDb);
     while ($aRow = mysql_fetch_assoc($rResult)) {
         $sUri = !$this->isEntryExisting($aRow['medUri']) ? $aRow['medUri'] : uriGenerate($aRow['medTitle'], $this->sType . '_main', 'Uri');
         $sUri = $this->oMigrationModule->_oDb->escape($sUri);
         $aSizeInfo = $this->getSizeInfo($aRow['medID'] . '.' . $aRow['medExt']);
         $sSize = $aSizeInfo['width'] . 'x' . $aSizeInfo['height'];
         $sStatus = $aRow['Approved'] == 'true' ? 'approved' : 'disapproved';
         $sHash = md5(microtime());
         // escape all data;
         $aRow = $this->escapeData($aRow);
         $sqlQuery = "\n\t                INSERT INTO \n\t                \t`{$this->sType}_main`\n\t                SET\n\t\t\t\t\t  `Owner` = '{$aRow['medProfId']}',\n\t\t\t\t\t  `Ext`   = '{$aRow['medExt']}',\n\t\t\t\t\t  `Size`  = '{$sSize}',\n\t\t\t\t\t  `Title` = '{$aRow['medTitle']}',\n\t\t\t\t\t  `Uri`   = '{$sUri}',\n\t\t\t\t\t  `Desc`  = '{$aRow['medDesc']}',\n\t\t\t\t\t  `Tags`  = '{$aRow['medTags']}',\n\t\t\t\t\t  `Date`  = '{$aRow['medDate']}',\n\t\t\t\t\t  `Views` = '{$aRow['medViews']}',\n\t\t\t\t\t  `Hash`  = '{$sHash}',\n\t\t\t\t\t  `Status` = '{$sStatus}'\n                ";
         $iResult = (int) $this->oMigrationModule->_oDb->query($sqlQuery);
         if ($iResult <= 0) {
             $this->setResultStatus('Database error. Cannot insert new photo to the database.');
             return MIGRATION_FAILED;
         }
         // get last file id;
         $iFileId = $this->oMigrationModule->_oDb->lastId();
         //transform the file
         $this->_exportFile(array('medID' => $aRow['medID'], 'medFile' => $aRow['medFile'], 'medProfId' => $aRow['medProfId'], 'medExt' => $aRow['medExt'], 'newID' => $iFileId));
         $oTag = new BxDolTags();
         $oTag->reparseObjTags($this->sType, $iFileId);
         // define album
         $sError = $this->_defineAlbum($iFileId, $aRow['medProfId'], $aRow['medTitle']);
         if ($sError) {
             $this->setResultStatus($sError);
             return MIGRATION_FAILED;
         }
         $sError = $this->_exportFavorites(array('old' => $aRow['medID'], 'new' => $iFileId));
         if ($sError) {
             $this->setResultStatus($sError);
             return MIGRATION_FAILED;
         }
         $sError = $this->_exportVotings(array('old' => $aRow['medID'], 'new' => $iFileId));
         if ($sError) {
             $this->setResultStatus($sError);
             return MIGRATION_FAILED;
         }
         $sError = $this->_exportComments(array('old' => $aRow['medID'], 'new' => $iFileId));
         if ($sError) {
             $this->setResultStatus($sError);
             return MIGRATION_FAILED;
         }
     }
     // set as finished;
     $this->setResultStatus('All photos were transferred');
     return MIGRATION_SUCCESSFUL;
 }
 /**
  * Function migrate profile photos data;
  * 
  * @return : (integer) operation result;
  */
 function getMigration()
 {
     if (!$this->oDolModule) {
         $this->setResultStatus('System error: object  instance is not received');
         return MIGRATION_FAILED;
     }
     // set new status;
     $this->setResultStatus('Profile Photos are transfered now');
     mysql_query('SET NAMES utf8', $this->rOldDb);
     $sqlQuery = "SELECT `med_id` as `medID`,\n        \t\t\t\t\t`med_prof_id` as `medProfId`,\n        \t\t\t\t\t`med_file` as `medFile`,\n        \t\t\t\t\t`med_title` as `medTitle`,\n        \t\t\t\t\tif(`med_status`='active', 'approved', 'disapproved') as `medStatus`,\n        \t\t\t\t\tUNIX_TIMESTAMP(`med_date`) as `medDate`\n        \t\t\t\t\tFROM `{$this->aOldTables['main']}` WHERE `med_type`='photo' GROUP BY `med_id`";
     $rResult = mysql_query($sqlQuery, $this->rOldDb);
     if ($rResult) {
         while ($aRow = mysql_fetch_assoc($rResult)) {
             if (!$this->isEntryExisting($aRow['medID'])) {
                 // escape all data;
                 $aRow = $this->escapeData($aRow);
                 $aRow['medExt'] = substr($aRow['medFile'], strpos($aRow['medFile'], '.') + 1);
                 $aSizeInfo = $this->getSizeInfo('photo_' . $aRow['medFile'], $aRow['medProfId']);
                 $sUri = uriGenerate($aRow['medTitle'], $this->sType . '_main', 'Uri');
                 $sSize = $aSizeInfo['width'] . 'x' . $aSizeInfo['height'];
                 $sHash = md5(microtime());
                 //transform the file
                 if (!$this->_exportFile(array('medID' => $aRow['medID'], 'medFile' => $aRow['medFile'], 'medProfId' => $aRow['medProfId'], 'medExt' => $aRow['medExt']))) {
                     continue;
                 }
                 $sqlQuery = "\n\t                \tINSERT INTO \n\t                \t\t`{$this->sType}_main`\n\t                \tSET\n\t            \t\t  `ID`    =  {$aRow['medID']},\n\t\t\t\t\t\t  `Owner` = '{$aRow['medProfId']}',\n\t\t\t\t\t\t  `Ext`   = '{$aRow['medExt']}',\n\t\t\t\t\t\t  `Size`  = '{$sSize}',\n\t\t\t\t\t\t  `Title` = '{$aRow['medTitle']}',\n\t\t\t\t\t\t  `Uri`   = '{$sUri}',\n\t\t\t\t\t\t  `Desc`  = '{$aRow['medDesc']}',\n\t\t\t\t\t\t  `Tags`  = '{$aRow['medTags']}',\n\t\t\t\t\t\t  `Date`  = '{$aRow['medDate']}',\n\t\t\t\t\t\t  `Views` = '{$aRow['medViews']}',\n\t\t\t\t\t\t  `Hash`  = '{$sHash}',\n\t\t\t\t\t\t  `Status` = '{$aRow['medStatus']}'\n\t                ";
                 $iResult = (int) $this->oMigrationModule->_oDb->query($sqlQuery);
                 if ($iResult <= 0) {
                     $this->setResultStatus('Database error. Cannot insert new photo to the database.');
                     return MIGRATION_FAILED;
                 }
                 // define album
                 $sError = $this->_defineAlbum($aRow['medID'], $aRow['medProfId'], $aRow['medTitle']);
                 if ($sError) {
                     $this->setResultStatus($sError);
                     return MIGRATION_FAILED;
                 }
                 $sError = $this->_exportVotings($aRow['medID']);
                 if ($sError) {
                     $this->setResultStatus($sError);
                     return MIGRATION_FAILED;
                 }
             } else {
                 $this->setResultStatus('Duplicate data. Photo with similar info already exists (remove all photos and start again)');
                 return MIGRATION_FAILED;
             }
         }
     }
     // set as finished;
     $this->setResultStatus('All photos were transferred');
     return MIGRATION_SUCCESSFUL;
 }
 public function performActionAdd()
 {
     $sAction = 'add';
     $oForm = $this->_getFormObject($sAction);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if (!empty($_FILES['icon_image']['tmp_name'])) {
             bx_import('BxDolStorage');
             $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
             $mixedIcon = $oStorage->storeFileFromForm($_FILES['icon_image'], false, 0);
             if ($mixedIcon === false) {
                 $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image') . $oStorage->getErrorString()), true);
                 return;
             }
             $oStorage->afterUploadCleanup($mixedIcon, 0);
             BxDolForm::setSubmittedValue('icon', $mixedIcon, $oForm->aFormAttrs['method']);
         }
         bx_import('BxDolPermalinks');
         $oPermalinks = BxDolPermalinks::getInstance();
         $sLink = $oForm->getCleanValue('link');
         $sLink = $oPermalinks->unpermalink($sLink);
         BxDolForm::setSubmittedValue('link', $sLink, $oForm->aFormAttrs['method']);
         $sName = $oPermalinks->getPageNameFromLink($sLink);
         if ($sName == '') {
             bx_import('BxDolStudioLanguagesUtils');
             $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
             $sName = BxDolForm::getSubmittedValue('title_system-' . $sLanguage, $oForm->aFormAttrs['method']);
             $sName = uriGenerate($sName, 'sys_menu_items', 'name', 'item');
         }
         $sSubmenu = $oForm->getCleanValue('submenu_object');
         if (!empty($sSubmenu)) {
             $sLink = $oForm->getCleanValue('link');
             if (empty($sLink)) {
                 BxDolForm::setSubmittedValue('link', 'javascript:void(0)', $oForm->aFormAttrs['method']);
             }
             BxDolForm::setSubmittedValue('target', '', $oForm->aFormAttrs['method']);
             BxDolForm::setSubmittedValue('onclick', 'bx_menu_popup(\'' . $sSubmenu . '\', this);', $oForm->aFormAttrs['method']);
         }
         $iId = (int) $oForm->insert(array('module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'name' => $sName, 'active' => 1, 'order' => $this->oDb->getItemOrderMax($this->sSet) + 1));
         if ($iId != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_items_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-item-create-popup', _t('_adm_nav_txt_items_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_item.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Exemplo n.º 8
0
 public function performActionAdd()
 {
     $sAction = 'add';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_display');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_display_add');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $this->_fillDisplayForm($oForm, $sAction);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $sName = uriGenerate($oForm->getCleanValue('display_name'), 'sys_form_displays', 'display_name', 'display');
         BxDolForm::setSubmittedValue('display_name', $sName, $oForm->aFormAttrs['method']);
         if (($iId = (int) $oForm->insert()) != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_displays_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-display-create-popup', _t('_bx_dev_frm_txt_displays_create_popup'), $this->_oTemplate->parseHtmlByName('form_add_display.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionAdd()
 {
     $sAction = 'add';
     $oForm = $this->_getFormObject($sAction);
     if ($oForm->isSubmitted() && isset($oForm->aInputs['set_name'])) {
         $this->updateSetFields($oForm);
     }
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         $sLanguage = $oLanguage->getCurrentLangName(false);
         $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $oForm->aFormAttrs['method']);
         $sObject = uriGenerate($sObject, 'sys_objects_menu', 'object', 'object');
         //--- New Set Creation
         if ($oForm->getCleanValue('set_name') == $this->sCreateNew) {
             $sSetTitleValue = $oForm->getCleanValue('set_title');
             $sSetName = uriGenerate($sSetTitleValue, 'sys_menu_sets', 'set_name', 'set');
             $sSetTitleKey = '_adm_nav_txt_set_' . $sSetName;
             if ($this->oDb->addSet(array('set_name' => $sSetName, 'module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'title' => $sSetTitleKey, 'deletable' => 1))) {
                 $oLanguage->addLanguageString($sSetTitleKey, $sSetTitleValue);
                 BxDolForm::setSubmittedValue('set_name', $sSetName, $oForm->aFormAttrs['method']);
             }
         }
         unset($oForm->aInputs['set_title']);
         $iId = (int) $oForm->insert(array('object' => $sObject, 'module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'deletable' => 1, 'active' => 1));
         if ($iId != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_menus_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-menu-create-popup', _t('_adm_nav_txt_menus_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_menu.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Exemplo n.º 10
0
 public function performActionAdd()
 {
     $sAction = 'add';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_prelist');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_prelist_add');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $sObject = uriGenerate($oForm->getCleanValue('key'), 'sys_form_pre_lists', 'key', 'key');
         BxDolForm::setSubmittedValue('key', $sObject, $oForm->aFormAttrs['method']);
         if (($iId = (int) $oForm->insert()) != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_prelists_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-prelist-create-popup', _t('_bx_dev_frm_txt_prelists_create_popup'), $this->oModule->_oTemplate->parseHtmlByName('form_add_list.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Exemplo n.º 11
0
 public function performActionAdd()
 {
     $sAction = 'add';
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance('mod_dev_nav_set', 'mod_dev_nav_set_add');
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_nav_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $sName = uriGenerate($oForm->getCleanValue('set_name'), 'sys_menu_sets', 'set_name', 'set');
         BxDolForm::setSubmittedValue('set_name', $sName, $oForm->aFormAttrs['method']);
         if ($oForm->insert() !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $sName);
         } else {
             $aRes = array('msg' => _t('_bx_dev_nav_err_sets_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-set-create-popup', _t('_bx_dev_nav_txt_sets_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_set.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Exemplo n.º 12
0
 function generateUri()
 {
     $f =& $this->aParams['db'];
     $sUri = $this->getCleanValue($f['uri_title']);
     return uriGenerate($sUri, $f['table'], $f['uri']);
 }
Exemplo n.º 13
0
 function getAddSubcatForm($iSubCategoryID = 0, $bOnlyForm = false)
 {
     //admin side only
     $sSubmitC = _t('_bx_ads_add_subcategory');
     $sAction = 'add_sub_category';
     $aParentCategories = array();
     $vParentValues = $this->_oDb->getAllCatsInfo();
     while ($aCategInfo = mysql_fetch_assoc($vParentValues)) {
         $iID = $aCategInfo['ID'];
         $sName = $aCategInfo['Name'];
         $aParentCategories[$iID] = $sName;
     }
     $sTitle = $sDescription = '';
     $iParentID = 0;
     if ($iSubCategoryID) {
         $aSubcatInfos = $this->_oDb->getSubcatInfo($iSubCategoryID);
         $sTitle = $aSubcatInfos[0]['NameSub'];
         $sDescription = $aSubcatInfos[0]['Description'];
         $iParentID = (int) $aSubcatInfos[0]['IDClassified'];
     }
     //adding form
     $aForm = array('form_attrs' => array('name' => 'create_sub_cats_form', 'action' => 'javascript: void(0)', 'method' => 'post'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLSubcatTable, 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'IDClassified' => array('type' => 'select', 'name' => 'IDClassified', 'caption' => _t('_bx_ads_parent_category'), 'values' => $aParentCategories, 'value' => $iParentID, 'db' => array('pass' => 'Int')), 'NameSub' => array('type' => 'text', 'name' => 'NameSub', 'caption' => _t('_Title'), 'required' => true, 'value' => $sTitle, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_bx_ads_title_error_desc', 128)), 'db' => array('pass' => 'Xss')), 'Description' => array('type' => 'text', 'name' => 'Description', 'caption' => _t('_Description'), 'value' => $sDescription, 'db' => array('pass' => 'Xss')), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sSubmitC, 'attrs' => array('onClick' => "AdmCreateSubcategory('{$this->sHomeUrl}{$this->sCurrBrowsedFile}'); return false;"))));
     if ($iSubCategoryID) {
         $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'id', 'value' => $iSubCategoryID);
     }
     $sCode = '';
     $sJS = $this->_oTemplate->addJs('main.js', true);
     $oForm = new BxTemplFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $aValsAdd = array();
         if ($iSubCategoryID == 0) {
             $sCategUri = uriGenerate(bx_get('NameSub'), $this->_oConfig->sSQLSubcatTable, 'SEntryUri');
             $aValsAdd['SEntryUri'] = $sCategUri;
         }
         $iLastId = -1;
         if ($iSubCategoryID > 0) {
             $oForm->update($iSubCategoryID, $aValsAdd);
             $iLastId = $iSubCategoryID;
         } else {
             $iLastId = $oForm->insert($aValsAdd);
         }
         if ($iLastId > 0) {
             $sCode = MsgBox(_t('_bx_ads_Sub_category_successfully_added'), 3);
         } else {
             $sCode = MsgBox(_t('_bx_ads_Sub_category_failed_add'), 3);
         }
     }
     if ($bOnlyForm) {
         return $sCode . $oForm->getCode();
     }
     $sResult = $sJS . $sCode . $oForm->getCode();
     if (bx_get('mode') == 'json') {
         require_once BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php';
         $oJson = new Services_JSON();
         return $oJson->encode($sResult);
         exit;
     }
     $sResult = $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sResult));
     return $GLOBALS['oFunctions']->popupBox('ads_add_sub_category', _t('_bx_ads_add_subcategory'), $sResult);
 }
Exemplo n.º 14
0
 function registerMember()
 {
     $oPC = new BxDolProfilesController();
     $oZ = new BxDolAlerts('profile', 'before_join', 0, 0, $this->aValues[0]);
     $oZ->alert();
     $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]);
     if (empty($aProfile1['NickName'])) {
         $aProfile1['NickName'] = uriGenerate(empty($aProfile1['FirstName']) ? genRndPwd(10, false) : $aProfile1['FirstName'], 'Profiles', 'NickName');
     }
     list($iId1, $sStatus1) = $oPC->createProfile($aProfile1);
     //--- check whether profile was created successfully or not
     if (!$iId1) {
         if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) {
             @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']);
         }
         return array(false, 'Fail');
     }
     //--- check for couple profile
     if ($this->bCouple) {
         $aProfile2 = $this->oPF->getProfileFromValues($this->aValues[1]);
         list($iId2, $sStatus2) = $oPC->createProfile($aProfile2, false, $iId1);
         if (!$iId2) {
             $oPC->deleteProfile($iId1);
             return array(false, 'Fail');
         }
     }
     //--- upload profile photo
     if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) {
         $sPass1 = getPassword($iId1);
         bx_login($iId1);
         check_logged();
         BxDolService::call('avatar', 'set_image_for_cropping', array($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']));
         if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
             $aFileInfo = array('medTitle' => _t('_sys_member_thumb_avatar'), 'medDesc' => _t('_sys_member_thumb_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getUsername($iId1), getParam('bx_photos_profile_album_name')), 'albumPrivacy' => BX_DOL_PG_ALL);
             BxDolService::call('photos', 'perform_photo_upload', array($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader');
         }
     }
     if (BxDolModule::getInstance('BxWmapModule')) {
         BxDolService::call('wmap', 'response_entry_add', array('profiles', $iId1));
     }
     //--- create system event
     bx_import('BxDolAlerts');
     $oZ = new BxDolAlerts('profile', 'join', $iId1, 0, array('status_text' => &$sStatus1));
     $oZ->alert();
     return array($iId1, $sStatus1);
 }
/**
 * SQL Inserting new SubClassifieds
 *
 * @param $sCategoryID	Added CategoryID FIeld value
 * @param $sName		Added Name FIeld value
 * @param $sDescription	Added Description FIeld value
 * @return SQL result
 */
function InsertCS($sCategoryID, $sName, $sDescription)
{
    $sNewUri = uriGenerate($sName, 'ClassifiedsSubs', 'SEntryUri', 128);
    $query = "INSERT INTO `ClassifiedsSubs` SET\r\n\t\t\t\t\t`IDClassified`='{$sCategoryID}',\r\n\t\t\t\t\t`NameSub`='{$sName}',\r\n\t\t\t\t\t`SEntryUri`='{$sNewUri}',\r\n\t\t\t\t\t`Description`='{$sDescription}'";
    $sqlRes = db_res($query);
    return $sqlRes;
}
 function createPage($aData, $bSendMails = true, $iMainMemberID = 0)
 {
     if (!$aData or !is_array($aData) or empty($aData)) {
         return false;
     }
     unset($aData['Couple']);
     unset($aData['Captcha']);
     unset($aData['TermsOfUse']);
     unset($aData['thumb']);
     unset($aData['uri']);
     /* @var $this->oPF BxDolProfileFields */
     $this->oPF = new MlClonetwoPageFields(100);
     if (!$this->oPF->aArea) {
         echo 'Profile Fields cache not loaded. Cannot continue.';
         return false;
     }
     $this->aItems = $this->oPF->aArea[0]['Items'];
     if ($iMainMemberID) {
         $aMainMember = $this->getPageInfo($iMainMemberID);
     } else {
         $aMainMember = false;
     }
     // begin profile info collecting
     $aNewPage = array();
     $aMediaFields = array();
     foreach ($this->aItems as $aItem) {
         $sItemName = $aItem['Name'];
         if (array_key_exists($sItemName, $aData)) {
             //if ($aItem['MediaType'] != 'none')
             //$aMediaFields[$aItem['MediaType']][$sItemName] = $aData[$sItemName];
             //else
             $aNewPage[$sItemName] = $aData[$sItemName];
             //if ($aData[$sItemName . '_photos'] && $aData[$sItemName])
             //$aPhotoFields[$sItemName] = $aData[$sItemName . '_photos'];
         } elseif ($aMainMember and array_key_exists($sItemName, $aMainMember) and $aItem['Type'] != 'system') {
             if ($aItem['Unique']) {
                 $aNewPage[$sItemName] = $this->genUniqueValue($sItemName, $aMainMember[$sItemName]);
             } else {
                 $aNewPage[$sItemName] = $aMainMember[$sItemName];
             }
         } else {
             switch ($aItem['Type']) {
                 case 'pass':
                     $aNewPage[$sItemName] = $this->genRandomPassword();
                     break;
                 case 'num':
                     $aNewPage[$sItemName] = (int) $aItem['Default'];
                     break;
                 case 'bool':
                     $aNewPage[$sItemName] = (bool) $aItem['Default'];
                     break;
                 case 'system':
                     switch ($sItemName) {
                         case 'id':
                             //set automatically
                         //set automatically
                         case 'Captcha':
                             //not been inserted
                         //not been inserted
                         case 'Location':
                             //not been inserted
                         //not been inserted
                         case 'Keyword':
                             //not been inserted
                         //not been inserted
                         case 'TermsOfUse':
                             //not been inserted
                             //pass
                             break;
                         case 'created':
                             $aNewPage[$sItemName] = time();
                             // set current date
                             break;
                         case 'featured':
                             $aNewPage[$sItemName] = false;
                             break;
                         case 'status':
                             $aNewPage[$sItemName] = 'approved';
                             break;
                     }
                     break;
                 default:
                     $aNewPage[$sItemName] = $aItem['Default'];
             }
         }
     }
     //we completed collecting
     $sEntryUri = uriGenerate($aNewPage['title'], 'ml_clonetwo_main', 'uri');
     $aNewPage['uri'] = $sEntryUri;
     $aNewPage['author_id'] = getLoggedId();
     $sSet = $this->collectSetString($aNewPage);
     $sQuery = "INSERT INTO `ml_clonetwo_main` SET \n{$sSet}";
     $rRes = db_res($sQuery);
     if ($rRes) {
         $iNewID = db_last_id();
         $aNewPage['title'] = sprintf($aNewPage['title'], $iNewID);
         $sEntryUri = uriGenerate($aNewPage['title'], 'ml_clonetwo_main', 'uri');
         $this->createPageCache($iNewID);
         $sStatus = getParam('ml_clonetwo_autoapproval') == 'on' || isAdmin() ? 'approved' : 'pending';
         $this->updatePage($iNewID, array('created' => time(), 'title' => $aNewPage['title'], 'uri' => $sEntryUri));
         return array($iNewID, $sEntryUri, $sStatus, $aNewPage['title']);
     } else {
         return array(false, 'Failed', 0);
     }
 }
Exemplo n.º 17
0
 function updateMediaShared($iMediaID, $aFileInfo)
 {
     $sMedUri = uriGenerate($aFileInfo['medTitle'], $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     return $this->oModule->_oDb->updateData($iMediaID, array('medTitle' => $aFileInfo['medTitle'], 'medUri' => $sMedUri, 'medDesc' => $aFileInfo['medDesc'], 'medDate' => time()));
 }
Exemplo n.º 18
0
 function insertSharedMediaToDb($sExt, $aFileInfo, $iAuthorId = 0, $aExtraData = array())
 {
     if (!$iAuthorId) {
         $iAuthorId = $this->_iOwnerId;
     }
     if (getParam($this->oModule->_oConfig->aGlParams['auto_activation']) == 'on') {
         $bAutoActivate = true;
         $sStatus = 'approved';
     } else {
         $bAutoActivate = false;
         $sStatus = 'pending';
     }
     $sFileTitle = $aFileInfo['medTitle'];
     $sFileDesc = $aFileInfo['medDesc'];
     $sFileTags = $aFileInfo['medTags'];
     $sCategory = implode(CATEGORIES_DIVIDER, $aFileInfo['Categories']);
     $sDimension = isset($aFileInfo['dimension']) ? $aFileInfo['dimension'] : (int) $aFileInfo['medSize'];
     $sAlbum = mb_strlen($_POST['extra_param_album']) > 0 ? $_POST['extra_param_album'] : getParam('sys_album_default_name');
     $sAlbum = isset($aFileInfo['album']) ? $aFileInfo['album'] : $sAlbum;
     $sMedUri = uriGenerate($sFileTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $sExtDb = trim($sExt, '.');
     $sCurTime = time();
     $aData = array('medProfId' => $iAuthorId, 'medExt' => $sExtDb, 'medTitle' => $sFileTitle, 'medUri' => $sMedUri, 'medDesc' => $sFileDesc, 'medTags' => $sFileTags, 'Categories' => $sCategory, 'medSize' => $sDimension, 'Approved' => $sStatus, 'medDate' => $sCurTime);
     $aData = array_merge($aData, $aExtraData);
     $iInsertedID = $this->oModule->_oDb->insertData($aData);
     if (0 < $iInsertedID) {
         $oTag = new BxDolTags();
         $oTag->reparseObjTags($this->oModule->_oConfig->sPrefix, $iInsertedID);
         $oCateg = new BxDolCategories();
         $oCateg->reparseObjTags($this->oModule->_oConfig->sPrefix, $iInsertedID);
         $aAlbumParams = isset($aFileInfo['albumPrivacy']) ? array('privacy' => $aFileInfo['albumPrivacy']) : array();
         $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iInsertedID, $bAutoActivate, $iAuthorId, $aAlbumParams);
         return $iInsertedID;
     }
     return 0;
 }
function uploadFile($sFile, $sDesc, $sTags, $iUser)
{
    global $dir;
    if ($_FILES['uploadFile']['error'] != 0) {
        $sCode = '<div class="uploadStatus">' . _t("_File upload error") . '</div>';
    } else {
        $aFileInfo = getimagesize($_FILES['uploadFile']['tmp_name']);
        if (!$aFileInfo) {
            $sCode = '<div class="uploadStatus">' . _t("_You uploaded not image file") . '</div>';
        } else {
            $ext = false;
            switch ($aFileInfo['mime']) {
                case 'image/jpeg':
                    $ext = 'jpg';
                    break;
                case 'image/gif':
                    $ext = 'gif';
                    break;
                case 'image/png':
                    $ext = 'png';
                    break;
                default:
                    $ext = false;
            }
            if (!$ext) {
                $sCode = '<div class="uploadStatus">' . _t("_You uploaded not JPEG, GIF or PNG file") . '</div>';
            } else {
                $sCode = '<div class="uploadStatus">' . _t("_Upload successful") . '</div>';
                $sActive = getParam("enable_shPhotoActivation") == 'on' ? 'true' : 'false';
                $sPhotoUri = uriGenerate($sFile, 'sharePhotoFiles', 'medUri');
                $sQuery = "INSERT INTO `sharePhotoFiles` (`medProfId`,`medTitle`,`medUri`,`medExt`,`medDesc`,`medTags`,`medDate`,`Approved`) VALUES('{$iUser}','{$sFile}','{$sPhotoUri}','{$ext}','{$sDesc}','{$sTags}'," . time() . ",'{$sActive}')";
                db_res($sQuery);
                $iNew = mysql_insert_id();
                reparseObjTags('photo', $iNew);
                $sNewFileName = $dir['sharingImages'] . $iNew . '.' . $ext;
                $sNewMainName = $dir['sharingImages'] . $iNew . '_m.' . $ext;
                $sNewThumbName = $dir['sharingImages'] . $iNew . '_t.' . $ext;
                if (!move_uploaded_file($_FILES['uploadFile']['tmp_name'], $sNewFileName)) {
                    $sCode = '<div class="uploadStatus">' . _t("_Couldn\\'t move file") . '</div>';
                } else {
                    chmod($sNewFileName, 0644);
                    $iWidth = (int) getParam("max_photo_width");
                    $iHeight = (int) getParam("max_photo_height");
                    $iThumbW = (int) getParam("max_thumb_width");
                    $iThumbH = (int) getParam("max_thumb_height");
                    if (imageResize($sNewFileName, $sNewMainName, $iWidth, $iHeight) != IMAGE_ERROR_SUCCESS) {
                        $sCode = '<div class="uploadStatus">' . _t("_Upload failed") . '</div>';
                    } else {
                        imageResize($sNewMainName, $sNewThumbName, $iThumbW, $iThumbH);
                        $bPermalink = getParam('permalinks_gallery_photos') == 'on' ? true : false;
                        $sFileLink = getFileUrl($iNew, $sPhotoUri, 'photo', $bPermalink);
                        header("Location:" . $sFileLink);
                        exit;
                    }
                }
            }
        }
    }
    return $sCode;
}
Exemplo n.º 20
0
 function updateMediaShared($iMediaID, $aFileInfo)
 {
     $sFileTitle = addslashes($aFileInfo['medTitle']);
     $sFileDesc = addslashes($aFileInfo['medDesc']);
     $sMedUri = uriGenerate($sFileTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $sCurTime = time();
     return $this->oModule->_oDb->updateData($iMediaID, array('medTitle' => $sFileTitle, 'medUri' => $sMedUri, 'medDesc' => $sFileDesc, 'medDate' => $sCurTime));
 }
 /**
  * Write SQL data into ClassifiedsAdvertisements
  *
  * @param $iMemberID	Member ID
  * @param $iSubClassifiedID	SubClassified ID, where Adv was added
  * @param $sSubject		Subject of Adv
  * @param $sMessage		Message of Adv
  * @param $sCustomFieldValue1 Custom Value 1
  * @param $sCustomFieldValue2 Custom Value 2
  * @param $iLifeTime		Life time of Adv, time in days how many showed Adv
  * @param $sMedIds		ID`s of attached pictures
  * @return SQL result
  */
 function InsertCA($iMemberID, $iSubClassifiedID, $sSubject, $sMessage, $sCustomFieldValue1, $sCustomFieldValue2, $iLifeTime, $sMedIds, $sTags)
 {
     $sNewUri = uriGenerate($sSubject, 'ClassifiedsAdvertisements', 'EntryUri', 50);
     $sStatus = getParam('autoApproval_Classifieds') == 'on' ? 'active' : 'new';
     $sQuery = "INSERT INTO `ClassifiedsAdvertisements` SET\r\n\t\t\t\t\t`IDProfile`='{$iMemberID}',\r\n\t\t\t\t\t`IDClassifiedsSubs`='{$iSubClassifiedID}',\r\n\t\t\t\t\t`DateTime`=NOW(),\r\n\t\t\t\t\t`Subject`='{$sSubject}',\r\n\t\t\t\t\t`EntryUri`='{$sNewUri}',\r\n\t\t\t\t\t`Message`='{$sMessage}',\r\n\t\t\t\t\t`Status` = '{$sStatus}',\r\n\t\t\t\t\t`CustomFieldValue1`={$sCustomFieldValue1},\r\n\t\t\t\t\t`CustomFieldValue2`={$sCustomFieldValue2},\r\n\t\t\t\t\t`LifeTime`={$iLifeTime},\r\n\t\t\t\t\t`Media`='{$sMedIds}',\r\n\t\t\t\t\t`Tags`='{$sTags}'\r\n\t\t";
     $vSqlRes = db_res($sQuery);
     return $vSqlRes;
 }
Exemplo n.º 22
0
 function createUserPage()
 {
     $sUri = uriGenerate(process_db_input($_REQUEST['uri']), $this->sDBTable . '_pages', 'Name');
     $sTitle = process_db_input($_REQUEST['title']);
     db_res("INSERT INTO `{$this->sDBTable}_pages` (`Name`, `Title`, `Order`, `System`) SELECT '{$sUri}', '{$sTitle}', MAX(`Order`) + 1, '0' FROM `{$this->sDBTable}_pages` LIMIT 1");
     if (!db_affected_rows()) {
         return array('code' => '1', 'message' => 'Failed database insert');
     }
     return array('code' => '0', 'message' => 'OK', 'uri' => $sUri);
 }
Exemplo n.º 23
0
function video_genUri($s)
{
    global $sModule;
    $sDBModule = DB_PREFIX . ucfirst($sModule);
    return uriGenerate($s, $sDBModule . 'Files', 'Uri', 255);
}
Exemplo n.º 24
0
 function initMusicFile($iMusicID, $sTitle, $sCategories, $sTags, $sDesc)
 {
     $sMedUri = uriGenerate($sTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $bRes = $this->oModule->_oDb->updateData($iMusicID, array('Categories' => $sCategories, 'medTitle' => $sTitle, 'medTags' => $sTags, 'medDesc' => $sDesc, 'medUri' => $sMedUri));
     $oTag = new BxDolTags();
     $oTag->reparseObjTags('bx_sounds', $iMusicID);
     $oCateg = new BxDolCategories();
     $oCateg->reparseObjTags('bx_sounds', $iMusicID);
     $bRes = true;
     //TODO chech why if false
     return $bRes;
 }
Exemplo n.º 25
0
    /**
     * Generate Form for NewPost/EditPost
     *
     * @param $iPostID - Post ID
     * @return HTML presentation of data
     */
    function AddNewPostForm($iPostID = 0, $bBox = true)
    {
        $this->CheckLogged();
        if ($iPostID == 0) {
            if (!$this->isAllowedPostAdd()) {
                return $this->_oTemplate->displayAccessDenied();
            }
        } else {
            $iOwnerID = (int) $this->_oDb->getPostOwnerByID($iPostID);
            if (!$this->isAllowedPostEdit($iOwnerID)) {
                return $this->_oTemplate->displayAccessDenied();
            }
        }
        $sPostCaptionC = _t('_Title');
        $sPostTextC = _t('_Text');
        $sAssociatedImageC = _t('_associated_image');
        $sAddBlogC = $iPostID ? _t('_Submit') : _t('_Add Post');
        $sTagsC = _t('_Tags');
        $sNewPostC = _t('_New Post');
        $sEditPostC = _t('_bx_blog_Edit_post');
        $sDelImgC = _t('_Delete image');
        $sErrorC = _t('_Error Occured');
        $sCaptionErrorC = _t('_bx_blog_Caption_error');
        $sTextErrorC = _t('_bx_blog_Text_error');
        $sTagsInfoC = _t('_sys_tags_note');
        $sLink = $this->genBlogFormUrl();
        $sAddingForm = '';
        $oCategories = new BxDolCategories();
        $oCategories->getTagObjectConfig();
        $aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'view', array(), _t('_bx_blog_privacy_view'));
        $aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'rate', array(), _t('_bx_blog_privacy_rate'));
        $aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'comment', array(), _t('_bx_blog_privacy_comment'));
        $sAction = $iPostID == 0 ? 'new_post' : 'edit_post';
        //adding form
        $aForm = array('form_attrs' => array('name' => 'CreateBlogPostForm', 'action' => $sLink, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLPostsTable, 'key' => 'PostID', 'submit_name' => 'add_button')), 'inputs' => array('PostCaption' => array('type' => 'text', 'name' => 'PostCaption', 'caption' => $sPostCaptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => $sCaptionErrorC), 'db' => array('pass' => 'Xss')), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => $sTagsC, 'info' => $sTagsInfoC, 'required' => false, 'db' => array('pass' => 'Xss')), 'PostText' => array('type' => 'textarea', 'html' => 2, 'name' => 'PostText', 'caption' => $sPostTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 65535), 'error' => $sTextErrorC), 'db' => array('pass' => 'XssHtml')), 'Categories' => $oCategories->getGroupChooser('bx_blogs', $this->_iVisitorID, true), 'File' => array('type' => 'file', 'name' => 'BlogPic[]', 'caption' => $sAssociatedImageC), 'AssociatedImage' => array('type' => 'hidden'), 'allowView' => $aAllowView, 'allowRate' => $aAllowRate, 'allowComment' => $aAllowComment, 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sAddBlogC)));
        if ($iPostID > 0) {
            $aBlogPost = $this->_oDb->getJustPostInfo($iPostID);
            $sPostCaption = $aBlogPost['PostCaption'];
            $sPostText = $aBlogPost['PostText'];
            $sPostTags = $aBlogPost['Tags'];
            $sPostPicture = $aBlogPost['PostPhoto'];
            if ($sPostPicture != '') {
                $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL;
                $sPostPictureTag = <<<EOF
<div class="blog_edit_image" id="edit_post_image_{$iPostID}">
    <img class="bx-def-shadow bx-def-round-corners bx-def-margin-sec-right" style="max-width:{$this->iThumbSize}px; max-height:{$this->iThumbSize}px;" src="{$sBlogsImagesUrl}big_{$sPostPicture}" />
    <a href="{$sLink}?action=del_img&amp;post_id={$iPostID}" onclick="BlogpostImageDelete('{$sLink}?action=del_img&post_id={$iPostID}&mode=ajax', 'edit_post_image_{$iPostID}');return false;" >{$sDelImgC}</a>
</div>
EOF;
                $aForm['inputs']['AssociatedImage']['type'] = 'custom';
                $aForm['inputs']['AssociatedImage']['content'] = $sPostPictureTag;
                $aForm['inputs']['AssociatedImage']['caption'] = $sAssociatedImageC;
            }
            $aCategories = explode(';', $aBlogPost['Categories']);
            $aForm['inputs']['PostCaption']['value'] = $sPostCaption;
            $aForm['inputs']['PostText']['value'] = $sPostText;
            $aForm['inputs']['Tags']['value'] = $sPostTags;
            $aForm['inputs']['Categories']['value'] = $aCategories;
            $aForm['inputs']['allowView']['value'] = $aBlogPost['allowView'];
            $aForm['inputs']['allowRate']['value'] = $aBlogPost['allowRate'];
            $aForm['inputs']['allowComment']['value'] = $aBlogPost['allowComment'];
            $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'EditPostID', 'value' => $iPostID);
            if ($aBlogPost['PostPhoto'] != '' && file_exists(BX_BLOGS_IMAGES_PATH . 'small_' . $aBlogPost['PostPhoto'])) {
                $GLOBALS['oTopMenu']->setCustomSubIconUrl(BX_BLOGS_IMAGES_URL . 'small_' . $aBlogPost['PostPhoto']);
            } else {
                $GLOBALS['oTopMenu']->setCustomSubIconUrl('book');
            }
            $GLOBALS['oTopMenu']->setCustomSubHeader($sPostCaption);
        }
        if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) {
            $aForm['inputs']['allowView']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) {
            $aForm['inputs']['allowRate']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
            $aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL;
        }
        $oForm = new BxTemplFormView($aForm);
        $oForm->initChecker();
        if ($oForm->isSubmittedAndValid()) {
            $this->CheckLogged();
            $iOwnID = $this->_iVisitorID;
            $sCurTime = time();
            $sPostUri = uriGenerate(bx_get('PostCaption'), $this->_oConfig->sSQLPostsTable, 'PostUri');
            $sAutoApprovalVal = getParam('blogAutoApproval') == 'on' ? "approval" : "disapproval";
            $aValsAdd = array('PostDate' => $sCurTime, 'PostStatus' => $sAutoApprovalVal);
            if ($iPostID == 0) {
                $aValsAdd['OwnerID'] = $iOwnID;
                $aValsAdd['PostUri'] = $sPostUri;
            }
            $iBlogPostID = -1;
            if ($iPostID > 0) {
                unset($aValsAdd['PostDate']);
                $oForm->update($iPostID, $aValsAdd);
                $this->isAllowedPostEdit($iOwnerID, true);
                $iBlogPostID = $iPostID;
            } else {
                $iBlogPostID = $oForm->insert($aValsAdd);
                $this->isAllowedPostAdd(true);
            }
            if ($iBlogPostID) {
                $this->iLastPostedPostID = $iBlogPostID;
                if ($_FILES) {
                    for ($i = 0; $i < count($_FILES['BlogPic']['tmp_name']); $i++) {
                        if ($_FILES['BlogPic']['error'][$i]) {
                            continue;
                        }
                        if (0 < $_FILES['BlogPic']['size'][$i] && 0 < strlen($_FILES['BlogPic']['name'][$i]) && 0 < $iBlogPostID) {
                            $sTmpFile = $_FILES['BlogPic']['tmp_name'][$i];
                            if (file_exists($sTmpFile) == false) {
                                break;
                            }
                            $aSize = getimagesize($sTmpFile);
                            if (!$aSize) {
                                @unlink($sTmpFile);
                                break;
                            }
                            switch ($aSize[2]) {
                                case IMAGETYPE_JPEG:
                                case IMAGETYPE_GIF:
                                case IMAGETYPE_PNG:
                                    $sOriginalFilename = $_FILES['BlogPic']['name'][$i];
                                    $sExt = strrchr($sOriginalFilename, '.');
                                    $sFileName = 'blog_' . $iBlogPostID . '_' . $i;
                                    @unlink($sFileName);
                                    move_uploaded_file($sTmpFile, BX_BLOGS_IMAGES_PATH . $sFileName . $sExt);
                                    @unlink($sTmpFile);
                                    if (strlen($sExt)) {
                                        $sPathSrc = BX_BLOGS_IMAGES_PATH . $sFileName . $sExt;
                                        $sPathDst = BX_BLOGS_IMAGES_PATH . '%s_' . $sFileName . $sExt;
                                        imageResize($sPathSrc, sprintf($sPathDst, 'small'), $this->iIconSize / 1, $this->iIconSize / 1);
                                        imageResize($sPathSrc, sprintf($sPathDst, 'big'), $this->iThumbSize, $this->iThumbSize);
                                        imageResize($sPathSrc, sprintf($sPathDst, 'browse'), $this->iBigThumbSize, null);
                                        imageResize($sPathSrc, sprintf($sPathDst, 'orig'), $this->iImgSize, $this->iImgSize);
                                        chmod(sprintf($sPathDst, 'small'), 0644);
                                        chmod(sprintf($sPathDst, 'big'), 0644);
                                        chmod(sprintf($sPathDst, 'browse'), 0644);
                                        chmod(sprintf($sPathDst, 'orig'), 0644);
                                        $this->_oDb->performUpdatePostWithPhoto($iBlogPostID, $sFileName . $sExt);
                                        @unlink($sPathSrc);
                                    }
                                    break;
                                default:
                                    @unlink($sTempFileName);
                                    return false;
                            }
                        }
                    }
                }
                //reparse tags
                bx_import('BxDolTags');
                $oTags = new BxDolTags();
                $oTags->reparseObjTags('blog', $iBlogPostID);
                //reparse categories
                $oCategories = new BxDolCategories();
                $oCategories->reparseObjTags('bx_blogs', $iBlogPostID);
                $sAlertAction = $iPostID == 0 ? 'create' : 'edit_post';
                bx_import('BxDolAlerts');
                $oZ = new BxDolAlerts('bx_blogs', $sAlertAction, $iBlogPostID, $this->_iVisitorID);
                $oZ->alert();
                header("X-XSS-Protection: 0");
                // to prevent browser's security audit to block youtube embeds(and others), just after post creation
                return $this->GenPostPage($iBlogPostID);
            } else {
                return MsgBox($sErrorC);
            }
        } else {
            $sAddingForm = $oForm->getCode();
        }
        $sCaption = $iPostID ? $sEditPostC : $sNewPostC;
        $sAddingFormVal = '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>';
        return $bBox ? DesignBoxContent($sCaption, '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>', 1) : $sAddingFormVal;
    }
 function savePage()
 {
     $aDiff = $this->getDiffValues(0);
     list($aUpd, $aMedia) = $this->oPF->getPageFromValues($aDiff);
     $sDelimeter = getParam('ml_clonetwo_multi_divider');
     $sDelimeter = $sDelimeter ? $sDelimeter : ';';
     if ($aDiff['title']) {
         $aUpd['uri'] = uriGenerate($aDiff['title'], 'ml_clonetwo_main', 'title');
     }
     $sTitle = $aDiff['title'] ? $aDiff['title'] : db_value("SELECT `title` FROM `ml_clonetwo_main` WHERE `id` = {$this->iPageID} LIMIT 1");
     if (!empty($aMedia)) {
         foreach ($aMedia as $sKey => $sValue) {
             $aMediaData = explode($sDelimeter, $aUpd[$sValue]);
             switch ($sKey) {
                 case 'photo':
                     $sTable = 'ml_clonetwo_images';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if ($_POST['thumb_radio']) {
                         db_res("UPDATE `ml_clonetwo_main` SET `thumb` = {$_POST['thumb_radio']} WHERE `id` = {$this->iPageID} LIMIT 1");
                     }
                     if (!empty($_POST[$sValue . '_check_photos'])) {
                         foreach ($_POST[$sValue . '_check_photos'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("photos", "perform_photo_upload", 'Uploader')) {
                         $i = 0;
                         foreach ($aMediaData as $sData) {
                             $aInfo = array('medTitle' => $_POST[$sValue . '_title_photos'][$i] ? $_POST[$sValue . '_title_photos'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                             if ($sData) {
                                 $this->looper();
                                 $iMediaId = BxDolService::call("photos", "perform_photo_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                     if (!db_value("SELECT `thumb` FROM `ml_clonetwo_main` WHERE `id` = {$this->iPageID} LIMIT 1") && $i == 0) {
                                         db_res("UPDATE `ml_clonetwo_main` SET `thumb` = {$iMediaId} WHERE `id` = {$this->iPageID} LIMIT 1");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'video':
                     $sTable = 'ml_clonetwo_videos';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_videos'])) {
                         foreach ($_POST[$sValue . '_check_videos'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("videos", "perform_video_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_videos'][$i] ? $_POST[$sValue . '_title_videos'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("videos", "perform_video_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'sound':
                     $sTable = 'ml_clonetwo_sounds';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_sounds'])) {
                         foreach ($_POST[$sValue . '_check_sounds'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("sounds", "perform_music_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_sounds'][$i] ? $_POST[$sValue . '_title_sounds'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("sounds", "perform_music_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'file':
                     $sTable = 'ml_clonetwo_files';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_files'])) {
                         foreach ($_POST[$sValue . '_check_files'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("files", "perform_file_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_files'][$i] ? $_POST[$sValue . '_title_files'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("files", "perform_file_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'youtube':
                     $i = 0;
                     $sTable = 'ml_clonetwo_youtube';
                     $iUIdField = 'id';
                     $iIdField = 'id_entry';
                     $sUrlField = 'url';
                     $sTitleField = 'title';
                     if (!empty($_POST[$sValue . '_check_youtube'])) {
                         foreach ($_POST[$sValue . '_check_youtube'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iUIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     foreach ($aMediaData as $sData) {
                         if ($sData) {
                             $sTitle = $_POST[$sValue . '_title_youtube'][$i];
                             if (db_value("SHOW TABLES LIKE '{$sTable}'") && $sData) {
                                 db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$sUrlField}` = '{$sData}', `{$sTitleField}` = '{$sTitle}'");
                             }
                         }
                         $i++;
                     }
                     break;
                 case 'rss':
                     $i = 0;
                     $sTable = 'ml_clonetwo_rss';
                     $iUIdField = 'id';
                     $iIdField = 'id_entry';
                     $sUrlField = 'url';
                     $sTitleField = 'name';
                     if (!empty($_POST[$sValue . '_check_rss'])) {
                         foreach ($_POST[$sValue . '_check_rss'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iUIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     foreach ($aMediaData as $sData) {
                         if ($sData) {
                             $sTitle = $_POST[$sValue . '_title_rss'][$i];
                             if (db_value("SHOW TABLES LIKE '{$sTable}'") && $sData) {
                                 db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$sUrlField}` = '{$sData}', `{$sTitleField}` = '{$sTitle}'");
                             }
                         }
                         $i++;
                     }
                     break;
             }
         }
     }
     $oModuleDb = new BxDolModuleDb();
     $aModule = $oModuleDb->getModuleByUri('clonetwo');
     $iProfileId = getLoggedId();
     bx_import('BxDolTags');
     $o = new BxDolTags();
     $o->reparseObjTags('ml_clonetwo', $this->iPageID);
     bx_import('BxDolCategories');
     $o = new BxDolCategories();
     $o->reparseObjTags('ml_clonetwo', $this->iPageID);
     $this->oPC->updatePage($this->iPageID, $aUpd);
 }
 function ActionAddUpdateElements()
 {
     $sActionText = '';
     if ($_POST['add_category']) {
         $sCategorySubject = process_db_input($_POST['caption']);
         $sCategoryDesc = process_db_input($_POST['description']);
         $sCategoryUri = uriGenerate(process_db_input($sCategorySubject), 'ArticlesCategory', 'CategoryUri', 255);
         $sAddQuery = "INSERT INTO `ArticlesCategory` SET `CategoryName` = '{$sCategorySubject}', `CategoryDescription` = '{$sCategoryDesc}', `CategoryUri`='{$sCategoryUri}'";
         if ($sCategorySubject == '' || $sCategoryDesc == '') {
             $sActionText = 'Category didn\'t add';
         } elseif (db_res($sAddQuery)) {
             $sActionText = 'Category Added';
         } else {
             $sActionText = 'Category didn\'t add';
         }
     } elseif ($_POST['edit_category']) {
         $sCategorySubject = process_db_input($_POST['caption']);
         $sCategoryDesc = process_db_input($_POST['description']);
         $iCategoryID = (int) $_POST['categoryID'];
         $sAddQuery = "UPDATE `ArticlesCategory` SET `CategoryName` = '{$sCategorySubject}', `CategoryDescription` = '{$sCategoryDesc}' WHERE `CategoryID` = '{$iCategoryID}' LIMIT 1;";
         if ($sCategorySubject == '' || $sCategoryDesc == '') {
             $sActionText = 'Category didn\'t add';
         } elseif (db_res($sAddQuery)) {
             $sActionText = 'Category Udated';
         } else {
             $sActionText = 'Category didn\'t updated';
         }
     } elseif ($_POST['add_article']) {
         $sArticleTitle = process_db_input($_POST['title']);
         $sArticle = process_db_input($_POST['article']);
         $iCategoryID = (int) $_POST['categoryID'];
         if ($_POST['flag'] == 'HTML') {
             $sFlag = 'HTML';
         } else {
             $sFlag = 'Text';
         }
         $sArticleUri = uriGenerate($sArticleTitle, 'Articles', 'Title', 100);
         $sOwner = $this->bAdminMode ? "" : ", `ownerID` = '{$this->iVisitorID}'";
         $sAddQuery = "INSERT INTO `Articles` SET `Title` = '{$sArticleTitle}', `Text` = '{$sArticle}', `CategoryID` = '{$iCategoryID}', `Date` = NOW(), `ArticleFlag` = '{$sFlag}', `ArticleUri`='{$sArticleUri}' {$sOwner}";
         if ($sArticleTitle == '' || $sArticle == '') {
             $sActionText = 'Article Not Added';
         } elseif (db_res($sAddQuery)) {
             $sActionText = 'Article Added';
         } else {
             $sActionText = 'Article Not Added';
         }
     } elseif ($_POST['edit_article']) {
         $sArticleTitle = process_db_input($_POST['title']);
         $sArticle = process_db_input($_POST['article']);
         $iCategoryID = (int) $_POST['categoryID'];
         $iArticleID = (int) $_POST['articleID'];
         $sArticleUri = uriGenerate($sArticleTitle, 'Articles', 'Title', 100);
         if ($_POST['flag'] == 'HTML') {
             $sFlag = 'HTML';
         } else {
             $sFlag = 'Text';
         }
         if ($this->bAdminMode) {
             $sOwner = ", `ownerID`='0'";
             $sOwnerCond = "";
         } else {
             $sOwner = ", `ownerID`='{$this->iVisitorID}'";
             $sOwnerCond = " AND `ownerID`='{$this->iVisitorID}'";
         }
         $sAddQuery = "UPDATE `Articles` SET `Title` = '{$sArticleTitle}', `Text` = '{$sArticle}', `CategoryID` = '{$iCategoryID}', `Date` = NOW(), `ArticleFlag` = '{$sFlag}', `ArticleUri`='{$sArticleUri}' {$sOwner} WHERE `ArticlesID` = '{$iArticleID}' {$sOwnerCond}";
         if ($sArticleTitle == '' || $sArticle == '') {
             $sActionText = 'Article Updated';
         } elseif (db_res($sAddQuery)) {
             $sActionText = 'Article Updated';
         } else {
             $sActionText = 'Article Not Updated';
         }
     }
     return $sActionText != '' ? MsgBox($sActionText) : '';
 }
Exemplo n.º 28
0
 protected function actionUriGet()
 {
     bx_import('BxDolStudioLanguagesUtils');
     $oLanguage = BxDolStudioLanguagesUtils::getInstance();
     $aLanguages = $oLanguage->getLanguages();
     $sLanguageDef = $oLanguage->getDefaultLangName();
     $sLanguageCur = $oLanguage->getCurrentLangName(false);
     $aValues = array();
     foreach ($aLanguages as $sName => $sTitle) {
         if (($mixedValue = bx_get($sName)) !== false) {
             $aValues[$sName] = bx_process_input($mixedValue);
         }
     }
     $sUri = "";
     if (($mixedValue = bx_get('uri')) !== false) {
         $sUri = bx_process_input($mixedValue);
     } else {
         if (array_key_exists('en', $aValues) && $aValues['en'] != '') {
             $sUri = $aValues['en'];
         } else {
             if (array_key_exists($sLanguageDef, $aValues) && $aValues[$sLanguageDef] != '') {
                 $sUri = $aValues[$sLanguageDef];
             } else {
                 if (array_key_exists($sLanguageCur, $aValues) && $aValues[$sLanguageCur] != '') {
                     $sUri = $aValues[$sLanguageCur];
                 } else {
                     if (count($aValues) > 0) {
                         foreach ($aValues as $sValue) {
                             if (!empty($sValue)) {
                                 $sUri = $sValue;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     $sUri = $sUri != "" ? uriGenerate($sUri, 'sys_objects_page', 'uri') : "";
     bx_import('BxDolPermalinks');
     $sUrl = BxDolPermalinks::getInstance()->permalink($this->sPageBaseUrl . $sUri);
     return array('eval' => $this->getPageJsObject() . '.onGetUri(oData)', 'uri' => $sUri, 'url' => $sUrl);
 }
Exemplo n.º 29
0
function MemberAddNews()
{
    global $max_l;
    global $max_h;
    $news_text = strlen($_POST['text']) > $max_l ? "LEFT ( '" . process_db_input($_POST['text']) . "', {$max_l} )" : "'" . process_db_input($_POST['text']) . "'";
    $news_header = strlen($_POST['header']) > $max_h ? "LEFT ( '" . process_db_input($_POST['header']) . "', {$max_h} )" : "'" . process_db_input($_POST['header']) . "'";
    $news_snippet = "'" . process_db_input($_POST['snippet']) . "'";
    $sNewsUri = uriGenerate($news_header, 'News', 'NewsUri', 50);
    $res = db_res("INSERT INTO `News` ( `Date`, `Header`, `Text`, `Snippet`, `NewsUri` ) VALUES ( NOW(), {$news_header}, {$news_text}, {$news_snippet}, '{$sNewsUri}')");
    return $res;
}
 /**
  * Creating a Blog
  *
  * @return MsgBox result
  */
 function ActionCreateBlog()
 {
     $this->CheckLogged();
     $sErrorC = _t('_Error Occured');
     $sUncategorizedC = _t('_Uncategorized');
     $sDescription = $this->process_html_db_input($_POST['Description']);
     $iOwnID = $this->aBlogConf['visitorID'];
     $sCategoryUri = uriGenerate($sUncategorizedC, 'BlogCategories', 'CategoryUri', 150);
     $sRequest = "INSERT INTO `Blogs` SET `OwnerID` = '{$iOwnID}', `Description` = '{$sDescription}', `Other` = 'nothing' ";
     db_res($sRequest, false);
     if (mysql_affected_rows() == 1) {
         $sAddQuery = "INSERT INTO `BlogCategories` SET\n\t\t\t\t`OwnerID` = {$iOwnID}, `CategoryName` = '{$sUncategorizedC}', `CategoryUri`='{$sCategoryUri}',`CategoryType` = '5',\n\t\t\t\t`CategoryPhoto` = '', `Date` = NOW()";
         db_res($sAddQuery);
         return $this->GenMemberBlog($iOwnID, false);
     } else {
         return MsgBox($sErrorC);
     }
 }