コード例 #1
1
ファイル: fortune.php プロジェクト: pombredanne/tuleap
 function quoteFromDir($dir)
 {
     $amount = 0;
     $index = 0;
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if (strpos($file, ".dat") != false) {
                 $len = strlen($file);
                 if (substr($file, $len - 4) == ".dat") {
                     $number = $this->getNumberOfQuotes($dir . "/" . $file);
                     $amount += $number;
                     $quotes[$index] = $amount;
                     $files[$index] = $file;
                     $index++;
                 }
             }
         }
         srand((double) microtime() * 1000000);
         $index = rand(0, $amount);
         $i = 0;
         while ($quotes[$i] < $index) {
             $i++;
         }
         return $this->getRandomQuote($dir . "/" . $files[$i]);
     }
     return -1;
 }
コード例 #2
0
ファイル: code.php プロジェクト: NingerJohn/vfinder
function create_captcha($width = 60, $height = 32)
{
    session_start();
    //生成验证码图片
    Header("Content-type: image/PNG");
    $im = imagecreate($width, $height);
    // width and height of image
    $back = ImageColorAllocate($im, 245, 245, 245);
    // specify background color
    imagefill($im, 0, 0, $back);
    // fill the background color into image
    $vcodes = "";
    srand((double) microtime() * 1000000);
    //生成4位数字
    for ($i = 0; $i < 4; $i++) {
        $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
        // 生成随机颜色
        $authnum = rand(1, 9);
        $vcodes .= $authnum;
        imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
    }
    for ($i = 0; $i < 100; $i++) {
        // interuppting
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
        // 画像素点函数
    }
    ImagePNG($im);
    ImageDestroy($im);
    $_SESSION['captcha'] = $vcodes;
}
コード例 #3
0
 function check($text)
 {
     $this->errors = array();
     $this->command = '';
     if (preg_match('/^([0-9]+)d([0-9]{1,3})([\\+-][0-9]+)?$/', $text, $matches)) {
         $this->command['launch'] = (int) $matches[1];
         $this->command['faces'] = (int) $matches[2];
         // Now go for corrections
         if (count($matches) == 4) {
             $this->command['bias'] = $matches[3];
         }
         if (!($this->command['launch'] && $this->command['faces'])) {
             //print_r($matches);
             $this->errors[] = "Be serious, not null dice please.";
             return false;
         }
     } else {
         //print_r($matches);
         // Too long
         //$this->errors[] = "'$text' is not a valid string for a dice launch. Valid strings match the following patterns xdyyy, xdyyy+z or xdyyy-z where x,  y and z are digits, you can have up to three y.";
         $this->errors[] = 'Not valid. Valid launches are like xdyyy';
         return false;
     }
     $this->text = $text;
     srand((double) microtime() * 1000000);
     return true;
 }
コード例 #4
0
/**
 * Generates a Photon URL.
 *
 * @see http://developer.wordpress.com/docs/photon/
 *
 * @param string $image_url URL to the publicly accessible image you want to manipulate
 * @param array|string $args An array of arguments, i.e. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456)
 * @return string The raw final URL. You should run this through esc_url() before displaying it.
 */
