<?php
/************************************************************************
- * M-XChange v0.2.1 Start: 04/25/2005 *
- * ================ Last change: 05/19/2008 *
+ * Mailer v0.2.1-FINAL Start: 04/25/2005 *
+ * =================== Last change: 05/19/2008 *
* *
* -------------------------------------------------------------------- *
* File : what-list_sponsor.php *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
************************************************************************/
// Some security stuff...
-if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
- require($INC);
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
+} // END - if
// Add description as navigation point
-ADD_DESCR('admin', __FILE__);
+addMenuDescription('admin', __FILE__);
-if (REQUEST_ISSET_GET('id')) {
+if (isGetRequestParameterSet('id')) {
// Show detailed informations to a sponsor
- $result = SQL_QUERY_ESC("SELECT company, position, gender, surname, family, street_nr1, street_nr2, zip, city, country, phone, fax, cell, email, url, tax_ident, status, sponsor_created, last_online, last_change, receive_warnings, points_amount, points_used, remote_addr, warning_interval, refid, ref_count
-FROM `{!_MYSQL_PREFIX!}_sponsor_data`
-WHERE `id`='%s' LIMIT 1",
- array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ `company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
+ `phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
+ `status`, `sponsor_created`, `last_online`, `last_change`, `receive_warnings`,
+ `points_amount`, `points_used`, `remote_addr`, `warning_interval`, `refid`, `ref_count`
+FROM
+ `{?_MYSQL_PREFIX?}_sponsor_data`
+WHERE
+ `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('id'))), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load sponsor details
- $DATA = SQL_FETCHARRAY($result);
+ $content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
// Check if an entry is empty
- foreach ($DATA as $k => $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;
+ foreach ($content as $k => $v) {
+ if (empty($v)) $content[$k] = '---';
+ } // END - foreach
// 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' , translateGender($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']);
+ // Sponsor's id
+ $content['id'] = getRequestParameter('id');
// Contact data
- define('__SPONSOR_PHONE' , $DATA['phone']);
- define('__SPONSOR_FAX' , $DATA['fax']);
- define('__SPONSOR_CELL' , $DATA['cell']);
- define('__SPONSOR_EMAIL' , generateEmailLink($DATA['email'], 'sponsor_data'));
- define('__SPONSOR_EMAIL_VALUE', $DATA['email']);
- define('__SPONSOR_URL' , DEREFERER($DATA['url']));
+ $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data');
// Timestamps
- define('__SPONSOR_CREATED' , generateDateTime($DATA['sponsor_created'], '2'));
- define('__SPONSOR_LAST_ONLINE', generateDateTime($DATA['last_online'], '2'));
- define('__SPONSOR_LAST_CHANGE', generateDateTime($DATA['last_change'], '2'));
- // Sponsor points
- define('__SPONSOR_AMOUNT' , translateComma($DATA['points_amount']));
- define('__SPONSOR_USED' , translateComma($DATA['points_used']));
- // Warning because low points
- define('__SPONSOR_REC_WARNING', translateYesNo($DATA['receive_warnings']));
- define('__SPONSOR_INTERVAL' , createFancyTime($DATA['warning_interval']));
+ $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
+ $content['last_online'] = generateDateTime($content['last_online'], 2);
+ $content['last_change'] = generateDateTime($content['last_change'], 2);
// Orders total
- define('__SPONSOR_ORDERS' , $orders);
- // Other data
- define('__SPONSOR_STATUS' , sponsorTranslateUserStatus($DATA['status']));
- define('__SPONSOR_REFID' , $DATA['refid']);
- define('__SPONSOR_REMOTE_ADR' , $DATA['remote_addr']);
- define('__SPONSOR_REFS' , $DATA['ref_count']);
+ $content['orders'] = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsorid', true);
// Load template
- LOAD_TEMPLATE("admin_list_sponsor_details");
+ loadTemplate('admin_list_sponsor_details', false, $content);
} else {
// Sponsor not found
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_404'), REQUEST_GET('id')));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id'))));
}
-} elseif (REQUEST_ISSET_GET('rid')) {
+} elseif (isGetRequestParameterSet('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__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`='%s' LIMIT 1",
+ array(bigintval(getRequestParameter('rid'))), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Free memory
SQL_FREERESULT($result);
`sponsor_created`, `last_online`, `points_amount`, `points_used`,
`remote_addr`, `ref_count`
FROM
- `{!_MYSQL_PREFIX!}_sponsor_data`
+ `{?_MYSQL_PREFIX?}_sponsor_data`
WHERE
`refid`='%s'
ORDER BY
`id` ASC",
- array(bigintval(REQUEST_GET('rid'))), __FILE__, __LINE__);
+ array(bigintval(getRequestParameter('rid'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// 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'), "<a href=\"{?URL?}/modules.php?module=admin&what=list_sponsor&id=".bigintval(REQUEST_GET('rid'))."\">".bigintval(REQUEST_GET('rid'))."</a>"));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&what=list_sponsor&id=' . bigintval(getRequestParameter('rid')) . '%}">' . bigintval(getRequestParameter('rid')) . '</a>'));
}
} else {
// Sponsor not found
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval(REQUEST_GET('rid'))));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('rid'))));
}
} else {
// List all sponsors
`id`, `gender`, `surname`, `family`, `email`, `status`,
`sponsor_created`, `last_online`, `points_amount`, `points_used`, `remote_addr`
FROM
- `{!_MYSQL_PREFIX!}_sponsor_data`
+ `{?_MYSQL_PREFIX?}_sponsor_data`
ORDER BY
`id` ASC", __FILE__, __LINE__);
- if (SQL_NUMROWS($result_main) > 0) {
+ if (!SQL_HASZERONUMS($result_main)) {
// At least one sponsor found!
- $OUT = ''; $SW = 2;
+ $OUT = '';
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' => translateGender($content['gender']),
- 'sname' => $content['surname'],
- 'fname' => $content['family'],
- 'email' => generateEmailLink($content['email'], 'sponsor_data'),
- 'status' => sponsorTranslateUserStatus($content['status']),
- 'created' => generateDateTime($content['sponsor_created'], '2'),
- 'last' => generateDateTime($content['last_online'], '2'),
- 'points' => translateComma($content['points_amount'] - $content['points_used']),
- 'ip' => $content['remote_addr'],
+ 'id' => $content['id'],
+ 'gender' => $content['gender'],
+ 'surname' => $content['surname'],
+ 'family' => $content['family'],
+ 'email' => generateEmailLink($content['email'], 'sponsor_data'),
+ 'status' => $content['status'],
+ 'sponsor_created' => generateDateTime($content['sponsor_created'], 2),
+ 'last_online' => generateDateTime($content['last_online'], 2),
+ 'points' => ($content['points_amount'] - $content['points_used']),
+ 'remote_addr' => $content['remote_addr'],
);
// Load row template
- $OUT .= LOAD_TEMPLATE('admin_list_sponsor_row', true, $content);
- $SW = 3 - $SW;
- }
+ $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
+ } // END - while
// Free memory
SQL_FREERESULT($result_main);
- // @TODO Rewrite this constant
- define('__SPONSOR_ROWS', $OUT);
-
// Load final template
- LOAD_TEMPLATE('admin_list_sponsor');
+ loadTemplate('admin_list_sponsor', false, $OUT);
} else {
// No sponsors registered so far
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_SPONSOR_NONE_REGISTERED'));
+ loadTemplate('admin_settings_saved', false, '{--ADMIN_SPONSOR_NONE_REGISTERED--}');
}
}
-//
+// [EOF]
?>