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


PHP environment函数代码示例

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


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


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