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


PHP colorize函数代码示例

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


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

示例1: register

 private function register($loop, $me)
 {
     $buffer = '';
     // Launching the linker
     $this->process = new \React\ChildProcess\Process('exec php linker.php', null, array('sid' => $this->sid, 'baseuri' => $this->baseuri));
     $this->process->start($loop);
     // Buffering the incoming data and fire it once its complete
     $this->process->stdout->on('data', function ($output) use($me, &$buffer) {
         if (substr($output, -1) == "") {
             $out = $buffer . substr($output, 0, -1);
             $buffer = '';
             $me->messageOut($out);
         } else {
             $buffer .= $output;
         }
     });
     // The linker died, we close properly the session
     $this->process->on('exit', function ($output) use($me) {
         echo colorize($this->sid, 'yellow') . " : " . colorize("linker killed \n", 'red');
         $me->process = null;
         $me->closeAll();
         $sd = new \Modl\SessionxDAO();
         $sd->delete($this->sid);
     });
     // Debug only, if the linker output some errors
     $this->process->stderr->on('data', function ($output) use($me) {
         echo $output;
     });
 }
开发者ID:Nyco,项目名称:movim,代码行数:29,代码来源:Session.php

示例2: fail

function fail($msg = null)
{
    $fail_msg = colorize(" [✗] \n" . $msg, 'red', true);
    if ($msg) {
        $fail_msg .= "\n";
    }
    return $fail_msg;
}
开发者ID:sushilmohanty,项目名称:student-workbook,代码行数:8,代码来源:training_util.php

示例3: getClient

/**
 * Returns an authorized API client.
 * @return Google_Client the authorized client object
 */
function getClient()
{
    global $credentialsPath;
    $client = new Google_Client();
    $client->setApplicationName(APPLICATION_NAME);
    $client->setScopes(GAPI_SCOPES);
    $client->setAuthConfigFile(CLIENT_SECRET_PATH);
    $client->setAccessType('offline');


    if (file_exists($credentialsPath)) {
        $accessToken = file_get_contents($credentialsPath);
    } else {
        $authUrl = $client->createAuthUrl();
        $authCode = false;
        if (isset($_POST['authCode']) && $_POST['authCode']) {
            $authCode = $_POST['authCode'];
        }

        if (!$authCode) {
            printf("Open the following link in your browser:\n<a href='%s' target='_blank'>link</a>\n", $authUrl);
            echo "<form method='post'><input name='authCode'><input type='submit' name='Check auth code'></form>";
            die;
        }

        if ($authCode) {
            // Exchange authorization code for an access token.
            $accessToken = $client->authenticate($authCode);
            if (file_put_contents($credentialsPath, $accessToken)) {
                printf("Credentials saved to %s: " . colorize("SUCCESS", "SUCCESS") . "<br>", $credentialsPath);
            } else {
                printf("Credentials saved to %s: " . colorize("FAILED", "FAILURE") . "<br>", $credentialsPath);
                die;
            }
        } else {
            die("No authCode");
        }
    }

    $client->setAccessToken($accessToken);

    // Refresh the token if it's expired.
    if ($client->isAccessTokenExpired()) {
        echo "Token is Expired. Trying to refresh.. <br>";
        $client = refreshToken($client);
    } else {
        echo "Everything fine<br>";
    }

    return $client;
}
开发者ID:ValentinNikolaev,项目名称:Asana-GDoc-reports,代码行数:55,代码来源:connect.php

示例4: output_error_cache

function output_error_cache()
{
    global $error_cache, $error_abort;
    if (count($error_cache)) {
        echo colorize(TYPE_ERROR, "Failed");
        if (PHP_SAPI == 'cli') {
            echo "\n\n";
        } else {
            echo "<br /><ol>\n";
        }
        foreach ($error_cache as $error_msg) {
            if (PHP_SAPI == 'cli') {
                echo "\n";
            } else {
                echo "<li>";
            }
            switch ($error_msg['t']) {
                case TYPE_NOTICE:
                    $msg = 'NOTICE';
                    break;
                case TYPE_WARNING:
                    $msg = 'WARNING';
                    break;
                case TYPE_ERROR:
                    $msg = 'ERROR';
                    break;
            }
            echo colorize($error_msg['t'], $msg);
            if (PHP_SAPI == 'cli') {
                echo "\t" . $error_msg['m'];
            } else {
                echo " " . $error_msg['m'] . "</li>";
            }
        }
        if (PHP_SAPI == 'cli') {
            echo "\n";
        } else {
            echo "</ol>\n";
        }
    } else {
        echo colorize(TYPE_OK, "OK");
        if (PHP_SAPI == 'cli') {
            echo "\n";
        } else {
            echo "\n<br />";
        }
    }
    echo "\n";
    $error_cache = array();
}
开发者ID:emildev35,项目名称:processmaker,代码行数:50,代码来源:langcheck.php