function jetpack_photon_url($image_url, $args = array(), $scheme = null)
{
    $image_url = trim($image_url);
    $image_url = apply_filters('jetpack_photon_pre_image_url', $image_url, $args, $scheme);
    $args = apply_filters('jetpack_photon_pre_args', $args, $image_url, $scheme);
    if (empty($image_url)) {
        return $image_url;
    }
    $image_url_parts = @parse_url($image_url);
    // Unable to parse
    if (!is_array($image_url_parts) || empty($image_url_parts['host']) || empty($image_url_parts['path'])) {
        return $image_url;
    }
    if (is_array($args)) {
        // Convert values that are arrays into strings
        foreach ($args as $arg => $value) {
            if (is_array($value)) {
                $args[$arg] = implode(',', $value);
            }
        }
        // Encode values
        // See http://core.trac.wordpress.org/ticket/17923
        $args = rawurlencode_deep($args);
    }
    // You can't run a Photon URL through Photon again because query strings are stripped.
    // So if the image is already a Photon URL, append the new arguments to the existing URL.
    if (in_array($image_url_parts['host'], array('i0.wp.com', 'i1.wp.com', 'i2.wp.com'))) {
        $photon_url = add_query_arg($args, $image_url);
        return jetpack_photon_url_scheme($photon_url, $scheme);
    }
    // This setting is Photon Server dependent
    if (!apply_filters('jetpack_photon_any_extension_for_domain', false, $image_url_parts['host'])) {
        // Photon doesn't support query strings so we ignore them and look only at the path.
        // However some source images are served via PHP so check the no-query-string extension.
        // For future proofing, this is a blacklist of common issues rather than a whitelist.
        $extension = pathinfo($image_url_parts['path'], PATHINFO_EXTENSION);
        if (empty($extension) || in_array($extension, array('php'))) {
            return $image_url;
        }
    }
    $image_host_path = $image_url_parts['host'] . $image_url_parts['path'];
    // Figure out which CDN subdomain to use
    srand(crc32($image_host_path));
    $subdomain = rand(0, 2);
    srand();
    $photon_url = "http://i{$subdomain}.wp.com/{$image_host_path}";
    // This setting is Photon Server dependent
    if (isset($image_url_parts['query']) && apply_filters('jetpack_photon_add_query_string_to_domain', false, $image_url_parts['host'])) {
        $photon_url .= '?q=' . rawurlencode($image_url_parts['query']);
    }
    if ($args) {
        if (is_array($args)) {
            $photon_url = add_query_arg($args, $photon_url);
        } else {
            // You can pass a query string for complicated requests but where you still want CDN subdomain help, etc.
            $photon_url .= '?' . $args;
        }
    }
    return jetpack_photon_url_scheme($photon_url, $scheme);
}
コード例 #5
0
ファイル: packager.php プロジェクト: scarygary/gallery3
 private function _reset()
 {
     $db = Database::instance();
     // Drop all tables
     foreach ($db->list_tables() as $table) {
         $db->query("DROP TABLE IF EXISTS `{$table}`");
     }
     // Clean out data
     dir::unlink(VARPATH . "uploads");
     dir::unlink(VARPATH . "albums");
     dir::unlink(VARPATH . "resizes");
     dir::unlink(VARPATH . "thumbs");
     dir::unlink(VARPATH . "modules");
     dir::unlink(VARPATH . "tmp");
     $db->clear_cache();
     module::$modules = array();
     module::$active = array();
     // Use a known random seed so that subsequent packaging runs will reuse the same random
     // numbers, keeping our install.sql file more stable.
     srand(0);
     gallery_installer::install(true);
     module::load_modules();
     foreach (array("user", "comment", "organize", "info", "rss", "search", "slideshow", "tag") as $module_name) {
         module::install($module_name);
         module::activate($module_name);
     }
 }
