当前位置: 首页>>代码示例>>PHP>>正文


PHP dbOne函数代码示例

本文整理汇总了PHP中dbOne函数的典型用法代码示例。如果您正苦于以下问题:PHP dbOne函数的具体用法?PHP dbOne怎么用?PHP dbOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dbOne函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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'));
    }
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:34,代码来源:api.php

示例2: ThemesApi_filesCheck

/**
 * check uploaded file to see if it's acceptable
 *
 * @param array $vars list of parameters
 *
 * @return boolean
 */
function ThemesApi_filesCheck($vars)
{
    /**
     * check if this file should be handled
     * by this plugin
     */
    $file = explode('/', $vars['requested_file']);
    $dir = $file[1];
    if ($file[1] != 'themes_api') {
        return true;
    }
    /**
     * if you are a moderator, then you can download
     */
    $id = $file[3];
    $moderated = dbOne('select moderated from themes_api where id=' . $id, 'moderated');
    if ($moderated == 'no') {
        die(__('This theme is awaiting moderation and has not been deemed as safe yet.'));
    }
    // save in database
    $referrer = @$_SERVER['HTTP_REFERER'];
    $ip = @$_SERVER['REMOTE_ADDR'];
    dbQuery('insert into themes_downloads values("",' . $id . ',"' . $referrer . '","' . $ip . '",now())');
    return false;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:32,代码来源:plugin.php

示例3: SMS_subscribeToAddressbook

/**
 * add a subscriber to an addressbook
 *
 * @param int $sid subscriber ID
 * @param int $aid addressbook ID
 *
 * @return null
 */
function SMS_subscribeToAddressbook($sid, $aid)
{
    $subscribers = json_decode(dbOne('select subscribers from sms_addressbooks where id=' . $aid, 'subscribers'));
    if (in_array($sid, $subscribers)) {
        return;
    }
    $subscribers[] = $sid;
    dbQuery('update sms_addressbooks set subscribers="' . addslashes(json_encode($subscribers)) . '" where id=' . $aid);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:17,代码来源:plugin.php

示例4: DynamicSearch_catags

/**
 * DynamicSearch_catags
 *
 * @param array  $catags categories
 * @param string $s      search string
 * @param string $cat    category to search
 * @param int    $limit  how many results to return
 *
 * @return array
 */
function DynamicSearch_catags($catags, $s, $cat, $limit)
{
    if (!in_array($cat, $catags)) {
        die('Category does not exist.');
    }
    $id = dbOne('select id from pages where name="' . $cat . '"', 'id');
    $gd = getDescendants($id);
    $q = dbAll('select * from pages where (id=' . $id . ' ' . $gd . ') and (body like "%' . $s . '%" or name like "%' . $s . '%") order by edate limit ' . $limit);
    return $q;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:20,代码来源:results.php

示例5: Aggregator_show

/**
 * check for new emails
 *
 * @param object $vars config object
 *
 * @return array array of results
 */
function Aggregator_show($vars)
{
    if (!is_array($vars) && isset($vars->id) && $vars->id) {
        $data = dbOne('select data from messaging_notifier where id=' . $vars->id, 'data', 'messaging_notifier');
        if ($data) {
            return Aggregator_parse(json_decode($data), $vars);
        }
    }
    return '';
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:17,代码来源:index.php

示例6: ImageGallery_adminDetailsGet

/**
 * ImageGallery_adminDetailsGet
 * get details of a gallery
 *
 * @return details of the gallery
 */
function ImageGallery_adminDetailsGet()
{
    $id = (int) @$_REQUEST['id'];
    if (!$id) {
        Core_quit();
    }
    $meta = dbOne('select meta from image_gallery where id=' . $id, 'meta');
    $meta = json_decode($meta, true);
    return $meta;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:16,代码来源:api-admin.php

示例7: Ads_adminTypesDelete

/**
 * delete an ad type
 *
 * @return null
 */
function Ads_adminTypesDelete()
{
    $id = (int) $_REQUEST['id'];
    $ads = dbOne('select count(id) ids from ads where type_id=' . $id, 'ids');
    if ($ads) {
        return array('error' => 'cannot delete this Ad Type because there are Ads using it');
    }
    dbQuery('delete from ads_types where id=' . $id);
    return array('ok' => 1);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:15,代码来源:api-admin.php

示例8: Stats_value

function Stats_value($type, $duration)
{
    switch ($type) {
        case 'unique_visitors':
        case 'page_loads':
            break;
        default:
            return 'invalid type';
    }
    $duration = (int) $duration;
    $sql = 'select sum(' . $type . ') as val from logs_archive' . ' where cdate>date_add(now(), interval -' . $duration . ' day)';
    return dbOne($sql, 'val');
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:13,代码来源:stats.php

示例9: IssueTracker_adminTypeNew

/**
 * get a list of issue types
 *
 * @return array list
 */
function IssueTracker_adminTypeNew()
{
    $name = $_REQUEST['name'];
    if (!$name) {
        return array('error' => 'no name provided');
    }
    $sql = 'select id from issuetracker_types where name="' . addslashes($name) . '"';
    if (dbOne($sql, 'id')) {
        return array('error' => 'an issue type with that name already exists');
    }
    dbQuery('insert into issuetracker_types set name="' . addslashes($name) . '"' . ', fields="[]"');
    return array('id' => dbLastInsertId());
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:18,代码来源:api-admin.php

示例10: 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;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:50,代码来源:api.php

示例11: isInGroup

 function isInGroup($group)
 {
     if (isset($this->groupsByName[$group])) {
         return $this->groupsByName[$group];
     }
     if (!isset($this->groupsByName)) {
         $this->groupsByName = array();
     }
     $gid = dbOne('select id from groups where name="' . addslashes($group) . '"', 'id');
     if (!$gid) {
         $this->groupsByName[$group] = 0;
         return false;
     }
     $this->groupsByName[$group] = dbOne('select groups_id from users_groups where groups_id=' . $gid . ' and user_accounts_id=' . $this->id, 'groups_id');
     return $this->groupsByName[$group];
 }
开发者ID:AmandaSyachri,项目名称:webworks-webme,代码行数:16,代码来源:User.php

示例12: Forms_verificationSend

/**
 * send a random code to an email address to verify it
 *
 * @ return array saying it happened
 */
function Forms_verificationSend()
{
    if (!isset($_REQUEST['email'])) {
        return array('error' => 'no email parameter');
    }
    $email = $_REQUEST['email'];
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return array('error' => 'invalid email address');
    }
    if (!isset($_SESSION['emails'])) {
        $_SESSION['emails'] = array();
    }
    if (!isset($_SESSION['emails'][$email])) {
        $pid = (int) @$_REQUEST['page'];
        if ($pid) {
            $page = Page::getInstance($pid);
            if (!$page) {
                return array('error' => 'page not found');
            }
            $page->initValues();
            $prevent = (int) @$page->vars['forms_preventUserFromSubmitting'];
            if ($prevent) {
                $id = (int) dbOne('select id from user_accounts where email="' . addslashes($email) . '"', 'id');
                if ($id) {
                    if ($prevent == 1) {
                        // don't allow any users to submit
                        return array('error' => $page->vars['forms_preventUserFromSubmittingMessage']);
                    }
                    if ($prevent < 4) {
                        // parse conditions
                        $user = User::getInstance($id);
                        if ($user) {
                            $cond_val = $page->vars['forms_preventUserFromSubmittingCondVal'];
                            $cond_key = $page->vars['forms_preventUserFromSubmittingCondKey'];
                            if ($prevent == 3 && $user->get($cond_key) == $cond_val || $prevent == 2 && $user->get($cond_key) != $cond_val) {
                                return array('error' => $page->vars['forms_preventUserFromSubmittingMessage']);
                            }
                        }
                    }
                }
            }
        }
        $_SESSION['emails'][$email] = rand(10000, 99999);
    }
    mail($email, '[' . $_SERVER['HTTP_HOST'] . '] email verification code', 'The verification code for this email address is: ' . $_SESSION['emails'][$email]);
    return array('ok' => 1);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:52,代码来源:api.php

示例13: Translate_checkCurrentPage

/**
 * switches the reader to a translation if one exists
 *
 *	@param object $PAGEDATA page object
 *
 * @return void
 */
function Translate_checkCurrentPage($PAGEDATA)
{
    // { if this is a translation page, and no language is selected, select this one.
    if ($PAGEDATA->type == 'translate' && !isset($_SESSION['translate-lang'])) {
        $_SESSION['translate-lang'] = $PAGEDATA->vars['translate_language'];
    }
    // }
    // { if no language is selected, then return
    if (!isset($_SESSION['translate-lang']) || !$_SESSION['translate-lang']) {
        return;
    }
    // }
    // { various checks if this page is a translation one
    $page_to_translate = $PAGEDATA->id;
    if ($PAGEDATA->type == 'translate') {
        // { if this page's language is the selected one, return
        if ($PAGEDATA->vars['translate_language'] == $_SESSION['translate-lang']) {
            return;
        }
        // }
        $page_to_translate = (int) $PAGEDATA->vars['translate_page_id'];
    }
    $trs = dbAll('select page_id from page_vars where name="translate_page_id" and value=' . $page_to_translate, false, 'page_vars');
    // { try to find a version of the current page in the selected language
    if ($trs === false || !count($trs)) {
        return;
    }
    $ids = array();
    foreach ($trs as $tr) {
        $ids[] = $tr['page_id'];
    }
    $page_id = dbOne('select page_id from page_vars where name="translate_language" and value="' . addslashes($_SESSION['translate-lang']) . '" limit 1', 'page_id');
    // { if none found, return
    if ($page_id === false) {
        return;
    }
    // }
    $page = Page::getInstance($page_id);
    if ($page->id) {
        redirect($page->getRelativeUrl());
    }
    // }
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:50,代码来源:plugin.php

示例14: News_displayHeadlines

/**
 * show the news in Headline mode
 *
 * @param array $PAGEDATA the page object
 *
 * @return string HTML of the news
 */
function News_displayHeadlines($PAGEDATA)
{
    $items_per_page = isset($PAGEDATA->vars['news_items']) ? $PAGEDATA->vars['news_items'] : 5;
    $p = isset($_REQUEST['news_page']) ? (int) $_REQUEST['news_page'] : 0;
    if ($p < 0) {
        $p = 0;
    }
    $arr = Core_cacheLoad('pages', 'news-' . $GLOBALS['id'] . '-' . $p . '-' . $items_per_page);
    if ($arr === false) {
        $order_by = isset($PAGEDATA->vars['news_order']) ? addslashes($PAGEDATA->vars['news_order']) : 'associated_date desc';
        $rs = dbAll('select * from pages where parent=' . $GLOBALS['id'] . ' order by ' . $order_by . ',cdate desc limit ' . $p . ',' . $items_per_page);
        $num_stories = dbOne('select count(id) as num from pages where parent=' . $GLOBALS['id'], 'num');
        Core_cacheSave('pages', 'news-' . $GLOBALS['id'] . '-' . $p . '-' . $items_per_page, array($num_stories, $rs));
    } else {
        $num_stories = $arr[0];
        $rs = $arr[1];
        unset($arr);
    }
    $nextprev = array();
    $nextprev[] = '<span class="page_n_of_n">' . __('page %1 of %2', array(1 + floor($p / $items_per_page), ceil($num_stories / $items_per_page)), 'core') . '</span>';
    if ($p) {
        $nextprev[] = '<a class="prev" href="?news_page=' . ($p - $items_per_page) . '">' . __('Previous Page') . '</a>';
    }
    if ($p + $items_per_page < $num_stories) {
        $nextprev[] = '<a class="next" href="?news_page=' . ($p + $items_per_page) . '">' . __('Next Page') . '</a>';
    }
    $nextprev = '<div class="nextprev">' . join(' | ', $nextprev) . '</div>';
    $html = $nextprev;
    $links = array();
    foreach ($rs as $r) {
        $page = Page::getInstance($r['id'], $r);
        $content = isset($PAGEDATA->vars['news_display']) && $PAGEDATA->vars['news_display'] == 'full' ? $page->render() : substr(preg_replace('/<[^>]*>/', '', preg_replace('#<h1>[^<]*</h1>#', '', $page->render())), 0, 600);
        $date = isset($PAGEDATA->vars['news_title']) && $PAGEDATA->vars['news_title'] == 'yes' ? '<h2 class="news-header"><a href="' . $page->getRelativeURL() . '">' . htmlspecialchars($page->name) . '</a></h2>' . '<a class="news-date" href="' . $page->getRelativeURL() . '">' . __('posted on %1', array(Core_dateM2H($page->associated_date)), 'core') . '</a>' : '';
        if (!isset($page->associated_date) || !$page->associated_date) {
            $page->associated_date = $page->cdate;
        }
        $links[] = $date . '<p class="news-paragraph">' . $content . '...</p>';
    }
    $html .= join('<div class="news-break"></div>', $links);
    $html .= $nextprev;
    return $html;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:49,代码来源:display.php

示例15: IssueTracker_getDepositedValue

/**
 * returns the amount of money that a issue has
 *
 * @return null
 */
function IssueTracker_getDepositedValue()
{
    $id = $_REQUEST['id'];
    $amount = 0;
    $meta = dbOne("select `meta` from `issuetracker_issues` where `id`=" . $id, 'meta');
    $meta = json_decode($meta, true);
    if (array_key_exists('paid_credits', $meta)) {
        $amount = $meta['paid_credits'];
    }
    return $amount;
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:16,代码来源:api.php


注:本文中的dbOne函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。