本文整理汇总了PHP中run函数的典型用法代码示例。如果您正苦于以下问题:PHP run函数的具体用法?PHP run怎么用?PHP run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run(&$vector, $esquerda, $direita, &$quick_trocas = 0)
{
$esq = $esquerda;
$dir = $direita;
$pivot = $vector[intval(($esq + $dir) / 2)];
$troca = 0;
while ($esq <= $dir) {
while ($vector[$esq] < $pivot) {
$esq++;
}
while ($vector[$dir] > $pivot) {
$dir--;
}
if ($esq <= $dir) {
$troca = $vector[$esq];
$vector[$esq] = $vector[$dir];
$vector[$dir] = $troca;
$esq++;
$dir--;
++$quick_trocas;
}
}
if ($dir > $esquerda) {
run($vector, $esquerda, $dir, $quick_trocas);
}
if ($esq < $direita) {
run($vector, $esq, $direita, $quick_trocas);
}
return $quick_trocas;
}
示例2: testRun
public function testRun()
{
$result = run(2, function ($q, $r) {
return disjPlus(eq($q, 2), eq($q, 3), eq($q, 4));
});
$this->assertEquals('(2 . (3))', sprintf('%s', $result));
}
示例3: run
function run($action = null, $command = null, $data = null)
{
if (is_null($action) && is_null($command) && is_null($data)) {
if (run('input', 'get', 'action') == 'api') {
return run('api', 'handle');
} else {
return run('web', 'serve');
}
}
$function = "\\" . $action . "\\" . $command;
if (!function_exists($function)) {
if (is_file('../app/' . $action . '.php')) {
require '../app/' . $action . '.php';
} else {
\app\log('Undefined action ' . $action);
die('Undefined action ' . $action);
}
}
if (function_exists($function)) {
if (!is_array($data)) {
$data = array($data);
}
return call_user_func_array($function, $data);
} else {
\app\log('Undefined command ' . $function);
die('Undefined command ' . $function);
}
}
示例4: threadall
function threadall($lang)
{
global $system_languages, $with_toolbar;
if (!user_has_role('writer')) {
return run('error/unauthorized', $lang);
}
$slang = false;
if (isset($_GET['slang'])) {
$slang = $_GET['slang'];
} else {
$slang = $lang;
}
if (!in_array($slang, $system_languages)) {
return run('error/notfound', $lang);
}
$site_title = translate('title', $lang);
$site_abstract = translate('description', $lang);
$site_cloud = translate('keywords', $lang);
head('title', translate('threadall:title', $slang));
head('description', false);
head('keywords', false);
head('robots', 'noindex, nofollow');
$edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '?' . 'clang=' . $lang : false;
$banner = build('banner', $lang, $with_toolbar ? false : compact('edit'));
$scroll = true;
$toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false;
$threadlist = build('threadlist', $lang, false, false, $slang);
$content = view('threadall', $slang, compact('site_title', 'site_abstract', 'site_cloud', 'threadlist'));
$output = layout('viewing', compact('toolbar', 'banner', 'content'));
return $output;
}
示例5: avatar
function avatar($lang, $arglist = false)
{
$name = false;
$size = 128;
if (is_array($arglist)) {
if (isset($arglist[0])) {
$name = $arglist[0];
} else {
if (isset($arglist['name'])) {
$name = $arglist['name'];
}
}
if (isset($arglist[1])) {
$size = $arglist[1];
} else {
if (isset($arglist['size'])) {
$size = $arglist['size'];
}
}
}
if (!$name or !$size or !is_numeric($size) or $size < 16 or $size > 200) {
return run('error/badrequest', $lang);
}
$img = identicon($name, $size);
header('Content-Type: image/png');
header("Content-Disposition: inline; filename={$name}");
imagepng($img);
imagedestroy($img);
return false;
}
示例6: ownedusers_pagesetup
function ownedusers_pagesetup()
{
// register links --
global $profile_id;
global $PAGE;
global $CFG;
global $USER;
$page_owner = $profile_id;
if ($CFG->owned_users) {
if (defined("context") && context == "network") {
if (run("users:type:get", $page_owner) == "person") {
$PAGE->menu_sub[] = array('name' => 'ownedusers:requests', 'html' => '<a href="' . $CFG->wwwroot . '_ownedusers/owned.php?owner=' . $page_owner . '">' . gettext("Owned " . $CFG->owned_users_caption) . '</a>');
}
}
if (defined("context") && context == "weblog") {
if (run("users:type:get", $page_owner) == "person") {
if ($result = get_records_select('users', "owner = ? AND user_type = ?", array($page_owner, 'person'))) {
$PAGE->menu_sub[] = array('name' => 'ownedusers:requests', 'html' => '<a href="' . $CFG->wwwroot . $USER->username . '/weblog/ownedusers/' . '">' . gettext($CFG->owned_users_caption . "' blogs") . '</a>');
}
}
}
if (defined("context") && context == "profile" && logged_on && !run("users:flags:get", array("admin", $USER->ident))) {
if ($result = get_records_select('users', "ident = ? and owner = ? AND user_type = ?", array($page_owner, $USER->ident, 'person'))) {
$PAGE->menu_sub[] = array('name' => 'profile:edit', 'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $page_owner . '">' . gettext("Edit this profile") . '</a>');
if (run("permissions:check", "profile")) {
$PAGE->menu_sub[] = array('name' => 'owneduser:pic', 'html' => a_hrefg("{$CFG->wwwroot}_icons/?context=profile&profile_id={$page_owner}", gettext("Change site picture")));
$PAGE->menu_sub[] = array('name' => 'profile:help', 'html' => '<a href="' . $CFG->wwwroot . 'help/profile_help.php">' . gettext("Page help") . '</a>');
}
}
}
}
}
示例7: check
function check()
{
$EnablePhileSight = GET_INFO_DAEMON("EnablePhileSight");
if ($EnablePhileSight == null) {
$EnablePhileSight = 0;
}
if ($EnablePhileSight == 0) {
writelogs("feature disabled, aborting...", __FUNCTION__, __FILE__, __LINE__);
die;
}
if (system_is_overloaded()) {
writelogs("System overloaded, aborting this feature for the moment", __FUNCTION__, __FILE__, __LINE__);
die;
}
@mkdir("/opt/artica/philesight");
$unix = new unix();
$min = $unix->file_time_min("/opt/artica/philesight/database.db");
$sock = new sockets();
$rr = $sock->GET_INFO("PhileSizeRefreshEach");
if ($rr == null) {
$rr = 120;
}
if ($rr == "disable") {
die;
}
writelogs("/opt/artica/philesight/database.db = {$min} minutes, {$rr} minutes to run", __FUNCTION__, __FILE__, __LINE__);
if ($min >= $rr) {
run();
}
}
示例8: blog_pagesetup
function blog_pagesetup()
{
// register links --
global $profile_id;
global $PAGE;
global $CFG;
$page_owner = $profile_id;
// main menu
if (isloggedin()) {
if (defined("context") && context == "weblog" && $page_owner == $_SESSION['userid']) {
$PAGE->menu[] = array('name' => 'blog', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/weblog\" class=\"selected\" >" . gettext("Your Blog") . '</a></li>');
} else {
$PAGE->menu[] = array('name' => 'blog', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/weblog\" >" . gettext("Your Blog") . '</a></li>');
}
}
$weblog_username = run("users:id_to_name", $page_owner);
// submenu
if (defined("context") && context == "weblog") {
if ($page_owner != -1) {
$PAGE->menu_sub[] = array('name' => 'blog:rssfeed', 'html' => "<a href=\"{$CFG->wwwroot}{$weblog_username}/weblog/rss/\"><img src=\"{$CFG->wwwroot}_templates/icons/rss.png\" border=\"0\" alt=\"rss\" /></a>");
if (run("permissions:check", "weblog") && logged_on) {
$PAGE->menu_sub[] = array('name' => 'blog:post', 'html' => "<a href=\"{$CFG->wwwroot}_weblog/edit.php?owner={$page_owner}\">" . gettext("Post a new entry") . '</a>');
}
$PAGE->menu_sub[] = array('name' => 'blog:view', 'html' => "<a href=\"{$CFG->wwwroot}{$weblog_username}/weblog/\">" . gettext("View blog") . '</a>');
$PAGE->menu_sub[] = array('name' => 'blog:archive', 'html' => "<a href=\"{$CFG->wwwroot}{$weblog_username}/weblog/archive/\">" . gettext("Archive") . '</a>');
$PAGE->menu_sub[] = array('name' => 'blog:friends', 'html' => "<a href=\"{$CFG->wwwroot}{$weblog_username}/weblog/friends/\">" . gettext("Friends' blogs") . '</a>');
}
$PAGE->menu_sub[] = array('name' => 'blog:everyone', 'html' => "<a href=\"{$CFG->wwwroot}_weblog/everyone.php\">" . gettext("View all posts") . '</a>');
if (logged_on) {
$PAGE->menu_sub[] = array('name' => 'blog:help', 'html' => "<a href=\"{$CFG->wwwroot}help/blogs_help.php\">" . gettext("Page help") . '</a>');
}
}
}
示例9: user
function user($lang, $arglist = false)
{
global $login_verified, $base_url;
$login = build('login', $lang);
if ($login === true) {
$r = !empty($arglist['r']) ? $arglist['r'] : false;
if ($login_verified and array_intersect($login_verified, user_profile('role'))) {
$user = $_SESSION['user'];
unset($_SESSION['user']);
if (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') {
return run('error/unauthorized', $lang);
}
$_SESSION['unverified_user'] = $user;
$next_page = url('sslverifyclient');
if ($r) {
$next_page .= '?r=' . $r;
}
} else {
$next_page = $r ? $r : url('home', $lang);
}
return reload($base_url . $next_page);
}
$banner = build('banner', $lang);
$content = view('user', $lang, compact('login'));
head('title', translate('user:title', $lang));
head('description', false);
head('keywords', false);
head('robots', 'noindex, nofollow');
$output = layout('standard', compact('banner', 'content'));
return $output;
}
示例10: start_realplexor
function start_realplexor()
{
global $REALPLEXOR_CONF, $OUT_TMP, $OUT_TMP_FH;
kill_realplexor();
$OUT_TMP = tempnam('non-existent', '');
if (pcntl_fork() == 0) {
$filter = '
$| = 1;
s/\\s*\\[\\w\\w\\w\\s.*?\\]\\s*//sg;
s/\\s*Opened files limit.*//mg;
s/\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+:\\s*//sg;
s/\\d+( bytes)/<N>$1/s;
s/(appending configuration from ).*/$1***/mg;
s/(\\[)\\d+\\.\\d+/$1*/sg;
s/(events=)\\d+/$1*/sg;
s/^/# /sg;
if ($del) {
$_ = "";
$del--;
}
';
$args = '';
if ($REALPLEXOR_CONF) {
$args = escapeshellarg(dirname(__FILE__) . '/fixture/' . $REALPLEXOR_CONF);
}
run("cd ../.. && perl dklab_realplexor.pl {$args} | tee -a {$OUT_TMP} " . "| perl -pe " . escapeshellarg($filter) . ($GLOBALS['VERBOSE'] ? "" : " | tail -n1"));
exit;
}
expect('/listening 127.0.0.1/');
}
示例11: adminuser
function adminuser($lang, $arglist = false)
{
if (!user_has_role('administrator')) {
return run('error/unauthorized', $lang);
}
$user_id = false;
if (is_array($arglist)) {
if (isset($arglist[0])) {
$user_id = $arglist[0];
}
}
if (!$user_id) {
return run('error/notfound', $lang);
}
$user_id = user_id($user_id);
if (!$user_id) {
return run('error/notfound', $lang);
}
$useredit = build('useredit', $lang, $user_id);
if ($useredit === false) {
return redirect('admin', $lang);
}
head('title', translate('admin:title', $lang));
head('description', false);
head('keywords', false);
head('robots', 'noindex, nofollow');
$admin = true;
$banner = build('banner', $lang, compact('admin'));
$content = view('adminuser', $lang, compact('useredit'));
$output = layout('standard', compact('banner', 'content'));
return $output;
}
示例12: community_pagesetup
function community_pagesetup()
{
// register links --
global $profile_id;
global $PAGE;
global $CFG;
$page_owner = $profile_id;
$usertype = run("users:type:get", $page_owner);
if ($usertype == "community") {
if (defined("context") && context == "profile") {
if (run("permissions:check", "profile")) {
$PAGE->menu_sub[] = array('name' => 'profile:edit', 'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $page_owner . '">' . gettext("Edit this profile") . '</a>');
$PAGE->menu_sub[] = array('name' => 'community:pic', 'html' => a_hrefg("{$CFG->wwwroot}_icons/?context=profile&profile_id={$page_owner}", gettext("Community site picture")));
$PAGE->menu_sub[] = array('name' => 'community:edit', 'html' => a_hrefg("{$CFG->wwwroot}_userdetails/?context=profile&profile_id={$page_owner}", gettext("Edit community details")));
}
}
if (defined("context") && (context == "profile" || context == "network")) {
$PAGE->menu_sub[] = array('name' => 'community:requests', 'html' => a_hrefg("{$CFG->wwwroot}_communities/requests.php?profile_id={$page_owner}", gettext("View membership requests")));
}
/*$PAGE->menu_sub[] = array( 'name' => 'community:members',
'html' => a_hrefg("{$CFG->wwwroot}_communities/members.php?owner=$page_owner" ,
gettext("Community Members")));*/
} else {
if ($usertype == "person") {
if (defined("context") && context == "network") {
$PAGE->menu_sub[] = array('name' => 'community', 'html' => a_hrefg("{$CFG->wwwroot}_communities/?owner={$page_owner}", gettext("Communities")));
$PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_hrefg("{$CFG->wwwroot}_communities/owned.php?owner={$page_owner}", gettext("Owned Communities")));
}
}
}
}
示例13: friend_pagesetup
function friend_pagesetup()
{
// register links --
global $profile_id;
global $PAGE;
global $CFG;
$page_owner = $profile_id;
if (isloggedin()) {
if (defined("context") && context == "network" && $page_owner == $_SESSION['userid']) {
$PAGE->menu[] = array('name' => 'network', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/friends/\" class=\"selected\" >" . gettext("Your Network") . '</a></li>');
} else {
$PAGE->menu[] = array('name' => 'network', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/friends/\" >" . gettext("Your Network") . '</a></li>');
}
}
if (defined("context") && context == "network") {
if (run("users:type:get", $page_owner) == "person") {
$friends_username = run("users:id_to_name", $page_owner);
$PAGE->menu_sub[] = array('name' => 'friend', 'html' => a_hrefg("{$CFG->wwwroot}{$friends_username}/friends/", gettext("Friends")));
$PAGE->menu_sub[] = array('name' => 'friend:of', 'html' => a_hrefg("{$CFG->wwwroot}_friends/friendsof.php?owner={$page_owner}", gettext("Friend of")));
$PAGE->menu_sub[] = array('name' => 'friend:requests', 'html' => a_hrefg("{$CFG->wwwroot}_friends/requests.php?owner={$page_owner}", gettext("Friendship requests")));
if ($CFG->foaf_enabled) {
$PAGE->menu_sub[] = array('name' => 'friend:foaf', 'html' => a_hrefg("{$CFG->wwwroot}{$friends_username}/foaf/", gettext("FOAF")));
}
if (isloggedin()) {
$PAGE->menu_sub[] = array('name' => 'friend:accesscontrols', 'html' => a_hrefg("{$CFG->wwwroot}_groups/", gettext("Access controls")));
if ($CFG->publicinvite == true) {
$PAGE->menu_sub[] = array('name' => 'friend:invite', 'html' => a_hrefg("{$CFG->wwwroot}_invite/", gettext("Invite a friend")));
}
$PAGE->menu_sub[] = array('name' => 'friend:help', 'html' => a_hrefg("{$CFG->wwwroot}help/network_help.php", gettext("Page help")));
}
}
}
}
示例14: captcha
function captcha($lang, $arglist = false)
{
$id = false;
if (is_array($arglist)) {
if (isset($arglist[0])) {
$id = $arglist[0];
}
}
$accepted = array('login', 'register', 'remindme', 'mailme', 'subscribe', 'unsubscribe', 'comment');
if ($id and !in_array($id, $accepted)) {
return run('error/badrequest', $lang);
}
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code = strrand($charset, 4);
if ($id) {
$_SESSION['captcha'][$id] = $code;
}
$img = strtag($code);
header('Content-Type: image/png');
header("Content-Disposition: inline; filename=captcha.png");
header("Cache-Control: no-cache");
imagepng($img);
imagedestroy($img);
return false;
}
示例15: editpage
function editpage($lang, $arglist = false)
{
global $default_folder;
$folder = $page = false;
if (is_array($arglist)) {
if (isset($arglist[1])) {
$folder = $arglist[0];
$page = $arglist[1];
} else {
if (isset($arglist[0])) {
$folder = $default_folder;
$page = $arglist[0];
}
}
}
if (!$folder or !$page) {
return run('error/notfound', $lang);
}
foreach (is_array($folder) ? $folder : array($folder) as $folder) {
$folder_id = thread_id($folder);
if ($folder_id) {
$page_id = thread_node_id($folder_id, $page, $lang);
if ($page_id) {
break;
}
}
}
if (!$folder_id or !$page_id) {
return run('error/notfound', $lang);
}
require_once 'actions/folderedit.php';
return folderedit($lang, array($folder_id, $page_id));
}