コード例 #6
0
 function _create_media_record($tmp_file_path, $file_name, $mime_type)
 {
     if (!file_exists($tmp_file_path)) {
         debug::write_error('tmp file not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('tmp_file' => $tmp_file_path));
         return false;
     }
     srand(time());
     $media_id = md5(uniqid(rand()));
     dir::mkdir(MEDIA_DIR);
     if (!copy($tmp_file_path, MEDIA_DIR . $media_id . '.media')) {
         debug::write_error('copy failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('dst' => MEDIA_DIR . $media_id . '.media', 'src' => $tmp_file_path));
         return false;
     }
     if (function_exists('md5_file')) {
         $etag = md5_file($tmp_file_path);
     } else {
         $fd = fopen($tmp_file_path, 'rb');
         $contents = fread($fd, filesize($tmp_file_path));
         fclose($fd);
         $etag = md5($contents);
     }
     $media_db_table = db_table_factory::instance('media');
     $media_db_table->insert(array('id' => $media_id, 'file_name' => $file_name, 'mime_type' => $mime_type, 'size' => filesize($tmp_file_path), 'etag' => $etag));
     $this->set_attribute('etag', $etag);
     return $media_id;
 }
コード例 #7
0
 function seed()
 {
     if ($this->makeMoreRandom) {
         usleep(1);
         srand((double) microtime() * 1000000);
     }
 }
コード例 #8
0
function tpl_function_adsense($params, &$tpl)
{
    // check to make sure this is a full story
    if (strcasecmp(pagename, "story") != 0) {
        // not a full story, no adsense sharing
        $tpl->assign($params['assign'], 0);
        return;
    }
    // check to see if the author has an adsense id on their profile
    if ($tpl->get_template_vars("google_adsense_id") == "") {
        // this author hasn't provided their adsense id, no sharing
        $tpl->assign($params['assign'], 0);
        return;
    }
    // make sure the logged in user isn't the same user who submitted the story
    // using a case insensitive compare because the user name isn't case sensitive
    if (strcasecmp($tpl->get_template_vars("user_logged_in"), $tpl->get_template_vars("link_submitter")) == 0) {
        // the user viewing the story is also the author, can't show them their own ads, no sharing
        $tpl->assign($params['assign'], 0);
        return;
    }
    // generate a random number between 1 and 100
    srand((double) microtime() * 10000000);
    $random = rand(1, 100);
    // check the random number against their adsense percent (defaults to 50% but can be adjusted)
    if ($random > $tpl->get_template_vars("google_adsense_percent")) {
        // if the random number is higher than their percent of revenue sharing, no sharing this time
        $tpl->assign($params['assign'], 0);
        return;
    }
    // passed all checks, use the users adsense ID for this page
    $tpl->assign($params['assign'], 1);
    return;
}
コード例 #9
0
function generate_code()
{
    $hours = date("H");
    // час
    $minuts = substr(date("H"), 0, 1);
    // минута
    $mouns = date("m");
    // месяц
    $year_day = date("z");
    // день в году
    $str = $hours . $minuts . $mouns . $year_day;
    //создаем строку
    $str = md5(md5($str));
    //дважды шифруем в md5
    $str = strrev($str);
    // реверс строки
    $str = substr($str, 3, 6);
    // извлекаем 6 символов, начиная с 3
    // Вам конечно же можно постваить другие значения, так как, если взломщики узнают, каким именно способом это все генерируется, то в защите не будет смысла.
    $array_mix = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
    srand((double) microtime() * 1000000);
    shuffle($array_mix);
    //Тщательно перемешиваем, соль, сахар по вкусу!!!
    return implode("", $array_mix);
}
コード例 #10
0
ファイル: Steampunk.php プロジェクト: bpr005/cse477_milltag
 public function __construct($seed = null)
 {
     if ($seed === null) {
         $seed = time();
     }
     srand($seed);
 }
コード例 #11
0
function insert_user($added_name, $password, $gradyear, $email, $type, $status = '')
{
    if (!$password) {
        srand(time());
        $password = rand(0, 999999);
    }
    if (!$email) {
        $email = $added_name . "@grinnell.edu";
    }
    $crpassword = User::hashPassword($password);
    $dbh = db_connect();
    $myrow = array("", $added_name, "", $crpassword, $email, "", "", "", "", "", "", $gradyear, "70", "14", "", "", $type, "", "", 0);
    add_row($dbh, "accounts", $myrow);
    mysql_query("UPDATE accounts SET created = NOW() WHERE\n\t\t\tusername = '******'");
    $added_id = get_item($dbh, "userid", "accounts", "username", $added_name);
    mysql_query("INSERT INTO plans (user_id) VALUES ({$added_id})");
    add_row($dbh, "display", array($added_id, "6", "7"));
    foreach (array(2, 4, 6, 8, 14, 15, 16) as $opt_link) {
        $myrow = array($added_id, $opt_link);
        add_row($dbh, "opt_links", $myrow);
    }
    $myrow = array($added_id, $status);
    add_row($dbh, "perms", $myrow);
    return array($password, $email);
}
コード例 #12
0
ファイル: AuthUsersPage.php プロジェクト: phpsmith/IS4C
 protected function post_id_reset_handler()
 {
     $newpass = '';
     srand();
     for ($i = 0; $i < 8; $i++) {
         switch (rand(1, 3)) {
             case 1:
                 // digit
                 $newpass .= chr(48 + rand(0, 9));
                 break;
             case 2:
                 // uppercase
                 $newpass .= chr(65 + rand(0, 25));
                 break;
             case 3:
                 $newpass .= chr(97 + rand(0, 25));
                 break;
         }
     }
     $changed = changeAnyPassword($this->id, $newpass);
     if ($changed) {
         $this->add_onload_command("showBootstrapAlert('#btn-bar', 'success', 'New password for {$this->id} is {$newpass}');\n");
     } else {
         $this->add_onload_command("showBootstrapAlert('#btn-bar', 'danger', 'Error changing password for {$this->id}');\n");
     }
     return true;
 }
コード例 #13
0
ファイル: comments.php プロジェクト: hardikamutech/loov
 /**
  * Constructor.
  *
  * @param BASE_CommentsParams $params
  */
 public function __construct(BASE_CommentsParams $params)
 {
     parent::__construct();
     $this->params = $params;
     $this->batchData = $params->getBatchData();
     $this->staticData = empty($this->batchData['_static']) ? array() : $this->batchData['_static'];
     $this->batchData = isset($this->batchData[$params->getEntityType()][$params->getEntityId()]) ? $this->batchData[$params->getEntityType()][$params->getEntityId()] : array();
     srand(time());
     $this->id = $params->getEntityType() . $params->getEntityId() . rand(1, 10000);
     $this->cmpContextId = "comments-{$this->id}";
     $this->assign('cmpContext', $this->cmpContextId);
     $this->assign('wrapInBox', $params->getWrapInBox());
     $this->assign('topList', in_array($params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI)));
     $this->assign('bottomList', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_PAGING);
     $this->assign('mini', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $this->isAuthorized = OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment') && $params->getAddComment();
     if (!$this->isAuthorized) {
         $errorMessage = $params->getErrorMessage();
         if (empty($errorMessage)) {
             $status = BOL_AuthorizationService::getInstance()->getActionStatus($params->getPluginKey(), 'add_comment');
             $errorMessage = OW::getUser()->isAuthenticated() ? $status['msg'] : OW::getLanguage()->text('base', 'comments_add_login_message');
         }
         $this->assign('authErrorMessage', $errorMessage);
     }
     $this->initForm();
 }
コード例 #14
0
 function cc_bill($cc_info, $member, $amount, $currency, $product_description, $charge_type, $invoice, $payment)
 {
     global $config;
     $log = array();
     //////////////////////// cc_bill /////////////////////////
     srand(time());
     if ($cc_info['cc_name_f'] == '') {
         $cc_info['cc_name_f'] = $member['name_f'];
         $cc_info['cc_name_l'] = $member['name_l'];
     }
     $vars = array("merchant" => $this->config['login'], "ticket" => $payment['payment_id'], "amount" => $amount, "card" => $cc_info['cc_number'], "expdate" => $cc_info['cc-expire'], "cardname" => $cc_info['cc_name_f'] . " " . $cc_info['cc_name_l'], "address" => $cc_info['cc_street'], "zip" => $cc_info['cc_zip'], "authenticator" => md5($this->config['secret'] . $this->config['login'] . $payment[payment_id] . $amount));
     if ($cc_info['cc_code']) {
         $vars['cvd'] = $cc_info['cc_code'];
     }
     // prepare log record
     $vars_l = $vars;
     $vars_l['card'] = $cc_info['cc'];
     if ($vars['cvd']) {
         $vars_l['cvd'] = preg_replace('/./', '*', $vars['cvd']);
     }
     $log[] = $vars_l;
     /////
     $res = $this->run_transaction($vars);
     $log[] = $res;
     if (preg_match("/Approved/i", $res[RESULT])) {
         return array(CC_RESULT_SUCCESS, "", $res['PNREF'], $log);
     } elseif (preg_match("/Declined/i", $res[RESULT])) {
         return array(CC_RESULT_DECLINE_PERM, $res['RESPMSG'] ? $res[RESPMSG] : $res[RESULT], "", $log);
     } else {
         return array(CC_RESULT_INTERNAL_ERROR, $res['RESPMSG'] ? $res[RESPMSG] : $res[RESULT], "", $log);
     }
 }
コード例 #15
0
ファイル: index.php プロジェクト: sonicmaster/RPG
 function sendnewpassword($mail)
 {
     global $lang;
     $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . $mail . "' LIMIT 1;", 'users', true);
     if (empty($ExistMail['email'])) {
         message($lang['mail_not_exist'], "index.php?modo=claveperdida", 2, false, false);
     } else {
         $Caracters = "aazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890";
         $Count = strlen($Caracters);
         $NewPass = "";
         $Taille = 6;
         srand((double) microtime() * 1000000);
         for ($i = 0; $i < $Taille; $i++) {
             $CaracterBoucle = rand(0, $Count - 1);
             $NewPass = $NewPass . substr($Caracters, $CaracterBoucle, 1);
         }
         $Title = $lang['mail_title'];
         $Body = $lang['mail_text'];
         $Body .= $NewPass;
         mail($mail, $Title, $Body);
         $NewPassSql = md5($NewPass);
         $QryPassChange = "UPDATE {{table}} SET ";
         $QryPassChange .= "`password` ='" . $NewPassSql . "' ";
         $QryPassChange .= "WHERE `email`='" . $mail . "' LIMIT 1;";
         doquery($QryPassChange, 'users');
     }
 }
コード例 #16
0
ファイル: navigation.php プロジェクト: alvinhoadcs/cs155
function nav_start_outer($page_title = null, $secret_token)
{
    ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3. org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="/static/zoobar.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<TITLE><?php 
    echo "{$page_title} - ";
    ?>
Zoobar Foundation
</TITLE>
</HEAD>
<div id="header">

<div>Stanford CS155 Project 2</div>

<?php 
    global $user;
    if ($user->id) {
        ?>

    <form method="POST" action="/" name="logoutform" id="logoutform" style="display:none;">
      <input type="hidden" name="action" value="logout">
      <input type="hidden" name="token" value="<?php 
        echo $secret_token;
        ?>
">
      <input type="submit" value="Logout">
    </form>

    <div><a href="#" onclick="document.getElementById('logoutform').submit();">
    <?php 
        echo "Log out " . htmlspecialchars($user->username);
        ?>
    </a></div>
<?php 
    }
    ?>

</div>

<?php 
    // Pick a random title for the page. This is funny for about 3 seconds.
    srand();
    $adjectives = array("Inquisitive", "Responsible", "Patriotic", "Trustworthy", "Sustainable", "Objective", "Disciplined", "Sensible", "Ethical", "Vigilant", "Principled", "Awesome");
    $nouns = array("Thinking", "Policy", "Dialogue", "Learning", "Discourse", "Research", "Advocacy");
    $adverbs = array("best", "brightest", "foremost", "leading", "proven", "loyal", "brave", "meritorious", "shrewd", "important", "skillful");
    $pluralnouns = array("thinkers", "minds", "students", "soldiers", "advocates", "representatives", "researchers");
    $concepts = array("21st century", "next generation", "new world order", "United States", "counterinsurgency", "information superhighway");
    $adjective = $adjectives[array_rand($adjectives)];
    $noun = $nouns[array_rand($nouns)];
    $adverb = $adverbs[array_rand($adverbs)];
    $pluralnoun = $pluralnouns[array_rand($pluralnouns)];
    $concept = $concepts[array_rand($concepts)];
    echo "<h1><a href='index.php'>Zoobar Foundation for " . "{$adjective} {$noun}</a></h1>";
    echo "<h2>Supporting the {$adverb} {$pluralnoun} of the {$concept}</h2>";
}
コード例 #17
0
ファイル: VerifyCode.php プロジェクト: blackzw/auth
function rand_create()
{
    //通知浏览器将要输出PNG图片
    Header("Content-type: image/PNG");
    //准备好随机数发生器种子
    srand((double) microtime() * 1000000);
    //准备图片的相关参数
    $im = imagecreate(62, 20);
    $black = ImageColorAllocate($im, 0, 0, 0);
    //RGB黑色标识符
    $white = ImageColorAllocate($im, 255, 255, 255);
    //RGB白色标识符
    $gray = ImageColorAllocate($im, 200, 200, 200);
    //RGB灰色标识符
    //开始作图
    imagefill($im, 0, 0, $gray);
    while (($randval = rand() % 100000) < 10000) {
    }
    $_SESSION["login_check_num"] = $randval;
    //将四位整数验证码绘入图片
    imagestring($im, 5, 10, 3, $randval, $black);
    //加入干扰象素
    for ($i = 0; $i < 200; $i++) {
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
    }
    //输出验证图片
    ImagePNG($im);
    //销毁图像标识符
    ImageDestroy($im);
}
コード例 #18
0
 /**
  * Changes the Mail address
  */
 function changeMail($mail)
 {
     $at = array('[AT]', ' AT ', '(AT)');
     srand((double) microtime() * 1000000);
     $rand = rand(0, count($at) - 1);
     return $mail = preg_replace("%@%", $at[$rand], $mail);
 }
コード例 #19
0
ファイル: SendNewPassword.php プロジェクト: sonicmaster/RPG
function sendnewpassword($email)
{
    $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . $email . "' LIMIT 1;", 'users', true);
    if (empty($ExistMail['email'])) {
        message('That address is not found !', 'Error');
    } else {
        $Caracters = "aazertyuiopqsdfghjklmwxcvbn���AZERTYUIOPQSDFGHJKLMWXCVBN���1234567890";
        $Count = strlen($Caracters);
        $NewPass = "";
        $Taille = 6;
        srand((double) microtime() * 1000000);
        for ($i = 0; $i < $Taille; $i++) {
            $CaracterBoucle = rand(0, $Count - 1);
            $NewPass = $NewPass . substr($Caracters, $CaracterBoucle, 1);
        }
        $Title = "Rogue Universe : Nytt l�senord";
        $Body = "H�r �r ditt nya l�senord : ";
        $Body .= $NewPass;
        mail($email, $Title, $Body);
        $NewPassSql = md5($NewPass);
        $QryPassChange = "UPDATE game_users SET ";
        $QryPassChange .= "`password` ='" . $NewPassSql . "' ";
        $QryPassChange .= "WHERE `email`='" . $email . "' LIMIT 1;";
        doquery($QryPassChange, 'users');
    }
}
コード例 #20
0
 /**
  * Create image from text (for captcha) 
  * @param int widht
  * @param int height	
  * @param string text
  * @param string Font (Arial)
  * @param int fontsize
  * @param string if not empty then save to file        
  * @param int randomline    
  */
 static function createImageTextKod($width, $height, $text, $TTFFile, $fontsize = 16, $file = '', $randomline = 2)
 {
     $img = imagecreate($width, $height);
     $col = imagecolorallocate($img, 255, 255, 255);
     $line = imagecolorallocate($img, 220, 220, 220);
     for ($i = 5; $i < $width; $i = $i + $fontsize) {
         imageline($img, $i, 0, $i, $height, $line);
     }
     for ($i = 5; $i < $height; $i = $i + $fontsize) {
         imageline($img, 0, $i, $width, $i, $line);
     }
     $c[0] = imagecolorallocate($img, 20, 50, 235);
     $c[1] = imagecolorallocate($img, 20, 220, 23);
     $c[2] = imagecolorallocate($img, 220, 20, 23);
     $c[3] = imagecolorallocate($img, 255, 120, 10);
     $c[4] = imagecolorallocate($img, 120, 120, 140);
     $c[5] = imagecolorallocate($img, 20, 130, 140);
     $c[6] = imagecolorallocate($img, 120, 130, 40);
     srand(time());
     for ($i = 0; $i < $randomline; $i++) {
         $color = $c[rand(0, 6)];
         $y1 = rand(0, $height);
         $y2 = rand(0, $height);
         imageline($img, 0, $y1, $width, $y2, $color);
     }
     for ($i = 0; $i < strlen($text); $i++) {
         $symb = substr($text, $i, 1);
         $color = $c[rand(0, 6)];
         $angle = rand(-15, 15);
         $y = $fontsize + intval($fontsize / 2) + intval($fontsize / 5) + rand(-intval($fontsize / 2), intval($fontsize / 2)) + 1;
         $x = $fontsize * $i + intval($fontsize / 2) + 1;
         imagettftext($img, $fontsize, $angle, $x, $y, $color, $TTFFile, $symb);
     }
     imagejpeg($img, $file, 90);
 }
