本文整理汇总了PHP中Sql_Fetch_Row函数的典型用法代码示例。如果您正苦于以下问题:PHP Sql_Fetch_Row函数的具体用法?PHP Sql_Fetch_Row怎么用?PHP Sql_Fetch_Row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sql_Fetch_Row函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: isSuperUser
function isSuperUser()
{
## for now mark webbler admins superuser
if (defined('WEBBLER') || defined('IN_WEBBLER')) {
return 1;
}
global $tables;
$issuperuser = 0;
# if (!isset($_SESSION["adminloggedin"])) return 0;
# if (!is_array($_SESSION["logindetails"])) return 0;
if (isset($_SESSION["logindetails"]["superuser"])) {
return $_SESSION["logindetails"]["superuser"];
}
if (isset($_SESSION["logindetails"]["id"])) {
if (is_object($GLOBALS["admin_auth"])) {
$issuperuser = $GLOBALS["admin_auth"]->isSuperUser($_SESSION["logindetails"]["id"]);
} else {
$query = ' select superuser ' . ' from %s' . ' where id = ?';
$query = sprintf($query, $tables['admin']);
$req = Sql_Query_Params($query, array($_SESSION['logindetails']['id']));
$req = Sql_Fetch_Row($req);
$issuperuser = $req[0];
}
$_SESSION["logindetails"]["superuser"] = $issuperuser;
}
return $issuperuser;
}
示例3: mysql_session_read
function mysql_session_read($SessionID)
{
# dbg("Reading session info for $SessionID");
$SessionTableName = $GLOBALS["SessionTableName"];
$SessionID = addslashes($SessionID);
$session_data_req = sql_query("SELECT data FROM {$SessionTableName} WHERE sessionid = '{$SessionID}'");
if (Sql_Affected_Rows() == 1) {
$data = Sql_Fetch_Row($session_data_req);
return $data[0];
} else {
return false;
}
}
示例4: accessLevel
function accessLevel($page)
{
global $tables, $access_levels;
if (!$GLOBALS["require_login"] || isSuperUser()) {
return "all";
}
if (!isset($_SESSION["adminloggedin"])) {
return 0;
}
if (!is_array($_SESSION["logindetails"])) {
return 0;
}
# check whether it is a page to protect
Sql_Query("select id from {$tables["task"]} where page = \"{$page}\"");
if (!Sql_Affected_Rows()) {
return "all";
}
$req = Sql_Query(sprintf('select level from %s,%s where adminid = %d and page = "%s" and %s.taskid = %s.id', $tables["task"], $tables["admin_task"], $_SESSION["logindetails"]["id"], $page, $tables["admin_task"], $tables["task"]));
$row = Sql_Fetch_Row($req);
return $access_levels[$row[0]];
}
示例5: resendConfirm
function resendConfirm($id)
{
global $tables, $envelope;
$userdata = Sql_Fetch_Array_Query("select * from {$tables["user"]} where id = {$id}");
$lists_req = Sql_Query(sprintf('select %s.name from %s,%s where
%s.listid = %s.id and %s.userid = %d', $tables["list"], $tables["list"], $tables["listuser"], $tables["listuser"], $tables["list"], $tables["listuser"], $id));
while ($row = Sql_Fetch_Row($lists_req)) {
$lists .= ' * ' . $row[0] . "\n";
}
if ($userdata["subscribepage"]) {
$subscribemessage = ereg_replace('\\[LISTS\\]', $lists, getUserConfig("subscribemessage:" . $userdata["subscribepage"], $id));
$subject = getConfig("subscribesubject:" . $userdata["subscribepage"]);
} else {
$subscribemessage = ereg_replace('\\[LISTS\\]', $lists, getUserConfig("subscribemessage", $id));
$subject = getConfig("subscribesubject");
}
logEvent($GLOBALS['I18N']->get('Resending confirmation request to') . " " . $userdata["email"]);
if (!TEST) {
return sendMail($userdata["email"], $subject, $_REQUEST["prepend"] . $subscribemessage, system_messageheaders($userdata["email"]), $envelope);
}
}
示例6: addKeywordLibrary
function addKeywordLibrary($name) {
$req = Sql_Query(sprintf('select id from keywordlib where name = "%s"',$name));
if (Sql_affected_Rows()) {
$row = Sql_Fetch_Row($req);
return $row[0];
}
Sql_Query(sprintf('insert into keywordlib (name) values("%s")',$name));
return Sql_Insert_id();
}
示例7: Sql_query
$sortBySql = 'order by entered asc';
break;
case 'entereddesc':
$sortBySql = 'order by entered desc';
break;
case 'embargoasc':
$sortBySql = 'order by embargo asc';
break;
case 'embargodesc':
$sortBySql = 'order by embargo desc';
break;
default:
$sortBySql = 'order by embargo desc, entered desc';
}
$req = Sql_query('select count(*) from ' . $tables['message'] . $whereClause . ' ' . $sortBySql);
$total_req = Sql_Fetch_Row($req);
$total = $total_req[0];
## Browse buttons table
$limit = $_SESSION['messagenumpp'];
$offset = 0;
if (isset($start) && $start > 0) {
$offset = $start;
} else {
$start = 0;
}
$paging = '';
if ($total > $_SESSION['messagenumpp']) {
$paging = simplePaging("messages{$url_keep}", $start, $total, $_SESSION['messagenumpp'], $GLOBALS['I18N']->get('Campaigns'));
}
$ls = new WebblerListing(s('Campaigns'));
$ls->usePanel($paging);
示例8: listPlaceHolders
function listPlaceHolders()
{
$html = '<table border="1"><tr><td><strong>' . s('Attribute') . '</strong></td><td><strong>' . s('Placeholder') . '</strong></td></tr>';
$req = Sql_query('select name from ' . $GLOBALS['tables']['attribute'] . ' order by listorder');
while ($row = Sql_Fetch_Row($req)) {
if (strlen($row[0]) <= 30) {
$html .= sprintf('<tr><td>%s</td><td>[%s]</td></tr>', $row[0], strtoupper(cleanAttributeName($row[0])));
}
}
$html .= '</table>';
return $html;
}
示例9: 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') {
//.........这里部分代码省略.........
示例10: output
if (VERBOSE) {
output("Invalid email: {$user['1']}, {$user['0']}");
}
logEvent("Invalid email, userid {$user['0']}, email {$user['1']}");
# mark it as sent anyway
if ($userid) {
$um = Sql_query("replace into {$tables['usermessage']} (entered,userid,messageid,status) values(now(),{$userid},{$messageid},\"invalid email\")");
}
$invalid++;
}
}
} else {
## and this is quite historical, and also unlikely to be every called
# because we now exclude users who have received the message from the
# query to find users to send to
$um = Sql_Fetch_Row($um);
$notsent++;
if (VERBOSE) {
output($GLOBALS['I18N']->get('Not sending to') . ' ' . $userdata[0] . ', ' . $GLOBALS['I18N']->get('already sent') . ' ' . $um[0]);
}
}
$status = Sql_query("update {$tables['message']} set processed = processed +1 where id = {$messageid}");
$processed = $notsent + $sent + $invalid + $unconfirmed + $cannotsend + $failed_sent;
#if ($processed % 10 == 0) {
if (0) {
output('AR' . $affrows . ' N ' . $num_users . ' P' . $processed . ' S' . $sent . ' N' . $notsent . ' I' . $invalid . ' U' . $unconfirmed . ' C' . $cannotsend . ' F' . $failed_sent);
$rn = $reload * $num_per_batch;
output('P ' . $processed . ' N' . $num_users . ' NB' . $num_per_batch . ' BT' . $batch_total . ' R' . $reload . ' RN' . $rn);
}
$totaltime = $GLOBALS['processqueue_timer']->elapsed(1);
$msgperhour = 3600 / $totaltime * $sent;
示例11: Get_Attribute_Value_Id_List
function Get_Attribute_Value_Id_List($attribute_id)
{
$AttributeChangerPlugin = $GLOBALS['AttributeChangerPlugin'];
$AttributeChangerData = $AttributeChangerPlugin->AttributeChangerData;
$case_array = $AttributeChangerData['case_array'];
$query = sprintf('select type, tablename from %s where id = %d', $AttributeChangerData['tables']['attribute'], $attribute_id);
$type_table_return = Sql_Query($query);
if (!$type_table_return) {
} else {
$row = Sql_Fetch_Row($type_table_return);
if (!$row[0] || !$row[1]) {
} else {
$type = $row[0];
$table = $row[1];
if ($case_array[$type] == "case_2" || $case_array[$type] == "case_3") {
$attribute_value_id_array = array();
$tablename = $AttributeChangerData['atribute_value_table_prefix'] . $table;
$value_query = sprintf('select id, name from %s', $tablename);
$value_query_return = Sql_Query($value_query);
if (!$value_query_return) {
} else {
while ($value_row = Sql_Fetch_Row($value_query_return)) {
$attribute_value_id_array[$value_row[0]] = $value_row[1];
}
}
return $attribute_value_id_array;
}
}
}
return null;
}
示例12: Sql_Fetch_Row
$d = Sql_Fetch_Row($val);
$user_att_value = $d[0];
}
break;
case "checkboxgroup":
$values = explode(',', $uservalue);
$valueIds = array();
foreach ($values as $importValue) {
$val = Sql_Query("select id from {$table_prefix}" . "listattr_{$att['1']} where name = \"{$importValue}\"");
# if we do not have this value add it
if (!Sql_Affected_Rows()) {
Sql_Query("insert into {$table_prefix}" . "listattr_{$att['1']} (name) values(\"{$importValue}\")");
Warn("Value {$importValue} added to attribute {$att['2']}");
$valueIds[] = Sql_Insert_Id();
} else {
$d = Sql_Fetch_Row($val);
$valueIds[] = $d[0];
}
}
$user_att_value = join(',', $valueIds);
break;
case "checkbox":
$uservalue = trim($uservalue);
#print $uservalue;exit;
if (!empty($uservalue) && $uservalue != "off") {
$user_att_value = "on";
} else {
$user_att_value = "";
}
break;
case "date":
示例13: sendEmail
function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array(), $forwardedby = array())
{
global $strThisLink, $PoweredByImage, $PoweredByText, $cached, $website;
if ($email == "") {
return 0;
}
#0013076: different content when forwarding 'to a friend'
if (FORWARD_ALTERNATIVE_CONTENT) {
$forwardContent = sizeof($forwardedby) > 0;
$messagedata = loadMessageData($messageid);
} else {
$forwardContent = 0;
}
if (empty($cached[$messageid])) {
$domain = getConfig("domain");
$message = Sql_query("select * from {$GLOBALS["tables"]["message"]} where id = {$messageid}");
$cached[$messageid] = array();
$message = Sql_fetch_array($message);
if (ereg("([^ ]+@[^ ]+)", $message["fromfield"], $regs)) {
# if there is an email in the from, rewrite it as "name <email>"
$message["fromfield"] = ereg_replace($regs[0], "", $message["fromfield"]);
$cached[$messageid]["fromemail"] = $regs[0];
# if the email has < and > take them out here
$cached[$messageid]["fromemail"] = ereg_replace("<", "", $cached[$messageid]["fromemail"]);
$cached[$messageid]["fromemail"] = ereg_replace(">", "", $cached[$messageid]["fromemail"]);
# make sure there are no quotes around the name
$cached[$messageid]["fromname"] = ereg_replace('"', "", ltrim(rtrim($message["fromfield"])));
} elseif (ereg(" ", $message["fromfield"], $regs)) {
# if there is a space, we need to add the email
$cached[$messageid]["fromname"] = $message["fromfield"];
$cached[$messageid]["fromemail"] = "listmaster@{$domain}";
} else {
$cached[$messageid]["fromemail"] = $message["fromfield"] . "@{$domain}";
## makes more sense not to add the domain to the word, but the help says it does
## so let's keep it for now
$cached[$messageid]["fromname"] = $message["fromfield"] . "@{$domain}";
}
# erase double spacing
while (ereg(" ", $cached[$messageid]["fromname"])) {
$cached[$messageid]["fromname"] = eregi_replace(" ", " ", $cached[$messageid]["fromname"]);
}
## this has weird effects when used with only one word, so take it out for now
# $cached[$messageid]["fromname"] = eregi_replace("@","",$cached[$messageid]["fromname"]);
$cached[$messageid]["fromname"] = trim($cached[$messageid]["fromname"]);
$cached[$messageid]["to"] = $message["tofield"];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]["subject"] = $forwardContent ? stripslashes($messagedata["forwardsubject"]) : $message["subject"];
$cached[$messageid]["replyto"] = $message["replyto"];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]["content"] = $forwardContent ? stripslashes($messagedata["forwardmessage"]) : $message["message"];
if (USE_MANUAL_TEXT_PART && !$forwardContent) {
$cached[$messageid]["textcontent"] = $message["textmessage"];
} else {
$cached[$messageid]["textcontent"] = '';
}
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]["footer"] = $forwardContent ? stripslashes($messagedata["forwardfooter"]) : $message["footer"];
$cached[$messageid]["htmlformatted"] = $message["htmlformatted"];
$cached[$messageid]["sendformat"] = $message["sendformat"];
if ($message["template"]) {
$req = Sql_Fetch_Row_Query("select template from {$GLOBALS["tables"]["template"]} where id = {$message["template"]}");
$cached[$messageid]["template"] = stripslashes($req[0]);
$cached[$messageid]["templateid"] = $message["template"];
# dbg("TEMPLATE: ".$req[0]);
} else {
$cached[$messageid]["template"] = '';
$cached[$messageid]["templateid"] = 0;
}
## @@ put this here, so it can become editable per email sent out at a later stage
$cached[$messageid]["html_charset"] = getConfig("html_charset");
## @@ need to check on validity of charset
if (!$cached[$messageid]["html_charset"]) {
$cached[$messageid]["html_charset"] = 'iso-8859-1';
}
$cached[$messageid]["text_charset"] = getConfig("text_charset");
if (!$cached[$messageid]["text_charset"]) {
$cached[$messageid]["text_charset"] = 'iso-8859-1';
}
}
# else
# dbg("Using cached {$cached[$messageid]["fromemail"]}");
if (VERBOSE) {
output($GLOBALS['I18N']->get('sendingmessage') . ' ' . $messageid . ' ' . $GLOBALS['I18N']->get('withsubject') . ' ' . $cached[$messageid]["subject"] . ' ' . $GLOBALS['I18N']->get('to') . ' ' . $email);
}
# erase any placeholders that were not found
# $msg = ereg_replace("\[[A-Z ]+\]","",$msg);
#0011857: forward to friend, retain attributes
if ($hash == 'forwarded' && defined('KEEPFORWARDERATTRIBUTES') && KEEPFORWARDERATTRIBUTES) {
$user_att_values = getUserAttributeValues($forwardedby['email']);
} else {
$user_att_values = getUserAttributeValues($email);
}
$userdata = Sql_Fetch_Assoc_Query(sprintf('select * from %s where email = "%s"', $GLOBALS["tables"]["user"], $email));
$url = getConfig("unsubscribeurl");
$sep = ereg('\\?', $url) ? '&' : '?';
$html["unsubscribe"] = sprintf('<a href="%s%suid=%s">%s</a>', $url, $sep, $hash, $strThisLink);
$text["unsubscribe"] = sprintf('%s%suid=%s', $url, $sep, $hash);
$html["unsubscribeurl"] = sprintf('%s%suid=%s', $url, $sep, $hash);
$text["unsubscribeurl"] = sprintf('%s%suid=%s', $url, $sep, $hash);
#0013076: Blacklisting posibility for unknown users
//.........这里部分代码省略.........
示例14: get_template_image
function get_template_image($templateid, $filename)
{
if (basename($filename) == 'powerphplist.png') {
$templateid = 0;
}
$query = ' select data' . ' from ' . $GLOBALS['tables']['templateimage'] . ' where template = ?' . ' and (filename = ? or filename= ?)';
$rs = Sql_Query_Params($query, array($templateid, $filename, basename($filename)));
$req = Sql_Fetch_Row($rs);
return $req[0];
}
示例15: validateAccount
/**
* validateAccount, verify that the logged in admin is still valid.
*
* this allows verification that the admin still exists and is valid
*
* @param int $id the ID of the admin as provided by validateLogin
*
* @return array
* index 0 -> false if failed, true if successful
* index 1 -> error message when validation fails
*
* eg
* return array(1,'OK'); // -> admin valid
* return array(0,'No such account'); // admin failed
*/
public function validateAccount($id)
{
/* can only do this after upgrade, which means
* that the first login will always fail
*/
$query = sprintf('select id, disabled,password from %s where id = %d', $GLOBALS['tables']['admin'], $id);
$data = Sql_Fetch_Row_Query($query);
if (!$data[0]) {
return array(0, s('No such account'));
} elseif (!ENCRYPT_ADMIN_PASSWORDS && sha1($noaccess_req[2]) != $_SESSION['logindetails']['passhash']) {
return array(0, s('Your session does not match your password. If you just changed your password, simply log back in.'));
} elseif ($data[1]) {
return array(0, s('your account has been disabled'));
}
## do this seperately from above, to avoid lock out when the DB hasn't been upgraded.
## so, ignore the error
$query = sprintf('select privileges from %s where id = %d', $GLOBALS['tables']['admin'], $id);
$req = Sql_Query($query);
if ($req) {
$data = Sql_Fetch_Row($req);
} else {
$data = array();
}
if (!empty($data[0])) {
$_SESSION['privileges'] = unserialize($data[0]);
}
return array(1, 'OK');
}