• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP environment函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: index

function index(&$vars)
{
    extract($vars);
    $theme = environment('theme');
    $atomfeed = $request->feed_url();
    return vars(array(&$Category, &$profile, &$atomfeed, &$collection, &$theme), get_defined_vars());
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:7,代码来源:categories.php


示例2: broadcast_email_notice

function broadcast_email_notice(&$model, &$rec)
{
    if (!isset($rec->title)) {
        return;
    }
    global $request, $db;
    $i = owner_of($rec);
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
    $where = array('subscriptions.subscribed' => $i->id);
    $Subscription->set_param('find_by', $where);
    $Subscription->find();
    while ($sub = $Subscription->MoveNext()) {
        $sid = $sub->FirstChild('identities');
        if (!in_array($sid->id, $sent_to) && $sub->email) {
            $html = false;
            // this is the body of the e-mail if ($html == false)
            $text = $rec->title;
            $subject = $i->nickname . " posted a notice";
            send_email($sid->email_value, $subject, $text, environment('email_from'), environment('email_name'), $html);
            $sent_to[] = $sid->id;
        }
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:25,代码来源:email_notice.php


示例3: View

 function View()
 {
     $this->named_vars = array();
     $this->header_sent = false;
     global $db;
     global $request;
     $env =& environment();
     if (isset($request->resource)) {
         $this->collection = new Collection($request->resource);
     } else {
         $this->collection = new Collection(null);
     }
     $this->named_vars['db'] =& $db;
     $this->named_vars['request'] =& $request;
     $this->named_vars['collection'] =& $this->collection;
     $this->named_vars['response'] =& $this;
     if (get_profile_id()) {
         $this->named_vars['profile'] =& get_profile();
     } else {
         $this->named_vars['profile'] = false;
     }
     if (isset($request->resource) && $request->resource != 'introspection') {
         $this->named_vars['resource'] =& $db->get_table($request->resource);
     } else {
         $this->named_vars['resource'] = false;
     }
     $this->named_vars['prefix'] = $db->prefix;
     $this->controller = $request->controller;
     load_apps();
     $controller_path = controller_path();
     // check for a controller file in controllers/[resource].php
     if (isset($request->resource)) {
         $cont = $controller_path . $request->resource . ".php";
         if (file_exists($cont)) {
             $this->controller = $request->resource . ".php";
         } elseif (isset($request->templates_resource[$request->resource]) && file_exists($controller_path . $request->templates_resource[$request->resource] . ".php")) {
             $this->controller = $request->templates_resource[$request->resource] . ".php";
         } else {
             if (isset($GLOBALS['PATH']['apps'])) {
                 foreach ($GLOBALS['PATH']['apps'] as $k => $v) {
                     if (file_exists($v['controller_path'] . $request->resource . ".php")) {
                         $this->controller = $request->resource . ".php";
                         $controller_path = $v['controller_path'];
                     }
                 }
             }
         }
     }
     if (is_file($controller_path . $this->controller)) {
         require_once $controller_path . $this->controller;
     } else {
         trigger_error('Sorry, the controller was not found at ' . $controller_path . $this->controller, E_USER_ERROR);
     }
     if (!isset($env['content_types'])) {
         trigger_error('Sorry, the content_types array was not found in the configuration file', E_USER_ERROR);
     }
     $this->negotiator = HTTP_Negotiate::choose($env['content_types']);
 }
开发者ID:voitto,项目名称:dbscript,代码行数:58,代码来源:view.php


示例4: defineEnvironment

 protected function defineEnvironment($strenv)
 {
     if (($env = environment($strenv)) === null) {
         $message = __METHOD__ . "() {$strenv} is not valid environment. " . "Use development, test or production.";
         throw new Sabel_Sakle_Exception($message);
     } elseif (!defined("ENVIRONMENT")) {
         define("ENVIRONMENT", $env);
     }
 }
开发者ID:hamaco,项目名称:phwittr-on-xoops,代码行数:9,代码来源:Task.php


示例5: Cookie

 function Cookie()
 {
     global $prefix;
     if (environment('cookielife')) {
         $this->expiration = environment('cookielife');
     }
     $this->cookiename = $prefix . $this->cookiename;
     if (array_key_exists($this->cookiename, $_COOKIE)) {
         $buffer = $this->_unpackage($_COOKIE[$this->cookiename]);
     } else {
         return false;
     }
 }
开发者ID:voitto,项目名称:dbscript,代码行数:13,代码来源:cookie.php


示例6: post

function post(&$vars)
{
    extract($vars);
    if (!get_profile_id()) {
        trigger_error('Sorry, the setting could not be saved', E_USER_ERROR);
    }
    $request->set_param(array('setting', 'profile_id'), get_profile_id());
    if (strpos($request->params['setting']['name'], 'password') !== false) {
        $request->set_param(array('setting', 'value'), md5_encrypt($request->params['setting']['value'], $db->dbname));
    }
    $settingname = $request->params['setting']['name'];
    $set = split('\\.', $settingname);
    if (is_array($set) && $set[0] == 'config') {
        if (!member_of('administrators')) {
            trigger_error('Sorry, you must be an administrator to do that', E_USER_ERROR);
        }
        $s = $Setting->find_by('name', $settingname);
        if ($s) {
            $db->delete_record($s);
        }
    }
    if ($settingname == 'app') {
        $do_install = false;
        $app = $settingname;
        $sources = environment('remote_sources');
        $remote_list = array();
        foreach ($sources as $name => $url) {
            $p = get_profile();
            $url = "http://" . $url . "&p=" . urlencode($p->profile_url) . "&a=" . urlencode($app);
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($curl);
            if ($result) {
                if (trim($result) == 'install') {
                    $do_install = true;
                }
                continue;
            }
            curl_close($curl);
        }
        if (!$do_install) {
            trigger_error('Sorry, you are not authorized to install ' . $app, E_USER_ERROR);
        }
    }
    $resource->insert_from_post($request);
    header_status('201 Created');
    redirect_to($request->resource);
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:50,代码来源:settings.php


示例7: broadcast_sms_notice

function broadcast_sms_notice(&$model, &$rec)
{
    $smskey = environment('zeepAccessKey');
    if (empty($smskey)) {
        return;
    }
    if (!isset($rec->title)) {
        return;
    }
    global $request, $db;
    $i = owner_of($rec);
    $notice_content = substr($rec->title, 0, 100);
    $sent_to = array();
    $Subscription = $db->model('Subscription');
    $Subscription->has_one('subscriber:identity');
    $where = array('subscriptions.subscribed' => $i->id);
    $Subscription->set_param('find_by', $where);
    $Subscription->find();
    while ($sub = $Subscription->MoveNext()) {
        $sid = $sub->FirstChild('identities');
        if (!in_array($sid->id, $sent_to) && $sub->sms) {
            $sent_to[] = $sid->id;
            $apiurl = environment('zeepUrl');
            $secret = environment('zeepSecretKey');
            $apikey = environment('zeepAccessKey');
            $http_date = gmdate(DATE_RFC822);
            $parameters = "user_id=" . $sid->id . "&body=" . urlencode($notice_content);
            $canonical_string = $apikey . $http_date . $parameters;
            $b64_mac = base64_encode(hash_hmac("sha1", $canonical_string, $secret, TRUE));
            $authentication = "Zeep {$apikey}:{$b64_mac}";
            $header = array("Authorization: " . $authentication, "Date: " . $http_date, "Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strval(strlen($parameters)));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $apiurl);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
            $response = curl_exec($ch);
            //echo $response; exit;
            curl_close($ch);
        }
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:45,代码来源:sms_notice.php


示例8: broadcast_notifixious_notice

function broadcast_notifixious_notice(&$model, &$rec)
{
    $notifixkey = '';
    $login = 'brianjesse';
    $pass = '';
    $notifixurl = 'notifixio.us';
    if (!isset($rec->title)) {
        return;
    }
    if (!get_profile_id()) {
        return;
    }
    $installed = environment('installed');
    if (!in_array('notifixious', $installed)) {
        return;
    }
    if (!class_exists('Services_JSON')) {
        lib_include('json');
    }
    $url = "http://" . $notifixurl . "/sources/find.json";
    $params = "url=" . urlencode(get_bloginfo('rss2_url'));
    $results = notifixious_http_request($url . "?" . $params, "GET");
    $jsonobj = json_decode($results[1]);
    $source_id = $jsonobj->sources->source->permalink;
    if ($source_id != "") {
        update_option('notifixiousSourceId', '' . $source_id . '', '', 'no');
        update_option('notifixiousRegistered', '1', '', 'no');
        update_option('notifixiousClaimed', '0', '', 'yes');
    } else {
        update_option('notifixiousSourceId', '0', '', 'no');
        update_option('notifixiousRegistered', '0', '', 'no');
    }
    $post = get_post($rec);
    $title = urlencode($post->post_title);
    $text = urlencode($post->post_content);
    $link = urlencode($post->guid);
    $url = "http://" . urlencode($login) . ":" . urlencode($pass) . "@" . $notifixurl . "/sources/" . $source_id . "/events.json?" . "event[title]=" . $title . "&event[text]=" . $text . "&event[link]=" . $link;
    echo $url;
    exit;
    //http://:@?event[title]=&event[text]=&event[link]=
    $arr = notifixious_http_request($url, "POST");
    print_r($arr);
    exit;
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:44,代码来源:notifix.php


示例9: send_to_twitter

function send_to_twitter(&$model, &$rec)
{
    if (!get_profile_id()) {
        return;
    }
    // if the Record does not have a title or uri, bail out
    if (!isset($rec->title) || !isset($rec->uri)) {
        return;
    }
    if (get_option('twitter_status') != 'enabled') {
        return;
    }
    global $db, $prefix;
    $sql = "SELECT oauth_key,oauth_secret FROM " . $prefix . "twitter_users WHERE profile_id = " . get_profile_id();
    $result = $db->get_result($sql);
    if ($db->num_rows($result) == 1) {
        // http://abrah.am
        lib_include('twitteroauth');
        $key = $db->result_value($result, 0, 'oauth_key');
        $secret = $db->result_value($result, 0, 'oauth_secret');
        $consumer_key = environment('twitterKey');
        $consumer_secret = environment('twitterSecret');
        $to = new TwitterOAuth($consumer_key, $consumer_secret, $key, $secret);
        $notice_content = substr($rec->title, 0, 140);
        $content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $notice_content), 'POST');
    } else {
        wp_plugin_include('twitter-tools');
        // set a flag on aktt
        global $aktt;
        $aktt->tweet_from_sidebar = false;
        // truncate the tweet at 140 chars
        $notice_content = substr($rec->title, 0, 140);
        // activate Twitter Tools
        $_GET['activate'] = true;
        // trip the init() function
        aktt_init();
        // make a new tweet object
        $tweet = new aktt_tweet();
        // set the tweetbody
        $tweet->tw_text = stripslashes($notice_content);
        // send the tweet to Twitter
        $aktt->do_tweet($tweet);
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:44,代码来源:twitter.php


示例10: getSplitEventsUrl

function getSplitEventsUrl()
{
    $env = environment();
    switch ($env) {
        case 'development':
            return getenv('SPLITIO_EVENTS_DEV_URL');
            break;
        case 'loadtesting':
            return getenv('SPLITIO_EVENTS_LOADTESTING_URL');
            break;
        case 'testing':
            return getenv('SPLITIO_EVENTS_TESTING_URL');
            break;
        case 'staging':
            return getenv('SPLITIO_EVENTS_STAGE_URL');
            break;
        case 'production':
        default:
            return SPLITIO_EVENTS_URL;
    }
}
开发者ID:splitio,项目名称:php-client,代码行数:21,代码来源:functions.php


示例11: followgrid

            followgrid();
            ?>
      </div>
  <?php 
        }
        ?>
  <?php 
    }
    ?>

<?php 
}
?>

<?php 
if (signed_in() && environment('categories') && !isset($request->params['byid']) && !in_array('settings', $request->activeroute->patterns)) {
    ?>
  
<?php 
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) {
        echo prologue_widget_recent_comments_avatar(array('before_widget' => ' <li id="recent-comments" class="widget widget_recent_comments"> ', 'after_widget' => '', 'before_title' => '<h2>', 'after_title' => '</h2>'));
        $before = "<h2>" . $txt['recent_projects'] . "</h2>\n";
        $after = "\n";
        $num_to_show = 35;
        echo prologue_recent_projects($num_to_show, $before, $after);
    }
    // if dynamic_sidebar
    ?>

<?php 
    if (!in_array('settings', $request->activeroute->patterns)) {
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:31,代码来源:sidebar.php


示例12: pre_update

 function pre_update(&$rec, $modified_field, $datatype)
 {
     trigger_before('pre_update', $rec, $this);
     if (isset($this->models[$rec->table]->field_attrs[$modified_field]['required'])) {
         if (!(strlen($rec->attributes[$modified_field]) > 0)) {
             trigger_error("Sorry, you must provide a value for {$modified_field}", E_USER_ERROR);
         }
     }
     if (isset($this->models[$rec->table]->field_attrs[$modified_field]['unique'])) {
         $result = $this->get_result("select " . $modified_field . " from " . $this->prefix . $rec->table . " where " . $modified_field . " = '" . $rec->attributes[$modified_field] . "' and " . $rec->primary_key . " != '" . $rec->attributes[$rec->primary_key] . "'");
         if ($this->num_rows($result) > 0) {
             trigger_error("Sorry, that {$modified_field} has already been taken.", E_USER_ERROR);
         }
     }
     if ($datatype == 'blob' && strlen($rec->attributes[$modified_field]) > 0) {
         if (environment('max_upload_mb')) {
             $max = 1048576 * environment('max_upload_mb');
             $size = filesize($rec->attributes[$modified_field]);
             if ($size > $max) {
                 trigger_error('Sorry but that file is too big, the limit is ' . environment('max_upload_mb') . ' megabytes', E_USER_ERROR);
             }
         }
         global $request;
         $coll = environment('collection_cache');
         if (isset($coll[$request->resource]) && $coll[$request->resource]['location'] == 'aws') {
             $this->file_upload = array($modified_field, $rec->attributes[$modified_field]);
             $this->aws_delfile($rec, $rec->id);
             $this->aws_putfile($rec, $rec->id);
             $rec->set_value($modified_field, '');
         } elseif (isset($coll[$request->resource]) && $coll[$request->resource]['location'] == 'uploads') {
             update_uploadsfile($this->prefix . $rec->table, $rec->id, $rec->attributes[$modified_field]);
             $rec->set_value($modified_field, '');
         } else {
             unlink_cachefile($this->prefix . $rec->table, $rec->id, $coll);
             $oid_result = $this->get_result("select " . $modified_field . " from " . $this->prefix . $rec->table . " where " . $rec->primary_key . " = '" . $rec->attributes[$rec->primary_key] . "'");
             if ($this->num_rows($oid_result) > 0) {
                 $prev_oid = $this->fetch_array($oid_result);
                 if (isset($prev_oid[0]) && $prev_oid[0] > 0) {
                     $result = $this->large_object_delete($prev_oid);
                 }
             }
             $oid = $this->large_object_create($this->prefix . $rec->table, $rec->attributes[$modified_field]);
             if ($oid > 0) {
                 $rec->attributes[$modified_field] = $oid;
             }
         }
     }
 }
开发者ID:voitto,项目名称:dbscript,代码行数:48,代码来源:postgresql.php


示例13: run

 function run()
 {
     global $config;
     $apps = environment('apps');
     $GLOBALS['PATH']['app_plugins'] = array();
     $GLOBALS['PATH']['apps'] = array();
     foreach ($apps as $app) {
         $GLOBALS['PATH']['app_plugins'][] = app_path() . $app . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
         $GLOBALS['PATH']['apps'][$app] = array('layout_path' => app_path() . $app . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR, 'model_path' => app_path() . $app . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR, 'controller_path' => app_path() . $app . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR);
     }
     //    if ( is_dir( $app . $env['view_folder'] ) )
     //      $request->set_template_path( $app . $env['view_folder'].DIRECTORY_SEPARATOR );
     //    else
     //      $request->set_template_path( $env['view_folder'].DIRECTORY_SEPARATOR );
     //    if ( is_dir( $app . $env['layout_folder'] ) )
     //      $request->set_layout_path( $app . $env['layout_folder'].DIRECTORY_SEPARATOR );
     //    else
     //      $request->set_layout_path( $env['layout_folder'].DIRECTORY_SEPARATOR );
 }
开发者ID:voitto,项目名称:dbscript,代码行数:19,代码来源:bootloader.php


示例14: send_email_notice

function send_email_notice(&$model, &$rec)
{
    global $db;
    global $request;
    if (!(get_profile_id() && $request->resource == 'groups')) {
        return;
    }
    // get data modesl for 3 tables
    $Entry =& $db->get_table('entries');
    $Group =& $db->get_table('groups');
    $Person =& $db->get_table('people');
    // load the first 20 records from the groups table
    $Group->find();
    // keep a list of people we have notified
    $sent_to = array();
    // get the name of the table from the data model reference we received
    $notify_table = $model->table;
    // get the primary key value of the record reference we received
    $notify_id = $rec->id;
    // if the table that was modified is a metadata table (comments, reviews)
    // notify about the "target" table being modified
    if (array_key_exists('target_id', $model->field_array)) {
        $e = $Entry->find($rec->attributes['target_id']);
        if ($e) {
            $notify_table = $e->resource;
            $notify_id = $e->record_id;
        }
    }
    // get the data model we are notifying about
    $datamodel =& $db->get_table($notify_table);
    // get the profile data for the current user
    $profile = owner_of($rec);
    // loop over each group
    while ($g = $Group->MoveNext()) {
        if (in_array($g->name, array('administrators', 'everyone', 'members'))) {
            continue;
        }
        // if the GROUP has READ or CREATE then do notify its members
        if ($rec->id && (in_array($g->name, $datamodel->access_list['read']['id']) || in_array($g->name, $datamodel->access_list['create'][$notify_table]))) {
            // loop over each member in the group
            while ($m = $g->NextChild('memberships')) {
                // get a person activerecord object for the member's person_id
                $p = $Person->find($m->person_id);
                if ($p) {
                    $action = $request->action;
                    $notify = "notify_" . $action;
                    // get an identities activerecord object for the person's first identity
                    // this is an example of traversing the result dataset without re-querying
                    $i = $p->FirstChild('identities');
                    // if we haven't already sent this person a message
                    if (isset($m->{$notify}) && $m->{$notify} && is_email($i->email_value) && !in_array($i->email_value, $sent_to)) {
                        // a token may be set to allow the notify-ee to "EXPRESS" register as a new site user
                        // it fills in some of the "new user" form info such as e-mail address for them
                        if (isset($i->token) && strlen($i->token) > 0) {
                            $addr = $request->url_for(array('resource' => $notify_table, 'id' => $notify_id, 'ident' => $i->token));
                        } else {
                            $addr = $request->url_for(array('resource' => $notify_table, 'id' => $notify_id));
                        }
                        // this is the HTML content of the e-mail
                        $html = ' 
            <!DOCTYPE HTML PUBLIC \\"-//W3C//DTD HTML 4.0 Transitional//EN\\"> 
            <html> 
            <body> 
            <br /> 
            <b><u><i>Click on this link:</i></u></b><br /> 
            <br />
            <font color="red"><a href="' . $addr . '">' . $addr . '</a></font> 
            </body> 
            </html>';
                        // oh wait, we are not going to send the HTML it is just wasting space for now
                        // comment this out to try the HTML yourself
                        $html = false;
                        // this is the body of the e-mail if ($html == false)
                        $text = 'Content was updated at the following location:' . "\r\n\r\n" . $addr . "\r\n\r\n";
                        // change the e-mail subject line depending on what action took place
                        if ($action == 'post') {
                            $actionmessage = " created a new ";
                        } elseif ($action == 'put') {
                            $actionmessage = " updated a ";
                        } elseif ($action == 'delete') {
                            $actionmessage = " deleted a ";
                        }
                        // set the e-mail subject to the current user's first name
                        // classify() converts a table name "nerds" to "Nerd"
                        // the converse is tableize()
                        $subject = $profile->given_name . $actionmessage . classify($request->resource);
                        // this sends e-mail using the xpertmailer package
                        // the environment() function reads a value from the config.yml file
                        send_email($i->email_value, $subject, $text, environment('email_from'), environment('email_name'), $html);
                        // add a new entry to the list of successful (more like woeful) recipients
                        $sent_to[] = $i->email_value;
                    }
                }
            }
        }
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:97,代码来源:email_group.php


示例15: omb_dev_alert

function omb_dev_alert($text)
{
    global $request;
    if (!isset_admin_email() || $request->domain != 'openmicroblogger.com') {
        return;
    }
    send_email(environment('email_from'), "admin alert for " . $request->base, $text, environment('email_from'), environment('email_name'), false);
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:8,代码来源:_functions.php


示例16: index

function index(&$vars)
{
    extract($vars);
    $blocks = environment('blocks');
    return vars(array(&$blocks, &$profile, &$collection), get_defined_vars());
}
开发者ID:voitto,项目名称:dbscript,代码行数:6,代码来源:index.php


示例17: set_tz_by_offset

if (isset($env['max_upload_mb'])) {
    $db->max_upload_megabytes($env['max_upload_mb']);
}
if (INTRANET) {
    $env['authentication'] = 'password';
}
//if (UPLOADS)
//  $env['collection_cache']['posts']['location'] = UPLOADS;
//if (UPLOADS)
//  $env['collection_cache']['identities']['location'] = UPLOADS;
// PHP5 only set server timezone
if (function_exists(timezone_abbreviations_list) && environment('timezone')) {
    if (setting('timezone')) {
        set_tz_by_offset(setting('timezone'));
    } else {
        set_tz_by_offset(environment('timezone'));
    }
}
/**
 * load virtual API methods
 */
global $api_methods, $api_method_perms;
$api_methods = array();
$api_method_perms = array();
$Method =& $db->model('Method');
$Method->find_by(array('eq' => 'like', 'function' => 'api_%'));
while ($m = $Method->MoveNext()) {
    $api_method_perms[$m->function] = array('table' => $m->resource, 'perm' => $m->permission);
    $api_methods[$m->function] = $m->code;
    $request->connect($m->route, array('action' => $m->function));
    if ($m->omb) {
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:31,代码来源:boot.php


示例18: do_shorten


//.........这里部分代码省略.........
                $trimpath = $id;
                $reference = get_code();
                $trimmed = date("d/m/Y", $time_of);
                $destination = $longurl;
                $trim_path = $id;
                $url_parts = @parse_url($longurl);
                $domain = $url_parts["host"];
                $visits = 0;
                $status_result = 'OK';
                $status_code = '200';
                $date_time = date("Y/m/d H:i:s O", $time_of);
                $l = $Url->find_by(array('id' => $id));
                if ($make_new_url) {
                    $l->set_value('text', $plain);
                    $l->set_value('title', $plain);
                    $l->set_value('trimurl', $strurl);
                    $l->set_value('created', date("Y-m-d H:i:s", $time_of));
                    $l->set_value('date', date("Y-m-d H:i:s", $time_of));
                    $l->set_value('trimpath', $trimpath);
                    $l->set_value('trimref', $reference);
                    $l->set_value('trimmed', $trimmed);
                    $l->set_value('trimvisits', $visits);
                    $l->set_value('trimtime', $date_time);
                    $l->save_changes();
                } else {
                    $reference = $l->reference;
                    $trimpath = $l->trimpath;
                    $reference = $l->trimref;
                    $trimmed = $l->trimmed;
                    $trimpath = $l->trimpath;
                    $trim_path = $l->trimpath;
                    $visits = $l->trimvisits;
                    $date_time = $l->trimtime;
                    $l->set_value('trimvisits', $l->trimvisits + 1);
                    $l->save_changes();
                }
            }
            $arr = array('destination', 'url', 'trimmed');
            if ($responsetype == 'json') {
                foreach ($arr as $var) {
                    ${$var} = str_replace('/', '\\/', ${$var});
                }
            }
            if (substr($longurl, -strlen($domain)) == $domain) {
                $destination .= '\\/';
            }
            $callback1 = '';
            $callback2 = '';
            if (isset($request->callback)) {
                $callback1 = $request->callback . '(';
                $callback2 = ')';
            }
            if ($responsetype == 'json') {
                header('Content-Type: application/json');
                header("Content-Disposition: inline");
            }
            if ($responsetype == 'xml') {
                echo '<?xml version="1.0" encoding="UTF-8"?>
<trim>
  <status result="OK" code="200" message="tr.im URL Added."/>
  <url>' . $strurl . '</url>
  <reference>' . $reference . '</reference>
  <trimpath>' . $trimpath . '</trimpath>
</trim>';
            }
            if ($responsetype == 'json') {
                echo $callback1 . '{"trimpath": "' . $trimpath . '", "reference": "' . $reference . '", "trimmed": "' . $trimmed . '", "destination": "' . $destination . '", "trim_path": "' . $trim_path . '", "domain": "' . $domain . '", "url": "' . $strurl . '", "visits": ' . $visits . ', "status": {"result": "' . $status_result . '", "code": "' . $status_code . '", "message": "tr.im URL Added."}, "date_time": "' . $date_time . '"}' . $callback2;
            }
        }
        $redircode = '<html>

  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=' . stripslashes($destination) . '">
    <meta name="robots" content="noindex"/>
    <link rel="canonical" href="' . stripslashes($destination) . '"/>
  </head>

  <body>

  </body>
  
</html>';
        $make_s3 = false;
        if ($url_base && $make_s3) {
            $redirfile = tempnam("/tmp", $url_base . '/' . $trimpath);
            $handle = fopen($redirfile, "w");
            fwrite($handle, $redircode);
            fclose($handle);
            lib_include('S3');
            $s3 = new S3(environment('awsAccessKey'), environment('awsSecretKey'));
            if ($s3) {
                $s3->getBucket($url_base);
                $s3->putObjectFile($redirfile, $url_base, $trimpath, 'public-read');
            }
        }
    }
    exit;
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:101,代码来源:Shortener.php


示例19: openid_continue

function openid_continue(&$vars)
{
    extract($vars);
    $valid = false;
    if (class_exists('MySQL') && environment('openid_version') > 1 && !isset($_SESSION['openid_degrade'])) {
        global $openid;
        wp_plugin_include(array('wp-openid'));
        $logic = new WordPressOpenID_Logic(null);
        $logic->activate_plugin();
        $consumer = WordPressOpenID_Logic::getConsumer();
        $openid->response = $consumer->complete($_SESSION['oid_return_to']);
        switch ($openid->response->status) {
            case Auth_OpenID_CANCEL:
                trigger_error('The OpenID assertion was cancelled.', E_USER_ERROR);
                break;
            case Auth_OpenID_FAILURE:
                // if we fail OpenID v2 here, we retry once with OpenID v1
                $_SESSION['openid_degrade'] = true;
                $request->set_param('return_url', $request->url_for('openid_continue') . '/');
                $request->set_param('protected_url', $request->base);
                $request->set_param('openid_url', $_SESSION['openid_url']);
                authenticate_with_openid();
                break;
            case Auth_OpenID_SUCCESS:
                $_SESSION['openid_complete'] = true;
                $valid = true;
                break;
        }
    }
    if (!$valid) {
        include $GLOBALS['PATH']['library'] . 'openid.php';
        $openid = new SimpleOpenID();
        $openid->SetIdentity($_SESSION['openid_url']);
        $openid->SetApprovedURL($request->url_for('openid_continue') . '/');
        $openid->SetTrustRoot($request->base);
        $server_url = $_SESSION['openid_server_url'];
        $openid->SetOpenIDServer($server_url);
        $valid = $openid->ValidateWithServer();
    }
    if ($valid) {
        $_SESSION['openid_complete'] = true;
    } else {
        trigger_error("Sorry, the openid server {$server_url} did not validate your identity.", E_USER_ERROR);
    }
    complete_openid_authentication($request);
    if (!empty($_SESSION['requested_url'])) {
        redirect_to($_SESSION['requested_url']);
    } else {
        redirect_to($request->base);
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:51,代码来源:security.php


示例20: app_installer_json

function app_installer_json(&$vars)
{
    extract($vars);
    if (!class_exists('Services_JSON')) {
        lib_include('json');
    }
    $json = new Services_JSON();
    $apps_list = array();
    if (isset($GLOBALS['PATH']['apps'])) {
        foreach ($GLOBALS['PATH']['apps'] as $k => $v) {
            if ($k != 'omb') {
                $apps_list[$k] = $k;
            }
        }
    }
    // apps_list = physical apps on this host
    $sources = environment('remote_sources');
    $remote_list = array();
    // remote_list = all not-installed apps on remote sources
    foreach ($sources as $name => $url) {
        $url = "http://" . $url . "&p=" . urlencode($request->uri);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $result = false;
        $result = curl_exec($curl);
        if ($result) {
            $data = mb_unserialize($result);
            foreach ($data as $appname => $appdata) {
                $remote_list[$appname] = $appname;
            }
        }
        curl_close($curl);
    }
    $i = $Identity->find(get_app_id());
    while ($s = $i->NextChild('settings')) {
        if ($s->name == 'app' && in_array($s->value, $apps_list)) {
            $apps_list = drop_array_element($apps_list, $s->value);
        }
    }
    $i = $Identity->find(get_app_id());
    while ($s = $i->NextChild('settings')) {
        if ($s->name == 'app' && in_array($s->value, $remote_list)) {
            $remote_list = drop_array_element($remote_list, $s->value);
        }
    }
    $all_apps = array_merge($apps_list, $remote_list);
    header("Content-Type: application/javascript");
    print $json->encode($all_apps);
    exit;
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:52,代码来源:identities.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP environment_get_errors函数代码示例发布时间:2022-05-15
下一篇:
PHP env函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap