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


PHP generate函数代码示例

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


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

示例1: login

function login($email, $password)
{
    $db = Database::getInstance();
    $mysqli = $db->getConnection();
    $mysqli->query("SET NAMES utf8");
    $sql_query = 'SELECT * FROM user WHERE email="' . $email . '"';
    $result = $mysqli->query($sql_query);
    $user = mysqli_fetch_assoc($result);
    global $password;
    //if password correct
    if (password_verify($password, $user['password'])) {
        session_start();
        $_SESSION['auth'] = true;
        $_SESSION['id'] = $user['id'];
        $_SESSION['user'] = $user['user'];
        //check keep login, set coockie
        if ($_POST['loginkeeping'] == "on") {
            $key = md5(generate(7, 15));
            setcookie('login', $user['user'], time() + 60 * 60 * 24 * 365);
            setcookie('key', $key, time() + 60 * 60 * 24 * 365);
            $sql_query = "UPDATE user SET cookie='" . $key . "' WHERE id='" . $user['id'] . "'";
            $mysqli->query($sql_query);
            //if no keep login, set cookie as NULL
        } else {
            $sql_query = "UPDATE user SET cookie=NULL WHERE id='" . $user['id'] . "'";
            $mysqli->query($sql_query);
        }
        header("Location: http://" . $_SERVER['SERVER_NAME']);
    } else {
        echo "Email or password is incorrect";
    }
}
开发者ID:Hydropericardium,项目名称:blog.dev,代码行数:32,代码来源:generate.php

示例2: __toString

 public function __toString()
 {
     if (!isset($this->style)) {
         $this->style = 1;
     }
     return generate($this->style);
 }
开发者ID:thomasmrln,项目名称:sheeter,代码行数:7,代码来源:Sheeter.php

示例3: login

function login($link, $email, $password)
{
    $password = generate($password);
    $query = mysqli_query($connection, "SELECT `user_name`, `user_password` FROM `members` WHERE `user_name` = '{$username}' AND `user_password` = '{$password}'");
    $count = mysqli_num_rows($query);
    //counting the number of returns
    //if the $count = 1 or more return true else return false
    if ($count >= 1) {
        return true;
    } else {
        return false;
    }
}
开发者ID:AoifeNiD,项目名称:phpNightmareChanged,代码行数:13,代码来源:user1.inc.php

示例4: generate

/**
 * This file is part of the magento-sample project
 *
 * (c) Sergey Kolodyazhnyy <sergey.kolodyazhnyy@gmail.com>
 *
 */
function generate($folder)
{
    $entries = array();
    /** @var SplFileInfo[] $iterator */
    $iterator = new FilesystemIterator($folder, FilesystemIterator::SKIP_DOTS);
    foreach ($iterator as $entry) {
        if (is_file($entry)) {
            $entries[$entry->getPathname()] = $entry->getPathname();
        } else {
            $entries += generate($entry);
        }
    }
    return $entries;
}
开发者ID:bcncommerce,项目名称:magento-sample,代码行数:20,代码来源:modman.php

示例5: test

function test($freq, $prn = false)
{
    global $fs, $filter;
    $data = generate($freq, 0.1, $fs);
    $res = filter($data, $filter);
    if ($prn) {
        for ($i = 0; $i < count($data); $i++) {
            echo "{$data[$i]}\t{$res[$i]}\n";
        }
    }
    $aIn = amplitude($data);
    $aOut = amplitude($res);
    return $aOut / $aIn;
}
开发者ID:RodionGork,项目名称:MusicBlinker,代码行数:14,代码来源:calculations.php

示例6: generate

function generate($srcPath, $dstPath = 'doc/', $imports = array())
{
    global $hide;
    if (!file_exists($dstPath)) {
        mkdir($dstPath, 0777, true);
    }
    $menu = "";
    #collect imports
    foreach (glob($srcPath . "*.hx") as $fname) {
        $import = str_replace(SRC_ROOT, '', $fname);
        $import = str_replace(DOC_ROOT, '', $fname);
        $import = preg_replace('/(\\.\\/)|(\\.\\/)/', '', $import);
        $import = preg_replace('/\\//', '.', $import);
        $import = preg_replace('/^([^a-zA-Z]*)/', '', $import);
        $import = preg_replace('/\\.hx$/', '', $import);
        $imports[basename($fname, '.hx')] = $import;
    }
    #process files
    foreach (glob($srcPath . "*.hx") as $fname) {
        $import = str_replace(SRC_ROOT, '', $fname);
        $import = str_replace(DOC_ROOT, '', $fname);
        $import = preg_replace('/(\\.\\/)|(\\.\\/)/', '', $import);
        $import = preg_replace('/\\//', '.', $import);
        $import = preg_replace('/^([^a-zA-Z]*)/', '', $import);
        $import = preg_replace('/\\.hx$/', '', $import);
        $skip = false;
        foreach ($hide as $ignore) {
            if (strpos($import, $ignore) !== false) {
                $skip = true;
                break;
            }
        }
        if ($skip) {
            continue;
        }
        $menu .= "<li class=\"class\"><a href=\"" . url($import) . "\" class=\"class\">" . basename($fname, '.hx') . "</a></li>\n";
        $doc = genDoc($fname, $imports);
        file_put_contents($dstPath . basename($fname, '.hx') . '.html', $doc);
    }
    #process dirs
    foreach (glob($srcPath . "*", GLOB_ONLYDIR) as $dirName) {
        $menu = "<li class=\"package\"><span class=\"package\">" . basename($dirName) . "</span>\n<ul>\n" . generate($dirName . '/', $dstPath . basename($dirName) . '/', $imports) . "</ul>\n</li>\n" . $menu;
    }
    return $menu;
}
开发者ID:devsaurin,项目名称:StablexUI,代码行数:45,代码来源:doc.php

