本文整理汇总了PHP中Sql_Fetch_Array函数的典型用法代码示例。如果您正苦于以下问题:PHP Sql_Fetch_Array函数的具体用法?PHP Sql_Fetch_Array怎么用?PHP Sql_Fetch_Array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sql_Fetch_Array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mergeUser
function mergeUser($userid)
{
$duplicate = Sql_Fetch_Array_Query("select * from {$GLOBALS["tables"]["user"]} where id = {$userid}");
printf('<br/>%s', $duplicate["email"]);
if (preg_match("/^duplicate[^ ]* (.*)/", $duplicate["email"], $regs)) {
print "-> " . $regs[1];
$email = $regs[1];
} elseif (preg_match("/^([^ ]+@[^ ]+) \\(\\d+\\)/", $duplicate["email"], $regs)) {
print "-> " . $regs[1];
$email = $regs[1];
} else {
$email = "";
}
if ($email) {
$orig = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"', $GLOBALS["tables"]["user"], $email));
if ($orig[0]) {
print " " . $GLOBALS['I18N']->get("user found");
$umreq = Sql_Query("select * from {$GLOBALS["tables"]["usermessage"]} where userid = " . $duplicate["id"]);
while ($um = Sql_Fetch_Array($umreq)) {
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS["tables"]["usermessage"], $orig[0], $um["entered"], $duplicate["id"], $um["entered"]));
}
$bncreq = Sql_Query("select * from {$GLOBALS["tables"]["user_message_bounce"]} where user = " . $duplicate["id"]);
while ($bnc = Sql_Fetch_Array($bncreq)) {
Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"', $GLOBALS["tables"]["user_message_bounce"], $orig[0], $bnc["time"], $duplicate["id"], $bnc["time"]));
}
Sql_Query("delete from {$GLOBALS["tables"]["listuser"]} where userid = " . $duplicate["id"]);
} else {
print " " . $GLOBALS['I18N']->get("no user found");
}
flush();
} else {
print "-> " . $GLOBALS['I18N']->get("unable to find original email");
}
}
示例2: rssUserHasContent
function rssUserHasContent($userid,$messageid,$frequency) {
global $tables;
switch ($frequency) {
case "weekly":
$interval = 'interval 7 day';break;
case "monthly":
$interval = 'interval 1 month';break;
case "daily":
default:
$interval = 'interval 1 day';break;
}
$cansend_req = Sql_Query(sprintf('select date_add(last,%s) < now() from %s where userid = %d',
$interval,$tables["user_rss"],$userid));
$exists = Sql_Affected_Rows();
$cansend = Sql_Fetch_Row($cansend_req);
if (!$exists || $cansend[0]) {
# we can send this user as far as the frequency is concerned
# now check whether there is actually some content
# check what lists to use. This is the intersection of the lists for the
# user and the lists for the message
$lists = array();
$listsreq = Sql_Query(sprintf('
select %s.listid from %s,%s where %s.listid = %s.listid and %s.userid = %d and
%s.messageid = %d',
$tables["listuser"],$tables["listuser"],$tables["listmessage"],
$tables["listuser"],$tables["listmessage"],
$tables["listuser"],$userid,$tables["listmessage"],$messageid));
while ($row = Sql_Fetch_Row($listsreq)) {
array_push($lists,$row[0]);
}
if (!sizeof($lists))
return 0;
$liststosend = join(",",$lists);
# request the rss items that match these lists and that have not been sent to this user
$itemstosend = array();
$max = sprintf('%d',getConfig("rssmax"));
if (!$max) {
$max = 30;
}
$itemreq = Sql_Query("select {$tables["rssitem"]}.*
from {$tables["rssitem"]} where {$tables["rssitem"]}.list in ($liststosend) order by added desc, list,title limit $max");
while ($item = Sql_Fetch_Array($itemreq)) {
Sql_Query("select * from {$tables["rssitem_user"]} where itemid = {$item["id"]} and userid = $userid");
if (!Sql_Affected_Rows()) {
array_push($itemstosend,$item["id"]);
}
}
# print "<br/>Items to send for user $userid: ".sizeof($itemstosend);
# if it is less than the treshold return nothing
$treshold = getConfig("rsstheshold");
if (sizeof($itemstosend) >= $treshold)
return $itemstosend;
else
return array();
}
return array();
}
示例3: userSelect
function userSelect($fieldname, $current = '')
{
$html = sprintf('<select name="%s">', $fieldname);
$req = Sql_Query(sprintf('select id,email from user order by email'));
while ($row = Sql_Fetch_Array($req)) {
$html .= sprintf('<option value="%d" %s>%s</option>', $row['id'], $current == $row['id'] ? 'selected="selected"' : '', $row['email']);
}
$html .= '</select>';
return $html;
}
示例4: adminMenu
function adminMenu()
{
global $adminlevel, $config;
if ($adminlevel == "superuser") {
$html .= menuLink("admins", "administrators");
$html .= menuLink("groups", "groups");
$html .= menuLink("users", "users");
$html .= menuLink("userattributes", "user attributes");
$req = Sql_Query('select * from attribute where type = "select" or type = "radio" or type = "checkboxgroup"');
while ($row = Sql_Fetch_Array($req)) {
$html .= menuLink("editattributes&id=" . $row["id"], "> " . $row["name"]);
}
$html .= menuLink("branches", "branch fields", "option=branchfields");
$html .= menuLink("templates", "templates");
}
return $html;
}
示例5: mergeUsers
function mergeUsers($original, $duplicate)
{
set_time_limit(60);
print '<br/>Merging ' . $duplicate . ' into ' . $original;
$umreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS["tables"]["usermessage"], $duplicate));
while ($um = Sql_Fetch_Array($umreq)) {
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS["tables"]["usermessage"], $original, $um["entered"], $duplicate, $um["entered"]), 1);
}
$bncreq = Sql_Query(sprintf('select * from %s where user = %d', $GLOBALS["tables"]["user_message_bounce"], $duplicate));
while ($bnc = Sql_Fetch_Array($bncreq)) {
Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"', $GLOBALS["tables"]["user_message_bounce"], $original, $bnc["time"], $duplicate, $bnc["time"]), 1);
}
$listreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS["tables"]["listuser"], $duplicate));
while ($list = Sql_Fetch_Array($listreq)) {
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s" and listid = %d', $GLOBALS["tables"]["listuser"], $original, $list["entered"], $duplicate, $list["entered"], $list['listid']), 1);
}
Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS["tables"]["listuser"], $duplicate));
Sql_Query(sprintf('delete from %s where user = %d', $GLOBALS["tables"]["user_message_bounce"], $duplicate));
Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS["tables"]["usermessage"], $duplicate));
# if (MERGE_DUPLICATES_DELETE_DUPLICATE) {
deleteUser($duplicate);
# }
flush();
}
示例6: ListAllAttributes
function ListAllAttributes() {
global $tables;
$attributes = array();
$attributedata = array();
$res = Sql_Query("select * from {$tables["attribute"]} order by listorder");
while ($row = Sql_Fetch_Array($res)) {
# print $row["id"]. " ".$row["name"];
$attributes[$row["id"]] = $row["listorder"];
$attributedata[$row["id"]]["id"] = $row["id"];
$attributedata[$row["id"]]["default_value"] = $row["default_value"];
$attributedata[$row["id"]]["listorder"] = $row["listorder"];
$attributedata[$row["id"]]["required"] = $row["required"];
$attributedata[$row["id"]]["default_value"] = $row["default_value"];
}
return ListAttributes($attributes,$attributedata,"checkforhtml");
}
示例7: forwardPage
function forwardPage($id)
{
global $tables;
$ok = true;
$subtitle = '';
$info = '';
$html = '';
$form = '';
$personalNote = '';
## Check requirements
# message
$mid = 0;
if (isset($_REQUEST['mid'])) {
$mid = sprintf('%d', $_REQUEST['mid']);
$messagedata = loadMessageData($mid);
$mid = $messagedata['id'];
if ($mid) {
$subtitle = $GLOBALS['strForwardSubtitle'] . ' ' . stripslashes($messagedata['subject']);
}
}
#mid set
# user
if (!isset($_REQUEST['uid']) || !$_REQUEST['uid']) {
FileNotFound();
}
## get userdata
$req = Sql_Query(sprintf('select * from %s where uniqid = "%s"', $tables['user'], sql_escape($_REQUEST['uid'])));
$userdata = Sql_Fetch_Array($req);
## verify that this subscriber actually received this message to forward, otherwise they're not allowed
$allowed = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and messageid = %d', $GLOBALS['tables']['usermessage'], $userdata['id'], $mid));
if (empty($userdata['id']) || $allowed[0] != $userdata['id']) {
## when sending a test email as an admin, the entry isn't there yet
if (empty($_SESSION['adminloggedin']) || $_SESSION['adminloggedin'] != $_SERVER['REMOTE_ADDR']) {
FileNotFound('<br/><i>' . $GLOBALS['I18N']->get('When testing the phpList forward functionality, you need to be logged in as an administrator.') . '</i><br/>');
}
}
$firstpage = 1;
## is this the initial page or a followup
# forward addresses
$forwardemail = '';
if (isset($_REQUEST['email']) && !empty($_REQUEST['email'])) {
$firstpage = 0;
$forwardPeriodCount = Sql_Fetch_Array_Query(sprintf('select count(user) from %s where date_add(time,interval %s) >= now() and user = %d and status ="sent" ', $tables['user_message_forward'], FORWARD_EMAIL_PERIOD, $userdata['id']));
$forwardemail = stripslashes($_REQUEST['email']);
$emails = explode("\n", $forwardemail);
$emails = trimArray($emails);
$forwardemail = implode("\n", $emails);
#0011860: forward to friend, multiple emails
$emailCount = $forwardPeriodCount[0];
foreach ($emails as $index => $email) {
$emails[$index] = trim($email);
if (is_email($email)) {
++$emailCount;
} else {
$info .= sprintf('<br />' . $GLOBALS['strForwardInvalidEmail'], $email);
$ok = false;
}
}
if ($emailCount > FORWARD_EMAIL_COUNT) {
$info .= '<br />' . $GLOBALS['strForwardCountReached'];
$ok = false;
}
} else {
$ok = false;
}
#0011996: forward to friend - personal message
# text cannot be longer than max, to prevent very long text with only linefeeds total cannot be longer than twice max
if (FORWARD_PERSONAL_NOTE_SIZE && isset($_REQUEST['personalNote'])) {
if (strlen(strip_newlines($_REQUEST['personalNote'])) > FORWARD_PERSONAL_NOTE_SIZE || strlen($_REQUEST['personalNote']) > FORWARD_PERSONAL_NOTE_SIZE * 2) {
$info .= '<BR />' . $GLOBALS['strForwardNoteLimitReached'];
$ok = false;
}
$personalNote = strip_tags(htmlspecialchars_decode(stripslashes($_REQUEST['personalNote'])));
$userdata['personalNote'] = $personalNote;
}
if ($userdata['id'] && $mid) {
if ($ok && count($emails)) {
## All is well, send it
require_once 'admin/sendemaillib.php';
#0013845 Lead Ref Scheme
if (FORWARD_FRIEND_COUNT_ATTRIBUTE) {
$iCountFriends = FORWARD_FRIEND_COUNT_ATTRIBUTE;
} else {
$iCountFriends = 0;
}
if ($iCountFriends) {
$nFriends = intval(UserAttributeValue($userdata['id'], $iCountFriends));
}
## remember the lists for this message in order to notify only those admins
## that own them
$messagelists = array();
$messagelistsreq = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS['tables']['listmessage'], $mid));
while ($row = Sql_Fetch_Row($messagelistsreq)) {
array_push($messagelists, $row[0]);
}
foreach ($emails as $index => $email) {
#0011860: forward to friend, multiple emails
$done = Sql_Fetch_Array_Query(sprintf('select user,status,time from %s where forward = "%s" and message = %d', $tables['user_message_forward'], $email, $mid));
$info .= '<br />' . $email . ': ';
if ($done['status'] === 'sent') {
//.........这里部分代码省略.........
示例8: s
print '<label>' . s('Name') . ':</label>
<input type="text" name="name[' . $row['id'] . ']" value="' . htmlspecialchars(stripslashes(strip_tags($row['name']))) . '" size="40" />';
print '<label>' . s('Type') . ': </label>
<!--<input type="hidden" name="type[' . $row['id'] . ']" value="' . $row['type'] . '">' . $row['type'] . '-->';
print '<select name="type[' . $row['id'] . ']" onchange="warn();">';
foreach ($types as $key => $val) {
printf('<option value="%s" %s>%s</option>', $val, $val == $row['type'] ? 'selected="selected"' : '', $GLOBALS['I18N']->get($val));
}
print '
</select>';
if (defined('IN_WEBBLER') && IN_WEBBLER || defined('WEBBLER') && WEBBLER) {
if ($row['type'] == 'select' || $row['type'] == 'radio' || $row['type'] == 'checkboxgroup') {
print ' ' . $I18N->get('authoritative list') . ' ';
printf('<select name="keywordlib[%d]"><option value="">-- select</option>', $row['id']);
$req = Sql_Query(sprintf('select id,name from keywordlib order by listorder,name'));
while ($kwlib = Sql_Fetch_Array($req)) {
printf('<option value="%d" %s>%s</option>', $kwlib['id'], $row['keywordlib'] == $kwlib['id'] ? 'selected="selected"' : '', htmlspecialchars($kwlib['name']));
}
print '</select>';
}
}
if ((!defined('IN_WEBBLER') || !IN_WEBBLER) && (!defined('WEBBLER') || !WEBBLER)) {
if ($row['type'] == 'select' || $row['type'] == 'radio' || $row['type'] == 'checkboxgroup') {
print PageLinkButton('editattributes&id=' . $row['id'], $I18N->get('edit values'));
}
}
print '<label>' . $GLOBALS['I18N']->get('Default Value') . ':</label>
<input type="text" name="default[' . $row['id'] . ']" value="' . htmlspecialchars(stripslashes($row['default_value'])) . '" size="40" />';
print '<label>' . $GLOBALS['I18N']->get('Order of Listing') . ':</label>
<input type="text" name="listorder[' . $row['id'] . ']" value="' . $row['listorder'] . '" size="5" />';
print '<label>' . $GLOBALS['I18N']->get('Is this attribute required ?') . '<input type="checkbox" name="required[' . $row['id'] . ']" value="1" ';
示例9: mergeUser
function mergeUser($userid)
{
$duplicate = Sql_Fetch_Array_Query("select * from {$GLOBALS['tables']['user']} where id = {$userid}");
printf('<br/>%s', $duplicate['email']);
if (preg_match('/^duplicate[^ ]* (.*)/', $duplicate['email'], $regs)) {
print '-> ' . $regs[1];
$email = $regs[1];
} elseif (preg_match("/^([^ ]+@[^ ]+) \\(\\d+\\)/", $duplicate['email'], $regs)) {
print '-> ' . $regs[1];
$email = $regs[1];
} else {
$email = '';
}
if ($email) {
$orig = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"', $GLOBALS['tables']['user'], $email));
if ($orig[0]) {
print ' ' . $GLOBALS['I18N']->get('user found');
$umreq = Sql_Query("select * from {$GLOBALS['tables']['usermessage']} where userid = " . $duplicate['id']);
while ($um = Sql_Fetch_Array($umreq)) {
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS['tables']['usermessage'], $orig[0], $um['entered'], $duplicate['id'], $um['entered']), 1);
}
$bncreq = Sql_Query("select * from {$GLOBALS['tables']['user_message_bounce']} where user = " . $duplicate['id']);
while ($bnc = Sql_Fetch_Array($bncreq)) {
Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"', $GLOBALS['tables']['user_message_bounce'], $orig[0], $bnc['time'], $duplicate['id'], $bnc['time']), 1);
}
Sql_Query("delete from {$GLOBALS['tables']['listuser']} where userid = " . $duplicate['id']);
Sql_Query("delete from {$GLOBALS['tables']['user_message_bounce']} where user = " . $duplicate['id']);
Sql_Query("delete from {$GLOBALS['tables']['usermessage']} where userid = " . $duplicate['id']);
if (MERGE_DUPLICATES_DELETE_DUPLICATE) {
deleteUser($duplicate['id']);
}
} else {
print ' ' . $GLOBALS['I18N']->get('no user found');
# so it must be save to rename the original to the actual email
Sql_Query(sprintf('update %s set email = "%s" where id = %d', $GLOBALS['tables']['user'], $email, $userid));
}
flush();
} else {
print '-> ' . $GLOBALS['I18N']->get('unable to find original email');
}
}
示例10: sprintf
$att_content .= sprintf('<div><b>%s</b> %s:</div><div><input type="text" name="localattachment%d" size="50"/></div>', $GLOBALS['I18N']->get('or'), $GLOBALS['I18N']->get('Path to file on server'), $att_cnt, $att_cnt);
}
$att_content .= sprintf('<div>%s:</div>
<div><textarea name="attachment%d_description" cols="65" rows="3" wrap="virtual"></textarea></div>', $GLOBALS['I18N']->get('Description of attachment'), $att_cnt);
}
$att_content .= '</div>';
# $shader = new WebblerShader("Attachments");
# $shader->addContent($att_content);
# $shader->initialstate = 'closed';
# print $shader->display();
}
// Load the email address for the admin user so we can use that as the default value in the testtarget field
# @@@ this only works with phplist authentication, needs to be abstracted
if (!isset($messagedata['testtarget'])) {
$res = Sql_Query(sprintf('Select email from %s where id = %d', $tables['admin'], $_SESSION['logindetails']['id']));
$admin_details = Sql_Fetch_Array($res);
$messagedata['testtarget'] = $admin_details['email'];
}
// if there isn't one, load the developer one, just being lazy here :-)
if (empty($messagedata['testtarget']) && isset($GLOBALS['developer_email'])) {
$messagedata['testtarget'] = $GLOBALS['developer_email'];
}
// Display the HTML for the "Send Test" button, and the input field for the email addresses
$sendtest_content = '<div class="sendTest" id="sendTest">
' . $sendtestresult . '
<input class="submit" type="submit" name="sendtest" value="' . s('Send Test') . '" /> ' . Help('sendtest') . ' ' . s('to email address(es)') . ':' . '<input type="text" name="testtarget" size="40" value="' . $messagedata['testtarget'] . '"/><br />' . s('(comma separate addresses - all must be existing subscribers)') . '
</div>';
# notification of progress of message sending
# defaulting to admin_details['email'] gives the wrong impression that this is the
# value in the database, so it is better to leave that empty instead
$notify_start = isset($messagedata['notify_start']) ? $messagedata['notify_start'] : '';
示例11: repeatMessage
function repeatMessage($msgid)
{
# if (!USE_REPETITION && !USE_rss) return;
$data = loadMessageData($msgid);
## do not repeat when it has already been done
if (!empty($data['repeatedid'])) {
return;
}
# get the future embargo, either "repeat" minutes after the old embargo
# or "repeat" after this very moment to make sure that we're not sending the
# message every time running the queue when there's no embargo set.
$msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval repeatinterval minute) as newembargo,
date_add(now(),interval repeatinterval minute) as newembargo2, date_add(embargo,interval repeatinterval minute) > now() as isfuture
from %s where id = %d and repeatuntil > now()', $GLOBALS["tables"]["message"], $msgid));
if (!$msgdata["id"] || !$msgdata["repeatinterval"]) {
return;
}
# copy the new message
$query = ' insert into ' . $GLOBALS['tables']['message'] . ' (entered)' . ' values' . ' (current_timestamp)';
Sql_Query($query);
$newid = Sql_Insert_Id($GLOBALS['tables']['message'], 'id');
require dirname(__FILE__) . '/structure.php';
if (!is_array($DBstruct["message"])) {
logEvent("Error including structure when trying to duplicate message {$msgid}");
return;
}
foreach ($DBstruct["message"] as $column => $rec) {
if ($column != "id" && $column != "entered" && $column != "sendstart") {
Sql_Query(sprintf('update %s set %s = "%s" where id = %d', $GLOBALS["tables"]["message"], $column, addslashes($msgdata[$column]), $newid));
}
}
$req = Sql_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['messagedata'], $msgid));
while ($row = Sql_Fetch_Array($req)) {
setMessageData($newid, $row['name'], $row['data']);
}
# check whether the new embargo is not on an exclusion
if (isset($GLOBALS["repeat_exclude"]) && is_array($GLOBALS["repeat_exclude"])) {
$repeatinterval = $msgdata["repeatinterval"];
$loopcnt = 0;
while (excludedDateForRepetition($msgdata["newembargo"])) {
$repeat += $msgdata["repeatinterval"];
$loopcnt++;
$msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval %d minute) as newembargo,
date_add(current_timestamp,interval %d minute) as newembargo2, date_add(embargo,interval %d minute) > current_timestamp as isfuture
from %s where id = %d and repeatuntil > current_timestamp', $repeatinterval, $repeatinterval, $repeatinterval, $GLOBALS["tables"]["message"], $msgid));
if ($loopcnt > 15) {
logEvent("Unable to find new embargo date too many exclusions? for message {$msgid}");
return;
}
}
}
# correct some values
if (!$msgdata["isfuture"]) {
$msgdata["newembargo"] = $msgdata["newembargo2"];
}
Sql_Query(sprintf('update %s set embargo = "%s",status = "submitted",sent = "" where id = %d', $GLOBALS["tables"]["message"], $msgdata["newembargo"], $newid));
list($e['year'], $e['month'], $e['day'], $e['hour'], $e['minute'], $e['second']) = sscanf($msgdata["newembargo"], '%04d-%02d-%02d %02d:%02d:%02d');
unset($e['second']);
setMessageData($newid, 'embargo', $e);
foreach (array("processed", "astext", "ashtml", "astextandhtml", "aspdf", "astextandpdf", "viewed", "bouncecount") as $item) {
Sql_Query(sprintf('update %s set %s = 0 where id = %d', $GLOBALS["tables"]["message"], $item, $newid));
}
# lists
$req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS["tables"]["listmessage"], $msgid));
while ($row = Sql_Fetch_Row($req)) {
Sql_Query(sprintf('insert into %s (messageid,listid,entered) values(%d,%d,current_timestamp)', $GLOBALS["tables"]["listmessage"], $newid, $row[0]));
}
# attachments
$req = Sql_Query(sprintf('select * from %s,%s where %s.messageid = %d and %s.attachmentid = %s.id', $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"], $GLOBALS["tables"]["message_attachment"], $msgid, $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"]));
while ($row = Sql_Fetch_Array($req)) {
if (is_file($row["remotefile"])) {
# if the "remote file" is actually local, we want to refresh the attachment, so we set
# filename to nothing
$row["filename"] = "";
}
Sql_Query(sprintf('insert into %s (filename,remotefile,mimetype,description,size)
values("%s","%s","%s","%s",%d)', $GLOBALS["tables"]["attachment"], addslashes($row["filename"]), addslashes($row["remotefile"]), addslashes($row["mimetype"]), addslashes($row["description"]), $row["size"]));
$attid = Sql_Insert_Id($GLOBALS['tables']['attachment'], 'id');
Sql_Query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)', $GLOBALS["tables"]["message_attachment"], $newid, $attid));
}
logEvent("Message {$msgid} was successfully rescheduled as message {$newid}");
## remember we duplicated, in order to avoid doing it again (eg when requeuing)
setMessageData($msgid, 'repeatedid', $newid);
}
示例12: repeatMessage
function repeatMessage($msgid)
{
# if (!USE_REPETITION && !USE_RSS) return;
# get the future embargo, either "repeat" minutes after the old embargo
# or "repeat" after this very moment to make sure that we're not sending the
# message every time running the queue when there's no embargo set.
$msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval repeatinterval minute) as newembargo,
date_add(now(),interval repeatinterval minute) as newembargo2, date_add(embargo,interval repeatinterval minute) > now() as isfuture
from %s where id = %d and repeatuntil > now()', $GLOBALS["tables"]["message"], $msgid));
if (!$msgdata["id"] || !$msgdata["repeatinterval"]) {
return;
}
# copy the new message
Sql_Query(sprintf('
insert into %s (entered) values(now())', $GLOBALS["tables"]["message"]));
$id = Sql_Insert_id();
require dirname(__FILE__) . '/structure.php';
if (!is_array($DBstruct["message"])) {
logEvent("Error including structure when trying to duplicate message {$msgid}");
return;
}
foreach ($DBstruct["message"] as $column => $rec) {
if ($column != "id" && $column != "entered" && $column != "sendstart") {
Sql_Query(sprintf('update %s set %s = "%s" where id = %d', $GLOBALS["tables"]["message"], $column, addslashes($msgdata[$column]), $id));
}
}
$req = Sql_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['messagedata'], $msgid));
while ($row = Sql_Fetch_Array($req)) {
Sql_Query(sprintf('insert into %s (name,id,data) values("%s",%d,"%s")', $GLOBALS['tables']['messagedata'], $row['name'], $id, addslashes($row['data'])));
}
# check whether the new embargo is not on an exclusion
if (is_array($GLOBALS["repeat_exclude"])) {
$repeatinterval = $msgdata["repeatinterval"];
$loopcnt = 0;
while (excludedDateForRepetition($msgdata["newembargo"])) {
$repeatinterval += $msgdata["repeatinterval"];
$loopcnt++;
$msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval %d minute) as newembargo,
date_add(now(),interval %d minute) as newembargo2, date_add(embargo,interval %d minute) > now() as isfuture
from %s where id = %d and repeatuntil > now()', $repeatinterval, $repeatinterval, $repeatinterval, $GLOBALS["tables"]["message"], $msgid));
if ($loopcnt > 15) {
logEvent("Unable to find new embargo date too many exclusions? for message {$msgid}");
return;
}
}
}
# correct some values
if (!$msgdata["isfuture"]) {
$msgdata["newembargo"] = $msgdata["newembargo2"];
}
Sql_Query(sprintf('update %s set embargo = "%s",status = "submitted",sent = "" where id = %d', $GLOBALS["tables"]["message"], $msgdata["newembargo"], $id));
// bug 0009687: maybe add "ashtml","astextandhtml" and put them in ashtml?
foreach (array("processed", "astext", "ashtml", "astextandhtml", "aspdf", "astextandpdf", "viewed", "bouncecount") as $item) {
Sql_Query(sprintf('update %s set %s = 0 where id = %d', $GLOBALS["tables"]["message"], $item, $id));
}
# lists
$req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS["tables"]["listmessage"], $msgid));
while ($row = Sql_Fetch_Row($req)) {
Sql_Query(sprintf('insert into %s (messageid,listid,entered) values(%d,%d,now())', $GLOBALS["tables"]["listmessage"], $id, $row[0]));
}
# attachments
$req = Sql_Query(sprintf('select * from %s,%s where %s.messageid = %d and %s.attachmentid = %s.id', $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"], $GLOBALS["tables"]["message_attachment"], $msgid, $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"]));
while ($row = Sql_Fetch_Array($req)) {
if (is_file($row["remotefile"])) {
# if the "remote file" is actually local, we want to refresh the attachment, so we set
# filename to nothing
$row["filename"] = "";
}
Sql_Query(sprintf('insert into %s (filename,remotefile,mimetype,description,size)
values("%s","%s","%s","%s",%d)', $GLOBALS["tables"]["attachment"], addslashes($row["filename"]), addslashes($row["remotefile"]), addslashes($row["mimetype"]), addslashes($row["description"]), $row["size"]));
$attid = Sql_Insert_id();
Sql_Query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)', $GLOBALS["tables"]["message_attachment"], $id, $attid));
}
logEvent("Message {$msgid} was successfully rescheduled as message {$id}");
}
示例13: Sql_query
$att_value = $val[0];
break;
default:
$att_value = $value;
break;
}
Sql_query(sprintf('replace into %s (adminattributeid,adminid,value) values("%s","%s","%s")', $tables["admin_attribute"], $attribute_index, $adminid, $att_value));
}
}
if ($createlist) {
Sql_Query(sprintf('insert into %s (name,description,active,owner)
values("%s","%s",1,%d)', $tables["list"], $loginname, $GLOBALS['I18N']->get('List for') . " {$loginname}", $adminid));
}
# copy permissions from the default set
$req = Sql_Query(sprintf('select * from %s where adminid = 0', $tables["admin_task"]));
while ($task = Sql_Fetch_Array($req)) {
Sql_Query(sprintf('insert into %s (adminid,taskid,level)
values(%d,%d,%d)', $tables["admin_task"], $adminid, $task["taskid"], $task["level"]));
}
}
// end if
}
}
// end while
print '<script language="Javascript" type="text/javascript"> finish(); </script>';
# let's be grammatically correct :-)
$dispemail = $count_email_add == 1 ? $GLOBALS['I18N']->get('new email was') . " " : $GLOBALS['I18N']->get('new emails were') . " ";
$dispemail2 = $additional_emails == 1 ? $GLOBALS['I18N']->get('email was') . " " : $GLOBALS['I18N']->get('emails were') . " ";
if (!$some && !$additional_emails) {
print "<br>" . $GLOBALS['I18N']->get("All the emails already exist in the database");
} else {
示例14: Sql_Query
break;
case "checkboxgroup":
$valreq = Sql_Query(sprintf('select name from %slistattr_%s where id in (%s)', sql_escape($_POST["remote_prefix"]), $att["tablename"], $att["value"]));
while ($vals = Sql_fetch_Row($valreq)) {
$value .= $vals[0] . ',';
}
break;
}
$att["displayvalue"] = $value;
array_push($useratt, $att);
}
$userlists = array();
$userlists = array_merge($_POST["lists"], $userlists);
if ($_POST["copyremotelists"]) {
$req = Sql_Query("select * from {$remote_tables["listuser"]},\n {$remote_tables["list"]} where {$remote_tables["listuser"]}.listid =\n {$remote_tables["list"]}.id and {$remote_tables["listuser"]}.userid = {$user['0']}");
while ($list = Sql_Fetch_Array($req)) {
# print $list["name"]."<br/>";
array_push($userlists, $list);
}
}
connectLocal();
foreach ($useratt as $att) {
$localattid = $attributemap[$att["attributeid"]];
if (!localattid) {
print $GLOBALS['I18N']->get('Error, no mapped attribute for') . " " . $att["name"] . "<br/>";
} else {
$tname = Sql_Fetch_Row_Query("select tablename from {$tables["attribute"]} where id = {$localattid}");
switch ($att["type"]) {
case "select":
case "radio":
$valueid = Sql_Fetch_Row_Query(sprintf('select id from %slistattr_%s where name = "%s"', $table_prefix, $tname[0], $att["displayvalue"]));
示例15: precacheMessage
//.........这里部分代码省略.........
#getConfig("text_charset");
if (!$cached[$messageid]["text_charset"]) {
$cached[$messageid]["text_charset"] = 'UTF-8';
#'iso-8859-1';
}
## if we are sending a URL that contains user attributes, we cannot pre-parse the message here
## but that has quite some impact on speed. So check if that's the case and apply
$cached[$messageid]['userspecific_url'] = preg_match('/\\[.+\\]/', $message['sendurl']);
if (!$cached[$messageid]['userspecific_url']) {
## Fetch external content here, because URL does not contain placeholders
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;
}
*/
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']);
}
}
if (preg_match("/##LISTOWNER=(.*)/", $cached[$messageid]['content'], $regs)) {
$cached[$messageid]['listowner'] = $regs[1];
$cached[$messageid]['content'] = str_replace($regs[0], "", $cached[$messageid]['content']);
} else {
$cached[$messageid]['listowner'] = 0;
}
if (!empty($cached[$messageid]['listowner'])) {
$att_req = Sql_Query("select name,value from {$GLOBALS["tables"]["adminattribute"]},{$GLOBALS["tables"]["admin_attribute"]} where {$GLOBALS["tables"]["adminattribute"]}.id = {$GLOBALS["tables"]["admin_attribute"]}.adminattributeid and {$GLOBALS["tables"]["admin_attribute"]}.adminid = " . $cached[$messageid]['listowner']);
while ($att = Sql_Fetch_Array($att_req)) {
$cached[$messageid]['content'] = preg_replace("#\\[LISTOWNER." . strtoupper(preg_quote($att["name"])) . "\\]#", $att["value"], $cached[$messageid]['content']);
}
}
$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']);
}
//if (defined('FCKIMAGES_DIR') && FCKIMAGES_DIR) {
//$cached[$messageid]['content'] = preg_replace('/<img(.*)src="\/lists\/'.FCKIMAGES_DIR.'(.*)>/iU','<img\\1src="'.$GLOBALS['public_scheme'].'://'.$baseurl.'/lists/'.FCKIMAGES_DIR.'\\2>',$cached[$messageid]['content']);
//}
return 1;
}