本文整理汇总了PHP中Functions::generate_random方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::generate_random方法的具体用法?PHP Functions::generate_random怎么用?PHP Functions::generate_random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::generate_random方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_id
public static function generate_id($prefix = "")
{
if (empty($prefix)) {
return Functions::generate_random(9) . uniqid() . Functions::generate_random(3);
} else {
////
// If prefix is less than 3 characters, pad with '_' so it is exactly 3 characters
////
if (strlen($prefix) < 3) {
$prefix = str_pad($prefix, 3, '__', STR_PAD_RIGHT);
}
////
// Prefix has a maximum length of 3 characters
////
$prefix = substr($prefix, 0, 3);
return $prefix . "_" . Functions::generate_random(5) . uniqid() . Functions::generate_random(3);
}
}
示例2: isset
<div class="span12">
<div class="well">
<?php
if (isset($_GET['param1']) && $_GET['param1'] == "saved") {
?>
<div class="alert alert-success" id="settings-saved-alert">
<strong>Settings saved successfully.</strong>
</div>
<?php
}
?>
<form id="form-settings" class="well form-horizontal" method="post" action="/actions/edit_settings.php">
<input type="hidden" name="instance_key" id="instance_key" value="<?php
echo isset($settings->data->instance_key) && !empty($settings->data->instance_key) ? $settings->data->instance_key : Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
?>
" />
<?php
if (isset($settings->modified)) {
?>
<div style="float: right;">
<a class="btn disabled">Modified <?php
echo $settings->modified;
?>
</a>
</div>
<div class="clear"></div>
<?php
}
?>
示例3: file_get_contents
# limitations under the License.
*/
////
// Require Functions class
////
require_once __DIR__ . "/classes/Functions.php";
////
// /app.config.php
////
if (!file_exists(__DIR__ . "/app.config.php")) {
if (copy(__DIR__ . "/app.config.default.php", __DIR__ . "/app.config.php")) {
print "-> Created file '/app.config.php'.\n";
}
$app_config = file_get_contents(__DIR__ . "/app.config.php");
if ($app_config !== false) {
if (file_put_contents(__DIR__ . "/app.config.php", str_replace("{{CRYPTO_SEED}}", Functions::generate_random(14) . uniqid() . Functions::generate_random(13), $app_config)) !== false) {
print "-> Wrote randomly generated CRYPTO_SEED to '/app.config.php'.\n";
}
}
}
/////
// /classes/MySQLConfiguration.php
////
if (!file_exists(__DIR__ . "/classes/MySQLConfiguration.php")) {
if (copy(__DIR__ . "/classes/MySQLConfiguration.default.php", __DIR__ . "/classes/MySQLConfiguration.php")) {
print "-> Created file '/classes/MySQLConfiguration.php'.\n";
}
}
////
// /classes/MongoConfiguration.php
////
示例4: dirname
# limitations under the License.
*/
require_once dirname(__DIR__) . "/classes/Requires.php";
//Get settings
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
$instance_key = null;
if (isset($row->data)) {
$row->data = json_decode($row->data);
if (isset($row->data->instance_key) && !empty($row->data->instance_key)) {
$instance_key = $row->data->instance_key;
} else {
$instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
$data = array("instance_key" => $instance_key, "default_ssh_username" => $row->data->default_ssh_username, "default_ssh_port" => $row->data->default_ssh_port, "default_interpreter" => $row->data->default_interpreter, "timezone_offset" => $row->data->timezone_offset, "timezone_daylight_savings" => $row->data->timezone_daylight_savings);
MySQLQueries::edit_settings(json_encode((object) $data));
}
} else {
$instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
$data = array("instance_key" => $instance_key);
MySQLQueries::edit_settings(json_encode((object) $data));
}
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
$servers[] = $row;
}
$payload = '{"event":"' . $instance_key . '","properties":{"token":"678f0669ff58d890eeb50633c91a633d","distinct_id":"' . $instance_key . '","ip":"' . Functions::get_remote_ip() . '","servers":"' . count($servers) . '","version":"' . Version::app . '","ip-address":"' . Functions::get_remote_ip() . '","mp_name_tag":"' . $instance_key . '","time":"' . time() . '"}}';
$curl = new Curl();
$curl->get_request("https://api.mixpanel.com/track/?data=" . base64_encode($payload));
$curl->close();
echo '{"instance_key":"' . $instance_key . '"}';