示例7: onkernelRequest

 public function onkernelRequest(GetResponseEvent $event)
 {
     //recuperation de la route courante
     $route = $event->getRequest()->attributes->get('_route');
     //on verifie a chaque renouvellement de route si on est pas dans les deux cas ci-dessous
     if ($route == 'aye_creche_livraison' || $route == 'aye_creche_validation') {
         //si c'est la cas on verifie qu'on a plus d'un article dans notre panier
         if ($this->session->has('panier')) {
             if (count($this->session->get('panier')) == 0) {
                 $event->setResponse(new RedirectResponse($this->router - generate('panier')));
             }
         }
         //on verifier bien que l'utilisateur est connecté  sinon on redirige dans la page de login avec le message flash
         if (!is_object($this->securityContext->getToken()->getUser())) {
             $this->session->getFlashBag()->add('notification', 'Vous devez vous identifier afin de finaliser votre achat');
             $event->setResponse(new RedirectResponse($this->router->generate('fos_user_security_login')));
         }
     }
 }
开发者ID:arnodinho,项目名称:symfony2,代码行数:19,代码来源:RedirectionListener.php

示例8: array_values

$lyrics = array_values($lyrics);
$names = scandir('names');
$names = array_diff($names, array('.', '..', '.DS_Store'));
$names = array_values($names);
if (isset($_POST['name']) and $_POST['lyrics']) {
    function generate($length = 5)
    {
        $chars = 'abdefhiknrstyz23456789';
        $numChars = strlen($chars);
        $string = '';
        for ($i = 0; $i < $length; $i++) {
            $string .= substr($chars, rand(1, $numChars) - 1, 1);
        }
        return $string;
    }
    $file = generate(5);
    $file .= '.txt';
    $names[] = $file;
    $handle = fopen('names/' . $file, 'x');
    fwrite($handle, trim($_POST['name']));
    fclose($handle);
    $lyrics[] = $file;
    $handle = fopen('lyrics/' . $file, 'x');
    fwrite($handle, $_POST['lyrics']);
    fclose($handle);
    array_values($names);
    array_values($lyrics);
    header('location: .');
}
if (isset($_POST['rename']) and $_POST['relyrics']) {
    $i = $_POST['i'];
开发者ID:agolomazov,项目名称:test,代码行数:31,代码来源:index.php

示例9: fopen

if (count($argv) == 8) {
    $fpopsperq = $argv[7];
}
$every = 1;
if (count($argv) == 9) {
    $every = $argv[8];
}
echo "generating work for {$name} from {$start} to {$end}, count = {$count}\n";
@unlink("createWorkScript");
$f = fopen("createWorkScript", "wb");
$wus = 0;
for ($i = $start, $loop = 0; $i < $end; $i += $count, $loop++) {
    if ($loop % $every != 0) {
        continue;
    }
    $wun = generate($input, $name, $i, $count, $dir);
    $cw = "";
    $cw .= "mv {$dir}/{$wun} `bin/dir_hier_path {$wun}`\n";
    $cw .= "bin/create_work ";
    $cw .= " --appname gnfslasieve4I1" . $ver . "e ";
    $cw .= " --wu_name {$wun} ";
    $cw .= " --wu_template templates/gnfslasieve4I1Xe_wu.xml ";
    $cw .= " --result_template templates/gnfslasieve4I1Xe_result.xml ";
    $cw .= " --rsc_fpops_est " . $fpopsperq * $count;
    $cw .= " --rsc_fpops_bound " . $fpopsperq * $count * 10;
    $cw .= " {$wun}\n";
    fwrite($f, $cw);
    $wus++;
}
fwrite($f, "rm createWorkScript\n");
fclose($f);
开发者ID:KarimAlloula,项目名称:cloud-and-control,代码行数:31,代码来源:gengnfswu.php

示例10: decode

    }
    ?>
<script>document.getElementById('info').style.display='none';</script>
<div id=info width=100% align=center>Retrive upload ID</div> 
<?php 
    $decode = decode($pwid[1]);
    $va = explode('/', $decode);
    if (!empty($va[2]) && !empty($va[4])) {
        $uid = $va[2];
        $upas = $va[4];
    } else {
        html_error('Error get User ID and/or User Password.');
    }
    $Url = parse_url("http://uploaded.to/js/script.js");
    $script = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"] . ($Url["query"] ? "?" . $Url["query"] : ""), $referrer, $cookie, 0, 0, $_GET["proxy"], $pauth);
    $editKey = generate(6);
    $serverUrl = cut_str($script, 'uploadServer = \'', '\'') . 'upload?admincode=' . $editKey . '&id=' . $uid . '&pw=' . $upas;
    $Url = parse_url("http://uploaded.to/io/upload/precheck");
    $id = rand(1, 15);
    $fileInfo['size'] = filesize($lfile);
    $fileInfo['id'] = 'file' . $id;
    $fileInfo['name'] = $lname;
    $fileInfo['editKey'] = $editKey;
    geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"] . ($Url["query"] ? "?" . $Url["query"] : ""), 'http://uploaded.to/upload', $cookie, $fileInfo, 0, $_GET["proxy"], $pauth);
    ?>
        <script>document.getElementById('info').style.display='none';</script>
<?php 
    $url = parse_url($serverUrl);
    $upagent = "Shockwave Flash";
    $fpost['Filename'] = $lname;
    $fpost['Upload'] = 'Submit Query';
开发者ID:mewtutorial,项目名称:RapidTube,代码行数:31,代码来源:uploaded.to.php

示例11: schoolQuery

        }
        return $rarr;
    } else {
        $carr = schoolQuery("all", $sid);
        $r1 = 227;
        $r2 = 82;
        $g1 = 85;
        $g2 = 4;
        $b1 = 66;
        $b2 = 53;
        $grad = 1 / sizeof($carr);
        $i = 0;
        foreach ($carr as $key => &$elem) {
            $elem["color"] = sprintf("%02s", dechex($r1 + $i * $grad * ($r2 - $r1))) . sprintf("%02s", dechex($g1 + $i * $grad * ($g2 - $g1))) . sprintf("%02s", dechex($b1 + $i * $grad * ($b2 - $b1)));
            $i++;
        }
        return array("All clubs" => $carr);
    }
}
// MAIN
$master_arr = [];
if (isset($_GET["int"]) && isset($_GET["sid"])) {
    $int = $_GET["int"];
    $sid = $_GET["sid"];
    $arr_clubs = populate($int, $sid, $conn);
    if (isset($arr_clubs) && $arr_clubs != -1) {
        $arr_interests = flipsort($arr_clubs, $conn);
        $master_arr = generate($arr_interests, $sid, $conn);
    }
}
echo json_encode($master_arr, JSON_UNESCAPED_UNICODE);
开发者ID:ninjiangstar,项目名称:Uniclubs-php,代码行数:31,代码来源:generate.php

示例12: generate

 function generate($nav, $parent = 0, $level = 0)
 {
     $out = '<ul level="' . $level . '">';
     foreach ($nav[$parent] as $nav_item) {
         $out .= '<li href="' . $nav_item->href . '">';
         if (isset($nav[$nav_item->id])) {
             $out .= '<span class="arrow"><img src="images/arrow_r.png" alt=">" /></span>';
         }
         $out .= '<a href="' . $nav_item->href . '" ' . (isset($nav[$nav_item->id]) ? '' : 'class="dink"') . '>' . $nav_item->name . '</a>';
         if ($nav_item->add_href) {
             $out .= '<a href="' . $nav_item->add_href . '" class="add"> <span style="font-size:12px;color:#CEDDEC">+</span></a>';
         }
         if (isset($nav[$nav_item->id])) {
             $out .= generate($nav, $nav_item->id, $level + 1);
         }
         $out .= '</li>';
     }
     $out .= '</ul>';
     return $out;
 }
开发者ID:flyingfish2013,项目名称:Syssh,代码行数:20,代码来源:user_model.php

示例13: mysqli_fetch_row

         //Hash pass
         $login = $_POST['usernamesignup'];
         //Take login
         $db = Database::getInstance();
         $mysqli = $db->getConnection();
         $mysqli->query("SET NAMES utf8");
         //connect to DB
         $sql_query = 'SELECT * FROM user WHERE email="' . $email . '" OR user="' . $login . '"';
         //Chek user in DB with login and meil
         $result = $mysqli->query($sql_query);
         $row = mysqli_fetch_row($result);
         $name = $row[1];
         $mail = $row[3];
         //CHECK IF NO USERS WITH LOGIN AND PASS
         if (empty($name) and empty($mail)) {
             $verification = generate(10, 20);
             //Create verification code
             //INSERT USER IN DB
             $sql_query = "INSERT INTO user (user, password, email,status,verification,verification_code) VALUES ('{$login}', '{$hash}', '{$email}','1','0','{$verification}')";
             $result = $mysqli->query($sql_query);
             login($email, $hash);
             //IF LOGIN OR PASS BUSY
         } else {
             echo "LOGIN or PASSWORD is busy";
         }
         //IF NO CONFIRM
     } else {
         echo "Passwords are not equal";
     }
     //IF EMPTY
 } else {
开发者ID:Hydropericardium,项目名称:blog.dev,代码行数:31,代码来源:sign.php

示例14: str_replace

            $html = str_replace("{VIEW_WINE_TYPE}", "VOIR LES VINS TYPE", $html);
            $html = str_replace("{Follow_Us}", "Suivez Nous", $html);
            $html = str_replace("{FEATURED_COLLECTIONS}", "SELECTION DE COLLECTIONS", $html);
            $html = str_replace("{FEATURED_WINE}", "VIN EN VEDETTE", $html);
            $html = str_replace("{LAST_FROM_BLOG}", "DERNIER DE BLOG", $html);
            $html = str_replace("{LAST_FROM_NEWS}", "DERNIER DE NOUVELLES", $html);
            $html = str_replace("{CUSTOMER_SERVICE}", "SERVICE À LA CLIENTÈLE", $html);
            $html = str_replace("{contacts_linl}", "CONTACTEZ NOUS", $html);
            $html = str_replace("{We_promise}", "Nous nous engageons à vous envoyer que de bonnes choses", $html);
            break;
    }
}
function generate()
{
    $rand = mt_rand(00, 99999999);
    return $rand;
}
$html = str_replace("{generate}", generate(), $html);
$html = str_replace("{vendors_link}", vendors_link(), $html);
$html = str_replace("{types_link}", types_link(), $html);
$html = str_replace("{clear_cart}", "http://" . $_SERVER['HTTP_HOST'] . "/" . $_GET['lang'] . "/?clearcart=true", $html);
$html = str_replace("{host}", "http://" . $_SERVER['HTTP_HOST'], $html);
$html = str_replace("{lang}", $_GET['lang'], $html);
$html = str_replace("{popup_cart}", popup_cart(), $html);
$html = str_replace("{full_price}", $_SESSION['fullprice'], $html);
if ($_SESSION['fullprice']) {
    $html = str_replace("{popup_total}", "<span style='margin-left:16px;' class='pull-left'>total price</span> <element style='margin-right:16px;' class='pull-right'>" . $_SESSION['fullprice'] . " CHF</element><div class='clr'></div>", $html);
} else {
    $html = str_replace("{popup_total}", "totlal price <span class='badge ptotal'>0</span> CHF", $html);
}
echo $html;
开发者ID:siberex82,项目名称:nad,代码行数:31,代码来源:index.php

示例15: array

$vals = array($module_name, $module_human_name);
function generate($template, $dest, $keys, $vals)
{
    if (file_exists($dest)) {
        echo "{$dest} already exists.  Overwrite?  [Y/n]  ";
        $fp = fopen('php://stdin', 'r');
        $answer = trim(fgets($fp));
        fclose($fp);
        if (strcasecmp($answer, 'Y') && $answer) {
            return false;
        }
    }
    $tmpl = implode('', file($template));
    $tmpl = str_replace($keys, $vals, $tmpl);
    $fp = fopen($dest, "w") or exit(1);
    fputs($fp, $tmpl);
    fclose($fp);
    return true;
}
if (generate($genpath . '/templates/config.tpl.php', $module_dir . DS . 'config' . DS . 'config.php', $keys, $vals)) {
    echo "New Config:     {$module_dir}" . DS . 'config' . DS . "config.php\n";
}
if (generate($genpath . '/templates/urls.tpl.php', $module_dir . DS . 'config' . DS . 'urls.php', $keys, $vals)) {
    echo "New Config:     {$module_dir}" . DS . 'config' . DS . "urls.php\n";
}
if (generate($genpath . '/templates/page.tpl.php', $module_dir . DS . 'pages' . DS . 'page.php', $keys, $vals)) {
    echo "New Controller: {$module_dir}" . DS . 'pages' . DS . "page.php\n";
}
echo "\n";
echo "To enable this module, add it to the MODULES constant in config/config.php\n\n";
exit(0);
开发者ID:jvinet,项目名称:pronto,代码行数:31,代码来源:generate.php


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