|
From: OryNider <ory...@us...> - 2007-06-06 22:24:41
|
Update of /cvsroot/mxbb/mx_phpCA/ads_mod In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3371/ads_mod Added Files: ads_common.php ads_constants.php ads_functions.php ads_integration.php ads_renewal_mailer.php index.html Log Message: --- NEW FILE: index.html --- <html> <head> <title>Mx phpCA - Classified Ads Module</title> </head> <body> <br /><br /><br /><br /><br /><br /><br /> <center><h1><a href="http://www.phpca.net">http://www.phpca.net</a></h1></center> </body> --- NEW FILE: ads_common.php --- <? /*************************************************************************** * ads_common.php * ------------------- * begin : Wednesday, Feb 15, 2006 * copyright : (C) 2006 Peter Mansion * email : su...@ph... * * $Id: ads_common.php,v 1.1 2007/06/06 22:24:31 orynider Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } define('IN_ADS', true); if ( !defined('ADS_MOD_PATH') ) { define('ADS_MOD_PATH', 'ads_mod/'); } if (!isset($ads_root_path) || empty($ads_root_path)) { $ads_root_path = $module_root_path . ADS_MOD_PATH . ''; } include_once($ads_root_path . 'ads_constants.'.$phpEx); // ********************************************************************** // Read language definition // ********************************************************************** if ( !file_exists( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_main.' . $phpEx ); $link_language='lang_english'; } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx ); $link_language='lang_' . $board_config['default_lang']; } // ********************************************************************** // Read theme definition and language in theme definition // ********************************************************************** if ( file_exists( $module_root_path . "templates/" . $theme['template_name'] . $theme['template_name'] . ".cfg" ) ) { // ---------- include($module_root_path . "templates/" . $theme['template_name'] . $theme['template_name'] . ".cfg"); // ---------- } else { // ---------- include($module_root_path . "templates/" . "subSilver/" . "subSilver.cfg"); // ---------- } // // Get Ads Config // $sql = "SELECT * FROM ". ADS_CONFIG_TABLE; if ( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not query ads config information", "", __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) { $ads_config_name = $row['config_name']; $ads_config_value = $row['config_value']; $ads_config[$ads_config_name] = $ads_config_value; } // // Check the version // if ( !$ads_config['version'] == '0.5.5' ) { message_die(GENERAL_ERROR, "Script and data out of sync. Please run dbupgrade.php", "", __LINE__, __FILE__); } // // Get Paid Ads Config // if ( $ads_config['paid_ads'] == 1 ) { $sql = "SELECT * FROM ". ADS_PAID_ADS_CONFIG_TABLE; if ( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not query paid ads config information", "", __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) { $ads_config_name = $row['config_name']; $ads_config_value = $row['config_value']; $ads_config[$ads_config_name] = $ads_config_value; } } include_once($ads_root_path . 'ads_functions.' . $phpEx); include_once($ads_root_path . 'ads_integration.' . $phpEx); $module_name = 'phpCA Classified Ads'; $sql = "SELECT * FROM " . MODULE_TABLE . " WHERE module_name = '$module_name'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't obtain the module informations from database", '', __LINE__, __FILE__, $sql); } while( $module = $db->sql_fetchrow($result) ) { $ads_module_copy = $module['module_copy']; $ads_module_name = $module['module_name']; $ads_module_version = $module['module_version']; } if( !empty($ads_module_copy) ) { $ads_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; $ads_module_copyright .= 'Classified Ads Powered by: <a href="http://pubory.uv.ro/" target="_blank">OryNider</a>, mxBB <i> - ' . $ads_module_name . '</i> ' . $ads_module_version . ' © 2007 is modified by <a href="http://www.mx-system.com/">MX-Team</a><br />'; $ads_module_copyright .= '[based on © 2005, 2006 <a href="http://www.phpca.net" target="_blank">PeteMan</a> - <i>phpCA Classified Ads</i> v' . $ads_config['version'] . ']'; $ads_module_copyright .= '</div>'; } else { $ads_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; $ads_module_copyright .= 'Classified Ads Powered by: <a href="http://pubory.uv.ro/" target="_blank">OryNider</a>, mxBB <i> - Music Center</i> v2.0.x © 2007 is modified by <a href="http://www.mx-system.com/">MX-Team</a><br />'; $ads_module_copyright .= '[based on © 2005, 2006 <a href="http://www.phpca.net" target="_blank">PeteMan</a> - <i>phpCA Classified Ads</i> v' . $ads_config['version'] . ']'; $ads_module_copyright .= '</div>'; } $template->assign_vars(array( 'L_INDEX' => '<<', 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'U_ADS_INDEX' => append_sid(this_ads_mxurl()), 'L_ADS_INDEX' => $lang['ads_index'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])), 'L_FORUM' => $lang['Forum'], 'L_CLASSIFIED_ADS' => $lang['classified_ads'], 'ADS_COPYRIGHT' => $ads_module_copyright, 'L_SEARCH_ADS' => $lang['search_ads'], 'L_MY_ADS' => $lang['my_ads'], 'U_CLASSIFIED_ADS' => append_sid(this_ads_mxurl()), 'U_SEARCH_ADS' => append_sid(this_ads_mxurl("ads_mode=ads_search")), 'U_MY_ADS' => append_sid(this_ads_mxurl("ads_mode=ads_search&search_name=" . $userdata['username'])) ) ); ?> --- NEW FILE: ads_renewal_mailer.php --- <? /*************************************************************************** * ads_renewal_mailer.php * ------------------- * begin : Wednesday, Feb 15, 2006 * copyright : (C) 2006 Peter Mansion * email : su...@ph... * * $Id: ads_renewal_mailer.php,v 1.1 2007/06/06 22:24:34 orynider Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ $filename = ADS_CHASERS_PATH .date('dMy').'.txt'; $file = fopen($filename, 'w'); if ( !$file ) { message_die(GENERAL_ERROR, 'Error creating chaser log file'); } // Get all active ads $sql = "SELECT * FROM ". ADS_ADVERTS_TABLE ." WHERE status = 'active' AND USER_ID <> ". ADS_GUEST; $result = $db->sql_query($sql); if ( $db->sql_numrows($result) > 0 ) { // Seed the random number generator srand((double) microtime() * 1000000); while ($row = $db->sql_fetchrow($result)) { $id = $row['id']; $username = $row['username']; $expiry_date = $row['expiry_date']; $expiry_date2 = date($lang['DATE_FORMAT'],$row['expiry_date']); $status = $row['status']; $sql = "SELECT * FROM ". ADS_CHASERS_TABLE ." WHERE id = '$id'"; $result2 = $db->sql_query($sql); $row2 = $db->sql_fetchrow($result2); if ( !$row2 ) { // Is first chase due? if ( time() >= ($expiry_date - ($ads_config['first_chase_days']*60*60*24)) ) { // Get recipients details from phpBB $profiledata = get_userdata($username,'true'); $recip_email = $profiledata['user_email']; // Renewal passwords only for free ads! if ( $ads_config['paid_ads'] == 0 ) { $renewal_password = rand(0,999999999); $renewal_password_link = "&renewal_password=$renewal_password"; } else { $renewal_password = 0; } // Populate the email fields $renewal_url = 'http://'.$board_config['server_name'].$board_config['script_path'].'ads_item_renewal.'.$phpEx.'?id='.$id.$renewal_password_link; $message = str_replace('%exp%', $expiry_date2, $lang['first_renewal_message'])."\r\n\r\n"; $message = $message.$renewal_url."\r\n\r\n"; $message = $message.$board_config['board_email_sig']; // Send first chase chaser_email($board_config['board_email'], $recip_email, $lang['first_renewal_title'], $message); // Add a row to the chasers table $last_chase_type = '1'; $sql = "INSERT INTO ". ADS_CHASERS_TABLE . " VALUES ($id, '$last_chase_type', $renewal_password)"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not insert chasers row', '', __LINE__, __FILE__, $sql); } // Create a record on the log file $record = $username.";".$expiry_date2.";".$lang['first_renewal_title']."\r\n"; fwrite ($file, $record); } } else { // Is second chase due? if ( $row2['last_chase_type'] == '1' and time() >= ($expiry_date - ($ads_config['second_chase_days']*60*60*24)) ) { // Get recipients details from phpBB $profiledata = get_userdata($username,'true'); $recip_email = $profiledata['user_email']; // Renewal passwords only for free ads! if ( $ads_config['paid_ads'] == 0 ) { $renewal_password = rand(0,999999999); $renewal_password_link = "&renewal_password=$renewal_password"; } else { $renewal_password = 0; } // Populate the email fields $renewal_url = 'http://'.$board_config['server_name'].$board_config['script_path'].'ads_item_renewal.'.$phpEx.'?id='.$id.$renewal_password_link; $message = str_replace('%exp%', $expiry_date2, $lang['second_renewal_message'])."\r\n\r\n"; $message = $message.$renewal_url."\r\n\r\n"; $message = $message.$board_config['board_email_sig']; // Send second chase chaser_email($board_config['board_email'], $recip_email, $lang['second_renewal_title'], $message); // Update the chasers table $last_chase_type = '2'; $sql = "UPDATE ". ADS_CHASERS_TABLE ." SET last_chase_type = '$last_chase_type' WHERE id = $id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update chasers data', '', __LINE__, __FILE__, $sql); } // Create a record on the log file $record = $username.";".$expiry_date2.";".$lang['second_renewal_title']."\r\n"; fwrite ($file, $record); } // Is final chase due? if ( $row2['last_chase_type'] == '2' and time() >= $expiry_date ) { // Get recipients details from phpBB $profiledata = get_userdata($username,'true'); $recip_email = $profiledata['user_email']; // Renewal passwords only for free ads! if ( $ads_config['paid_ads'] == 0 ) { $renewal_password = rand(0,999999999); $renewal_password_link = "&renewal_password=$renewal_password"; } else { $renewal_password = 0; } // Populate the email fields $renewal_url = 'http://'.$board_config['server_name'].$board_config['script_path'].'ads_item_renewal.'.$phpEx.'?id='.$id.$renewal_password_link; $message = str_replace('%exp%', $expiry_date2, $lang['final_renewal_message'])."\r\n\r\n"; $message = $message.$renewal_url."\r\n\r\n"; $message = $message.$board_config['board_email_sig']; // Send second chase chaser_email($board_config['board_email'], $recip_email, $lang['final_renewal_title'], $message); // Update the chasers table $last_chase_type = 'F'; $sql = "UPDATE ". ADS_CHASERS_TABLE ." SET last_chase_type = '$last_chase_type' WHERE id = $id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update chasers data', '', __LINE__, __FILE__, $sql); } // Create a record on the log file $record = $username.";".$expiry_date2.";".$lang['final_renewal_title']."\r\n"; fwrite ($file, $record); // Expire the ad if active $status = 'expired'; $sql = "UPDATE ". ADS_ADVERTS_TABLE ." SET status = '$status' WHERE id = $id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update chasers data', '', __LINE__, __FILE__, $sql); } // Delete the images $sql = "SELECT * FROM ". ADS_IMAGES_TABLE ." WHERE id = $id AND img_deleted_ind = 0"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $img_seq_no = $row['img_seq_no']; $sql2 = "UPDATE ". ADS_IMAGES_TABLE ." SET img_deleted_ind = 1 WHERE id = '$id' AND img_seq_no = '$img_seq_no'"; if ( !$result2 = $db->sql_query($sql2) ) { message_die(GENERAL_ERROR, 'Could not update this image', '', __LINE__, __FILE__, $sql2); } $filename = ADS_IMAGES_PATH .'ad'.$id.'_img'.$img_seq_no.'_thumb.jpg'; unlink($filename); $filename = ADS_IMAGES_PATH .'ad'.$id.'_img'.$img_seq_no.'_medium.jpg'; unlink($filename); $filename = ADS_IMAGES_PATH .'ad'.$id.'_img'.$img_seq_no.'_large.jpg'; unlink($filename); } } } } } $record = $lang['successful_completion']."\r\n"; fwrite ($file, $record); fclose ($file); ?> --- NEW FILE: ads_constants.php --- <? /*************************************************************************** * ads_constants.php * ------------------- * begin : Wednesday, Feb 15, 2006 * copyright : (C) 2006 Peter Mansion * email : su...@ph... * * $Id: ads_constants.php,v 1.1 2007/06/06 22:24:31 orynider Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } // User Levels for Ads system <- do NOT change these values define('ADS_ANONYMOUS', -1); define('ADS_GUEST', -1); define('ADS_USER', 0); define('ADS_ADMIN', 1); define('ADS_MOD', 2); define('ADS_PRIVATE', 3); // Path (trailing slash required) define('ADS_IMAGES_PATH', $module_root_path . 'upload/images/'); // define('ADS_CHASERS_PATH', $module_root_path . 'upload/chasers/'); define('ADS_CHASERS_PATH', $module_root_path . 'upload/chasers/'); define('ADS_PAYMENTS_PATH', $module_root_path . 'upload/payments/'); // Table names !defined('ADS_ADVERTS_TABLE') ? define('ADS_ADVERTS_TABLE', $mx_table_prefix.'ads_adverts') : false; !defined('ADS_CATEGORIES_TABLE') ? define('ADS_CATEGORIES_TABLE', $mx_table_prefix.'ads_categories') : false; !defined('ADS_CHASERS_TABLE') ? define('ADS_CHASERS_TABLE', $mx_table_prefix.'ads_chasers') : false; !defined('ADS_COMMENTS_TABLE') ? define('ADS_COMMENTS_TABLE', $mx_table_prefix.'ads_comments') : false; !defined('ADS_CONFIG_TABLE') ? define('ADS_CONFIG_TABLE', $mx_table_prefix.'ads_config') : false; !defined('ADS_DETAILS_TABLE') ? define('ADS_DETAILS_TABLE', $mx_table_prefix.'ads_details') : false; !defined('ADS_IMAGES_TABLE') ? define('ADS_IMAGES_TABLE', $mx_table_prefix.'ads_images') : false; !defined('ADS_PAID_ADS_CONFIG_TABLE') ? define('ADS_PAID_ADS_CONFIG_TABLE', $mx_table_prefix.'ads_paid_ads_config') : false; !defined('ADS_PAYPAL_PAYMENTS') ? define('ADS_PAYPAL_PAYMENTS', $mx_table_prefix.'ads_paypal_payments') : false; !defined('ADS_RATE_TABLE') ? define('ADS_RATE_TABLE', $mx_table_prefix.'ads_rate') : false; !defined('ADS_USERS_TABLE') ? define('ADS_USERS_TABLE', $mx_table_prefix.'ads_users') : false; ?> --- NEW FILE: ads_integration.php --- <?php /** * * @package mxBB Portal Module - mx_phpCA * @version $Id: ads_integration.php,v 1.1 2007/06/06 22:24:34 orynider Exp $ * @copyright (c) 2002-2006 [OryNider, ory...@rd...] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } $ads_index = $ads_config['index']; $override_default_pages = $ads_config['override_default_pages']; $integration_enabled = $ads_config['enable_integration']; // MX add-on // Generate paths for page and standalone mode // ...function based on original function written by Markus :-) function this_ads_mxurl($args = '', $force_standalone_mode = false) { global $mx_root_path, $module_root_path, $page_id, $ads_index, $phpEx, $integration_enabled, $is_block; if( $force_standalone_mode || !$is_block ) { $mxurl = $mx_root_path . 'modules/mx_phpCA/' . 'adverts.' . $phpEx . ($args == '' ? '' : '?' . $args); } else { $mxurl = $mx_root_path . 'index.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= '?page=' . $page_id . ($args == '' ? '' : '&' . $args); } else { $mxurl .= '?page=' . $ads_index . ($args == '' ? '' : '&' . $args); } } return $mxurl; } function this_ads_portalurl($args = '') { global $mx_root_path, $module_root_path, $page_id, $ads_index, $phpEx, $integration_enabled, $is_block; if( $integration_enabled != "1" ) { $mxurl = $mx_root_path . 'modules/mx_phpCA/' . 'adverts.' . $phpEx . ($args == '' ? '' : '?' . $args); } else { $mxurl = $mx_root_path . 'index.' . $phpEx . '?page=' . $ads_index . ($args == '' ? '' : '&' . $args); } return $mxurl; } function this_ads_loginurl($args = '', $force_standalone_mode = false) { global $mx_root_path, $module_root_path, $page_id, $ads_index, $phpEx, $integration_enabled, $is_block; $mxurl = $mx_root_path . 'index.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $page_id; } else { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $ads_index; } return $mxurl; } function this_ads_rssurl($args = '') { global $page_id, $ads_index, $phpEx; $mxurl = 'index.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= '?page=' . $page_id . ($args == '' ? '' : '&' . $args); } else { $mxurl .= '?page=' . $ads_index . ($args == '' ? '' : '&' . $args); } return $mxurl; } // -------------------------------------------------------------------------------- // That's all Folks! // -------------------------------------------------------------------------------- ?> --- NEW FILE: ads_functions.php --- <? /*************************************************************************** * ads_functions.php * ------------------- * begin : Wednesday, Feb 15, 2006 * copyright : (C) 2006 Peter Mansion * email : su...@ph... * * $Id: ads_functions.php,v 1.1 2007/06/06 22:24:33 orynider Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ // ========================= // View allowed // ========================= function view_allowed($view_level) { global $userdata, $phpEx; if ( $view_level == ADS_GUEST ) { $view_allowed = TRUE; } if ( $view_level == ADS_USER and $userdata['session_logged_in'] ) { $view_allowed = TRUE; } if ( $view_level == ADS_MOD and $userdata['user_level'] == MOD ) { $view_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $view_allowed = TRUE; } if ( $view_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Move allowed // ========================= function move_allowed($user_id, $ads_move_level) { global $userdata, $phpEx; if ( ( $ads_move_level == ADS_USER and $userdata['user_id'] == $user_id and $userdata['session_logged_in'] ) or ( $ads_move_level == ADS_USER and $userdata['user_level'] == MOD ) ) { $move_allowed = TRUE; } if ( $ads_move_level == ADS_MOD and $userdata['user_level'] == MOD ) { $move_allowed = TRUE; } if ($userdata['user_level'] == ADMIN ) { $move_allowed = TRUE; } if ( $move_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Search allowed // ========================= function search_allowed($search_level) { global $userdata, $phpEx; if ( $search_level == ADS_GUEST ) { $search_allowed = TRUE; } if ( $search_level == ADS_USER and $userdata['session_logged_in'] ) { $search_allowed = TRUE; } if ( $search_level == ADS_MOD and $userdata['user_level'] == MOD ) { $search_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $search_allowed = TRUE; } if ( $search_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Create allowed // ========================= function create_allowed($cat_create_level) { global $userdata, $phpEx; if ( $cat_create_level == ADS_GUEST ) { $create_allowed = TRUE; } else { if ( !$userdata['session_logged_in'] ) { redirect(append_sid("login.$phpEx?redirect=ads_create.$phpEx")); } } if ( $cat_create_level == ADS_USER ) { $create_allowed = TRUE; } if ( $cat_create_level == ADS_MOD and $userdata['user_level'] == MOD ) { $create_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $create_allowed = TRUE; } if ( $create_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Edit allowed // ========================= function edit_allowed($user_id, $cat_edit_level) { global $userdata, $phpEx; if ( ( $cat_edit_level == ADS_USER and $userdata['user_id'] == $user_id and $userdata['session_logged_in'] ) or ( $cat_edit_level == ADS_USER and $userdata['user_level'] == MOD ) ) { $edit_allowed = TRUE; } if ( $cat_edit_level == ADS_MOD and $userdata['user_level'] == MOD ) { $edit_allowed = TRUE; } if ($userdata['user_level'] == ADMIN ) { $edit_allowed = TRUE; } if ( $edit_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Delete allowed // ========================= function delete_allowed($user_id, $cat_delete_level) { global $userdata, $phpEx; if ( ( $cat_delete_level == ADS_USER and $userdata['user_id'] == $user_id and $userdata['session_logged_in'] ) or ( $cat_delete_level == ADS_USER and $userdata['user_level'] == MOD ) ) { $delete_allowed = TRUE; } if ( $cat_delete_level == ADS_MOD and $userdata['user_level'] == MOD ) { $delete_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $delete_allowed = TRUE; } if ( $delete_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Image allowed // ========================= function image_allowed($user_id, $cat_image_level) { global $userdata, $phpEx; if ( ( $cat_image_level == ADS_USER and $userdata['user_id'] == $user_id and $userdata['session_logged_in'] ) or ( $cat_image_level == ADS_USER and $userdata['user_level'] == MOD ) ) { $image_allowed = TRUE; } if ( $cat_image_level == ADS_MOD and $userdata['user_level'] == MOD ) { $image_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $image_allowed = TRUE; } if ( $image_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================= // Comment allowed // ========================= function comment_allowed($cat_comment_level) { global $userdata, $phpEx; if ( $cat_comment_level == ADS_GUEST ) { $comment_allowed = TRUE; } if ( $cat_comment_level == ADS_USER and $userdata['session_logged_in'] ) { $comment_allowed = TRUE; } if ( $cat_comment_level == ADS_MOD and $userdata['user_level'] == MOD ) { $comment_allowed = TRUE; } if ( $userdata['user_level'] == ADMIN ) { $comment_allowed = TRUE; } if ( $comment_allowed == TRUE) { return TRUE; } else { return FALSE; } } // ========================================================== // ResizeImage - based on an original script by PHPGarage.com // ========================================================== function ResizeImage($im, $resizewidth, $resizeheight, $filename) { $width = imagesx($im); $height = imagesy($im); if (($resizewidth and $width > $resizewidth) or ($resizeheight and $height > $resizeheight)) { if ($resizewidth and $width > $resizewidth) { $widthratio = $resizewidth/$width; $resizewidth_ind = true; } if ($resizeheight and $height > $resizeheight) { $heightratio = $resizeheight/$height; $resizeheight_ind = true; } if ($resizewidth_ind and $resizeheight_ind) { if ($widthratio < $heightratio) { $ratio = $widthratio; } else { $ratio = $heightratio; } } elseif ($resizewidth_ind) { $ratio = $widthratio; } elseif ($resizeheight_ind) { $ratio = $heightratio; } $newwidth = $width * $ratio; $newheight = $height * $ratio; if (function_exists("imagecopyresampled")) { $newim = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } else { $newim = imagecreate($newwidth, $newheight); imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } touch($filename . ".jpg"); ImageJpeg ($newim,$filename . ".jpg"); // ImageDestroy ($newim); } else { touch($filename . ".jpg"); ImageJpeg ($im,$filename . ".jpg"); } } // ========================= // Image popups // ========================= //function popup($medium_img_url, $large_img_url, $title, $width=false, $height=false) //{ // $title_urlencoded = rawurlencode($title); // $title_mouseover = addslashes($title); // if ( (!is_integer($width)) or (!is_integer($height)) ) // { // $size = @getimagesize("$large_img_url"); // $width = $size[0]; // $height = $size[1]; // } // $image = "<a href=\"#\" onclick=\"window.open('ads_popup.php?z=$large_img_url&width=$width&height=$height&title=$title_urlencoded','photopopup','width=$width,height=$height,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,screenx=150,screeny=150');return false\" onMouseOver=\"window.status='$title_mouseover';return true\" onMouseOut=\"window.status='';return true\"><img src='$medium_img_url' border='0'></a>"; // return $image; //} // ========================================================== // Set the confirmation code // ========================================================== function confirmation_code() { $image = imagecreate(120, 30); $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); $darkgray = imagecolorallocate($image, 0x50, 0x50, 0x50); srand((double)microtime()*1000000); for ($i = 0; $i < 30; $i++) { $x1 = rand(0,120); $y1 = rand(0,30); $x2 = rand(0,120); $y2 = rand(0,30); imageline($image, $x1, $y1, $x2, $y2 , $gray); } for ($i = 0; $i < 5; $i++) { $cnum[$i] = rand(0,9); } for ($i = 0; $i < 5; $i++) { $fnt = rand(5,8); $x = $x + rand(12 , 20); $y = rand(7 , 12); imagestring($image, $fnt, $x, $y, $cnum[$i] , $darkgray); } $digit = "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]"; session_start(); $_SESSION['digit'] = $digit; //header('Content-type: image/png'); $image = imagepng($image); imagedestroy($image); return $image; } // ========================================================== // Send a chaser email // ========================================================== function chaser_email($sender_email, $recip_email, $subject, $message) { global $board_config, $phpEx, $phpbb_root_path; global $email_headers, $user_lang; include_once($phpbb_root_path . 'includes/emailer.'.$phpEx); // Left in for debugging //echo '===============================<br>'; //echo '$sender_email=',$sender_email,'<br>'; //echo '$recip_email=',$recip_email,'<br>'; //echo '$subject=',$subject,'<br>'; //echo '$message=',$message,'<br>'; $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($sender_email); $emailer->replyto($sender_email); $emailer->use_template('admin_send_email', $user_lang); $emailer->email_address($recip_email); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array( 'SITENAME' => $board_config['sitename'], 'BOARD_EMAIL' => $board_config['board_email'], 'MESSAGE' => $message)); $emailer->send(); $emailer->reset(); } // ========================================================== // Create a comma separated value file from an array // ========================================================== function create_csv_file($file, $data) { //check for array if (is_array($data)) { $post_values=array_values($data); //build csv data foreach($post_values as $i) {$csv.="\"$i\",";} //remove the last comma from string $csv = substr($csv,0,-1); //check for existence of file if (file_exists($file) and is_writeable($file)) {$mode = "a";} else {$mode="w";} //create file pointer $fp = @fopen($file,$mode); //write to file fwrite($fp,$csv . "\n"); //close file pointer fclose($fp); return true; } else { return false; } } // ========================================================== // Create a comma separated value file from an array // ========================================================== function create_error_file($file, $message) { $open = fopen ($file, "a"); if ($open) { fwrite ($open, $message."\r\n"); fclose ($open); } } // ========================================================== // Pick a currency code // ========================================================== function cc_select($default, $select_name = 'currency_code') { global $lang; if ( !isset($default) ) { $default == 'GBP'; } $cc_select = '<select name="' . $select_name . '">'; while( list($cc_code, $cc_desc) = @each($lang['paypal_cc']) ) { $selected = ( $cc_code == $default ) ? ' selected="selected"' : ''; $cc_select .= '<option value="' . $cc_code . '"' . $selected . '>' . $cc_desc . '</option>'; } $cc_select .= '</select>'; return $cc_select; } // ========================================================== // Pick a language code // ========================================================== function lc_select($default, $select_name = 'language_code') { global $lang; if ( !isset($default) ) { $default == 'GB'; } $lc_select = '<select name="' . $select_name . '">'; while( list($lc_code, $lc_desc) = @each($lang['paypal_lc']) ) { $selected = ( $lc_code == $default ) ? ' selected="selected"' : ''; $lc_select .= '<option value="' . $lc_code . '"' . $selected . '>' . $lc_desc . '</option>'; } $lc_select .= '</select>'; return $lc_select; } // ========================================================== // htmlspecialchars_decode // ========================================================== function htmlspecialchars_decode_php4($str, $quote_style = ENT_COMPAT) { if ( function_exists('htmlspecialchars_decode') ) { return htmlspecialchars_decode($str); } else { if ( function_exists('get_html_translation_table') ) { return strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); } else { return strtr($str, str_replace(array('&', ''', '"', '<', '>'), array('&', "'", '"', '<', '>'), $category)); } } } ?> |