コード例 #21
0
ファイル: Socket.php プロジェクト: mmr/b1n
 private function Connect($servers)
 {
     if ($this->IsConnected()) {
         throw new Exception('Already connected');
     }
     if (!is_array($servers) || count($servers) == 0) {
         throw new Exception('No servers');
     }
     foreach ($servers as $s) {
         if (!ereg("[^:]+:[0-9]+", $s)) {
             throw new Exception($s . ' is not a valid server');
         }
     }
     srand((double) microtime() * 1000000);
     shuffle($servers);
     foreach ($servers as $s) {
         list($server, $port) = explode(":", $s);
         $server = gethostbyname($server);
         $this->socket = fsockopen($server, $port, $errno, $err);
         if ($this->IsConnected()) {
             break;
         }
     }
     if ($this->IsConnected()) {
         return true;
     } else {
         throw new Exception($errno . ' - ' . $err);
     }
 }
コード例 #22
0
 function random_generator($digits)
 {
     srand((double) microtime() * 10000000);
     //Array of alphabets
     $input = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
     $random_generator = "";
     // Initialize the string to store random numbers
     for ($i = 1; $i < $digits + 1; $i++) {
         // Loop the number of times of required digits
         if (rand(1, 2) == 1) {
             // to decide the digit should be numeric or alphabet
             // Add one random alphabet
             $rand_index = array_rand($input);
             $random_generator .= $input[$rand_index];
             // One char is added
         } else {
             // Add one numeric digit between 1 and 10
             $random_generator .= rand(1, 10);
             // one number is added
         }
         // end of if else
     }
     // end of for loop
     return $random_generator;
 }
