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


PHP require_get函数代码示例

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


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

示例1: findJob

 /**
  * If we have a ?job_id parameter, then select only this job
  */
 function findJob(Connection $db, Logger $logger)
 {
     if ($this->isJobsDisabled($logger)) {
         return false;
     }
     // mark all once-failed test jobs as failing
     $q = $db->prepare("SELECT * FROM jobs WHERE is_executing=0 AND is_error=0 AND is_test_job=1 AND execution_count >= ?");
     $q->execute(array(1));
     if ($failed = $q->fetchAll()) {
         $logger->info("Found " . number_format(count($failed)) . " test jobs that have failed once");
         foreach ($failed as $job) {
             $q = $db->prepare("UPDATE jobs SET is_executed=1,is_error=1 WHERE id=?");
             $q->execute(array($job['id']));
             $logger->info("Marked test job " . $job['id'] . " as failed");
         }
     }
     // mark all jobs that have been executing for far too long as failed
     $q = $db->prepare("SELECT * FROM jobs WHERE is_executing=1 AND execution_started <= DATE_SUB(NOW(), INTERVAL 30 MINUTE)");
     $q->execute(array());
     if ($timeout = $q->fetchAll()) {
         $logger->info("Found " . number_format(count($timeout)) . " jobs that have timed out");
         foreach ($timeout as $job) {
             $q = $db->prepare("UPDATE jobs SET is_timeout=1, is_executing=0 WHERE id=?");
             $q->execute(array($job['id']));
             $logger->info("Marked job " . $job['id'] . " as timed out");
         }
     }
     if (require_get("job_id", false)) {
         $q = $db->prepare("SELECT * FROM jobs WHERE id=? LIMIT 1");
         $q->execute(array(require_get("job_id")));
         return $q->fetch();
     } else {
         return parent::findJob($db, $logger);
     }
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:38,代码来源:OpenclerkJobRunner.php

示例2: getConfig

 function getConfig()
 {
     // load graph data, which is also used to construct the hash
     $config = array('days' => require_get("days", false), 'delta' => require_get("delta", false), 'arg0' => require_get('arg0', false), 'arg0_resolved' => require_get('arg0_resolved', false), 'technical_type' => require_get('technical_type', false), 'technical_period' => require_get('technical_period', false), 'user_id' => require_get('user_id', false), 'user_hash' => require_get('user_hash', false));
     if (!$config['days']) {
         $config['days'] = 45;
         // default
     }
     return $config;
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:10,代码来源:Graph.php

示例3: batch_footer

function batch_footer()
{
    if (require_get("key", false)) {
        // we're running from a web browser
        // include page gen times etc
        page_footer();
    } else {
        // we are running from the CLI
        // we still need to calculate performance metrics
        performance_metrics_page_end();
    }
}
开发者ID:phpsource,项目名称:openclerk,代码行数:12,代码来源:_batch.php

示例4: auth

 /**
  * Execute OAuth2 authentication and return the user.
  */
 static function auth(ProviderInterface $provider)
 {
     if (!require_get("code", false)) {
         redirect($provider->getAuthorizationUrl());
         return false;
     } else {
         // optionally check for abuse etc
         if (!\Openclerk\Events::trigger('oauth2_auth', $provider)) {
             throw new UserAuthenticationException("Login was cancelled by the system.");
         }
         $token = $provider->getAccessToken('authorization_code', array('code' => require_get("code")));
         // now find the relevant user
         return $provider->getUserDetails($token);
     }
 }
开发者ID:openclerk,项目名称:users,代码行数:18,代码来源:UserOAuth2.php

示例5: run

 function run($reporter)
 {
     $only = require_get("only", false);
     // we just load all PHP files within this directory
     if ($handle = opendir('.')) {
         echo "<ul style=\"padding: 10px; list-style: none;\">";
         echo "<li style=\"display: inline-block; margin-right: 5px;\"><a href=\"" . url_for('tests/') . "\"><b>All tests</b></a></li>\n";
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != ".." && substr(strtolower($entry), -4) == ".php" && strtolower($entry) != 'index.php') {
                 echo "<li style=\"display: inline-block; margin-right: 5px;\"><a href=\"" . url_for('tests/', array('only' => $entry)) . "\">" . htmlspecialchars($entry) . "</a></li>\n";
             }
         }
         echo "</ul>";
         closedir($handle);
     }
     parent::run($reporter);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:17,代码来源:index.php

示例6: require_login

<?php

/**
 * Purchase premium accounts.
 */
require_login();
require __DIR__ . "/../layout/templates.php";
$messages = array();
$errors = array();
$user = get_user(user_id());
require_user($user);
$currency = require_post("currency", require_get("currency", false));
if (!$currency || !is_valid_currency($currency) || !in_array($currency, get_site_config('premium_currencies'))) {
    $errors[] = t("Unknown currency or no currency specified.");
    set_temporary_errors($errors);
    redirect(url_for('premium'));
}
$messages = array();
$errors = array();
class PurchaseException extends Exception
{
}
if (require_post("months", false) || require_post("years", false)) {
    try {
        $months = require_post("months", false);
        $years = require_post("years", false);
        if (!is_numeric($months) || !is_numeric($years) || !($months > 0 || $years > 0) || $months > 99 || $years > 99) {
            throw new PurchaseException(t("Invalid period selection."));
        }
        $cost = 0;
        if ($months > 0) {
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:purchase.php

示例7: __construct

class OpenclerkJobRunnerType extends \Core\OpenclerkJobRunner
{
    var $job_prefix;
    function __construct($job_prefix)
    {
        parent::__construct();
        $this->job_prefix = $job_prefix;
    }
    /**
     * Find a job that starts with the given prefix
     */
    function findJob(Connection $db, Logger $logger)
    {
        if ($this->isJobsDisabled($logger)) {
            return false;
        }
        $q = $db->prepare("SELECT * FROM jobs WHERE (job_prefix=? OR job_type=?) AND " . $this->defaultFindJobQuery() . " LIMIT 1");
        $q->execute(array($this->job_prefix, $this->job_prefix));
        return $q->fetch();
    }
}
if (isset($argv)) {
    $job_prefix = $argv[2];
} else {
    $job_prefix = require_get("type");
}
$logger = new \Monolog\Logger("batch_run");
$logger->pushHandler(new \Core\MyLogger());
$logger->info("Running job type '{$job_prefix}'");
$runner = new OpenclerkJobRunnerType($job_prefix);
$runner->runOne(db(), $logger);
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:batch_run_type.php

示例8: require_get

<?php

$value1 = require_get("value1", "1");
$currency1 = require_get("currency1", "btc");
$value2 = require_get("value2", "");
$currency2 = require_get("currency2", "usd");
?>

<div class="calculator">
<span class="row">
<input type="text" id="value1" value="<?php 
echo htmlspecialchars($value1);
?>
">
<select id="currency1">
<?php 
foreach (get_all_currencies() as $cur) {
    echo "<option value=\"" . htmlspecialchars($cur) . "\" class=\"currency_name_" . htmlspecialchars($cur) . "\"" . ($cur == $currency1 ? " selected" : "") . ">" . get_currency_abbr($cur) . "</option>\n";
}
?>
</select>
</span>

<span class="row">
<span class="equals">=</span>
</span>

<span class="row">
<input type="text" id="value2" value="<?php 
echo htmlspecialchars($value2);
?>
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:_calculator.php

示例9: require_admin

<?php

/**
 * Admin status page: jobs distribution
 */
require_admin();
require __DIR__ . "/../layout/templates.php";
$messages = array();
$errors = array();
page_header("Admin: Jobs Distribution", "page_admin_jobs_distribution");
$q = db()->prepare("SELECT COUNT(*) AS c, SUM(is_error) AS errors, SUM(execution_count) AS execs, AVG(priority) AS priority, job_type FROM (SELECT * FROM jobs WHERE is_executed=1 ORDER BY id DESC LIMIT " . (int) require_get("n", 4000) . ") AS j GROUP BY job_type ORDER BY c DESC");
$q->execute();
$jobs = $q->fetchAll();
$total_c = 0;
foreach ($jobs as $job) {
    $total_c += $job['c'];
}
// where 0..100% = fine; 110% = good; etc
function get_error_class($n)
{
    if ($n <= 1) {
        // 0%
        return "perfect";
    } else {
        if ($n <= 1.25) {
            return "good";
        } else {
            if ($n <= 1.5) {
                return "ok";
            } else {
                if ($n <= 1.75) {
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:admin_jobs_distribution.php

示例10: require_get

<thead>
  <tr>
    <th>Job ID</th>
    <th>Priority</th>
    <th>Job type</th>
    <th>Manual</th>
    <th>Executing</th>
    <th>Attempts</th>
    <th>Created at</th>
    <th>User</th>
    <th></th>
  </tr>
</thead>
<tbody>
<?php 
$order_by = require_get("oldest", false) ? "created_at ASC, priority ASC, id ASC" : "priority ASC, id ASC";
$q = db()->prepare("SELECT jobs.*, users.email FROM jobs\n    LEFT JOIN users ON jobs.user_id=users.id\n    WHERE is_executed=0 ORDER BY {$order_by} LIMIT 50");
$q->execute();
while ($job = $q->fetch()) {
    ?>
  <tr>
    <td><?php 
    echo number_format($job['id']);
    ?>
</td>
    <td><?php 
    echo number_format($job['priority']);
    ?>
</td>
    <td><?php 
    echo htmlspecialchars($job['job_type']);
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:admin_jobs.php

示例11: require_get

<?php

require __DIR__ . "/../layout/templates.php";
$q = require_get("q");
if (!is_string($q)) {
    set_temporary_errors(array(t("Invalid article key.")));
    redirect(url_for('help'));
}
if (!$q) {
    redirect(url_for('help'));
}
// we define all knowledge base articles ourselves, so that there's no chance
// of a security breach/injection
$knowledge = get_knowledge_base();
global $title;
$title = false;
foreach ($knowledge as $label => $a) {
    if (isset($a[$q])) {
        $title = $a[$q];
    }
}
if (!$title) {
    set_temporary_errors(array(t("No such knowledge base article ':key'.", array(':key' => htmlspecialchars($q)))));
    redirect(url_for('help'));
}
if (is_array($title)) {
    global $kb_inline;
    $kb_inline = $title['inline'];
    $title = $title['title'];
    $q = 'inline';
}
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:kb.php

示例12: require_login

<?php

/**
 * Allows users to add additional OAuth2 locations for their account.
 * Issue #266
 */
require_login();
// POST overrides GET
$oauth2 = require_post("oauth2", require_get("oauth2", false));
$messages = array();
$errors = array();
try {
    if ($oauth2) {
        $user = \Users\User::getInstance(db());
        $args = array("oauth2" => $oauth2);
        $url = absolute_url(url_for('oauth2_add', $args));
        $provider = Users\OAuth2Providers::createProvider($oauth2, $url);
        try {
            \Users\UserOAuth2::addIdentity(db(), $user, $provider);
            $messages[] = t("Added OAuth2 identity ':identity' to your account.", array(':identity' => htmlspecialchars($provider->getKey())));
            // redirect
            $destination = url_for('user#user_openid');
            set_temporary_messages($messages);
            set_temporary_errors($errors);
            redirect($destination);
        } catch (\Users\UserSignupException $e) {
            $errors[] = $e->getMessage();
        }
    }
} catch (Exception $e) {
    if (!$e instanceof EscapedException) {
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:oauth2_add.php

示例13: Exception

<?php

throw new Exception("This functionality is currently unavailable.");
$email = trim(require_post("email", require_get("email", false)));
$hash = require_post("hash", require_get("hash", false));
$password = require_post("password", require_get("password", false));
if ($password && !is_string($password)) {
    throw new Exception(t("Invalid password parameter"));
}
$password2 = require_post("password2", require_get("password2", false));
if ($password2 && !is_string($password2)) {
    throw new Exception(t("Invalid repeated password parameter"));
}
$messages = array();
$errors = array();
if ($email && $password) {
    if (!$hash) {
        $errors[] = t("No hash specified.");
    }
    if ($password && (strlen($password) < 6 || strlen($password) > 255)) {
        $errors[] = t("Please select a password between :min-:max characters long.", array(':min' => 6, ':max' => 255));
    }
    if ($password && $password != $password2) {
        $errors[] = t("Those passwords do not match.");
    }
    // check the request hash
    $q = db()->prepare("SELECT * FROM users WHERE email=? AND ISNULL(password_hash) = 0");
    $q->execute(array($email));
    $user = $q->fetch();
    if (!$user) {
        $errors[] = t("No such user account exists.");
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:password_reset.php

示例14: ht

<?php 
}
?>
</tbody>
</table>
</div>

<div class="finance-form">

<h2><?php 
echo ht("Add Account");
?>
</h2>

<?php 
$account = array('title' => require_get('title', ""), 'description' => require_get('description', ""), 'gst' => require_get('gst', ""));
?>

<form action="<?php 
echo htmlspecialchars(url_for('finance_accounts'));
?>
" method="post">
<table>
<tr>
  <th><?php 
echo ht("Title:");
?>
</th>
  <td><input type="text" name="title" size="32" value="<?php 
echo htmlspecialchars($account['title']);
?>
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:finance_accounts.php

示例15: str_replace

                // possible injection here... strip all protocol information to prevent redirection to external site
                $destination = str_replace('#[a-z]+://#im', '', $destination);
                redirect($destination);
            }
        }
    }
} catch (Exception $e) {
    if (!$e instanceof EscapedException) {
        $e = new EscapedException(htmlspecialchars($e->getMessage()), (int) $e->getCode(), $e);
    }
    $errors[] = $e->getMessage();
}
if (require_get("need_admin", false)) {
    $errors[] = t("You need to be logged in as an administrator to do that.");
}
if ($destination && !require_get("pause", false)) {
    $errors[] = t("You need to be logged in to proceed.");
}
require __DIR__ . "/../layout/templates.php";
page_header(t("Login"), "page_login", array('js' => 'auth'));
?>

<?php 
require_template("login");
?>

<div class="authentication-form">
<h2><?php 
echo ht("Login");
?>
</h2>
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:login.php


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