// 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;
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...
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(),
// 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
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
$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__);
}
bigintval(postRequestElement('type')),
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
postRequestElement('html'),
bigintval($id)
bigintval(postRequestElement('type')),
postRequestElement('url'),
bigintval(postRequestElement('cat')),
- $MAX_SEND,
+ $content['target_send'],
bigintval(postRequestElement('zip')),
bigintval($id)
), __FILE__, __LINE__);
// 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 {
if (SQL_NUMROWS($result_cats) > 0) {
if ($total > 0) {
// Initialize array...
- $CATS = array(
+ $categories = array(
'id' => array(),
'name' => array(),
'userids' => array()
} // 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)) {
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++;
// 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
// 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'));
} // END - if
// Load all email types...
- while ($typeS[] = SQL_FETCHROW($result)) {
+ while ($types[] = SQL_FETCHROW($result)) {
// Nothing to do here... ;-)
} // END - while
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
if ((isPostRequestElementSet('data')) || ((getConfig('order_multi_page') != 'Y') && ((!isAdmin()) && (!isExtensionActive('html_mail'))))) {
// Pre-output categories
- $CAT = '';
- foreach ($CATS['id'] as $key => $value) {
- $CAT .= " <option value=\"".$value."\"";
- if (($OLD_ORDER) && ($content['cat_id'] == $value)) $CAT .= ' selected="selected"';
- $CAT .= ">".$CATS['name'][$key]." (".$CATS['userids'][$key]." {--USER_IN_CAT--})</option>\n";
+ $content['category_selection'] = '';
+ foreach ($categories['id'] as $key => $value) {
+ $content['category_selection'] .= " <option value=\"".$value."\"";
+ if (($OLD_ORDER) && ($content['cat_id'] == $value)) $content['category_selection'] .= ' selected="selected"';
+ $content['category_selection'] .= ">".$categories['name'][$key]." (".$categories['userids'][$key]." {--USER_IN_CAT--})</option>\n";
} // END - foreach
// Mail type
- $type = '';
- foreach ($typeS as $key => $value) {
- $P = translateComma($typeS[$key][1]);
+ $content['type_selection'] = '';
+ foreach ($types as $key => $value) {
+ $P = translateComma($types[$key][1]);
if (is_array($value)) {
// Output option line
- $type .= " <option value=\"".$typeS[$key][0]."\"";
- if (($OLD_ORDER) && ($content['payment_id'] == $typeS[$key][0])) $type .= ' selected="selected"';
- $type .= ">".$P." {--PER_MAIL--} - ".$typeS[$key][3]." - ".round($typeS[$key][2])." {--PAYMENT--}</option>\n";
+ $content['type_selection'] .= " <option value=\"".$types[$key][0]."\"";
+ if (($OLD_ORDER) && ($content['payment_id'] == $types[$key][0])) $content['type_selection'] .= ' selected="selected"';
+ $content['type_selection'] .= ">".$P." {--PER_MAIL--} - ".$types[$key][3]." - ".round($types[$key][2])." {--PAYMENT--}</option>\n";
} // END - if
} // END - foreach
- // Put all in constants for the template
- $content['category_selection'] = $CAT;
- $content['type_selection'] = $type;
-
if (isPostRequestElementSet('zip')) {
// Output entered ZIP code
$content['zip_content'] = loadTemplate('member_order-zip', true, postRequestElement('zip'));
$content['html_extension'] = loadTemplate('member_order-html_ext', true, addValidHtmlTags());
} else {
// Extension not active and/or class not uploaded
- $content['html_extension'] = "<tr><td colspan=\"5\"><input type=\"hidden\" name=\"html\" value=\"N\"> /</td></tr>";
+ $content['html_extension'] = "<tr><td colspan=\"5\"><input type=\"hidden\" name=\"html\" value=\"N\" /></td></tr>";
}
// Output form for page 2
- loadTemplate('member_order_page2');
+ loadTemplate('member_order_page2', false, $content);
} else {
// Remember maybe entered ZIP code in constant
$add = '';