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


PHP get_app函数代码示例

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


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

示例1: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s'", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    send_register_open_eml($user[0]['email'], $a->config['sitename'], $a->get_baseurl(), $user[0]['username'], $register[0]['password']);
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:28,代码来源:regmod.php

示例2: search_doc_files

function search_doc_files($s)
{
    $a = get_app();
    $itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
    App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
    $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
    $regexop = db_getfunc('REGEXP');
    $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC));
    $r = fetch_post_tags($r, true);
    for ($x = 0; $x < count($r); $x++) {
        $r[$x]['text'] = $r[$x]['body'];
        $r[$x]['rank'] = 0;
        if ($r[$x]['term']) {
            foreach ($r[$x]['term'] as $t) {
                if (stristr($t['term'], $s)) {
                    $r[$x]['rank']++;
                }
            }
        }
        if (stristr($r[$x]['sid'], $s)) {
            $r[$x]['rank']++;
        }
        $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
        // bias the results to the observer's native language
        if ($r[$x]['lang'] === App::$language) {
            $r[$x]['rank'] = $r[$x]['rank'] + 10;
        }
    }
    usort($r, 'doc_rank_sort');
    return $r;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:31,代码来源:help.php

示例3: wfinger_init

function wfinger_init(&$a)
{
    $result = array();
    $scheme = '';
    if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
        $scheme = 'https';
    } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
        $scheme = 'https';
    }
    // Don't complain to me - I'm just implementing the spec.
    if ($scheme !== 'https') {
        header($_SERVER["SERVER_PROTOCOL"] . ' ' . 500 . ' ' . 'Webfinger requires HTTPS');
        killme();
    }
    $resource = $_REQUEST['resource'];
    $r = null;
    if ($resource) {
        if (strpos($resource, 'acct:') === 0) {
            $channel = str_replace('acct:', '', $resource);
            if (strpos($channel, '@') !== false) {
                $host = substr($channel, strpos($channel, '@') + 1);
                if (strcasecmp($host, get_app()->get_hostname())) {
                    goaway('https://' . $host . '/.well-known/webfinger?resource=' . $resource);
                }
                $channel = substr($channel, 0, strpos($channel, '@'));
            }
        }
        if (strpos($resource, 'http') === 0) {
            $channel = str_replace('~', '', basename($resource));
        }
        $r = q("select * from channel left join xchan on channel_hash = xchan_hash \n\t\t\twhere channel_address = '%s' limit 1", dbesc($channel));
    }
    header('Access-Control-Allow-Origin: *');
    header('Content-type: application/jrd+json');
    if ($resource && $r) {
        $h = q("select hubloc_addr from hubloc where hubloc_hash = '%s'", dbesc($r[0]['channel_hash']));
        $result['subject'] = $resource;
        $aliases = array(z_root() . '/channel/' . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address']);
        if ($h) {
            foreach ($h as $hh) {
                $aliases[] = 'acct:' . $hh['hubloc_addr'];
            }
        }
        $result['aliases'] = array();
        $result['properties'] = array('http://webfinger.net/ns/name' => $r[0]['channel_name']);
        foreach ($aliases as $alias) {
            if ($alias != $resource) {
                $result['aliases'][] = $alias;
            }
        }
        $result['links'] = array(array('rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l']), array('rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address']), array('rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address']), array('rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr']));
    } else {
        header($_SERVER["SERVER_PROTOCOL"] . ' ' . 400 . ' ' . 'Bad Request');
        killme();
    }
    $arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result);
    call_hooks('webfinger', $arr);
    echo json_encode($arr['result']);
    killme();
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:60,代码来源:wfinger.php

示例4: checksites_run