コード例 #23
0
 protected function configure()
 {
     $vd6fe1d0be6347b8ef2427fa629c04485 = $this->options['tmbPath'];
     if ($vd6fe1d0be6347b8ef2427fa629c04485) {
         if (!file_exists($vd6fe1d0be6347b8ef2427fa629c04485)) {
             if (@mkdir($vd6fe1d0be6347b8ef2427fa629c04485)) {
                 chmod($vd6fe1d0be6347b8ef2427fa629c04485, $this->options['tmbPathMode']);
             } else {
                 $vd6fe1d0be6347b8ef2427fa629c04485 = '';
             }
         }
         if (is_dir($vd6fe1d0be6347b8ef2427fa629c04485) && is_readable($vd6fe1d0be6347b8ef2427fa629c04485)) {
             $this->tmbPath = $vd6fe1d0be6347b8ef2427fa629c04485;
             $this->tmbPathWritable = is_writable($vd6fe1d0be6347b8ef2427fa629c04485);
         }
     }
     $v599dcce2998a6b40b1e38e8c6006cb0a = preg_match('/^(imagick|gd|auto)$/i', $this->options['imgLib']) ? strtolower($this->options['imgLib']) : 'auto';
     if (($v599dcce2998a6b40b1e38e8c6006cb0a == 'imagick' || $v599dcce2998a6b40b1e38e8c6006cb0a == 'auto') && extension_loaded('imagick')) {
         $this->imgLib = 'imagick';
     } else {
         $this->imgLib = function_exists('gd_info') ? 'gd' : '';
     }
     if ($this->tmbPath) {
         srand((double) microtime() * 1000000);
         if (rand(1, 200) <= $this->options['tmbCleanProb']) {
             $v44ba5ca65651b4f36f1927576dd35436 = scandir($this->tmbPath);
             for ($v865c0c0b4ab0e063e5caa3387c1a8741 = 0, $v03c7c0ace395d80182db07ae2c30f034 = count($v44ba5ca65651b4f36f1927576dd35436); $v865c0c0b4ab0e063e5caa3387c1a8741 < $v03c7c0ace395d80182db07ae2c30f034; $v865c0c0b4ab0e063e5caa3387c1a8741++) {
                 $v2df194d510f49f84d83ac1fb0b00b749 = pathinfo($v44ba5ca65651b4f36f1927576dd35436[$v865c0c0b4ab0e063e5caa3387c1a8741]);
                 if (strtolower($v2df194d510f49f84d83ac1fb0b00b749['extension']) == 'png') {
                     @unlink($this->tmbPath . DIRECTORY_SEPARATOR . $v44ba5ca65651b4f36f1927576dd35436[$v865c0c0b4ab0e063e5caa3387c1a8741]);
                 }
             }
         }
     }
 }
