/***************************************************************************
* Dolphin Smart Community Builder
* -----------------
* begin : Mon Mar 23 2006
* copyright : (C) 2006 BoonEx Group
* website : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
require_once( '../inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
$logged['admin'] = member_auth( 1 );
$ADMIN = $logged['admin'];
if( $_POST['action'] == 'banner_upload' && strlen($_FILES['banner_upload']['name']) )
{
$new_filename = "{$dir['banners']}{$_FILES['banner_upload']['name']}";
$scan = getimagesize( $_FILES['banner_upload']['tmp_name'] );
if ( $scan && ( 1 == $scan[2] || 2 == $scan[2] || 3 == $scan[2] || 4 == $scan[2] || 6 == $scan[2] )
&& move_uploaded_file( $_FILES['banner_upload']['tmp_name'], $new_filename ) )
{
$f = fopen ($new_filename, "r");
if (!$f)
{
$status_text = "Cannot open file for read";
}
else
{
$fsize = filesize ($new_filename);
$buffer = fread ($f, $fsize);
fclose ($f);
chmod( $new_filename, 0644 );
$i_arr = getimagesize( $new_filename );
$filename = process_db_input($_FILES['banner_upload']['name']);
$result = db_res("INSERT INTO aff_banners (Banner, XSize, YSize) VALUES ( '$filename', '$i_arr[0]', '$i_arr[1]' ) ");
$status_text = "File {$_FILES['banner_upload']['name']} successfully uploaded.";
}
}
else
{
$status_text = "Error: file wasn't uploaded";
}
}
// - delete (uncheck) banner ----------------
if ( !$demo_mode && $_POST['prf_form_submit'] == "Delete" )
{
$i = 0;
while( list( $key, $val ) = each( $_POST ) )
{
if ( (int)$key && $val == "on" )
{
$res = db_res("DELETE FROM aff_banners WHERE `ID` = '$key'");
if (!$res)
{
$err = 1;
break;
}
++$i;
}
}
if ( $err )
$status_text = "Banner was NOT successfully deleted";
else
$status_text = "$i banner(s) was(were) successfully deleted.";
}
// - edit banner ------------------
if ( !$demo_mode && (int)$_GET['EditBanner'] )
{
$editban_arr = db_arr( "SELECT * FROM aff_banners WHERE ID = '". (int)$_GET['EditBanner']. "'" );
}
if ( $_POST['EditBannerSubmit'] )
{
$xsize = (int)$_POST['XSize'];
$ysize = (int)$_POST['YSize'];
$banner_name = process_db_input( $_POST['BannerName'] );
$status = $_POST['Status'] == 'active' ? 'Active' : 'Approval';
$text = process_db_input( $_POST['Text'] );
$banner_id = (int)$_POST['ID'];
$query = "UPDATE aff_banners SET `XSize` = $xsize, `YSize` = $ysize, `BannerName` = '$banner_name', `Status` = '$status', `Text` = '$text' WHERE `ID` = $banner_id";
$res = db_res($query);
if ( $res )
$status_text = "Banner was successfully updated";
else
$status_text = "Banner was NOT successfully updated.";
}
$page = (int)$_GET['page'];
$p_per_page = (int)$_GET['p_per_page'];
if ( !$page )
$page = 1;
if ( !$p_per_page )
$p_per_page = 30;
// ------------------------------
$p_num = db_arr( "SELECT COUNT(*) FROM aff_banners WHERE Added='1'" );
$p_num = $p_num[0];
$pages_num = ceil( $p_num / $p_per_page );
$real_first_p = (int)($page - 1) * $p_per_page;
$page_first_p = $real_first_p + 1;
$result = db_res( "SELECT ID, XSize, YSize, Banner, BannerName, Status, Text, Added, COUNT(ID) AS m_count FROM aff_banners GROUP BY ID $part_addon ORDER BY ID ASC LIMIT $real_first_p, $p_per_page" );
$page_p_num = mysql_num_rows( $result );
$_page['header'] = "Banner List";
$_page['header_text'] = "Banner List";
TopCodeAdmin();
ContentBlockHead("Upload new banner");
if ( strlen($status_text) )
echo "