function checksites_run($argv, $argc)
{
    cli_startup();
    $a = get_app();
    logger('checksites: start');
    if ($argc > 1 && $argv[1]) {
        $site_id = $argv[1];
    }
    if ($site_id) {
        $sql_options = " and site_url = '" . dbesc($argv[1]) . "' ";
    }
    $days = intval(get_config('system', 'sitecheckdays'));
    if ($days < 1) {
        $days = 30;
    }
    $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d {$sql_options} ", db_utcnow(), db_quoteinterval($days . ' DAY'), intval(SITE_TYPE_ZOT));
    if (!$r) {
        return;
    }
    foreach ($r as $rr) {
        if (!strcasecmp($rr['site_url'], z_root())) {
            continue;
        }
        $x = ping_site($rr['site_url']);
        if ($x['success']) {
            logger('checksites: ' . $rr['site_url']);
            q("update site set site_update = '%s' where site_url = '%s' ", dbesc(datetime_convert()), dbesc($rr['site_url']));
        } else {
            logger('marking dead site: ' . $x['message']);
            q("update site set site_dead = 1 where site_url = '%s' ", dbesc($rr['site_url']));
        }
    }
    return;
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:34,代码来源:checksites.php

示例5: getCalendarObject

 /**
  * Returns information from a single calendar object, based on it's object
  * uri.
  *
  * The returned array must have the same keys as getCalendarObjects. The
  * 'calendardata' object is required here though, while it's not required
  * for getCalendarObjects.
  *
  * @param string $calendarId
  * @param string $objectUri
  * @throws Sabre_DAV_Exception_FileNotFound
  * @return array
  */
 function getCalendarObject($calendarId, $objectUri)
 {
     $a = get_app();
     $user_id = $a->user["uid"];
     $obj = FriendicaVirtualCalSourceBackend::getItemsByUri($user_id, $objectUri);
     return array("id" => IntVal($obj["data_uri"]), "calendardata" => $obj["ical"], "uri" => $obj["data_uri"], "lastmodified" => $obj["date"], "calendarid" => $calendarId, "etag" => $obj["ical_etag"], "size" => IntVal($obj["ical_size"]));
 }
开发者ID:robhell,项目名称:friendica-addons,代码行数:20,代码来源:dav_caldav_backend_friendica.inc.php

示例6: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory_submit_url'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user[0]['username'], '$email' => $user[0]['email'], '$password' => $register[0]['password'], '$uid' => $user[0]['uid']));
    $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:robhell,项目名称:friendica,代码行数:30,代码来源:regmod.php

示例7: repair_ostatus_content

function repair_ostatus_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $o = "<h2>" . t("Resubsribing to OStatus contacts") . "</h2>";
    $uid = local_user();
    $a = get_app();
    $counter = intval($_REQUEST['counter']);
    $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE\n                `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING));
    if (!$r) {
        return $o . t("Error");
    }
    $total = $r[0]["total"];
    $r = q("SELECT `url` FROM `contact` WHERE\n                `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)\n\t\tORDER BY `url`\n\t\tLIMIT %d, 1", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING), $counter++);
    if (!$r) {
        $o .= t("Done");
        return $o;
    }
    $o .= "<p>" . $counter . "/" . $total . ": " . $r[0]["url"] . "</p>";
    $o .= "<p>" . t("Keep this window open until done.") . "</p>";
    $result = new_contact($uid, $r[0]["url"], true);
    $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . $a->get_baseurl() . '/repair_ostatus?counter=' . $counter . '">';
    return $o;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:27,代码来源:repair_ostatus.php

示例8: edit

 function edit($staff_id)
 {
     $app = get_app();
     $staff = Staff::find_by_id($staff_id);
     //GET
     if ($app->request()->isGet()) {
         render_with_layout('misc.php', 'Staffs/edit.php', compact('staff'));
     }
     //POST
     if ($app->request()->isPost()) {
         $post = $app->request()->post();
         //
         $staff->identifier = $post['identifier'];
         $staff->name = $post['name'];
         $staff->short = $post['short'];
         $staff->group_id = $post['group_id'];
         if (!$staff->is_valid()) {
             $app->flashNow('errors', $staff->errors);
             render_with_layout('misc.php', 'Staffs/add.php', compact('staff'));
         } else {
             $staff->save();
             $app->flash('success', '员工信息更新成功!');
             redirect('/staffs');
         }
     }
 }
开发者ID:saintyk,项目名称:yndl_2,代码行数:26,代码来源:Staffs.php

示例9: onedirsync_run

function onedirsync_run($argv, $argc)
{
    cli_startup();
    $a = get_app();
    logger('onedirsync: start ' . intval($argv[1]));
    if ($argc > 1 && intval($argv[1])) {
        $update_id = intval($argv[1]);
    }
    if (!$update_id) {
        logger('onedirsync: no update');
        return;
    }
    $r = q("select * from updates where ud_id = %d limit 1", intval($update_id));
    if (!$r) {
        return;
    }
    if ($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED || !$r[0]['ud_addr']) {
        return;
    }
    // Have we probed this channel more recently than the other directory server
    // (where we received this update from) ?
    // If we have, we don't need to do anything except mark any older entries updated
    $x = q("select * from updates where ud_addr = '%s' and ud_date > '%s' and ( ud_flags & %d ) order by ud_date desc limit 1", dbesc($r[0]['ud_addr']), dbesc($r[0]['ud_date']), intval(UPDATE_FLAGS_UPDATED));
    if ($x) {
        $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not ( ud_flags & %d ) and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), intval(UPDATE_FLAGS_UPDATED), dbesc($x[0]['ud_date']));
        return;
    }
    update_directory_entry($r[0]);
    return;
}
开发者ID:Mauru,项目名称:red,代码行数:30,代码来源:onedirsync.php

示例10: add_twig_path

/**
 * Adds a path into the Twig Filesystem Loader.
 *
 * @param $path the path to add
 * @param bool $default If true will send the path to the beginning, this means the most important path
 * @param bool $weight path into a specif place
 *
 * @return boolean.
 */
function add_twig_path($path, $default = false, $weight = false)
{
    $app = get_app();
    if ($default === true) {
        $app->getTwigLoader()->prependPath($path);
        return true;
    } elseif ($default === false && $weight === false) {
        $app->getTwigLoader()->addPath($path);
        return true;
    }
    $paths = $app->getTwigLoader()->getPaths();
    $reindexed_paths = array();
    if (count($paths) < $weight) {
        //Higer than current paths so goes last.
        $app->getTwigLoader()->addPath($path);
        return true;
    }
    if (count($paths) > 0) {
        $reindexed_paths[] = array_shift($paths);
        //Defaults keeps being the default.
    }
    $index = 0;
    while ($current_path = array_shift($paths)) {
        // Look a position for the current weight.
        if ($index == $weight) {
            $reindexed_paths[] = $path;
        } else {
            $reindexed_paths[] = $current_path;
        }
        $index++;
    }
    $app->getTwigLoader()->setPaths($reindexed_paths);
    return true;
}
开发者ID:42mate,项目名称:towel,代码行数:43,代码来源:twig.inc.php

示例11: view

 function view($id)
 {
     //file_id
     $app = get_app();
     $file = File::find_by_id($id);
     $app->render('Files/view.php', compact('file'));
 }
开发者ID:saintyk,项目名称:yndl_2,代码行数:7,代码来源:Files.php

示例12: page_content

function page_content(&$a)
{
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = argv(2);
    $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
    if (!$u) {
        notice(t('Channel not found.') . EOL);
        return;
    }
    if ($_REQUEST['rev']) {
        $revision = " and revision = " . intval($_REQUEST['rev']) . " ";
    } else {
        $revision = " order by revision desc ";
    }
    require_once 'include/security.php';
    $sql_options = item_permissions_sql($u[0]['channel_id']);
    $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
    if (!$r) {
        // Check again with no permissions clause to see if it is a permissions issue
        $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
        if ($x) {
            // Yes, it's there. You just aren't allowed to see it.
            notice(t('Permission denied.') . EOL);
        } else {
            notice(t('Page not found.') . EOL);
        }
        return;
    }
    if ($r[0]['layout_mid']) {
        $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']));
        if ($l) {
            require_once 'include/comanche.php';
            comanche_parser(get_app(), $l[0]['body']);
        }
    }
    // logger('layout: ' . print_r($a->layout,true));
    // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
    if ($perms['write_pages']) {
        $chan = $a->channel['channel_id'];
        $who = $channel_address;
        $which = $r[0]['id'];
        $o .= writepages_widget($who, $which);
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
开发者ID:Mauru,项目名称:red,代码行数:59,代码来源:page.php

示例13: get_template_file

 public function get_template_file($file, $root = '')
 {
     $a = get_app();
     $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root);
     $template = new FriendicaSmarty();
     $template->filename = $template_file;
     return $template;
 }
开发者ID:ZerGabriel,项目名称:friendica,代码行数:8,代码来源:friendica_smarty.php

示例14: view

 function view($unit_id)
 {
     $app = get_app();
     $unit = Unit::find_by_id($unit_id);
     if ($unit) {
         $app->render('Units/view.php', compact('unit'));
     }
 }
开发者ID:saintyk,项目名称:yndl_2,代码行数:8,代码来源:Units.php

示例15: page_init

function page_init(&$a)
{
    // We need this to make sure the channel theme is always loaded.
    $which = argv(1);
    $profile = 0;
    profile_load($a, $which, $profile);
    if ($a->profile['profile_uid']) {
        head_set_icon($a->profile['thumb']);
    }
    // load the item here in the init function because we need to extract
    // the page layout and initialise the correct theme.
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = argv(2);
    $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
    if (!$u) {
        notice(t('Channel not found.') . EOL);
        return;
    }
    if ($_REQUEST['rev']) {
        $revision = " and revision = " . intval($_REQUEST['rev']) . " ";
    } else {
        $revision = " order by revision desc ";
    }
    require_once 'include/security.php';
    $sql_options = item_permissions_sql($u[0]['channel_id']);
    $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
    if (!$r) {
        // Check again with no permissions clause to see if it is a permissions issue
        $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
        if ($x) {
            // Yes, it's there. You just aren't allowed to see it.
            notice(t('Permission denied.') . EOL);
        } else {
            notice(t('Page not found.') . EOL);
        }
        return;
    }
    if ($r[0]['layout_mid']) {
        $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']));
        if ($l) {
            require_once 'include/comanche.php';
            comanche_parser(get_app(), $l[0]['body']);
            get_app()->pdl = $l[0]['body'];
        }
    }
    $a->data['webpage'] = $r;
}
开发者ID:redmatrix,项目名称:red,代码行数:58,代码来源:page.php


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