# GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $banner = null; if (isset($_POST['id'])) { $banner = $db->selectObject('banner_ad', 'id=' . intval($_POST['id'])); $loc = unserialize($banner->location_data); } if (exponent_permissions_check('manage', $loc)) { $filenew = $_FILES['file']['tmp_name']; $fileup = getimagesize($filenew); if ($fileup[2] > 0 && $fileup[1] > 0) { $banner = banner_ad::update($_POST, $banner); $banner->location_data = serialize($loc); if (!isset($banner->file_id)) { $directory = 'files/BannerModule/' . $loc->src; $file = file::update('file', $directory, null); if (is_object($file)) { $banner->file_id = $db->insertObject($file, 'file'); $db->insertObject($banner, 'banner_ad'); } else { // If file::update() returns a non-object, it should be a string. That string is the error message. $post = $_POST; $post['_formError'] = $file; exponent_sessions_set('last_POST', $post); header('Location: ' . $_SERVER['HTTP_REFERER']); } } else {
# GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } $banner = null; if (isset($_GET['id'])) { $banner = $db->selectObject('banner_ad', 'id=' . intval($_GET['id'])); if ($banner) { $loc = unserialize($banner->location_data); } } if (exponent_permissions_check('manage', $loc)) { $i18n = exponent_lang_loadFile('modules/BannerModule/actions/ad_edit.php'); $form = banner_ad::form($banner); $form->location($loc); $form->meta('action', 'ad_save'); if (is_really_writable(BASE . 'files/BannerModule/' . $loc->src)) { $form->registerBefore('submit', 'file', $i18n['file'], new uploadcontrol()); } else { $form->controls['submit']->disabled = 1; $form->registerBefore('name', null, '', new htmlcontrol('<div class="error">' . $i18n['no_upload'] . '</div>')); } $template = new template('BannerModule', '_form_ad_edit'); $template->assign('form_html', $form->toHTML()); $template->assign('is_edit', isset($_GET['id']) ? 1 : 0); $template->output(); } else { echo SITE_403_HTML; }