示例5: show_menu

function show_menu()
{
    echo colorize("\nWhat would you like to do:\n", 'blue', true);
    echo colorize("1> Create A User And A Tweet\n", 'blue', false);
    echo colorize("2> Read A User Record\n", 'blue', false);
    echo colorize("3> Batch Read Tweets For A User\n", 'blue', false);
    echo colorize("4> Scan All Tweets For All Users\n", 'blue', false);
    echo colorize("5> Check and Set -- Update User Password\n", 'blue', false);
    echo colorize("6> Query Tweets By Username And Users By Tweet Count Range\n", 'blue', false);
    echo colorize("7> Stream UDF -- Aggregation Based on Tweet Count By Region\n", 'blue', false);
    echo colorize("0> Exit\n", 'blue', false);
    echo colorize("\nSelect 0-7 and hit enter: ", 'blue', false);
    return intval(trim(readline()));
}
开发者ID:sushilmohanty,项目名称:student-workbook,代码行数:14,代码来源:program.php

示例6: checkBOM

function checkBOM($filename)
{
    global $auto;
    $contents = file_get_contents($filename);
    $charset[1] = substr($contents, 0, 1);
    $charset[2] = substr($contents, 1, 1);
    $charset[3] = substr($contents, 2, 1);
    if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {
        if ($auto == 1) {
            $rest = substr($contents, 3);
            rewrite($filename, $rest);
            return colorize("BOM found, automatically removed.", "NOTE");
        } else {
            return colorize("BOM found", "WARNING");
        }
    } else {
        return colorize("BOM Not Found.", "WARNING");
    }
}
开发者ID:eyblog,项目名称:library,代码行数:19,代码来源:removebom.php

示例7: setWebsocket

 public function setWebsocket($baseuri, $port)
 {
     $explode = parse_url($baseuri);
     echo "\n" . "--- " . colorize("Server Configuration - Apache", 'purple') . " ---" . "\n";
     echo colorize("Enable the Secure WebSocket to WebSocket tunneling", 'yellow') . "\n# a2enmod proxy_wstunnel \n";
     echo colorize("Add this in your configuration file (default-ssl.conf)", 'yellow') . "\nProxyPass /ws/ ws://localhost:{$port}/\n";
     echo "\n" . "--- " . colorize("Server Configuration - nginx", 'purple') . " ---" . "\n";
     echo colorize("Add this in your configuration file", 'yellow') . "\n";
     echo "location /ws/ {\n    proxy_pass http://localhost:{$port}/;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade \$http_upgrade;\n    proxy_set_header Connection \"Upgrade\";\n    proxy_set_header Host \$host;\n    proxy_set_header X-Real-IP \$remote_addr;\n    proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto https;\n    proxy_redirect off;\n}\n\n";
     $path = $explode['host'] . $explode['path'];
     if ($explode['scheme'] == 'https') {
         $ws = 'wss://' . $path . 'ws/';
         $secured = 'true';
         echo colorize("Encrypted ", 'green') . "\n";
     } else {
         $ws = 'ws://' . $path . 'ws/';
         $secured = 'false';
         echo colorize("Unencrypted ", 'red') . "\n";
     }
     file_put_contents(CACHE_PATH . 'websocket', $secured);
     return $ws;
 }
开发者ID:Anon215,项目名称:movim,代码行数:22,代码来源:Core.php

示例8: updateUser

 /**
  * Updates the user with the tweet count and latest tweet info
  * @param string $username
  * @param int $ts
  * @param int $tweet_count
  * @return boolean whether the update succeeded
  * @throws \Aerospike\Training\Exception
  */
 private function updateUser($username, $ts, $tweet_count)
 {
     $key = $this->getUserKey($username);
     $bins = array('tweetcount' => $tweet_count, 'lasttweeted' => $ts);
     echo colorize("Updating the user record ≻", 'black', true);
     if ($this->annotate) {
         display_code(__FILE__, __LINE__, 6);
     }
     $status = $this->client->put($key, $bins);
     if ($status !== Aerospike::OK) {
         echo fail();
         // throwing an \Aerospike\Training\Exception
         throw new Exception($this->client, "Failed to get the user {$username}");
     }
     echo success();
     return true;
 }
开发者ID:sushilmohanty,项目名称:student-workbook,代码行数:25,代码来源:TweetService.php

示例9: display_code

