add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success'); } else { $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error'); } tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['page'] . '&bID=' . $HTTP_GET_VARS['bID'])); break; case 'insert': case 'update': if (isset($HTTP_POST_VARS['banners_id'])) $banners_id = tep_db_prepare_input($HTTP_POST_VARS['banners_id']); $banners_title = tep_db_prepare_input($HTTP_POST_VARS['banners_title']); $banners_url = tep_db_prepare_input($HTTP_POST_VARS['banners_url']); $new_banners_group = tep_db_prepare_input($HTTP_POST_VARS['new_banners_group']); $banners_group = (empty($new_banners_group)) ? tep_db_prepare_input($HTTP_POST_VARS['banners_group']) : $new_banners_group; $banners_html_text = tep_db_prepare_input($HTTP_POST_VARS['banners_html_text']); $banners_image_local = tep_db_prepare_input($HTTP_POST_VARS['banners_image_local']); $banners_image_target = tep_db_prepare_input($HTTP_POST_VARS['banners_image_target']); $db_image_location = ''; $expires_date = tep_db_prepare_input($HTTP_POST_VARS['expires_date']); $expires_impressions = tep_db_prepare_input($HTTP_POST_VARS['expires_impressions']); $date_scheduled = tep_db_prepare_input($HTTP_POST_VARS['date_scheduled']); $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) ) { $banner_error = true; } } } if ($banner_error == false) { $db_image_location = (tep_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); if ($action == 'insert') { $insert_sql_data = array('date_added' => 'now()', 'status' => '1'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_BANNERS, $sql_data_array); $banners_id = tep_db_insert_id(); $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success'); } elseif ($action == 'update') { tep_db_perform(TABLE_BANNERS, $sql_data_array, 'update', "banners_id = '" . (int)$banners_id . "'"); $messageStack->add_session(SUCCESS_BANNER_UPDATED, 'success'); } if (tep_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); tep_db_query("update " . TABLE_BANNERS . " set expires_date = '" . tep_db_input($expires_date) . "', expires_impressions = null where banners_id = '" . (int)$banners_id . "'"); } elseif (tep_not_null($expires_impressions)) { tep_db_query("update " . TABLE_BANNERS . " set expires_impressions = '" . tep_db_input($expires_impressions) . "', expires_date = null where banners_id = '" . (int)$banners_id . "'"); } if (tep_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); tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_scheduled = '" . tep_db_input($date_scheduled) . "' where banners_id = '" . (int)$banners_id . "'"); } tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'bID=' . $banners_id)); } else { $action = 'new'; } break; case 'deleteconfirm': $banners_id = tep_db_prepare_input($HTTP_GET_VARS['bID']); if (isset($HTTP_POST_VARS['delete_image']) && ($HTTP_POST_VARS['delete_image'] == 'on')) { $banner_query = tep_db_query("select banners_image from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); $banner = tep_db_fetch_array($banner_query); if (is_file(DIR_FS_CATALOG_IMAGES . $banner['banners_image'])) { if (is_writeable(DIR_FS_CATALOG_IMAGES . $banner['banners_image'])) { unlink(DIR_FS_CATALOG_IMAGES . $banner['banners_image']); } else { $messageStack->add_session(ERROR_IMAGE_IS_NOT_WRITEABLE, 'error'); } } else { $messageStack->add_session(ERROR_IMAGE_DOES_NOT_EXIST, 'error'); } } tep_db_query("delete from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); tep_db_query("delete from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$banners_id . "'"); if (function_exists('imagecreate') && tep_not_null($banner_extensio)) { 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'); tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['page'])); break; } } // check if the graphs directory exists $dir_ok = false; if (function_exists('imagecreate') && tep_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' => ''); $bInfo = new objectInfo($parameters); if (isset($HTTP_GET_VARS['bID'])) { $form_action = 'update'; $bID = tep_db_prepare_input($HTTP_GET_VARS['bID']); $banner_query = tep_db_query("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 from " . TABLE_BANNERS . " where banners_id = '" . (int)$bID . "'"); $banner = tep_db_fetch_array($banner_query); $bInfo->objectInfo($banner); } elseif (tep_not_null($HTTP_POST_VARS)) { $bInfo->objectInfo($HTTP_POST_VARS); } $groups_array = array(); $groups_query = tep_db_query("select distinct banners_group from " . TABLE_BANNERS . " order by banners_group"); while ($groups = tep_db_fetch_array($groups_query)) { $groups_array[] = array('id' => $groups['banners_group'], 'text' => $groups['banners_group']); } ?>
banners_title, '', true); ?>
banners_url); ?>
banners_group) . TEXT_BANNERS_NEW_GROUP . '
' . tep_draw_input_field('new_banners_group', '', '', ((sizeof($groups_array) > 0) ? false : true)); ?>
' . DIR_FS_CATALOG_IMAGES . tep_draw_input_field('banners_image_local', (isset($bInfo->banners_image) ? $bInfo->banners_image : '')); ?>
banners_html_text); ?>

(dd/mm/yyyy)

(dd/mm/yyyy)
' . tep_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; ?>
' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
'' . $bInfo->banners_title . ''); $contents = array('form' => tep_draw_form('banners', FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['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' => '
' . tep_draw_checkbox_field('delete_image', 'on', true) . ' ' . TEXT_INFO_DELETE_IMAGE); $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (is_object($bInfo)) { $heading[] = array('text' => '' . $bInfo->banners_title . ''); $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_BANNERS_DATE_ADDED . ' ' . tep_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' => '
' . tep_image(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banner_id . '.' . $banner_extension)); } else { include(DIR_WS_FUNCTIONS . 'html_graphs.php'); $contents[] = array('align' => 'center', 'text' => '
' . tep_banner_graph_infoBox($bInfo->banners_id, '3')); } $contents[] = array('text' => tep_image(DIR_WS_IMAGES . 'graph_hbar_blue.gif', 'Blue', '5', '5') . ' ' . TEXT_BANNERS_BANNER_VIEWS . '
' . tep_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, tep_date_short($bInfo->date_scheduled))); if ($bInfo->expires_date) { $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_EXPIRES_AT_DATE, tep_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, tep_date_short($bInfo->date_status_change))); } break; } if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { echo ' ' . "\n"; } ?>
banners_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?>
 
' . tep_image(DIR_WS_IMAGES . 'icon_popup.gif', 'View Banner') . ' ' . $banners['banners_title']; ?> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', 'Set Inactive', 10, 10) . ''; } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', 'Set Active', 10, 10) . '  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', 'Inactive', 10, 10); } ?> ' . tep_image(DIR_WS_ICONS . 'statistics.gif', ICON_STATISTICS) . ' '; if (isset($bInfo) && is_object($bInfo) && ($banners['banners_id'] == $bInfo->banners_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
display_count($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_BANNERS); ?> display_links($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
' . tep_image_button('button_new_banner.gif', IMAGE_NEW_BANNER) . ''; ?>
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '