$v) { if (empty($v)) $DATA[$k] = "---"; } // Check for sponsor's orders (only count) $result_orders = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_sponsor_orders` WHERE sponsorid='%s'", array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); list($orders) = SQL_FETCHROW($result_orders); SQL_FREERESULT($result_orders); if (empty($orders)) $orders = 0; // Prepare all data for the template // @TODO Rewrite this huge amount of constants // Sponsor's ID define('__SPONSOR_ID' , REQUEST_GET('id')); // Company's data define('__SPONSOR_COMPANY' , $DATA['company']); define('__SPONSOR_POSITION' , $DATA['position']); define('__SPONSOR_TAX_IDENT' , $DATA['tax_ident']); // Personal data define('__SPONSOR_GENDER' , TRANSLATE_GENDER($DATA['gender'])); define('__SPONSOR_SURNAME' , $DATA['surname']); define('__SPONSOR_FAMILY' , $DATA['family']); define('__SPONSOR_STREET1' , $DATA['street_nr1']); define('__SPONSOR_STREET2' , $DATA['street_nr2']); define('__SPONSOR_ZIP' , $DATA['zip']); define('__SPONSOR_CITY' , $DATA['city']); define('__SPONSOR_COUNTRY' , $DATA['country']); // Contact data define('__SPONSOR_PHONE' , $DATA['phone']); define('__SPONSOR_FAX' , $DATA['fax']); define('__SPONSOR_CELL' , $DATA['cell']); define('__SPONSOR_EMAIL' , "mailto:".$DATA['email']); define('__SPONSOR_EMAIL_VALUE', $DATA['email']); define('__SPONSOR_URL' , DEREFERER($DATA['url'])); // Timestamps define('__SPONSOR_CREATED' , MAKE_DATETIME($DATA['sponsor_created'], "2")); define('__SPONSOR_LAST_ONLINE', MAKE_DATETIME($DATA['last_online'], "2")); define('__SPONSOR_LAST_CHANGE', MAKE_DATETIME($DATA['last_change'], "2")); // Sponsor points define('__SPONSOR_AMOUNT' , TRANSLATE_COMMA($DATA['points_amount'])); define('__SPONSOR_USED' , TRANSLATE_COMMA($DATA['points_used'])); // Warning because low points define('__SPONSOR_REC_WARNING', TRANSLATE_YESNO($DATA['receive_warnings'])); define('__SPONSOR_INTERVAL' , CREATE_FANCY_TIME($DATA['warning_interval'])); // Orders total define('__SPONSOR_ORDERS' , $orders); // Other data define('__SPONSOR_STATUS' , SPONSOR_TRANSLATE_STATUS($DATA['status'])); define('__SPONSOR_REFID' , $DATA['refid']); define('__SPONSOR_REMOTE_ADR' , $DATA['remote_addr']); define('__SPONSOR_REFS' , $DATA['ref_count']); // Load template LOAD_TEMPLATE("admin_list_sponsor_details"); } else { // Sponsor not found LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_404'), REQUEST_GET('id'))); } } elseif (REQUEST_ISSET_GET(('rid'))) { // Search for sponsor $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE id='%s' LIMIT 1", array(bigintval(REQUEST_GET('rid'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Free memory SQL_FREERESULT($result); // Sponsor found so let's list all his referals $result = SQL_QUERY_ESC("SELECT id, gender, surname, family, email, status, sponsor_created, last_online, points_amount, points_used, remote_addr, ref_count FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE refid='%s' ORDER BY `id`", array(bigintval(REQUEST_GET('rid'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { // List refs now // Free memory SQL_FREERESULT($result); } else { // No refs made so far LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_REFS_404'), "".bigintval(REQUEST_GET('rid'))."")); } } else { // Sponsor not found LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval(REQUEST_GET('rid')))); } } else { // List all sponsors $result_main = SQL_QUERY("SELECT id, gender, surname, family, email, status, sponsor_created, last_online, points_amount, points_used, remote_addr FROM `{!_MYSQL_PREFIX!}_sponsor_data` ORDER BY `id`", __FILE__, __LINE__); if (SQL_NUMROWS($result_main) > 0) { // At least one sponsor found! $OUT = ""; $SW = 2; while ($content = SQL_FETCHARRAY($result_main)) { // Transfer data to array // @TODO Rewritings: sname->surname,fname->family,ip->remote_addr in template $content = array( 'id' => $content['id'], 'sw' => $SW, 'gender' => TRANSLATE_GENDER($content['gender']), 'sname' => $content['surname'], 'fname' => $content['family'], 'email' => "mailto:".$content['email'], 'status' => SPONSOR_TRANSLATE_STATUS($content['status']), 'created' => MAKE_DATETIME($content['sponsor_created'], "2"), 'last' => MAKE_DATETIME($content['last_online'], "2"), 'points' => TRANSLATE_COMMA($content['points_amount'] - $content['points_used']), 'ip' => $content['remote_addr'], ); // Load row template $OUT .= LOAD_TEMPLATE("admin_list_sponsor_row", true, $content); $SW = 3 - $SW; } // Free memory SQL_FREERESULT($result_main); // @TODO Rewrite this constant define('__SPONSOR_ROWS', $OUT); // Load final template LOAD_TEMPLATE("admin_list_sponsor"); } else { // No sponsors registered so far LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SPONSOR_NONE_REGISTERED')); } } // ?>