if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
if (isset($args['a']) || isset($args['clean'])) {
    $start = __LINE__;
    echo colorize("Removing the records ≻", 'black', true);
    for ($i = 4; $i < 10; $i++) {
        $key = $db->initKey("test", "characters", $i);
        $db->remove($key);
    }
    if ($status == Aerospike::OK) {
        echo success();
    } else {
        echo standard_fail($db);
    }
    if (isset($args['a']) || isset($args['annotate'])) {
        display_code(__FILE__, $start, __LINE__);
    }
    $start = __LINE__;
    echo colorize("Dropping the index ≻", 'black', true);
    $status = $db->dropIndex("test", "age_index");
    if ($status == Aerospike::OK) {
        echo success();
    } else {
        echo standard_fail($db);
    }
    if (isset($args['a']) || isset($args['annotate'])) {
        display_code(__FILE__, $start, __LINE__);
    }
}
$db->close();
开发者ID:serphen,项目名称:aerospike-client-hhvm,代码行数:31,代码来源:simple.php

示例10: elseif

            // roll back the test value
            $kv['v']--;
        }
    } else {
        $res = $db->get($key, $r);
        $reads++;
        if ($res != Aerospike::OK) {
            $read_fails++;
        } elseif ($r['bins']['v'] != $kv['v']) {
            $read_fails++;
        }
    }
}
$end = microtime(true);
if ($read_fails == 0 && $write_fails == 0) {
    echo success();
} else {
    echo standard_fail($db);
}
echo colorize("{$num_ops} serial operations, {$reads} reads, {$writes} writes (every {$write_every} records)\n", 'green', true);
$color = $read_fails > 0 ? 'red' : 'green';
echo colorize("Failed reads: {$read_fails}\n", $color, true);
$color = $write_fails > 0 ? 'red' : 'green';
echo colorize("Failed writes: {$write_fails}\n", $color, true);
$delta = $end - $begin;
$tps = $num_ops / $delta;
echo colorize("Total time: {$delta}s TPS:{$tps}\n", 'purple', true);
$db->close();
?>

开发者ID:serphen,项目名称:aerospike-client-hhvm,代码行数:29,代码来源:read-write-mix.php

示例11: trim

$un = trim(fgets(STDIN));
if (empty($un)) {
    $un = 'username';
}
$config['username_property'] = $un;
unset($un);
// A property of the above model to use for passwords.
echo colorize('Model property for hashed password', 'cyan', true) . ' [password]: ';
$pw = trim(fgets(STDIN));
if (empty($pw)) {
    $pw = 'password';
}
$config['password_property'] = $pw;
unset($pw);
// Get a unique password salt. Generate a random one if the user doesn't specify one.
echo colorize('Unique password salt', 'cyan', true) . ' [' . colorize('Randomly Generated', 'green') . ']: ';
$salt = trim(fgets(STDIN));
if (empty($salt)) {
    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
    $salt = '';
    for ($i = 0; $i < 72; $i++) {
        $salt .= substr($chars, rand(0, strlen($chars) - 1), 1);
    }
}
$config['auth_salt'] = $salt;
unset($salt, $chars, $i);
echo "Installing configuration profile...\n";
// Write the new configuration to the config file
$installationValues = <<<EOF
<?php
开发者ID:johnpbloch,项目名称:verily,代码行数:30,代码来源:install.php

示例12: convertForOutput

/**
 * @param string $value
 * @return string
 */
function convertForOutput($value, $color = COLOR_PURPLE)
{
    if ($GLOBALS['ricegrain-validator-colorize'] == true) {
        return colorize(var_export($value, true), $color);
    } else {
        return var_export($value, true);
    }
}
开发者ID:ricegrain,项目名称:ricegrain-validator,代码行数:12,代码来源:validation-config-viewer.php