コード例 #24
0
ファイル: uploader.php プロジェクト: gambric/ceramichesofia
function random()
{
    $gammaDeiCaratteri = "abcdefghijklmnopqrstuvwxyz1234567890";
    //ABCDEFGHIJKLMNOPQRSTUVWXYZ
    srand((double) microtime() * 1000000);
    // inizializzo la variabile $elaborazione
    // evitando spiacevoli notice
    $elaborazione = '';
    for ($contatore = 0; $contatore < 8; $contatore++) {
        // prendo un numero casuale da 0 a strlen($gammaDeiCaratteri)-1
        // si parte dallo 0 e non dall'1
        $numeroCasuale = rand(0, strlen($gammaDeiCaratteri) - 1);
        // prendo dalla variabile $gammaDeiCaratteri un solo carattere
        // che è posizionato al numero $numeroCasuale
        // se per esempio il $numeroCasuale risultante � 4 il carattere
        // che prendero è "e"
        $carattere = substr($gammaDeiCaratteri, $numeroCasuale, 1);
        // aggiungo a $elaborazione il carattere risultante
        // mediante la concatenazione (vedi il punto in mezzo alle due variabili)
        $elaborazione = $elaborazione . $carattere;
    }
    // fine del ciclo
    // ritorno la stringa elaborata che conterr� a tutti gli effetti una password casuale
    return $elaborazione;
}
コード例 #25
0
 public function up()
 {
     $this->insert('{{property_group}}', ['object_id' => 3, 'name' => Yii::t('app', 'Special actions'), 'is_internal' => 1, 'hidden_group_title' => 1]);
     $propertyGroupId = $this->db->lastInsertID;
     $this->addColumn('{{%product_property}}', 'todays_deals', Schema::TYPE_INTEGER);
     $this->addColumn('{{%product_property}}', 'sale', Schema::TYPE_INTEGER);
     $this->insert('{{%property}}', ['property_group_id' => $propertyGroupId, 'name' => Yii::t('app', 'Show in Today\'s deals'), 'key' => 'todays_deals', 'value_type' => 'NUMBER', 'property_handler_id' => 3, 'is_column_type_stored' => 1, 'handler_additional_params' => '{}']);
     $todaysDealsPropertyId = $this->db->lastInsertID;
     $this->insert('{{%property}}', ['property_group_id' => $propertyGroupId, 'name' => Yii::t('app', 'Show in Sale'), 'key' => 'sale', 'value_type' => 'NUMBER', 'property_handler_id' => 3, 'is_column_type_stored' => 1, 'handler_additional_params' => '{}']);
     $salePropertyId = $this->db->lastInsertID;
     $q = new \yii\db\Query();
     $ids = $q->select('id')->from('{{%product}}')->where(['like', 'name', 'Lenovo'])->column();
     srand();
     foreach ($ids as $id) {
         $this->insert('{{%object_property_group}}', ['object_id' => 3, 'object_model_id' => $id, 'property_group_id' => $propertyGroupId]);
         $this->insert('{{%product_property}}', ['object_model_id' => $id, 'todays_deals' => rand(0, 1), 'sale' => rand(0, 1)]);
     }
     $this->insert('{{%filter_sets}}', ['category_id' => 3, 'sort_order' => 4, 'property_id' => $salePropertyId]);
     $this->insert('{{%filter_sets}}', ['category_id' => 3, 'sort_order' => 3, 'property_id' => $todaysDealsPropertyId]);
     $this->insert('{{%prefiltered_pages}}', ['slug' => 'sale', 'active' => '1', 'last_category_id' => '3', 'params' => '{"' . $salePropertyId . '":"1"}', 'title' => 'Total sale in our awesome shop!', 'announce' => NULL, 'content' => '<p>This is an example content for our prefiltered page</p>', 'h1' => 'Total sale - up to 20%', 'meta_description' => 'Harry up! Total sale in our awesome shop - up to 20%!', 'breadcrumbs_label' => 'Total sale', 'view_id' => '0']);
     $this->insert('{{%prefiltered_pages}}', ['slug' => 'todays-deals', 'active' => '1', 'last_category_id' => '3', 'params' => '{"' . $todaysDealsPropertyId . '":"1"}', 'title' => 'Today\'s deals!', 'announce' => NULL, 'content' => '<p>Here\'s some hand-picked products for the Deal of the day!</p>', 'h1' => 'Deal of the day - up to 30%!', 'meta_description' => 'Deal of the day in our shop!', 'breadcrumbs_label' => 'Deal of the day', 'view_id' => '0']);
     $this->insert('{{navigation}}', ['parent_id' => 1, 'name' => Yii::t('app', 'Today\'s deals'), 'url' => '/todays-deals', 'sort_order' => -1]);
     $this->insert('{{navigation}}', ['parent_id' => 1, 'name' => Yii::t('app', 'Sale'), 'url' => '/sale', 'sort_order' => 3]);
     $this->update('{{%page}}', ['slug_compiled' => ':mainpage:', 'content' => 'You can edit content of main page in backend/page section'], ['id' => 1]);
     $this->insert('{{%view}}', ['name' => 'Main page', 'view' => '@app/extensions/demo/views/main-page.php']);
     $this->insert('{{%view_object}}', ['view_id' => $this->db->lastInsertID, 'object_id' => 1, 'object_model_id' => 1]);
 }
