add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success'); } else { $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error'); } zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $_GET['bID'])); break; case 'setbanners_on_ssl': if ( ($_GET['flagbanners_on_ssl'] == '0') || ($_GET['flagbanners_on_ssl'] == '1') ) { $db->Execute("update " . TABLE_BANNERS . " set banners_on_ssl='" . $_GET['flagbanners_on_ssl'] . "' where banners_id='" . $_GET['bID'] . "'"); $messageStack->add_session(SUCCESS_BANNER_ON_SSL_UPDATED, 'success'); } else { $messageStack->add_session(ERROR_UNKNOWN_BANNER_ON_SSL, 'error'); } zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $_GET['bID'])); break; case 'setbanners_open_new_windows': if ( ($_GET['flagbanners_open_new_windows'] == '0') || ($_GET['flagbanners_open_new_windows'] == '1') ) { $db->Execute("update " . TABLE_BANNERS . " set banners_open_new_windows='" . $_GET['flagbanners_open_new_windows'] . "' where banners_id='" . $_GET['bID'] . "'"); $messageStack->add_session(SUCCESS_BANNER_OPEN_NEW_WINDOW_UPDATED, 'success'); } else { $messageStack->add_session(ERROR_UNKNOWN_BANNER_OPEN_NEW_WINDOW, 'error'); } zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $_GET['bID'])); break; case 'insert': case 'update': if (isset($_POST['banners_id'])) $banners_id = zen_db_prepare_input($_POST['banners_id']); $banners_title = zen_db_prepare_input($_POST['banners_title']); $banners_url = zen_db_prepare_input($_POST['banners_url']); $new_banners_group = zen_db_prepare_input($_POST['new_banners_group']); $banners_group = (empty($new_banners_group)) ? zen_db_prepare_input($_POST['banners_group']) : $new_banners_group; $banners_html_text = zen_db_prepare_input($_POST['banners_html_text']); $banners_image_local = zen_db_prepare_input($_POST['banners_image_local']); $banners_image_target = zen_db_prepare_input($_POST['banners_image_target']); $db_image_location = ''; $expires_date = zen_db_prepare_input($_POST['expires_date']); $expires_impressions = zen_db_prepare_input($_POST['expires_impressions']); $date_scheduled = zen_db_prepare_input($_POST['date_scheduled']); $status = zen_db_prepare_input($_POST['status']); $banners_open_new_windows = zen_db_prepare_input($_POST['banners_open_new_windows']); $banners_on_ssl = zen_db_prepare_input($_POST['banners_on_ssl']); $banners_sort_order = zen_db_prepare_input($_POST['banners_sort_order']); $banner_error = false; if (empty($banners_title)) { $messageStack->add(ERROR_BANNER_TITLE_REQUIRED, 'error'); $banner_error = true; } if (empty($banners_group)) { $messageStack->add(ERROR_BANNER_GROUP_REQUIRED, 'error'); $banner_error = true; } if (empty($banners_html_text)) { if (empty($banners_image_local)) { $banners_image = new upload('banners_image'); $banners_image->set_destination(DIR_FS_CATALOG_IMAGES . $banners_image_target); if ( ($banners_image->parse() == false) || ($banners_image->save() == false) ) { $messageStack->add(ERROR_BANNER_IMAGE_REQUIRED, 'error'); $banner_error = true; } } } if ($banner_error == false) { $db_image_location = (zen_not_null($banners_image_local)) ? $banners_image_local : $banners_image_target . $banners_image->filename; $sql_data_array = array('banners_title' => $banners_title, 'banners_url' => $banners_url, 'banners_image' => $db_image_location, 'banners_group' => $banners_group, 'banners_html_text' => $banners_html_text, 'status' => $status, 'banners_open_new_windows' => $banners_open_new_windows, 'banners_on_ssl' => $banners_on_ssl, 'banners_sort_order' => (int)$banners_sort_order); if ($action == 'insert') { $insert_sql_data = array('date_added' => 'now()', 'status' => '1'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); zen_db_perform(TABLE_BANNERS, $sql_data_array); $banners_id = zen_db_insert_id(); $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success'); } elseif ($action == 'update') { zen_db_perform(TABLE_BANNERS, $sql_data_array, 'update', "banners_id = '" . (int)$banners_id . "'"); $messageStack->add_session(SUCCESS_BANNER_UPDATED, 'success'); } // NOTE: status will be reset by the /functions/banner.php if (zen_not_null($expires_date)) { list($day, $month, $year) = explode('/', $expires_date); $expires_date = $year . ((strlen($month) == 1) ? '0' . $month : $month) . ((strlen($day) == 1) ? '0' . $day : $day); $db->Execute("update " . TABLE_BANNERS . " set expires_date = '" . zen_db_input($expires_date) . "', expires_impressions = null where banners_id = '" . (int)$banners_id . "'"); } elseif (zen_not_null($expires_impressions)) { $db->Execute("update " . TABLE_BANNERS . " set expires_impressions = '" . zen_db_input($expires_impressions) . "', expires_date = null where banners_id = '" . (int)$banners_id . "'"); } if (zen_not_null($date_scheduled)) { list($day, $month, $year) = explode('/', $date_scheduled); $date_scheduled = $year . ((strlen($month) == 1) ? '0' . $month : $month) . ((strlen($day) == 1) ? '0' . $day : $day); $db->Execute("update " . TABLE_BANNERS . " set date_scheduled = '" . zen_db_input($date_scheduled) . "' where banners_id = '" . (int)$banners_id . "'"); } else { $db->Execute("update " . TABLE_BANNERS . " set date_scheduled = null where banners_id = '" . (int)$banners_id . "'"); } zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'bID=' . $banners_id)); } else { $action = 'new'; } break; case 'deleteconfirm': $banners_id = zen_db_prepare_input($_GET['bID']); if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) { $banner = $db->Execute("select banners_image from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); if (is_file(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image'])) { if (is_writeable(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image'])) { unlink(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image']); } else { $messageStack->add_session(ERROR_IMAGE_IS_NOT_WRITEABLE, 'error'); } } else { $messageStack->add_session(ERROR_IMAGE_DOES_NOT_EXIST, 'error'); } } $db->Execute("delete from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); $db->Execute("delete from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$banners_id . "'"); if (function_exists('imagecreate') && zen_not_null($banner_extension)) { if (is_file(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { unlink(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension); } } if (is_file(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension)) { if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension)) { unlink(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension); } } if (is_file(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension)) { if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension)) { unlink(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension); } } if (is_file(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension)) { if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension)) { unlink(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension); } } } $messageStack->add_session(SUCCESS_BANNER_REMOVED, 'success'); zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'])); break; } } // check if the graphs directory exists $dir_ok = false; if (function_exists('imagecreate') && zen_not_null($banner_extension)) { if (is_dir(DIR_WS_IMAGES . 'graphs')) { if (is_writeable(DIR_WS_IMAGES . 'graphs')) { $dir_ok = true; } else { $messageStack->add(ERROR_GRAPHS_DIRECTORY_NOT_WRITEABLE, 'error'); } } else { $messageStack->add(ERROR_GRAPHS_DIRECTORY_DOES_NOT_EXIST, 'error'); } } ?> > <?php echo TITLE; ?>
'', 'date_scheduled' => '', 'banners_title' => '', 'banners_url' => '', 'banners_group' => '', 'banners_image' => '', 'banners_html_text' => '', 'expires_impressions' => '', 'banners_open_new_windows' => '', 'banners_on_ssl' => ''); $bInfo = new objectInfo($parameters); if (isset($_GET['bID'])) { $form_action = 'update'; $bID = zen_db_prepare_input($_GET['bID']); $banner = $db->Execute("select banners_title, banners_url, banners_image, banners_group, banners_html_text, status, date_format(date_scheduled, '%d/%m/%Y') as date_scheduled, date_format(expires_date, '%d/%m/%Y') as expires_date, expires_impressions, date_status_change, banners_open_new_windows, banners_on_ssl, banners_sort_order from " . TABLE_BANNERS . " where banners_id = '" . (int)$bID . "'"); $bInfo->objectInfo($banner->fields); } elseif (zen_not_null($_POST)) { $bInfo->objectInfo($_POST); } if (!isset($bInfo->status)) $bInfo->status = '1'; switch ($bInfo->status) { case '0': $is_status = false; $not_status = true; break; case '1': $is_status = true; $not_status = false; break; default: $is_status = true; $not_status = false; break; } if (!isset($bInfo->banners_open_new_windows)) $bInfo->banners_open_new_windows = '1'; switch ($bInfo->banners_open_new_windows) { case '0': $is_banners_open_new_windows = false; $not_banners_open_new_windows = true; break; case '1': $is_banners_open_new_windows = true; $not_banners_open_new_windows = false; break; default: $is_banners_open_new_windows = true; $not_banners_open_new_windows = false; break; } if (!isset($bInfo->banners_on_ssl)) $bInfo->banners_on_ssl = '1'; switch ($bInfo->banners_on_ssl) { case '0': $is_banners_on_ssl = false; $not_banners_on_ssl = true; break; case '1': $is_banners_on_ssl = true; $not_banners_on_ssl = false; break; default: $is_banners_on_ssl = true; $not_banners_on_ssl = false; break; } $groups_array = array(); $groups = $db->Execute("select distinct banners_group from " . TABLE_BANNERS . " order by banners_group"); while (!$groups->EOF) { $groups_array[] = array('id' => $groups->fields['banners_group'], 'text' => $groups->fields['banners_group']); $groups->MoveNext(); } ?>
' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . ' ' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON); ?> ' . zen_image(DIR_WS_IMAGES . 'icon_blue_on.gif', IMAGE_ICON_BANNER_ON_SSL_ON) . ' ' . zen_image(DIR_WS_IMAGES . 'icon_blue_off.gif', IMAGE_ICON_BANNER_ON_SSL_OFF); ?> ' . zen_image(DIR_WS_IMAGES . 'icon_orange_on.gif', IMAGE_ICON_BANNER_OPEN_NEW_WINDOWS_ON) . ' ' . zen_image(DIR_WS_IMAGES . 'icon_orange_off.gif', IMAGE_ICON_BANNER_OPEN_NEW_WINDOWS_OFF); ?>
' . TEXT_INFO_BANNER_STATUS; ?>
' . TEXT_INFO_BANNER_OPEN_NEW_WINDOWS; ?>
' . TEXT_INFO_BANNER_ON_SSL; ?>
banners_title, zen_set_field_length(TABLE_BANNERS, 'banners_title'), true); ?>
banners_url, zen_set_field_length(TABLE_BANNERS, 'banners_url')); ?>
banners_group) . TEXT_BANNERS_NEW_GROUP . '
' . zen_draw_input_field('new_banners_group', '', '', ((sizeof($groups_array) > 0) ? false : true)); ?>
' . DIR_FS_CATALOG_IMAGES . zen_draw_input_field('banners_image_local', (isset($bInfo->banners_image) ? $bInfo->banners_image : ''), zen_set_field_length(TABLE_BANNERS, 'banners_image')); ?>
' . zen_draw_textarea_field('banners_html_text', 'soft', '60', '5', $bInfo->banners_html_text); ?>
' . zen_draw_input_field('banners_sort_order', $bInfo->banners_sort_order, zen_set_field_length(TABLE_BANNERS, 'banners_sort_order'), false); ?>

