本文整理汇总了PHP中Sql_Fetch_Assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP Sql_Fetch_Assoc函数的具体用法?PHP Sql_Fetch_Assoc怎么用?PHP Sql_Fetch_Assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sql_Fetch_Assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateLogin
/**
* validateLogin, verify that the login credentials are correct.
*
* @param string $login the login field
* @param string $password the password
*
* @return array
* index 0 -> false if login failed, index of the administrator if successful
* index 1 -> error message when login fails
*
* eg
* return array(5,'OK'); // -> login successful for admin 5
* return array(0,'Incorrect login details'); // login failed
*/
public function validateLogin($login, $password)
{
$query = sprintf('select password, disabled, id from %s where loginname = "%s"', $GLOBALS['tables']['admin'], sql_escape($login));
$req = Sql_Query($query);
$admindata = Sql_Fetch_Assoc($req);
$encryptedPass = hash(ENCRYPTION_ALGO, $password);
$passwordDB = $admindata['password'];
#Password encryption verification.
if (strlen($passwordDB) < $GLOBALS['hash_length']) {
// Passwords are encrypted but the actual is not.
#Encrypt the actual DB password before performing the validation below.
$encryptedPassDB = hash(ENCRYPTION_ALGO, $passwordDB);
$query = sprintf('update %s set password = "%s" where loginname = "%s"', $GLOBALS['tables']['admin'], $encryptedPassDB, sql_escape($login));
$passwordDB = $encryptedPassDB;
$req = Sql_Query($query);
}
if ($admindata['disabled']) {
return array(0, s('your account has been disabled'));
} elseif (!empty($passwordDB) && $encryptedPass == $passwordDB) {
return array($admindata['id'], 'OK');
} else {
if (!empty($GLOBALS['admin_auth_module'])) {
Error(s('Admin authentication has changed, please update your admin module'), 'https://resources.phplist.com/documentation/errors/adminauthchange');
return;
}
return array(0, s('incorrect password'));
}
if (!empty($GLOBALS['admin_auth_module'])) {
Error(s('Admin authentication has changed, please update your admin module'), 'https://resources.phplist.com/documentation/errors/adminauthchange');
return;
}
return array(0, s('Login failed'));
}
示例2: listMemberCounts
/**
* Create the html to show the number of list members in up to three totals.
* Confirmed - subscriber is confirmed and not blacklisted
* Not confirmed - subscriber is not confirmed and not blacklisted
* Blacklisted - subscriber is blacklisted.
*
* @param int $listId the list id, or 0 for all subscribers
* @return string
*/
function listMemberCounts($listId)
{
global $tables;
if ($listId) {
$join = "JOIN {$tables['listuser']} lu ON u.id = lu.userid\n WHERE lu.listid = {$listId}";
} else {
$join = '';
}
$req = Sql_Query("SELECT\n SUM(1) AS total,\n SUM(IF(u.confirmed = 1 && u.blacklisted = 0, 1, 0)) AS confirmed,\n SUM(IF(u.confirmed = 0 && u.blacklisted = 0, 1, 0)) AS notconfirmed,\n SUM(IF(u.blacklisted = 1, 1, 0)) AS blacklisted\n FROM {$tables['user']} u\n {$join}");
$counts = Sql_Fetch_Assoc($req);
$membersDisplay = sprintf('<span class="memberCount" title="%s">%s</span>' . ' (' . '<span class="unconfirmedCount" title="%s">%s</span>, ' . ' ' . '<span class="blacklistedCount" title="%s">%s</span>' . ')', s('Confirmed members'), number_format($counts['confirmed']), s('Unconfirmed members'), number_format($counts['notconfirmed']), s('Blacklisted members'), number_format($counts['blacklisted']));
return $membersDisplay;
}
示例3: Retreive_And_Unserialize
function Retreive_And_Unserialize()
{
$retrieve_serialized_query = sprintf("select value from %s", $this->AttributeChangerData['attribute_changer_tablename']);
$retrieve_s_return = Sql_Query($retrieve_serialized_query);
if (!$retrieve_s_return) {
print "ERROR NO STORED SESSION";
die;
}
$returned_result = Sql_Fetch_Assoc($retrieve_s_return);
if (!isset($returned_result['value'])) {
print "ERROR Improperly stored value data";
die;
}
//print_r($returned_result);
$serialized_session = $returned_result['value'];
//print($serialized_session);
$this->Current_Session = unserialize(base64_decode($serialized_session));
}
示例4: Get_Attribute_List
function Get_Attribute_List()
{
$AttributeChangerPlugin = $GLOBALS['AttributeChangerPlugin'];
$AttributeChangerData = $AttributeChangerPlugin->AttributeChangerData;
$case_array = $AttributeChangerData['case_array'];
$query = sprintf('select * from %s', $AttributeChangerData['tables']['attribute']);
$attribute_data_return = Sql_Query($query);
if ($attribute_data_return) {
$new_attribute_list = array();
while ($attribute_data = Sql_Fetch_Assoc($attribute_data_return)) {
if (!isset($attribute_data['id']) || !isset($attribute_data['name']) || !isset($attribute_data['type'])) {
//not known format, cannot use
} else {
if (isset($new_attribute_list[$attribute_data['id']])) {
//cannot have duplicates, but really wont
continue;
}
//use the attribute list to get type and value information
$new_attribute_list[$attribute_data['id']] = $attribute_data;
//must check tables for values
if ($case_array[$attribute_data['type']] == "case_2" || $case_array[$attribute_data['type']] == "case_3") {
if (!isset($attribute_data['tablename'])) {
//this wouldnt make sense
unset($new_attribute_list[$attribute_data['id']]);
} else {
$new_attribute_list[$attribute_data['id']]['allowed_value_ids'] = $this->Get_Attribute_Value_Id_List($attribute_data['id']);
if ($new_attribute_list[$attribute_data['id']]['allowed_value_ids'] === null) {
//was an error, something missing, no values is just empty array, must still match, so unset
unset($new_attribute_list[$attribute_data['id']]);
}
}
} else {
//is other input type, do not set values array
}
}
}
//print_r($new_attribute_list);
return $new_attribute_list;
} else {
//no rows :S
//PRINT AN ERROR I GUESS LOL
return null;
}
}
示例5: s
$_SESSION['action_result'] = s('Category assignments saved');
Redirect('list');
} else {
Info(s('Categories saved'), true);
}
}
$req = Sql_Query(sprintf('select * from %s %s', $tables['list'], $subselect));
if (!Sql_Affected_Rows()) {
Info(s('All lists have already been assigned a category') . '<br/>' . PageLinkButton('list', s('Back')), true);
}
print '<div class="fright">' . PageLinkButton('catlists&show=all', s('Re-edit all lists')) . '</div>';
print '<div class="fright">' . PageLinkButton('configure&id=list_categories&ret=catlists', $I18N->get('Configure Categories')) . '</div>';
$ls = new WebblerListing(s('Categorise lists'));
$aListCategories = listCategories();
if (count($aListCategories)) {
while ($row = Sql_Fetch_Assoc($req)) {
$ls->addELement($row['id']);
$ls->addColumn($row['id'], $GLOBALS['I18N']->get('Name'), stripslashes($row['name']));
$catselect = '<select name="category[' . $row['id'] . ']">';
$catselect .= '<option value="">-- ' . s('choose category') . '</option>';
$catselect .= '<option value="">-- ' . s('none') . '</option>';
foreach ($aListCategories as $category) {
$category = trim($category);
$catselect .= sprintf('<option value="%s" %s>%s</option>', $category, $category == $row['category'] ? 'selected="selected"' : '', $category);
}
$catselect .= '</select>';
$ls->addColumn($row['id'], s('Category'), $catselect);
}
}
$ls->addButton(s('save'), 'javascript:document.categoryedit.submit();');
print $ls->display();
示例6: sendEmail
function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array(), $forwardedby = array())
{
$getspeedstats = VERBOSE && !empty($GLOBALS['getspeedstats']) && isset($GLOBALS['processqueue_timer']);
$sqlCountStart = $GLOBALS["pagestats"]["number_of_queries"];
$isTestMail = isset($_GET['page']) && $_GET['page'] == 'send';
## for testing concurrency, put in a delay to check if multiple send processes cause duplicates
#usleep(rand(0,10) * 1000000);
global $strThisLink, $strUnsubscribe, $PoweredByImage, $PoweredByText, $cached, $website, $counters;
if ($email == "") {
return 0;
}
if ($getspeedstats) {
output('sendEmail start ' . $GLOBALS['processqueue_timer']->interval(1));
}
#0013076: different content when forwarding 'to a friend'
if (FORWARD_ALTERNATIVE_CONTENT) {
$forwardContent = sizeof($forwardedby) > 0;
} else {
$forwardContent = 0;
}
if (empty($cached[$messageid])) {
if (!precacheMessage($messageid, $forwardContent)) {
unset($cached[$messageid]);
logEvent('Error loading message ' . $messageid . ' in cache');
return 0;
}
} else {
# dbg("Using cached {$cached[$messageid]["fromemail"]}");
if (VERBOSE) {
output('Using cached message');
}
}
if (VERBOSE) {
output(s('Sending message %d with subject %s to %s', $messageid, $cached[$messageid]["subject"], $email));
}
## at this stage we don't know whether the content is HTML or text, it's just content
$content = $cached[$messageid]['content'];
if (VERBOSE && $getspeedstats) {
output('Load user start');
}
$userdata = array();
$user_att_values = array();
#0011857: forward to friend, retain attributes
if ($hash == 'forwarded' && defined('KEEPFORWARDERATTRIBUTES') && KEEPFORWARDERATTRIBUTES) {
$user_att_values = getUserAttributeValues($forwardedby['email']);
} elseif ($hash != 'forwarded') {
$user_att_values = getUserAttributeValues($email);
}
if (!is_array($user_att_values)) {
$user_att_values = array();
}
foreach ($user_att_values as $key => $val) {
$newkey = cleanAttributeName($key);
## in the help, we only list attributes with "strlen < 20"
unset($user_att_values[$key]);
if (strlen($key) < 20) {
$user_att_values[$newkey] = $val;
}
}
# print '<pre>';var_dump($user_att_values);print '</pre>';exit;
$query = sprintf('select * from %s where email = ?', $GLOBALS["tables"]["user"]);
$rs = Sql_Query_Params($query, array($email));
$userdata = Sql_Fetch_Assoc($rs);
if (empty($userdata['id'])) {
$userdata = array();
}
#var_dump($userdata);
if (stripos($content, "[LISTS]") !== false) {
$listsarr = array();
$req = Sql_Query(sprintf('select list.name from %s as list,%s as listuser where list.id = listuser.listid and listuser.userid = %d', $GLOBALS["tables"]["list"], $GLOBALS["tables"]["listuser"], $userdata["id"]));
while ($row = Sql_Fetch_Row($req)) {
array_push($listsarr, $row[0]);
}
if (!empty($listsarr)) {
$html['lists'] = join('<br/>', $listsarr);
$text['lists'] = join("\n", $listsarr);
} else {
$html['lists'] = $GLOBALS['strNoListsFound'];
$text['lists'] = $GLOBALS['strNoListsFound'];
}
unset($listsarr);
}
if (VERBOSE && $getspeedstats) {
output('Load user end');
}
if ($cached[$messageid]['userspecific_url']) {
if (VERBOSE && $getspeedstats) {
output('fetch personal URL start');
}
## Fetch external content, only if the URL has placeholders
if ($GLOBALS["can_fetchUrl"] && preg_match("/\\[URL:([^\\s]+)\\]/i", $content, $regs)) {
while (isset($regs[1]) && strlen($regs[1])) {
$url = $regs[1];
if (!preg_match('/^http/i', $url)) {
$url = 'http://' . $url;
}
$remote_content = fetchUrl($url, $userdata);
# @@ don't use this
# $remote_content = includeStyles($remote_content);
if ($remote_content) {
//.........这里部分代码省略.........
示例7: processQueueOutput
return;
}
$counters['batch_total'] = $counters['num_per_batch'];
$counters['failed_sent'] = 0;
$counters['invalid'] = 0;
$counters['sent'] = 0;
if (0 && $reload) {
processQueueOutput(s('Sent in last run') . ": {$lastsent}", 0, 'progress');
processQueueOutput(s('Skipped in last run') . ": {$lastskipped}", 0, 'progress');
}
$script_stage = 1;
# we are active
$notsent = $unconfirmed = $cannotsend = 0;
## check for messages that need requeuing
$req = Sql_Query(sprintf('select id from %s where requeueinterval > 0 and requeueuntil > now() and status = "sent"', $tables['message']));
while ($msg = Sql_Fetch_Assoc($req)) {
Sql_query(sprintf('UPDATE %s
SET status = "submitted",
sendstart = null,
embargo = embargo +
INTERVAL (FLOOR(TIMESTAMPDIFF(MINUTE, embargo, GREATEST(embargo, NOW())) / requeueinterval) + 1) * requeueinterval MINUTE
WHERE id = %d', $GLOBALS['tables']['message'], $msg['id']));
foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
$plugin->messageReQueued($msg['id']);
}
## @@@ need to update message data as well
}
$messagelimit = '';
## limit the number of campaigns to work on
if (defined('MAX_PROCESS_MESSAGE')) {
$messagelimit = sprintf(' limit %d ', MAX_PROCESS_MESSAGE);
示例8: getPageLock
function getPageLock($force = 0)
{
global $tables;
$thispage = $GLOBALS['page'];
if ($thispage == 'pageaction') {
$thispage = $_GET['action'];
}
$thispage = preg_replace('/\\W/', '', $thispage);
# cl_output('getting pagelock '.$thispage);
# ob_end_flush();
if ($GLOBALS['commandline'] && $thispage == 'processqueue') {
if (is_object($GLOBALS['MC'])) {
## multi-send requires a valid memcached setup
$max = MAX_SENDPROCESSES;
} else {
$max = 1;
}
} else {
$max = 1;
}
## allow killing other processes
if ($force) {
Sql_query('delete from ' . $tables['sendprocess'] . ' where page = "' . sql_escape($thispage) . '"');
}
$running_req = Sql_query(sprintf('select now() - modified as age,id from %s where page = "%s" and alive order by started desc', $tables['sendprocess'], sql_escape($thispage)));
$count = Sql_Num_Rows($running_req);
$running_res = Sql_Fetch_Assoc($running_req);
$waited = 0;
# while ($running_res['age'] && $count >= $max) { # a process is already running
while ($count >= $max) {
# don't check age, as it may be 0
# cl_output('running process: '.$running_res['age'].' '.$max);
if ($running_res['age'] > 600) {
# some sql queries can take quite a while
#cl_output($running_res['id'].' is old '.$running_res['age']);
# process has been inactive for too long, kill it
Sql_query("update {$tables['sendprocess']} set alive = 0 where id = " . $running_res['id']);
} elseif ((int) $count >= (int) $max) {
# cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
sleep(1);
# to log the messages in the correct order
if ($GLOBALS['commandline']) {
cl_output(s('A process for this page is already running and it was still alive %d seconds ago', $running_res['age']), 0);
cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
exit;
}
output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
flush();
$abort = ignore_user_abort(0);
sleep(20);
}
++$waited;
if ($waited > 10) {
# we have waited 10 cycles, abort and quit script
output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
return false;
}
$running_req = Sql_query('select now() - modified,id from ' . $tables['sendprocess'] . " where page = \"{$thispage}\" and alive order by started desc");
$count = Sql_Num_Rows($running_req);
$running_res = Sql_Fetch_row($running_req);
}
if (!empty($GLOBALS['commandline'])) {
$processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
} else {
$processIdentifier = $_SERVER['REMOTE_ADDR'];
}
$res = Sql_query('insert into ' . $tables['sendprocess'] . ' (started,page,alive,ipaddress) values(now(),"' . $thispage . '",1,"' . $processIdentifier . '")');
$send_process_id = Sql_Insert_Id();
$abort = ignore_user_abort(1);
# cl_output('Got pagelock '.$send_process_id );
return $send_process_id;
}
示例9: getPageLock
function getPageLock($force = 0)
{
global $tables;
$thispage = $GLOBALS["page"];
if ($thispage == 'pageaction') {
$thispage = $_GET['action'];
}
# cl_output('getting pagelock '.$thispage);
# ob_end_flush();
if ($GLOBALS["commandline"] && $thispage == 'processqueue') {
if (is_object($GLOBALS['MC'])) {
## multi-send requires a valid memcached setup
$max = MAX_SENDPROCESSES;
} else {
$max = 1;
}
} else {
$max = 1;
}
## allow killing other processes
if ($force) {
Sql_Query_Params("delete from " . $tables['sendprocess'] . " where page = ?", array($thispage));
}
$query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
$running_req = Sql_Query_Params($query, array($thispage));
$running_res = Sql_Fetch_Assoc($running_req);
$count = Sql_Num_Rows($running_req);
if (VERBOSE) {
cl_output($count . ' out of ' . $max . ' active processes');
}
$waited = 0;
# while ($running_res['age'] && $count >= $max) { # a process is already running
while ($count >= $max) {
# don't check age, as it may be 0
# cl_output('running process: '.$running_res['age'].' '.$max);
if ($running_res['age'] > 600) {
# some sql queries can take quite a while
#cl_output($running_res['id'].' is old '.$running_res['age']);
# process has been inactive for too long, kill it
Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = " . $running_res['id']);
} elseif ((int) $count >= (int) $max) {
# cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
output(sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'), $running_res['age']), 0);
sleep(1);
# to log the messages in the correct order
if ($GLOBALS["commandline"]) {
cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
exit;
}
output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
flush();
$abort = ignore_user_abort(0);
sleep(20);
}
$waited++;
if ($waited > 10) {
# we have waited 10 cycles, abort and quit script
output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
return false;
}
$query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
$running_req = Sql_Query_Params($query, array($thispage));
$running_res = Sql_Fetch_Assoc($running_req);
$count = Sql_Num_Rows($running_req);
}
$query = ' insert into ' . $tables['sendprocess'] . ' (started, page, alive, ipaddress)' . ' values' . ' (current_timestamp, ?, 1, ?)';
if (!empty($GLOBALS['commandline'])) {
$processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
} else {
$processIdentifier = $_SERVER['REMOTE_ADDR'];
}
$res = Sql_Query_Params($query, array($thispage, $processIdentifier));
$send_process_id = Sql_Insert_Id($tables['sendprocess'], 'id');
$abort = ignore_user_abort(1);
# cl_output('Got pagelock '.$send_process_id );
return $send_process_id;
}
示例10: processMbox
case "mbox":
$download_report = processMbox($bounce_mailbox);
break;
default:
Error($GLOBALS['I18N']->get("bounce_protocol not supported"));
return;
}
# now we have filled database with all available bounces
## reprocess the unidentified ones, as the bounce detection has improved, so it might catch more
cl_output('reprocessing');
$reparsed = $count = 0;
$reidentified = 0;
$req = Sql_Query(sprintf('select * from %s where status = "unidentified bounce"', $tables['bounce']));
$total = Sql_Affected_Rows();
cl_output(s('%d bounces to reprocess', $total));
while ($bounce = Sql_Fetch_Assoc($req)) {
$count++;
if ($count % 25 == 0) {
cl_progress(s('%d out of %d processed', $count, $total));
}
$bounceBody = decodeBody($bounce['header'], $bounce['data']);
$userid = findUserID($bounceBody);
$messageid = findMessageId($bounceBody);
if (!empty($userid) || !empty($messageid)) {
$reparsed++;
if (processBounceData($bounce['id'], $messageid, $userid)) {
$reidentified++;
}
}
}
cl_output(s('%d out of %d processed', $count, $total));
示例11: Sql_query
. ' from ' . $tables['list']
. $subselect
. ' order by listorder '.$limit;
$result = Sql_query($query);
*/
}
while ($row = Sql_fetch_array($result)) {
## we only consider confirmed and not blacklisted subscribers members of a list
## we assume "confirmed" to be 1 or 0, so that the sum gives the total confirmed
## could be incorrect, as 1000 is also "true" but will be ok (saves a few queries)
## same with blacklisted, but we're disregarding that for now, because blacklisted subscribers should not
## be on the list at all.
## @@TODO increase accuracy, without adding loads of queries.
$query = ' select count(u.id) as total,' . ' sum(u.confirmed) as confirmed, ' . ' sum(u.blacklisted) as blacklisted ' . ' from ' . $tables['listuser'] . ' lu, ' . $tables['user'] . ' u where u.id = lu.userid and listid = ? ';
$req = Sql_Query_Params($query, array($row["id"]));
$membercount = Sql_Fetch_Assoc($req);
$members = $membercount['confirmed'];
$unconfirmedMembers = (int) ($membercount['total'] - $members);
$desc = stripslashes($row['description']);
if ($unconfirmedMembers > 0) {
$membersDisplay = '<span class="memberCount">' . $members . '</span> <span class="unconfirmedCount">(' . $unconfirmedMembers . ')</span>';
} else {
$membersDisplay = '<span class="memberCount">' . $members . '</span>';
}
//## allow plugins to add columns
// @@@ TODO review this
//foreach ($GLOBALS['plugins'] as $plugin) {
//$desc = $plugin->displayLists($row) . $desc;
//}
$element = '<!-- ' . $row['id'] . '-->' . stripslashes($row['name']);
$ls->addElement($element);
示例12: shortenTextDisplay
$ls->addColumn($element, ' ', shortenTextDisplay($messagedata['subject'], 30));
$element = ucfirst(s('Date entered'));
$ls->addElement($element);
$ls->addColumn($element, ' ', $messagedata['entered']);
$element = ucfirst(s('Date sent'));
$ls->addElement($element);
$ls->addColumn($element, ' ', $messagedata['sent']);
$element = ucfirst(s('Sent as HTML'));
$ls->addElement($element);
$ls->addColumn($element, ' ', $messagedata['astextandhtml']);
$element = ucfirst(s('Sent as text'));
$ls->addElement($element);
$ls->addColumn($element, ' ', $messagedata['astext']);
$totalSent = 0;
$sentQ = Sql_Query(sprintf('select status,count(userid) as num from %s where messageid = %d group by status', $tables['usermessage'], $id));
while ($row = Sql_Fetch_Assoc($sentQ)) {
$element = ucfirst($row['status']);
$ls->addElement($element);
$ls->addColumn($element, ' ', $row['num']);
if ($row['status'] == 'sent') {
$totalSent = $row['num'];
}
}
/*
$element = ucfirst(s('Bounced'));
$ls->addElement($element);
$ls->addColumn($element,' ',$messagedata['bouncecount']);
*/
$bounced = Sql_Fetch_Row_Query(sprintf('select count(distinct user) from %s where message = %d', $tables['user_message_bounce'], $id));
$element = ucfirst(s('Bounced'));
$ls->addElement($element);
示例13: precacheMessage
//.........这里部分代码省略.........
if ($GLOBALS['can_fetchUrl'] && preg_match("/\\[URL:([^\\s]+)\\]/i", $cached[$messageid]['content'], $regs)) {
$remote_content = fetchUrl($regs[1], array());
# $remote_content = fetchUrl($message['sendurl'],array());
# @@ don't use this
# $remote_content = includeStyles($remote_content);
if ($remote_content) {
$cached[$messageid]['content'] = str_replace($regs[0], $remote_content, $cached[$messageid]['content']);
# $cached[$messageid]['content'] = $remote_content;
$cached[$messageid]['htmlformatted'] = strip_tags($remote_content) != $remote_content;
## 17086 - disregard any template settings when we have a valid remote URL
$cached[$messageid]['template'] = null;
$cached[$messageid]['templateid'] = null;
} else {
#print Error(s('unable to fetch web page for sending'));
logEvent('Error fetching URL: ' . $message['sendurl'] . ' cannot proceed');
return false;
}
}
if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
output('fetch URL end');
}
/*
print $message['sendurl'];
print $remote_content;exit;
*/
}
// end if not userspecific url
if ($cached[$messageid]['htmlformatted']) {
# $cached[$messageid]["content"] = compressContent($cached[$messageid]["content"]);
}
$cached[$messageid]['google_track'] = $message['google_track'];
/*
else {
print $message['sendurl'];
exit;
}
*/
foreach ($GLOBALS['plugins'] as $plugin) {
$plugin->processPrecachedCampaign($messageid, $cached[$messageid]);
}
if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
output('parse config start');
}
/*
* this is not a good idea, as it'll replace eg "unsubscribeurl" with a general one instead of personalised
* if (is_array($GLOBALS["default_config"])) {
foreach($GLOBALS["default_config"] as $key => $val) {
if (is_array($val)) {
$cached[$messageid]['content'] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['content']);
$cached[$messageid]["textcontent"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]["textcontent"]);
$cached[$messageid]["textfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['textfooter']);
$cached[$messageid]["htmlfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['htmlfooter']);
}
}
}
*/
if (VERBOSE && !empty($GLOBALS['getspeedstats'])) {
output('parse config end');
}
## ##17233 not that many fields are actually useful, so don't blatantly use all
# foreach($message as $key => $val) {
foreach (array('subject', 'id', 'fromname', 'fromemail') as $key) {
$val = $message[$key];
if (!is_array($val)) {
$cached[$messageid]['content'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['content']);
$cached[$messageid]['textcontent'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['textcontent']);
$cached[$messageid]['textfooter'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['textfooter']);
$cached[$messageid]['htmlfooter'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['htmlfooter']);
}
}
/*
* cache message owner and list owner attribute values
*/
$cached[$messageid]['adminattributes'] = array();
$result = Sql_Query("SELECT a.name, aa.value\n FROM {$tables['adminattribute']} a\n JOIN {$tables['admin_attribute']} aa ON a.id = aa.adminattributeid\n JOIN {$tables['message']} m ON aa.adminid = m.owner\n WHERE m.id = {$messageid}");
if ($result !== false) {
while ($att = Sql_Fetch_Array($result)) {
$cached[$messageid]['adminattributes']['OWNER.' . $att['name']] = $att['value'];
}
}
$result = Sql_Query("SELECT DISTINCT l.owner\n FROM {$tables['list']} AS l\n JOIN {$tables['listmessage']} AS lm ON lm.listid = l.id\n WHERE lm.messageid = {$messageid}");
if ($result !== false && Sql_Num_Rows($result) == 1) {
$row = Sql_Fetch_Assoc($result);
$listOwner = $row['owner'];
$att_req = Sql_Query("SELECT a.name, aa.value\n FROM {$tables['adminattribute']} a\n JOIN {$tables['admin_attribute']} aa ON a.id = aa.adminattributeid\n WHERE aa.adminid = {$listOwner}");
while ($att = Sql_Fetch_Array($att_req)) {
$cached[$messageid]['adminattributes']['LISTOWNER.' . $att['name']] = $att['value'];
}
}
$baseurl = $GLOBALS['website'];
if (defined('UPLOADIMAGES_DIR') && UPLOADIMAGES_DIR) {
## escape subdirectories, otherwise this renders empty
$dir = str_replace('/', '\\/', UPLOADIMAGES_DIR);
$cached[$messageid]['content'] = preg_replace('/<img(.*)src="\\/' . $dir . '(.*)>/iU', '<img\\1src="' . $GLOBALS['public_scheme'] . '://' . $baseurl . '/' . UPLOADIMAGES_DIR . '\\2>', $cached[$messageid]['content']);
}
foreach (array('content', 'template', 'htmlfooter') as $element) {
$cached[$messageid][$element] = parseLogoPlaceholders($cached[$messageid][$element]);
}
return 1;
}
示例14: sprintf
} else {
print '<p>' . $GLOBALS['I18N']->get('None found') . '</p>';
}
return;
}
$query = sprintf('select lu.userid, count(umb.bounce) as numbounces from %s lu join %s umb on lu.userid = umb.user
where ' . ' lu.listid = %d
group by lu.userid
', $GLOBALS['tables']['listuser'], $GLOBALS['tables']['user_message_bounce'], $listid);
$req = Sql_Query($query);
$total = Sql_Affected_Rows();
$limit = '';
$numpp = 150;
$selectOtherlist = new buttonGroup(new Button(PageUrl2('listbounces'), $GLOBALS['I18N']->get('Select another list')));
$lists = Sql_Query(sprintf('select id,name from %s list %s order by listorder', $tables['list'], $isowner_where));
while ($list = Sql_Fetch_Assoc($lists)) {
$selectOtherlist->addButton(new Button(PageUrl2('listbounces') . '&id=' . $list['id'], htmlspecialchars($list['name'])));
}
print $selectOtherlist->show();
if ($total) {
print PageLinkButton('listbounces&type=dl&id=' . $listid, 'Download emails');
}
print '<p>' . s('%d bounces to list %s', $total, listName($listid)) . '</p>';
$start = empty($_GET['start']) ? 0 : sprintf('%d', $_GET['start']);
if ($total > $numpp && !$download) {
# print Paging2('listbounces&id='.$listid,$total,$numpp,'Page');
# $listing = sprintf($GLOBALS['I18N']->get("Listing %s to %s"),$s,$s+$numpp);
$limit = "limit {$start}," . $numpp;
print simplePaging('listbounces&id=' . $listid, $start, $total, $numpp);
$query .= $limit;
$req = Sql_Query($query);
示例15: loadImageCache
function loadImageCache($messagedata = array())
{
$this->curid = $messagedata['id'];
$this->cache[$this->curid] = array();
// Make sure that the cache defined
// even if no images
$msgtbl = $GLOBALS['tables']['inlineImagePlugin_msg'];
$imgtbl = $GLOBALS['tables']['inlineImagePlugin_image'];
$query = sprintf('select original, imagetag, cid, type, file_name, local_name from %s natural join %s where id = %d', $msgtbl, $imgtbl, $this->curid);
$result = Sql_Query($query);
$i = 0;
while ($row = Sql_Fetch_Assoc($result)) {
$this->cache[$this->curid][$i] = $row;
$this->cache[$this->curid][$i]['contents'] = file_get_contents($row['local_name']);
$i++;
}
}