function getFormCode() { $oForm = new BxTemplFormView($this->aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $aValsAdd = array('Date' => time(), 'Uri' => $oForm->generateUri(), 'Status' => 'active', 'Owner' => $this->iOwnerId); if ($this->iAlbumId > 0 && $this->aInfo['Owner'] == $this->iOwnerId) { $aValsAdd = array('Date' => time()); if (!$oForm->update($this->iAlbumId, $aValsAdd)) { return MsgBox(_t('_sys_album_save_error')); } else { return MsgBox(_t('_sys_album_save_succ')); } } else { $iAlbumId = $oForm->insert($aValsAdd); if (!$iAlbumId) { return MsgBox(_t('_sys_album_save_error')); } else { return MsgBox(_t('_sys_album_save_succ')); } } } else { return $oForm->getCode(); } }
function getPostForm($iUnitID = 0) { $sAddNewC = _t('_bx_quotes_add_new'); $sAction = 'add'; $sQText = $sQText = ''; if ($iUnitID) { $aQinfo = $this->_oDb->getQuote($iUnitID); $sQText = $aQinfo['Text']; $sQAuthor = $aQinfo['Author']; $sAction = 'edit'; } $aForm = array('form_attrs' => array('name' => 'create_quotes_form', 'action' => BX_DOL_URL_ROOT . 'modules/?r=quotes/administration/', 'method' => 'post'), 'params' => array('db' => array('table' => 'bx_quotes_units', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'Text' => array('type' => 'textarea', 'name' => 'Text', 'caption' => _t('_bx_quotes_text'), 'required' => true, 'value' => $sQText, 'checker' => array('func' => 'length', 'params' => array(3, 1024), 'error' => _t('_bx_quotes_text_err', 1024)), 'db' => array('pass' => 'Xss')), 'Author' => array('type' => 'text', 'name' => 'Author', 'caption' => _t('_bx_quotes_author'), 'required' => true, 'value' => $sQAuthor, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_bx_quotes_author_err', 128)), 'db' => array('pass' => 'Xss')), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => _t('_Submit')))); if ($iUnitID) { $aForm['inputs']['hidden_unitid'] = array('type' => 'hidden', 'name' => 'ID', 'value' => $iUnitID); } $sCode = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sCode = MsgBox(_t('_bx_quotes_fail'), 1); $aValsAdd = array(); $iLastId = -1; if ($iUnitID > 0) { $oForm->update($iUnitID, $aValsAdd); $iLastId = $iUnitID; $sCode = MsgBox(_t('_bx_quotes_edited_success'), 1); } else { $iLastId = $oForm->insert($aValsAdd); $sCode = MsgBox(_t('_bx_quotes_success'), 1); } } return DesignBoxAdmin($sAddNewC, $sCode . $oForm->getCode(), '', '', 11); }
function update($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) { $CNF =& $this->_oModule->_oConfig->CNF; if (isset($CNF['FIELD_CHANGED'])) { $aValsToAdd[$CNF['FIELD_CHANGED']] = time(); } return parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges); }
function getManageBannersBlock() { $sAsNew = _t('_adm_bann_Insert_as_new'); $sErrorC = _t('_Error Occured'); $sApplyChangesC = _t('_Submit'); $sTopC = _t('_Top'); $sLeftC = _t('_adm_bann_Left'); $sRightC = _t('_adm_bann_Right'); $sBottomC = _t('_Bottom'); $sHShiftC = _t('_adm_bann_HShift'); $sVShiftC = _t('_adm_bann_VShift'); $sTitleC = _t('_Title'); $sUrlC = _t('_URL'); $sActiveC = _t('_Active'); $sTextC = _t('_Text'); $sStartDateC = _t('_Start date'); $sEndDateC = _t('_Expiration date'); $sDefaultC = _t('_adm_bann_default'); $sPositionOnPageC = _t('_adm_bann_Position_on_the_page'); // get start & end dates $start_date_default = "2008-01-01 00:00:00"; $end_date_default = "2015-01-01 00:00:00"; $start_date = bx_get('start_date') !== false ? bx_get('start_date') : $start_date_default; $end_date = bx_get('end_date') !== false ? bx_get('end_date') : $end_date_default; $Title = $Url = $Active = $Text = $Position = $lhshift = $lvshift = $rhshift = $rvshift = ''; $iBannerID = (int) $_GET['banner_id']; $action = "new"; if ($iBannerID > 0 && !strlen(bx_get('action'))) { //banner edit $banns_arr = db_arr("SELECT * FROM `sys_banners` WHERE `ID`='{$iBannerID}'"); $action = "modify"; $Title = $banns_arr['Title']; $Url = $banns_arr['Url']; $Text = $banns_arr['Text']; $Active = $banns_arr['Active']; $Position = $banns_arr['Position']; $lhshift = $banns_arr['lhshift']; $lvshift = $banns_arr['lvshift']; $rhshift = $banns_arr['rhshift']; $rvshift = $banns_arr['rvshift']; list($iYearStart, $iMonthStart, $iDayStart) = explode('-', $banns_arr['campaign_start']); //$start_date = "{$iDayStart}/{$iMonthStart}/{$iYearStart}"; $start_date = "{$iYearStart}-{$iMonthStart}-{$iDayStart} 00:00:00"; list($iYearEnd, $iMonthEnd, $iDayEnd) = explode('-', $banns_arr['campaign_end']); //$end_date = "{$iDayEnd}/{$iMonthEnd}/{$iYearEnd}"; $end_date = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd} 00:00:00"; } $sFormTitle = htmlspecialchars($Title); $sFormUrl = htmlspecialchars($Url); $sFormActiveState = $Active ? 'checked="checked"' : ''; $sFormActiveStateVal = $Active ? 'yes' : ''; $sFormActiveStateChk = $Active ? true : false; $sFormBannerText = $Text; $sFormStartDate = $start_date; $sFormStartDateDef = $start_date_default; $sFormEndDate = $end_date; $sFormEndDateDef = $end_date_default; $sTopPosState = substr_count($Position, "1") > 0 ? 'checked="checked"' : ''; $sLeftPosState = substr_count($Position, "2") > 0 ? 'checked="checked"' : ''; $sRightPosState = substr_count($Position, "3") > 0 ? 'checked="checked"' : ''; $sBottomPosState = substr_count($Position, "4") > 0 ? 'checked="checked"' : ''; $sTopShift = substr_count($Position, "2") > 0 ? $lhshift : ''; $sLeftShift = substr_count($Position, "2") > 0 ? $lvshift : ''; $sRightShift = substr_count($Position, "3") > 0 ? $rhshift : ''; $sBottomShift = substr_count($Position, "3") > 0 ? $rvshift : ''; $sActionAdd = $action == "modify" ? $sAsNew . ' <input type=checkbox name=as_new />' : ''; $sCustomPositions = <<<EOF <table border=0 width=100% cellspacing=10 cellpading=20> \t<tr> \t\t<td colspan=5 align=center><input type=checkbox name="pos_top" {$sTopPosState} />{$sTopC}</td> \t</tr> \t<tr> \t\t<td colspan=2 align=center><input type=checkbox name="pos_left" {$sLeftPosState} />{$sLeftC}</td> \t\t<td> </td> \t\t<td colspan=2 align=center><input type=checkbox name="pos_right" {$sRightPosState} />{$sRightC}</td> \t</tr> \t<tr> \t\t<td>{$sHShiftC}</td> \t\t<td>{$sVShiftC}</td> \t\t<td> </td> \t\t<td>{$sHShiftC}</td> \t\t<td>{$sVShiftC}</td> \t</tr> \t<tr> \t\t<td><input name="lhshift" type=input size=5 value={$sTopShift} /></td> \t\t<td><input name="lvshift" type=input size=5 value={$sLeftShift} /></td> \t\t<td> </td> \t\t<td><input name="rhshift" type=input size=5 value={$sRightShift} /></td> \t\t<td><input name="rvshift" type=input size=5 value={$sBottomShift} /></td> \t</tr> \t<tr> \t\t<td colspan=5 align=center><input type=checkbox name="pos_bottom" {$sBottomPosState} />{$sBottomC}</td> \t</tr> </table> {$sActionAdd} EOF; $aForm = array('form_attrs' => array('name' => 'apply_ip_list_form', 'action' => $GLOBALS['site']['url_admin'] . 'banners.php', 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_banners', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('BannerTitle' => array('type' => 'text', 'name' => 'Title', 'value' => $sFormTitle, 'caption' => $sTitleC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => _t('_chars_to_chars', 2, 128)), 'db' => array('pass' => 'Xss')), 'BannerUrl' => array('type' => 'text', 'name' => 'Url', 'value' => $sFormUrl, 'caption' => $sUrlC, 'required' => false, 'db' => array('pass' => 'Xss')), 'BannerActive' => array('type' => 'checkbox', 'name' => 'Active', 'caption' => $sActiveC, 'value' => 1, 'checked' => $sFormActiveStateChk), 'BannerText' => array('type' => 'textarea', 'name' => 'Text', 'value' => $sFormBannerText, 'caption' => $sTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(10, 32000), 'error' => _t('_chars_to_chars', 10, 32000)), 'db' => array('pass' => 'All')), 'StartDate' => array('type' => 'datetime', 'name' => 'start_date', 'value' => $sFormStartDate, 'caption' => $sStartDateC, 'label' => "{$sDefaultC}: {$sFormStartDateDef}", 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'display' => 'filterDate'), 'EndDate' => array('type' => 'datetime', 'name' => 'end_date', 'value' => $sFormEndDate, 'caption' => $sEndDateC, 'label' => "{$sDefaultC}: {$sFormEndDateDef}", 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'display' => 'filterDate'), 'Positions' => array('type' => 'custom', 'name' => 'Position', 'caption' => $sPositionOnPageC, 'content' => $sCustomPositions), 'ID' => array('type' => 'hidden', 'name' => 'banner_id', 'value' => $iBannerID), 'Action' => array('type' => 'hidden', 'name' => 'action', 'value' => $action), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sApplyChangesC))); $sResult = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { list($iYearStart, $iMonthStart, $iDayStart) = explode('-', $oForm->getCleanValue('start_date')); $sDateStart = "{$iYearStart}-{$iMonthStart}-{$iDayStart}"; list($iYearEnd, $iMonthEnd, $iDayEnd) = explode('-', $oForm->getCleanValue('end_date')); $sDateEnd = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd}"; $sCurTime = date("Y-m-d"); // 2010-12-31 $iLastId = (int) $oForm->getCleanValue('banner_id'); $banner_pos = ""; if ($oForm->getCleanValue('pos_top') == "on") { $banner_pos .= '1'; } if ($oForm->getCleanValue('pos_left') == "on") { $banner_pos .= '2'; } if ($oForm->getCleanValue('pos_right') == "on") { $banner_pos .= '3'; } if ($oForm->getCleanValue('pos_bottom') == "on") { $banner_pos .= '4'; } $banner_pos = (int) $banner_pos; $banner_lhshift = (int) $oForm->getCleanValue('lhshift'); $banner_lvshift = (int) $oForm->getCleanValue('lvshift'); $banner_rhshift = (int) $oForm->getCleanValue('rhshift'); $banner_rvshift = (int) $oForm->getCleanValue('rvshift'); $aValsAdd = array('Position' => $banner_pos, 'Active' => '' != $oForm->getCleanValue('Active') ? 1 : 0, 'Created' => $sCurTime, 'campaign_start' => $sDateStart, 'campaign_end' => $sDateEnd, 'lhshift' => $banner_lhshift, 'lvshift' => $banner_lvshift, 'rhshift' => $banner_rhshift, 'rvshift' => $banner_rvshift); if ($oForm->getCleanValue('action') == 'modify' && $oForm->getCleanValue('as_new') != "on" && $iLastId > 0) { $oForm->update($iLastId, $aValsAdd); } if ($oForm->getCleanValue('action') == 'new' || $oForm->getCleanValue('as_new') == "on" && $oForm->getCleanValue('action') == 'modify') { $iLastId = $oForm->insert($aValsAdd); } $sResult = $iLastId > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC); } return DesignBoxContent(_t('_adm_bann_title'), $sResult . $oForm->getCode(), 1); }
function update($val, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) { $sPwd = $this->getCleanValue(self::$FIELD_PASSWORD); if ($sPwd) { $sSalt = genRndSalt(); $sPasswordHash = encryptUserPwd($sPwd, $sSalt); } $aValsToAdd = array_merge($aValsToAdd, array(self::$FIELD_CHANGED => time()), $sPwd ? array(self::$FIELD_PASSWORD => $sPasswordHash, self::$FIELD_SALT => $sSalt) : array()); return parent::update($val, $aValsToAdd, $aTrackTextFieldsChanges); }
function getEmailMessage($sAction) { $sErrorC = _t('_Error Occured'); $sApplyChangesC = _t('_Save'); $sSubjectC = _t('_Subject'); $sBodyC = _t('_adm_mmail_Body'); $sTextBodyC = _t('_adm_mmail_Text_email_body'); $sPreviewMessageC = _t('_Preview'); $sDeleteC = _t('_Delete'); $sMessageID = (int) $_POST['msgs_id']; $sSubject = $sBody = ""; if ($_POST['body'] && $_POST['action'] != 'delete') { $sSubject = process_pass_data($_POST['subject']); $sBody = process_pass_data($_POST['body']); } elseif ($sMessageID) { list($sSubject, $sBody) = $GLOBALS['MySQL']->getRow("SELECT `subject`, `body` FROM `sys_sbs_messages` WHERE `id`='" . $sMessageID . "' LIMIT 1", MYSQL_NUM); } $sSubject = htmlspecialchars($sSubject); $aForm = array('form_attrs' => array('name' => 'sys_sbs_messages', 'action' => $GLOBALS['site']['url_admin'] . 'notifies.php', 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_sbs_messages', 'key' => 'ID', 'submit_name' => 'add_message')), 'inputs' => array('subject' => array('type' => 'text', 'name' => 'subject', 'value' => $sSubject, 'caption' => $sSubjectC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => $sErrorC), 'db' => array('pass' => 'Xss')), 'body' => array('type' => 'textarea', 'name' => 'body', 'value' => $sBody, 'caption' => $sBodyC, 'required' => true, 'html' => 2, 'attrs' => array('style' => "height:400px;"), 'checker' => array('func' => 'length', 'params' => array(10, 32000), 'error' => $sErrorC), 'db' => array('pass' => 'XssHtml')), 'msgs_id' => array('type' => 'hidden', 'name' => 'msgs_id', 'value' => $sMessageID), 'control' => array('type' => 'input_set', array('type' => 'submit', 'name' => 'add_message', 'caption' => $sApplyChangesC, 'value' => $sApplyChangesC), array('type' => 'submit', 'name' => 'preview_message', 'caption' => $sPreviewMessageC, 'value' => $sPreviewMessageC)))); if ($sMessageID) { $aForm['inputs']['control'][] = array('type' => 'submit', 'name' => 'delete_message', 'caption' => $sDeleteC, 'value' => $sDeleteC); } $sResult = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { if ($sAction == 'add') { if ($sMessageID > 0) { $oForm->update($sMessageID); } else { $sMessageID = $oForm->insert(); } } $sResult = $sMessageID > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC); } return DesignBoxContent(_t('_adm_mmail_Email_message'), $sResult . $oForm->getCode(), 11); }
/** * 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&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 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); }
function getManagingForm() { $sApplyChangesC = _t('_sys_admin_apply'); $sFromC = _t('_From'); $sToC = _t('_To'); $sSampleC = _t('_adm_ipbl_sample'); $sTypeC = _t('_adm_ipbl_IP_Role'); $sDescriptionC = _t('_Description'); $sDatatimeC = _t('_adm_ipbl_Date_of_finish'); $sErrorC = _t('_Error Occured'); $aForm = array('form_attrs' => array('name' => 'apply_ip_list_form', 'action' => $this->_sActionUrl, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_ip_list', 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('FromIP' => array('type' => 'text', 'name' => 'from', 'caption' => $sFromC, 'info' => $sSampleC . ': 10.0.0.0', 'required' => true, 'checker' => array('func' => 'length', 'params' => array(7, 15), 'error' => $sErrorC)), 'ToIP' => array('type' => 'text', 'name' => 'to', 'caption' => $sToC, 'info' => $sSampleC . ': 10.0.0.100', 'required' => true, 'checker' => array('func' => 'length', 'params' => array(7, 15), 'error' => $sErrorC)), 'IPRole' => array('type' => 'select', 'name' => 'type', 'caption' => $sTypeC, 'values' => array('allow', 'deny'), 'required' => true), 'DateTime' => array('type' => 'datetime', 'name' => 'LastDT', 'caption' => $sDatatimeC, 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => $sErrorC), 'db' => array('pass' => 'DateTime')), 'Desc' => array('type' => 'text', 'name' => 'desc', 'caption' => $sDescriptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(2, 128), 'error' => $sErrorC), 'db' => array('pass' => 'Xss')), 'ID' => array('type' => 'hidden', 'value' => '0', 'name' => 'id'), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sApplyChangesC))); $sResult = ''; $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { /*list($iDay, $iMonth, $iYear) = explode( '/', $_REQUEST['datatime']); $iDay = (int)$iDay; $iMonth = (int)$iMonth; $iYear = (int)$iYear; //$sCurTime = date("Y:m:d H:i:s");// 2012-06-20 15:46:21 $sCurTime = "{$iYear}:{$iMonth}:{$iDay} 12:00:00";*/ $sFrom = sprintf("%u", ip2long($_REQUEST['from'])); $sTo = sprintf("%u", ip2long($_REQUEST['to'])); $sType = (int) $_REQUEST['type'] == 1 ? 'deny' : 'allow'; $aValsAdd = array('From' => $sFrom, 'To' => $sTo, 'Type' => $sType); $iLastId = (int) $_REQUEST['id'] > 0 ? (int) $_REQUEST['id'] : -1; if ($iLastId > 0) { $oForm->update($iLastId, $aValsAdd); } else { $iLastId = $oForm->insert($aValsAdd); } $sResult = $iLastId > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC); } return $sResult . $oForm->getCode(); }
function getEditForm($aValues, $aAddFields = array()) { $oCategories = new BxDolCategories(); if (isset($this->_aForm['inputs']['categories'])) { //--- convert post form to edit one ---// $this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true, $aValues['categories']); } if (!empty($aValues) && is_array($aValues)) { foreach ($aValues as $sKey => $sValue) { if (array_key_exists($sKey, $this->_aForm['inputs'])) { if ($this->_aForm['inputs'][$sKey]['type'] == 'checkbox') { $this->_aForm['inputs'][$sKey]['checked'] = (int) $sValue == 1 ? true : false; } else { if ($this->_aForm['inputs'][$sKey]['type'] == 'select_box' && $this->_aForm['inputs'][$sKey]['name'] == 'Categories') { $aCategories = preg_split('/[' . $oCategories->sTagsDivider . ']/', $sValue, 0, PREG_SPLIT_NO_EMPTY); $this->_aForm['inputs'][$sKey]['value'] = $aCategories; } else { $this->_aForm['inputs'][$sKey]['value'] = $sValue; } } } } unset($this->_aForm['inputs']['author_id']); $this->_aForm['inputs']['id'] = array('type' => 'hidden', 'name' => 'id', 'value' => $aValues['id'], 'db' => array('pass' => 'Int')); $this->_aForm['inputs']['post']['value'] = _t("_td_edit"); } $oForm = new BxTemplFormView($this->_aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $iDateNow = mktime(); $iDatePublish = $oForm->getCleanValue('when'); if ($iDatePublish > $iDateNow) { $iStatus = BX_TD_STATUS_PENDING; } else { if ($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove()) { $iStatus = BX_TD_STATUS_ACTIVE; } else { $iStatus = BX_TD_STATUS_INACTIVE; } } $aDefFields = array('date' => $iDateNow, 'status' => $iStatus); $oForm->update($aValues['id'], array_merge($aDefFields, $aAddFields)); //--- 'System' -> Edit for Alerts Engine ---// bx_import('BxDolAlerts'); $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'edit', $aValues['id'], $this->_iOwnerId); $oAlert->alert(); //--- 'System' -> Edit for Alerts Engine ---// //--- Reparse Global Tags ---// $oTags = new BxDolTags(); $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues['id']); //--- Reparse Global Tags ---// //--- Reparse Global Categories ---// $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues['id']); //--- Reparse Global Categories ---// header('Location: ' . $oForm->aFormAttrs['action']); } else { return $oForm->getCode(); } }
function _getLevelsCreateForm($iLevelId, $bActive = false) { $sSubmitUrl = BX_DOL_URL_ADMIN . 'memb_levels.php'; $aLevel = array(); if (($bEdit = $iLevelId != 0) === true) { $aLevel = $GLOBALS['MySQL']->getRow("SELECT `Name` AS `Name`, `Description` AS `Description`, `Order` AS `Order` FROM `sys_acl_levels` WHERE `ID`='" . $iLevelId . "' LIMIT 1"); } $aForm = array('form_attrs' => array('id' => 'adm-mlevels-create', 'action' => $sSubmitUrl . '?tab=levels_add', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'sys_acl_levels', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'Submit')), 'inputs' => array('Active' => array('type' => 'hidden', 'name' => 'Active', 'value' => 'no', 'db' => array('pass' => 'Xss')), 'Purchasable' => array('type' => 'hidden', 'name' => 'Purchasable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Removable' => array('type' => 'hidden', 'name' => 'Removable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Name' => array('type' => 'text', 'name' => 'Name', 'caption' => _t('_adm_txt_mlevels_name'), 'value' => isset($aLevel['Name']) ? $aLevel['Name'] : '', 'required' => true, 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_adm_txt_mlevels_name_err'))), 'Icon' => array('type' => 'file', 'name' => 'Icon', 'caption' => _t('_adm_txt_mlevels_icon'), 'required' => true, 'checker' => array('func' => '', 'params' => '', 'error' => _t('_adm_txt_mlevels_icon_err'))), 'Description' => array('type' => 'textarea', 'name' => 'Description', 'caption' => _t('_adm_txt_mlevels_description'), 'value' => isset($aLevel['Description']) ? $aLevel['Description'] : '', 'db' => array('pass' => 'XssHtml')), 'Order' => array('type' => 'text', 'name' => 'Order', 'caption' => _t('_adm_txt_mlevels_order'), 'value' => isset($aLevel['Order']) ? $aLevel['Order'] : 0, 'required' => true, 'db' => array('pass' => 'Int'), 'checker' => array('func' => 'preg', 'params' => array('/^[1-9][0-9]*$/'), 'error' => _t('_adm_txt_mlevels_order_err'))), 'Submit' => array('type' => 'submit', 'name' => 'Submit', 'value' => _t('_adm_btn_mlevels_add')))); //--- Convert Add to Edit if ($bEdit) { unset($aForm['inputs']['Active']); unset($aForm['inputs']['Purchasable']); unset($aForm['inputs']['Removable']); unset($aForm['inputs']['Icon']); $aForm['form_attrs']['action'] = $sSubmitUrl . '?action=edit&level=' . $iLevelId; $aForm['inputs']['Submit']['value'] = _t('_adm_btn_mlevels_save'); $aForm['inputs']['ID'] = array('type' => 'hidden', 'name' => 'ID', 'value' => $iLevelId, 'db' => array('pass' => 'Int')); } $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { //--- Add new level if (!$bEdit) { $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/'; $sFileName = time(); $sFileExt = ''; if ($GLOBALS['MySQL']->getOne("SELECT `Name` FROM `sys_acl_levels` WHERE `Name`='" . $oForm->getCleanValue('Name') . "' LIMIT 1")) { $oForm->aInputs['Name']['error'] = _t('_adm_txt_mlevels_name_err_non_uniq'); } elseif (isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt)) { $sPath = $sFilePath . $sFileName . '.' . $sFileExt; imageResize($sPath, $sPath, 110, 110); $iId = (int) $oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt)); if ($iId != 0) { $sName = $oForm->getCleanValue('Name'); addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName); } header('Location: ' . $sSubmitUrl); exit; } else { $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error']; } } else { $bResult = $oForm->update($iLevelId); if ($bResult !== false) { deleteStringFromLanguage('_adm_txt_mp_' . strtolower($aLevel['Name'])); $sName = $oForm->getCleanValue('Name'); addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName); } header('Location: ' . $sSubmitUrl); exit; } } return $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_create.html', array('display' => $bActive ? 'block' : 'none', 'form' => $oForm->getCode())); }