コード例 #26
0
function random_generator($digits)
{
    // function starts
    srand((double) microtime() * 10000000);
    $input = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
    $random_generator = "";
    // Initialize the string to store random numbers
    for ($i = 1; $i <= $digits; $i++) {
        // Loop the number of times of required digits
        if (rand(1, 2) == 1) {
            // to decide the digit should be numeric or alphabet
            // Add one random alphabet
            $rand_index = array_rand($input);
            $random_generator .= $input[$rand_index];
            // One char is added
        } else {
            // Add one numeric digit between 1 and 9
            $random_generator .= rand(1, 9);
            // one number is added
        }
        // end of if else
    }
    // end of for loop
    return $random_generator;
}
コード例 #27
0
function generateSessionId()
{
    // generate rand num
    srand(time());
    $randNum = rand(1000000000, 2147483647) . rand(1000000000, 2147483647) . rand(0, 9);
    return $randNum;
}
コード例 #28
0
ファイル: wikiplugin_sort.php プロジェクト: rjsmelo/tiki
function wikiplugin_sort($data, $params)
{
    global $tikilib;
    extract($params, EXTR_SKIP);
    $sort = isset($sort) ? $sort : "asc";
    $lines = preg_split("/\n+/", $data, -1, PREG_SPLIT_NO_EMPTY);
    // separate lines into array
    // $lines = array_filter( $lines, "chop" ); // remove \n
    srand((double) microtime() * 1000000);
    // needed for shuffle;
    if ($sort == "asc") {
        natcasesort($lines);
    } else {
        if ($sort == "desc") {
            natcasesort($lines);
            $lines = array_reverse($lines);
        } else {
            if ($sort == "reverse") {
                $lines = array_reverse($lines);
            } else {
                if ($sort == "shuffle") {
                    shuffle($lines);
                }
            }
        }
    }
    reset($lines);
    if (is_array($lines)) {
        $data = implode("\n", $lines);
    }
    $data = trim($data);
    return $data;
}
コード例 #29
0
ファイル: test.php プロジェクト: nahue/Siefu
function createRandomPassword() {



    $chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNLOPQRSTUVXWYZ023456789";

    srand((double)microtime()*1000000);

    $i = 0;

    $pass = '' ;



    while ($i <= 10) {

        $num = rand() % 33;

        $tmp = substr($chars, $num, 1);

        $pass = $pass . $tmp;

        $i++;

    }



    return $pass;



}
コード例 #30
0
ファイル: Data.php プロジェクト: CE-Webmaster/CE-Hub
 public function encryptString($plaintext, $key)
 {
     srand((double) microtime() * 1000000);
     $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB), MCRYPT_RAND);
     $cipher = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, $plaintext, MCRYPT_MODE_CFB, $iv);
     return $iv . $cipher;
 }