X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-order.php;h=b214a719c614beb8a81c0a429909c4784ef17b04;hp=491160aa2d8c248099366f935e07c035f04d93b2;hb=d92d8b4ddd219b65df8e0bba5e4354c0bbfba5c9;hpb=e2cda4256059886cd7791d2751606856072c7cbc;ds=sidebyside
diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php
index 491160aa2d..b214a719c6 100644
--- a/inc/modules/member/what-order.php
+++ b/inc/modules/member/what-order.php
@@ -63,22 +63,26 @@ $content['min'] = getConfig('order_min');
// Count unconfirmed mails
$links = countSumTotalData(getUserId(), 'user_links', 'id', 'userid', true);
-// Does the user has more than 0 mails per day set?
-$HOLIDAY = 'userid';
+// Do we have ext-holiday installed?
+$HOLIDAY = 'serid';
if ((isExtensionActive('holiday')) && (getExtensionVersion('holiday') >= '0.1.3')) {
// Fetch also holiday activation data
- $HOLIDAY = '`holiday_active`';
+ $HOLIDAY = 'holiday_active';
} // END - if
-$result_mmails = SQL_QUERY_ESC("SELECT `userid`, `receive_mails`, `mail_orders`, ".$HOLIDAY."
+$result_mmails = SQL_QUERY_ESC("SELECT `userid`, `receive_mails`, `mail_orders`, `".$HOLIDAY."`
FROM `{?_MYSQL_PREFIX?}_user_data`
WHERE `userid`=%s AND `max_mails` > 0 LIMIT 1",
array(getUserId()), __FILE__, __LINE__);
$mmails = SQL_NUMROWS($result_mmails);
list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
+
+// Free result
SQL_FREERESULT($result_mmails);
-if ($HOLIDAY == $DMY) $HOLIDAY='N';
+
+// Fix non-existent ext-holidy
+if ($HOLIDAY == $DMY) $HOLIDAY = 'N';
$ALLOWED = $MAXI - $ORDERS;
if (getConfig('order_max_full') == 'MAX') $ALLOWED = $MAXI;
@@ -89,7 +93,7 @@ $total = countSumTotalData(getUserId(), 'user_points', 'points') - countSumTotal
if (($HOLIDAY == 'Y') && (getExtensionVersion('holiday') >= '0.1.3')) {
// Holiday is active!
loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_ORDER_NOT_POSSIBLE'));
-} elseif ((isPostRequestElementSet(('frametester'))) && ($ALLOWED > 0) && (postRequestElement('receiver') > 0)) {
+} elseif ((isPostRequestElementSet('frametester')) && ($ALLOWED > 0) && (postRequestElement('receiver') > 0)) {
// Continue with the frametester, we first need to store the data temporary in the pool
//
// First we would like to store the data and get it's pool position back...
@@ -97,7 +101,9 @@ if (($HOLIDAY == 'Y') && (getExtensionVersion('holiday') >= '0.1.3')) {
FROM
`{?_MYSQL_PREFIX?}_pool`
WHERE
- `sender`=%s AND `url`='%s' AND `timestamp` > (UNIX_TIMESTAMP() - %s)
+ `sender`=%s AND
+ `url`='%s' AND
+ `timestamp` > (UNIX_TIMESTAMP() - %s)
LIMIT 1",
array(
getUserId(),
@@ -234,7 +240,7 @@ ORDER BY
// Load receivers from database
$TEST = array(); $cnt = 0;
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($holidayContent = SQL_FETCHARRAY($result)) {
if ($HOLIDAY) {
// Check for his holiday status
$result_holiday = SQL_QUERY_ESC("SELECT
@@ -244,16 +250,16 @@ FROM
WHERE
`userid`=%s AND `holiday_start` < UNIX_TIMESTAMP() AND `holiday_end` > UNIX_TIMESTAMP()
LIMIT 1",
- array(bigintval($content['userid'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_holiday) == 1) $content['userid'] = 0; // Exclude user who are in holiday
+ array($holidayContent['userid']), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result_holiday) == 1) $holidayContent['userid'] = 0; // Exclude user who are in holiday
// Free memory
SQL_FREERESULT($result_holiday);
} // END - if
- if ($content['userid'] > 0) {
+ if ($holidayContent['userid'] > 0) {
// Add receiver
- $TEST[] = $content['userid'];
+ $TEST[] = $holidayContent['userid'];
$cnt++;
} // END - if
} // END - while
@@ -265,59 +271,56 @@ LIMIT 1",
$RECEIVER = implode($TEST, ';');
// Count array for maximum sent
- $MAX_SEND = count($TEST);
+ $content['target_send'] = count($TEST);
// Update receiver list
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`receive_mails`-1 WHERE `userid` IN (%s) LIMIT %s",
- array(str_replace(';', ", ", $RECEIVER), $MAX_SEND), __FILE__, __LINE__);
+ array(str_replace(';', ", ", $RECEIVER), $content['target_send']), __FILE__, __LINE__);
// Is calculated max receivers larger than wanted receivers then reset it
- if ($MAX_SEND > postRequestElement('receiver')) $MAX_SEND = bigintval(postRequestElement('receiver'));
+ if ($content['target_send'] > postRequestElement('receiver')) $content['target_send'] = bigintval(postRequestElement('receiver'));
// Calculate used points
- $USED = $MAX_SEND * getPaymentPoints(bigintval(postRequestElement('type')));
+ $USED = $content['target_send'] * getPaymentPoints(bigintval(postRequestElement('type')));
// Fix empty zip code
if (!isPostRequestElementSet('zip')) setRequestPostElement('zip', '0');
// Check if he has enougth points for this order and selected more than 0 receivers
- if (($USED > 0) && ($USED <= $total) && ($MAX_SEND > 0)) {
+ if (($USED > 0) && ($USED <= $total) && ($content['target_send'] > 0)) {
// Gettings points is okay, so we can add $USED later from
- $TIME = time();
if (($id == '0') || ($type != 'TEMP')) {
// New order
$id = 0;
if (isExtensionActive('html_mail')) {
// HTML extension is active
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_pool` (`sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `zip`, `html_msg`)
- VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
+ VALUES ('%s','%s','%s','%s','%s','TEMP',UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s')",
array(
getUserId(),
postRequestElement('subject'),
postRequestElement('text'),
$RECEIVER,
bigintval(postRequestElement('type')),
- $TIME,
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
postRequestElement('html')
), __FILE__, __LINE__);
} else {
// No HTML extension is active
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_pool` (`sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `zip`)
- VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')",
+ VALUES ('%s','%s','%s','%s','%s','TEMP',UNIX_TIMESTAMP(),'%s','%s','%s','%s')",
array(
getUserId(),
postRequestElement('subject'),
postRequestElement('text'),
$RECEIVER,
bigintval(postRequestElement('type')),
- $TIME,
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
), __FILE__, __LINE__);
}
@@ -348,7 +351,7 @@ LIMIT 1",
bigintval(postRequestElement('type')),
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
postRequestElement('html'),
bigintval($id)
@@ -377,7 +380,7 @@ LIMIT 1",
bigintval(postRequestElement('type')),
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
bigintval($id)
), __FILE__, __LINE__);
@@ -387,21 +390,23 @@ LIMIT 1",
// Do we need to get the ID number?
if ($id == 0) {
// Order is placed as temporary. We need to get it's id for the frametester
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s AND `subject`='%s' AND `payment_id`=%s AND `data_type`='TEMP' AND `timestamp`=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s AND `subject`='%s' AND `payment_id`=%s AND `data_type`='TEMP' AND `timestamp`=UNIX_TIMESTAMP() LIMIT 1",
array(
getUserId(),
postRequestElement('subject'),
- bigintval(postRequestElement('type')),
- $TIME
+ bigintval(postRequestElement('type'))
), __FILE__, __LINE__);
+ // Get pool id
list($id) = SQL_FETCHROW($result);
+
+ // Free result
SQL_FREERESULT($result);
- }
+ } // END - if
// ID is received so we can redirect the user, used points will be added when he send's out the mail
$URL = 'modules.php?module=frametester&order=' . $id;
- } elseif ($MAX_SEND == 0) {
+ } elseif ($content['target_send'] == 0) {
// Not enougth receivers found which can receive mails
$URL = 'modules.php?module=login&what=order&code=' . getCode('MORE_RECEIVERS2');
} else {
@@ -431,7 +436,7 @@ ORDER BY
if (SQL_NUMROWS($result_cats) > 0) {
if ($total > 0) {
// Initialize array...
- $CATS = array(
+ $categories = array(
'id' => array(),
'name' => array(),
'userids' => array()
@@ -447,13 +452,13 @@ ORDER BY
} // END - if
// ... and begin loading stuff
- while ($content = SQL_FETCHARRAY($result_cats)) {
- $CATS['id'][] = bigintval($content['id']);
- $CATS['name'][] = $content['cat'];
+ while ($categoriesContent = SQL_FETCHARRAY($result_cats)) {
+ $categories['id'][] = bigintval($categoriesContent['id']);
+ $categories['name'][] = $categoriesContent['cat'];
// Select users in current category
$result_userids = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != '%s' ORDER BY `userid` ASC",
- array(bigintval($content['id']), getUserId()), __FILE__, __LINE__);
+ array(bigintval($categoriesContent['id']), getUserId()), __FILE__, __LINE__);
$userid_cnt = 0;
while (list($ucat) = SQL_FETCHROW($result_userids)) {
@@ -486,8 +491,8 @@ LIMIT 1",
array(bigintval($ucat)), __FILE__, __LINE__);
if ((SQL_NUMROWS($result_ver) == 1) && (isPostRequestElementSet('zip')) && (getConfig('order_multi_page') == 'Y')) {
+ // Get zip code
list($zip) = SQL_FETCHROW($result_ver);
- SQL_FREERESULT($result_ver);
if (substr($zip, 0, strlen(postRequestElement('zip'))) == postRequestElement('zip')) {
// Ok, ZIP part is found
$userid_cnt++;
@@ -496,12 +501,15 @@ LIMIT 1",
// Count numbers up!
$userid_cnt += SQL_NUMROWS($result_ver);
}
+
+ // Free result
+ SQL_FREERESULT($result_ver);
} // END - if
} // END - while
// Free memory
SQL_FREERESULT($result_userids);
- $CATS['userids'][] = $userid_cnt;
+ $categories['userids'][] = $userid_cnt;
} // END - while
// Free memory
@@ -510,7 +518,7 @@ LIMIT 1",
// Now we need to load the mail types...
$result = SQL_QUERY("SELECT `id`, `price`, `payment`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `payment` ASC", __FILE__, __LINE__);
- $typeS = array();
+ $types = array();
if (SQL_NUMROWS($result) > 0) {
// Check for message ID in URL
$message = getMessageFromErrorCode(getRequestElement('code'));
@@ -521,7 +529,7 @@ LIMIT 1",
} // END - if
// Load all email types...
- while ($typeS[] = SQL_FETCHROW($result)) {
+ while ($types[] = SQL_FETCHROW($result)) {
// Nothing to do here... ;-)
} // END - while
@@ -562,22 +570,29 @@ LIMIT 1",
FROM
`{?_MYSQL_PREFIX?}_pool`
WHERE
- `sender`=%s AND `data_type`='TEMP'
+ `sender`=%s AND
+ `data_type`='TEMP'
LIMIT 1",
array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Old order found
- $content = SQL_FETCHARRAY($result);
+ $content = merge_array($content, SQL_FETCHARRAY($result));
// Fix max receivers when it is too much
- if ((isset($CATS['userids'][$content['cat_id']])) && ($content['target_send'] > $CATS['userids'][$content['cat_id']])) $content['target_send'] = $CATS['userids'][$content['cat_id']];
+ if ((isset($categories['userids'][$content['cat_id']])) && ($content['target_send'] > $categories['userids'][$content['cat_id']])) {
+ // Fix it
+ $content['target_send'] = $categories['userids'][$content['cat_id']];
+ } // END - if
// Old order is grabbed
$OLD_ORDER = true;
} else {
// Default output for that your members don't forget it...
- $content['url'] = 'http://';
+ $content['url'] = 'http://';
+ $content['target_send'] = $content['min'];
+ $content['subject'] = '{--ORDER_DEFAULT_SUBJECT--}';
+ $content['text'] = '{--ORDER_DEFAULT_TEXT--}';
}
// Free result
@@ -585,29 +600,25 @@ LIMIT 1",
if ((isPostRequestElementSet('data')) || ((getConfig('order_multi_page') != 'Y') && ((!isAdmin()) && (!isExtensionActive('html_mail'))))) {
// Pre-output categories
- $CAT = '';
- foreach ($CATS['id'] as $key => $value) {
- $CAT .= "