示例13: create_schema

 /**
  * Create database schema
  */
 public function create_schema()
 {
     if (!$this->tables) {
         die('No tables given');
     }
     // Create each table
     foreach ($this->tables as $table => $schema) {
         // Report status to user
         print 'Dropping table ' . colorize($table, 'yellow') . "\n";
         // Remove table
         $this->db->query("DROP TABLE IF EXISTS \"{$table}\"");
         $sql = "CREATE TABLE \"{$table}\" (\n";
         $index = array();
         $unique = array();
         // Defaults for columns
         $defaults = array('type' => 'string', 'length' => NULL, 'index' => FALSE, 'null' => TRUE, 'default' => '', 'unique' => FALSE, 'precision' => 0, 'scale' => 0);
         foreach ($schema as $column => $data) {
             $data = $data + $defaults;
             $type = $data['type'];
             // Integer?
             if ($type == 'primary' or $type == 'integer') {
                 // Default to int
                 $length = $data['length'] ? $data['length'] : 2147483647;
                 if ($length <= 32767) {
                     $type = 'smallint';
                 } elseif ($length <= 2147483647) {
                     $type = 'integer';
                 } else {
                     $type = 'bigint';
                 }
                 // Is this the primary column?
                 if ($data['type'] == 'primary') {
                     $primary = $column;
                     // Primary keys are special
                     $sql .= "\t\"{$column}\" serial primary key,\n";
                     continue;
                 }
             } elseif ($type == 'string') {
                 // Even if "text" isn't a valid type in SQL
                 // PostgreSQL treats it the same as "character varying" (i.e. "varchar")
                 $type = 'text';
             } elseif ($type == 'boolean') {
                 $type = 'boolean';
             } elseif ($type == 'decimal') {
                 $type = 'decimal(' . $data['precision'] . ',' . $data['scale'] . ')';
             } else {
                 $type = 'timestamp without time zone';
             }
             // Build Column Definition
             $sql .= "\t\"{$column}\" {$type}";
             // NULL and FALSE are both valid defaults
             if ($data['default'] !== '') {
                 if (is_bool($data['default']) or $data['default'] === NULL) {
                     $sql .= ' DEFAULT ' . $data['default'];
                 } else {
                     $sql .= ' DEFAULT \'' . $data['default'] . "'";
                 }
             }
             // Add NULL
             if (!$data['null']) {
                 $sql .= ' NOT NULL';
             }
             $sql .= ",\n";
             // Is the column unique?
             if ($data['unique']) {
                 $unique[] = $column;
             }
             // Index the column?
             if ($data['index']) {
                 $index[] = $column;
             }
         }
         foreach ($unique as $column) {
             $key = $table . '_' . $column . '_u';
             //.chr(mt_rand(65,90));
             $sql .= "CONSTRAINT {$key} UNIQUE ({$column}),\n";
             // Creating a unique constraint automattically creates an index
             foreach ($index as $id => $field) {
                 if ($field === $column) {
                     unset($index[$id]);
                 }
             }
         }
         // Remove ending comma and close table
         $sql = substr($sql, 0, -2) . "\n);";
         // Create table
         print $sql . "\n";
         $this->db->query($sql);
         // Create any indexes
         foreach ($index as $column) {
             $key = $table . '_' . $column . '_i';
             //.chr(mt_rand(65,90));
             $sql = "CREATE INDEX {$key} ON \"{$table}\" USING btree ({$column})";
             print $sql . "\n";
             $this->db->query($sql);
         }
         // Report status to user
//.........这里部分代码省略.........
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:101,代码来源:PGSQL.php

示例14: liveExecuteCommand

function liveExecuteCommand($cmd)
{
    echo "<pre>";
    while (@ob_end_flush()) {
    }
    // end all output buffers if any
    //	$process = popen("$cmd 2>&1 ; echo Exit status : $?", 'r');
    $process = popen("{$cmd} 2>&1", 'r');
    $complete_output = "";
    while (!feof($process)) {
        $live_output = fread($process, 100);
        $complete_output = $complete_output . $live_output;
        $live_output = colorize(str_replace(chr(10), '<br />', $live_output));
        echo "{$live_output}";
        @ob_flush();
        @flush();
    }
    pclose($process);
    // get exit status
    preg_match('/[0-9]+$/', $complete_output, $matches);
    echo "</pre>";
    // return exit status and intended output
    if (isset($matches[0])) {
        return array('exit_status' => $matches[0], 'output' => str_replace("Exit status : " . $matches[0], '', $complete_output));
    }
}
开发者ID:pniederlag,项目名称:TYPO3.Packer,代码行数:26,代码来源:review.php

示例15: comploc

function comploc()
{
    echo colorize("Locales compiler\n", 'green');
    $folder = CACHE_PATH . '/locales/';
    if (!file_exists($folder)) {
        $bool = mkdir($folder);
        if (!$bool) {
            echo colorize("The locales cache folder can't be created", 'red');
            exit;
        }
    } else {
        echo colorize("Folder already exist, don't re-create it\n", 'red');
    }
    $langs = loadLangArray();
    foreach ($langs as $key => $value) {
        $langarr = parseLangFile(DOCUMENT_ROOT . '/locales/' . $key . '.po');
        $out = '<?php global $translations;
        $translations = array(';
        foreach ($langarr as $msgid => $msgstr) {
            if ($msgid != '') {
                $out .= '"' . $msgid . '" => "' . $msgstr . '",' . "\n";
            }
        }
        $out .= ');';
        $fp = fopen($folder . $key . '.php', 'w');
        fwrite($fp, $out);
        fclose($fp);
        echo "- {$key} compiled\n";
    }
}
开发者ID:christine-ho-dev,项目名称:movim,代码行数:30,代码来源:mud.php


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