本文整理汇总了PHP中dbRow函数的典型用法代码示例。如果您正苦于以下问题:PHP dbRow函数的具体用法?PHP dbRow怎么用?PHP dbRow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbRow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BannerImage_drawForm
/**
* blah
*
* @param int $id id of the banner
*
* @return null
*/
function BannerImage_drawForm($id = 0)
{
if (!$id) {
$fdata = array('id' => 0, 'html' => '', 'name' => 'banner');
} else {
$fdata = dbRow("select * from banners_images where id={$id}");
}
echo '<form method="post" action="/ww.admin/plugin.php?_plugin=banner-ima' . 'ge&_page=index" enctype="multipart/form-data"><input type="hidden' . '" name="id" value="' . (int) $fdata['id'] . '" />';
echo '<table>';
// {
echo '<tr><th>Name</th><td><input name="name" value="' . htmlspecialchars($fdata['name']) . '" /></td></tr>';
// }
// { what pages should this be applied to
echo '<tr><th>Pages</th><td>This banner will only be shown on the <select' . ' name="pages_' . $fdata['id'] . '[]" multiple="multiple" style="max-width' . ':200px;height:500px">';
$ps = dbAll('select * from banners_pages where bannerid=' . $fdata['id']);
$pages = array();
if (count($ps)) {
foreach ($ps as $p) {
$pages[] = $p['pageid'];
}
}
BannerImage_selectKiddies(0, 1, $pages);
echo '</select> pages. <span style="color:red;font-weight:bold">If no pag' . 'es are specified, then the banner will be shown on all pages.</span><' . '/td></tr>';
// }
// { show HTML form
echo '<tr><th>Banner</th><td><div id="banner_image_html">' . ckeditor('html_' . $fdata['id'], Core_unfixImageResizes($fdata['html']), 0, '', 180) . '</div></td></tr>';
// }
// { show submit button and end form
echo '<tr><td><a href="./plugin.php?_plugin=banner-image&_page=index&dele' . 'te_banner=' . $fdata['id'] . '" onclick="return confirm(\'are you sure yo' . 'u want to remove this banner?\');" title="remove banner">[x]</a></td>' . '<td><input type="submit" name="save_banner" value="Update" /></td></tr>';
// }
echo '</table></form>';
}
示例2: Privacy_register
/**
* register, and login
*
* @return array status
*/
function Privacy_register()
{
$password = $_REQUEST['password'];
$token = $_REQUEST['token'];
$reg = @$_SESSION['privacy']['registration'];
$email = @$reg['email'];
$custom = @$reg['custom'];
if (!is_array($custom)) {
$custom = array();
}
$sql = 'select id from user_accounts where email="' . addslashes($email) . '"';
if (dbOne($sql, 'id')) {
return array('error' => __('already registered'));
}
if ($token && $token == @$reg['token']) {
$latlngsql = '';
if (@$custom['_location']) {
$latlng = dbRow('select lat,lng from locations where id=' . (int) $custom['_location']);
if ($latlng) {
$latlngsql = ',location_lat=' . $latlng['lat'] . ',location_lng=' . $latlng['lng'];
}
}
$sql = 'insert into user_accounts set email="' . addslashes($email) . '",' . 'password=md5("' . addslashes($password) . '"),active=1,date_created=now(),' . 'extras="' . addslashes(json_encode($custom)) . '"' . $latlngsql;
dbQuery($sql);
return array('ok' => 1);
} else {
return array('error' => __('token does not match'));
}
}
示例3: createUser
function createUser()
{
if (isset($_POST['register'])) {
$username = filter_var($_POST['username'], FILTER_SANITIZE_SPECIAL_CHARS);
$f_name = filter_var($_POST['f_name'], FILTER_SANITIZE_SPECIAL_CHARS);
$l_name = filter_var($_POST['l_name'], FILTER_SANITIZE_SPECIAL_CHARS);
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$re_email = filter_var($_POST['re_email'], FILTER_VALIDATE_EMAIL);
$pass = filter_var($_POST['pass'], FILTER_SANITIZE_SPECIAL_CHARS);
$pass = md5($pass);
/* OBS att jag är medveten om att bara md5 inte är bra... */
$re_pass = filter_var($_POST['re_pass'], FILTER_SANITIZE_SPECIAL_CHARS);
$count = dbRow("SELECT COUNT(*) AS count FROM litter_users\n\t\t\tWHERE username = '{$username}'");
if ($username == "" || $f_name == "" || $l_name == "" || $pass == "") {
print "<h4>You didn't complete the form!</h4>";
} elseif ($count['count'] > 0) {
print "<h4>This username is allreday taken!</h4>";
} elseif ($email !== $re_email) {
print "<h4>The two e-mails didn't match!</h4>";
} elseif ($email === false || $re_email === false) {
print "<h4>This is not a valid e-mail</h4>";
} elseif ($pass !== md5($re_pass)) {
print "<h4>The two passwords didn't match!</h4>";
} else {
dbAdd("INSERT INTO litter_users \n\t\t(username, f_name, l_name, email, pass)\n\t\tVALUES('@{$username}', '{$f_name}', '{$l_name}', '{$email}', '{$pass}')");
$new_id = dbRow("SELECT user_id FROM litter_users\n\t\t\t\tWHERE username = '@{$username}'");
mkdir('userIMG/' . $new_id['user_id']);
session_start();
$_SESSION['error'] = 'Your account has been created! Lets go:';
header('Location: form.php');
}
} else {
print "<h4>Something went wrong... Please try again later!</h4>";
}
}
示例4: IssueTracker_adminTypeGet
/**
* get an issue type's details
*
* @return array list
*/
function IssueTracker_adminTypeGet()
{
$id = (int) $_REQUEST['id'];
$r = dbRow('select * from issuetracker_types where id=' . $id);
$r['fields'] = json_decode($r['fields']);
return $r;
}
示例5: __construct
/**
* instantiate a User object
*
* @param int $id the user id
* @param array $r a pre-defined array to fill in the values
* @param boolean $enabled whether to only instantiate users that are enabled
*
* @return null
*/
function __construct($id, $r = false, $enabled = true)
{
$id = (int) $id;
if (!$id) {
return;
}
$filter = $enabled ? ' and active' : '';
if (!$r) {
$r = Core_cacheLoad('user_accounts', $id . '|' . $filter, -1);
if ($r === -1) {
$r = dbRow("select * from user_accounts where id={$id} {$filter} limit 1");
Core_cacheSave('user_accounts', $id . '|' . $filter, $r);
}
}
if (!count($r) || !is_array($r)) {
return false;
}
foreach ($r as $k => $val) {
$this->{$k} = $val;
}
if (!isset($this->id)) {
return false;
}
$this->dbVals = $r;
self::$instances[$this->id] =& $this;
}
示例6: Ads_widget
/**
* show ads
*
* @param array $params parameters
*
* @return ads HTML
*/
function Ads_widget($params)
{
if (!isset($params->{'ad-type'})) {
return 'missing ad type';
}
$type_id = (int) $params->{'ad-type'};
$howmany = (int) $params->{'how-many'};
$type = dbRow('select * from ads_types where id=' . $type_id);
$ads = array();
$i = 0;
if ($howmany > 1) {
$sql = 'select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active and cdate>date_add(now(), interval -2 day) order by rand()' . ' limit ' . $howmany;
$adsNew = dbAll($sql);
for (; $i < count($adsNew); ++$i) {
$ads[] = $adsNew[$i];
}
}
$adsOld = dbAll('select id,image_url,target_type,poster from ads' . ' where type_id=' . $type_id . ' and is_active order by rand()' . ' limit ' . $howmany);
for ($j = 0; $j < $howmany - $i && $j < count($adsOld); ++$j) {
$ads[] = $adsOld[$j];
}
$html = '<div class="ads-wrapper type-' . $type_id . '">';
foreach ($ads as $ad) {
$html .= Ads_adShow($ad, $type);
dbQuery('insert into ads_track set ad_id=' . $ad['id'] . ', view=1, cdate=now()');
}
$html .= '</div>';
WW_addScript('ads/j/js.js');
WW_addCSS('/ww.plugins/ads/css.css');
return $html;
}
示例7: Mailinglists_adminListDetails
/**
* get info about a mailing list
*
* @return info
*/
function Mailinglists_adminListDetails()
{
$id = (int) $_REQUEST['id'];
$row = dbRow('select * from mailinglists_lists where id=' . $id);
if (!$row['meta']) {
$row['meta'] = '{}';
}
$row['meta'] = json_decode($row['meta']);
return $row;
}
示例8: show_banner
function show_banner($vars)
{
$banner = false;
if (!is_array($vars) && @$vars->id) {
$b = Core_cacheLoad('banner-images', 'id' . $vars->id);
if ($b === false) {
$b = dbRow('select * from banners_images where id=' . $vars->id);
if ($b && count($b) && !$b['html']) {
$b['html'] = BannerImage_getImgHtml($vars->id);
dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $vars->id);
}
Core_cacheSave('banner-images', 'id' . $vars->id, $b);
}
} elseif ($GLOBALS['PAGEDATA']->id) {
$b = Core_cacheLoad('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id);
if ($b === false) {
$b = dbAll('select * from banners_pages,banners_images where pageid=' . $GLOBALS['PAGEDATA']->id . ' and bannerid=id');
Core_cacheSave('banner-images', 'bypage' . $GLOBALS['PAGEDATA']->id, $b);
}
$i = rand(0, count($b) - 1);
$b = isset($b[$i]) ? $b[$i] : false;
if ($b && count($b) && !$b['html']) {
$b['html'] = BannerImage_getImgHtml($b['id']);
dbQuery('update banners_pages set html="' . addslashes($b['html']) . '" where id=' . $b['id']);
}
}
if (!isset($b) || $b === false || !count($b)) {
$b = Core_cacheLoad('banner-image', 'all');
if ($b === false) {
$b = dbAll('select * from banners_images');
Core_cacheSave('banner-image', 'all', $b);
}
$i = rand(0, count($b) - 1);
$b = isset($b[$i]) ? $b[$i] : false;
}
if ($b && count($b)) {
$banner = $b['html'];
if (!$banner) {
$banner = BannerImage_getImgHtml($vars->id);
}
}
if (!$banner) {
if (is_array($vars) && @$vars['default']) {
$banner = $vars['default'];
} else {
$banner = '';
}
}
if (!$banner) {
return '';
}
return '<style type="text/css">#banner{background:none}</style>' . $banner;
}
示例9: __construct
function __construct($v, $byField = 0, $fromRow = 0, $pvq = 0)
{
# byField: 0=ID; 1=Name; 3=special
if (!$byField && is_numeric($v)) {
// by ID
$r = $fromRow ? $fromRow : ($v ? dbRow("select * from pages where id={$v} limit 1") : array());
} else {
if ($byField == 1) {
// by name
$name = strtolower(str_replace('-', '_', $v));
$fname = 'page_by_name_' . md5($name);
$r = dbRow("select * from pages where name like '" . addslashes($name) . "' limit 1");
} else {
if ($byField == 3 && is_numeric($v)) {
// by special
$fname = 'page_by_special_' . $v;
$r = dbRow("select * from pages where special&{$v} limit 1");
} else {
return false;
}
}
}
if (!count($r || !is_array($r))) {
return false;
}
if (!isset($r['id'])) {
$r['id'] = 0;
}
if (!isset($r['type'])) {
$r['type'] = 0;
}
if (!isset($r['special'])) {
$r['special'] = 0;
}
if (!isset($r['name'])) {
$r['name'] = 'NO NAME SUPPLIED';
}
foreach ($r as $k => $v) {
$this->{$k} = $v;
}
$this->urlname = $r['name'];
$this->dbVals = $r;
self::$instances[$this->id] =& $this;
self::$instancesByName[preg_replace('/[^a-z0-9]/', '-', strtolower($this->urlname))] =& $this;
self::$instancesBySpecial[$this->special] =& $this;
if (!$this->vars) {
$this->vars = '{}';
}
$this->vars = json_decode($this->vars);
}
示例10: getByNameAndValue
/**
* get a page variable by its name and value
*
* @param string $name name of the variable you're searching for
* @param string $value value of the variable you're searching for
* @param boolean $includePageRow whether to also return the page row
*
* @return PageVars object
*/
function getByNameAndValue($name, $value, $includePageRow = false)
{
if (!array_key_exists($name, self::$instancesByNameAndValue) || !array_key_exists($value, self::$instancesByNameAndValue[$name])) {
if (!array_key_exists($name, self::$instancesByNameAndValue)) {
self::$instancesByNameAndValue[$name] = array();
}
if ($includePageRow) {
self::$instancesByNameAndValue[$name][$value] = dbRow("SELECT * FROM page_vars,pages WHERE page_vars.name='" . addslashes($name) . "' AND value='" . addslashes($value) . "' AND pages.id=page_vars.page_id LIMIT 1");
} else {
self::$instancesByNameAndValue[$name][$value] = dbRow("SELECT * FROM page_vars WHERE name='" . addslashes($name) . "' AND value='" . addslashes($value) . "' LIMIT 1");
}
}
return self::$instancesByNameAndValue[$name][$value];
}
示例11: Menu_getHtml
function Menu_getHtml()
{
global $DBVARS;
require_once SCRIPTBASE . 'ww.incs/menus.php';
require_once SCRIPTBASE . 'ww.incs/common.php';
$vars = null;
if (isset($_REQUEST['vars'])) {
$vars = json_decode($_REQUEST['vars']);
}
if ($vars && isset($vars->id) && $vars->id) {
$id = $vars->id;
$vars = Core_cacheLoad('menus', $id, -1);
if ($vars === -1) {
$vars = dbRow('select * from menus where id=' . $id);
Core_cacheSave('menus', $id, $vars);
}
if ($vars['cache']) {
header('Cache-Control: max-age=' . $vars['cache'] . ', public');
header('Expires: Fri, 1 Jan 2500 01:01:01 GMT');
header('Expires-Active: On');
header('Pragma:');
header('Last-modified: ' . gmdate('D, d M Y H:i:s', time()));
}
if ($vars['parent'] == '-1') {
global $PAGEDATA;
$pid = $PAGEDATA->id;
if ($pid) {
$n = dbOne('select id from pages where parent=' . $pid . ' limit 1', id);
if (!$n) {
$pid = (int) $PAGEDATA->parent;
if (!$pid) {
return '';
}
}
}
$vars['parent'] = $pid;
}
}
header('Content-type: text/javascript');
echo 'document.write("' . addslashes(Core_menuShowFg($vars)) . '");';
echo join(';', $GLOBALS['scripts_inline']);
$cdn = isset($DBVARS['cdn']) ? '//' . $DBVARS['cdn'] : '';
foreach ($GLOBALS['scripts'] as $r) {
echo 'document.write("<script src=\\"' . $cdn . $r . '\\"></script>");';
}
foreach ($GLOBALS['css_urls'] as $r) {
echo 'document.write("<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"' . $cdn . $r . '\\"/>");';
}
exit;
}
示例12: PageSummaries_getHtml
/**
* retrieve HTML summary for a set page
*
* @param int $id ID of the page
*
* @return string HTML summary for a set page
*/
function PageSummaries_getHtml($id)
{
$PAGEDATA = Page::getInstance($id);
global $sitedomain;
$r = dbRow('select * from page_summaries where page_id="' . $PAGEDATA->id . '"');
if (!count($r)) {
return '<em>This page is marked as a page summary, but there is no ' . 'information on how to handle it.</em>';
}
if ($r['rss']) {
return PageSummaries_rssToHtml($r['rss']);
}
// { build rss
$title = $PAGEDATA->title == '' ? $sitedomain : htmlspecialchars($PAGEDATA->title);
$rss = '<' . '?xml version="1.0" ?' . '><rss version="2.0"><channel><title>' . $title . '</title>';
$rss .= '<link>' . $_SERVER['REQUEST_URI'] . '</link><description>RSS for ' . $PAGEDATA->name . '</description>';
$category = $PAGEDATA->category ? ' and category="' . $PAGEDATA->category . '"' : '';
$containedpages = PageSummaries_getContainedPages($r['parent_id']);
if (count($containedpages)) {
$q2 = dbAll('select edate,name,title,body from pages where id in (' . join(',', $containedpages) . ')' . $category . ' order by cdate desc limit 20');
foreach ($q2 as $r2) {
$rss .= '<item>';
if (!$r2['title']) {
$r2['title'] = $r2['name'];
}
$rss .= '<title>' . htmlspecialchars($r2['title']) . '</title>';
$rss .= '<pubDate>' . date_m2h($r2['edate']) . '</pubDate>';
// { build body
if ($r['amount_to_show'] == 0 || $r['amount_to_show'] == 1) {
$length = $r['amount_to_show'] == 0 ? 300 : 600;
$body = str_replace(' ', ' ', preg_replace('/<[^>]*>/', ' ', str_replace(array('&', ' ', '‘'), array('&', ' ', '''), $r2['body'])));
$body = substr($body, 0, $length) . '...';
} else {
$body = $r2['body'];
}
$body = str_replace('€', '€', $body);
// }
$rss .= '<description>' . $body . '</description>';
$rss .= '<link>http://' . $_SERVER['HTTP_HOST'] . '/' . urlencode(str_replace(' ', '-', $r2['name'])) . '</link>';
$rss .= '</item>';
}
}
$rss .= '</channel></rss>';
dbQuery('update page_summaries set rss="' . addslashes($rss) . '" where page_id="' . $PAGEDATA->id . '"');
// }
return PageSummaries_rssToHtml($rss);
}
示例13: __construct
function __construct($v, $byField = 0, $fromRow = 0, $pvq = 0)
{
if (!$byField && is_numeric($v)) {
$r = $fromRow ? $fromRow : ($v ? dbRow("SELECT * FROM pages WHERE id={$v} LIMIT 1") : array());
} else {
if ($byField == 1) {
$name = strtolower(str_replace('-', '_', $v));
$fname = 'page_by_name_' . md5($name);
$r = dbRow("SELECT * FROM pages WHERE name LIKE '" . $name . "' LIMIT 1");
} else {
if ($byField == 3 && is_numeric($v)) {
$fname = 'page_by_special_' . $v;
$r = dbRow("SELECT * FROM pages WHERE special&{$v} limit 1");
} else {
return false;
}
}
}
if (!count($r || !is_array($r))) {
return false;
}
if (!isset($r['id'])) {
$r['id'] = 0;
}
if (!isset($r['type'])) {
$r['type'] = 0;
}
if (!isset($r['special'])) {
$r['special'] = 0;
}
if (!isset($r['name'])) {
$r['name'] = 'NO NAME SUPPLIED';
}
foreach ($r as $k => $v) {
$this->{$k} = $v;
}
$this->urlname = $r['name'];
$this->dbVals = $r;
self::$instances[$this->id] =& $this;
self::$instancesByName[preg_replace('/[^a-z0-9]/', '-', strtolower($this->urlname))] =& $this;
self::$instancesBySpecial[$this->special] =& $this;
if (!$this->vars) {
$this->vars = '{}';
}
$this->vars = json_decode($this->vars);
}
示例14: Forum_rssHandler
/**
* get a list of posts for an RSS feed
*
* @param Object $PAGEDATA The page
*
* @return array array of articles
**/
function Forum_rssHandler($PAGEDATA)
{
$items = array();
$posts = dbAll('select id,thread_id,author_id,created_date,body from forums_posts' . ' where moderated order by created_date desc limit 10');
$threads = array();
$authors = array();
foreach ($posts as $post) {
if (!isset($authors[$post['author_id']])) {
$authors[$post['author_id']] = dbRow('select name from user_accounts where id=' . $post['author_id']);
}
if (!isset($threads[$post['thread_id']])) {
$threads[$post['thread_id']] = dbRow('select forum_id,name from forums_threads where id=' . $post['thread_id']);
}
$items[] = array('title' => 'post by ' . $authors[$post['author_id']]['name'] . ' in "' . $threads[$post['thread_id']]['name'] . '"', 'description' => $post['body'], 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $PAGEDATA->getRelativeURL() . '?forum-f=' . $threads[$post['thread_id']]['forum_id'] . '&forum-t=' . $post['thread_id'] . '#forum-c-' . $post['id'], 'guid' => 'post-' . $post['id'], 'pubDate' => Core_dateM2H($post['created_date'], 'rfc822'));
}
return array('title' => 'Posts for ' . $PAGEDATA->getRelativeURL(), 'link' => 'http://' . $_SERVER['HTTP_HOST'] . $PAGEDATA->getRelativeURL(), 'description' => 'Posts for ' . $PAGEDATA->getRelativeURL(), 'generator' => 'WebME CMS', 'items' => $items);
}
示例15: poll_display
function poll_display()
{
WW_addScript('polls');
$poll = dbRow('select * from poll where enabled limit 1');
if (!count($poll)) {
return '<div class="polls-wrapper"><em>No polls available.</em></div>';
}
$id = $poll['id'];
$html = '<div class="polls-wrapper" poll-id="' . $id . '">';
$html .= '<div class="question">' . $poll['body'] . '</div><ul class="answers">';
$answers = dbAll("select * from poll_answer where poll_id={$id} order by num");
foreach ($answers as $answer) {
$html .= '<li><input type="radio" name="poll_answer" value=' . '"' . $answer['num'] . '" />' . htmlspecialchars($answer['answer']) . '</li>';
}
$html .= '</ul><input type="button" class="polls-vote" value="Vote" /><inpu' . 't type="button" class="polls-results" value="View Results" />';
$html .= '</div>';
return $html;
}