(dd/mm/yyyy)

(dd/mm/yyyy)
' . zen_draw_input_field('expires_impressions', $bInfo->expires_impressions, 'maxlength="7" size="7"') . ' ' . TEXT_BANNERS_IMPRESSIONS; ?>
' . TEXT_BANNERS_INSERT_NOTE . '
' . TEXT_BANNERS_EXPIRCY_NOTE . '
' . TEXT_BANNERS_SCHEDULE_NOTE; ?>
' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
'' . $bInfo->banners_title . ''); $contents = array('form' => zen_draw_form('banners', FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $bInfo->banners_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '
' . $bInfo->banners_title . ''); if ($bInfo->banners_image) $contents[] = array('text' => '
' . zen_draw_checkbox_field('delete_image', 'on', true) . ' ' . TEXT_INFO_DELETE_IMAGE); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (is_object($bInfo)) { $heading[] = array('text' => '' . $bInfo->banners_title . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_BANNERS_DATE_ADDED . ' ' . zen_date_short($bInfo->date_added)); if ( (function_exists('imagecreate')) && ($dir_ok) && ($banner_extension) ) { $banner_id = $bInfo->banners_id; $days = '3'; include(DIR_WS_INCLUDES . 'graphs/banner_infobox.php'); $contents[] = array('align' => 'center', 'text' => '
' . zen_image(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banner_id . '.' . $banner_extension)); } else { include(DIR_WS_FUNCTIONS . 'html_graphs.php'); $contents[] = array('align' => 'center', 'text' => '
' . zen_banner_graph_infoBox($bInfo->banners_id, '3')); } $contents[] = array('text' => zen_image(DIR_WS_IMAGES . 'graph_hbar_blue.gif', 'Blue', '5', '5') . ' ' . TEXT_BANNERS_BANNER_VIEWS . '
' . zen_image(DIR_WS_IMAGES . 'graph_hbar_red.gif', 'Red', '5', '5') . ' ' . TEXT_BANNERS_BANNER_CLICKS); if ($bInfo->date_scheduled) $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_SCHEDULED_AT_DATE, zen_date_short($bInfo->date_scheduled))); if ($bInfo->expires_date) { $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_EXPIRES_AT_DATE, zen_date_short($bInfo->expires_date))); } elseif ($bInfo->expires_impressions) { $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_EXPIRES_AT_IMPRESSIONS, $bInfo->expires_impressions)); } if ($bInfo->date_status_change) $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_STATUS_CHANGE, zen_date_short($bInfo->date_status_change))); } break; } if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { echo ' ' . "\n"; } ?>
Execute($banners_query_raw); $check_count=1; if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS) { while (!$check_page->EOF) { if ($check_page->fields['banners_id'] == $_GET['bID']) { break; } $check_count++; $check_page->MoveNext(); } $_GET['page'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS) !=0 ? .5 : 0)),0); } else { $_GET['page'] = 1; } } $banners_query_raw = "select banners_id, banners_title, banners_image, banners_group, status, expires_date, expires_impressions, date_status_change, date_scheduled, date_added, banners_open_new_windows, banners_on_ssl, banners_sort_order from " . TABLE_BANNERS . " order by banners_title, banners_group"; $banners_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $banners_query_raw, $banners_query_numrows); $banners = $db->Execute($banners_query_raw); while (!$banners->EOF) { $info = $db->Execute("select sum(banners_shown) as banners_shown, sum(banners_clicked) as banners_clicked from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$banners->fields['banners_id'] . "'"); if ((!isset($_GET['bID']) || (isset($_GET['bID']) && ($_GET['bID'] == $banners->fields['banners_id']))) && !isset($bInfo) && (substr($action, 0, 3) != 'new')) { $bInfo_array = array_merge($banners->fields, $info->fields); $bInfo = new objectInfo($bInfo_array); } $banners_shown = ($info->fields['banners_shown'] != '') ? $info->fields['banners_shown'] : '0'; $banners_clicked = ($info->fields['banners_clicked'] != '') ? $info->fields['banners_clicked'] : '0'; if (isset($bInfo) && is_object($bInfo) && ($banners->fields['banners_id'] == $bInfo->banners_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
fields['banners_id'] . '\')">' . zen_image(DIR_WS_IMAGES . 'icon_popup.gif', 'View Banner') . ' ' . $banners->fields['banners_title']; ?> fields['banners_group']; ?> fields['status'] == '1') { echo '' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . ''; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . ''; } ?> fields['banners_open_new_windows'] == '1') { echo '' . zen_image(DIR_WS_IMAGES . 'icon_orange_on.gif', IMAGE_ICON_BANNER_OPEN_NEW_WINDOWS_ON) . ''; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_orange_off.gif', IMAGE_ICON_BANNER_OPEN_NEW_WINDOWS_OFF) . ''; } ?> fields['banners_on_ssl'] == '1') { echo '' . zen_image(DIR_WS_IMAGES . 'icon_blue_on.gif', IMAGE_ICON_BANNER_ON_SSL_ON) . ''; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_blue_off.gif', IMAGE_ICON_BANNER_ON_SSL_OFF) . ''; } ?> fields['banners_sort_order']; ?> fields['banners_id']) . '">' . zen_image(DIR_WS_ICONS . 'statistics.gif', ICON_STATISTICS) . ' '; if (isset($bInfo) && is_object($bInfo) && ($banners->fields['banners_id'] == $bInfo->banners_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
display_count($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_BANNERS); ?> display_links($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?>
' . zen_image_button('button_new_banner.gif', IMAGE_NEW_BANNER) . ''; ?>
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '