本文整理汇总了PHP中RAND函数的典型用法代码示例。如果您正苦于以下问题:PHP RAND函数的具体用法?PHP RAND怎么用?PHP RAND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RAND函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateTempFilename
public static function generateTempFilename(&$tab_arqs, $path)
{
$list = 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');
$N = $list[rand(0, count($list) - 1)] . date('U') . $list[rand(0, count($list) - 1)] . RAND(12345, 9999999999.0) . $list[rand(0, count($list) - 1)] . $list[rand(0, count($list) - 1)] . RAND(12345, 9999999999.0) . '.tmp';
$aux = $path . '/' . $N;
array_push($tab_arqs, $aux);
return $aux;
}
示例2: addUser
public function addUser($firstName, $lastName, $email, $password)
{
$apikey = SHA1($email . $password . RAND() . time());
$stmt = $this->pdo->prepare("INSERT INTO `users` (`firstName`, `lastName`, `email`,`password`, `apikey`) VALUES (?, ?, ?, SHA1(?), ?)");
if ($stmt->execute(array($firstName, $lastName, $email, $password, $apikey))) {
return $this->pdo->lastInsertId();
} else {
return 0;
}
}
示例3: token
function token()
{
$str = "";
for ($i = 0; $i <= 10; $i++) {
//$str.=chr(RAND(1,100));
}
$str .= RAND(0, 9999999999999.0);
$_SESSION["x"] = $str;
return "üretilen değer:<br/>" . $str;
}
示例4: ImageSVG
function ImageSVG($data)
{
$this->svg_info = array();
// mPDF 4.4.006
if (preg_match('/<!ENTITY/si', $data)) {
// Get User-defined entities
preg_match_all('/<!ENTITY\\s+([a-z]+)\\s+\\"(.*?)\\">/si', $data, $ent);
// Replace entities
for ($i = 0; $i < count($ent[0]); $i++) {
$data = preg_replace('/&' . preg_quote($ent[1][$i], '/') . ';/is', $ent[2][$i], $data);
}
}
// mPDF 4.4.003
if (preg_match('/xlink:href=/si', $data)) {
// Get links
preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href=["\']#(.*?)["\'](.*?)\\/>/si', $data, $links);
if (count($links[0])) {
$links[5] = array();
}
// mPDF 4.5.010
// Delete links from data - keeping in $links
for ($i = 0; $i < count($links[0]); $i++) {
$links[5][$i] = 'tmpLink' . RAND(100000, 9999999);
// mPDF 4.5.010
$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', '<MYLINKS' . $links[5][$i] . '>', $data);
// mPDF 4.5.010
}
// Get targets
preg_match_all('/<(linearGradient|radialgradient)([^>]*)id=["\'](.*?)["\'](.*?)>(.*?)<\\/(linearGradient|radialgradient)>/si', $data, $m);
$targets = array();
$stops = array();
// keeping in $targets
for ($i = 0; $i < count($m[0]); $i++) {
$stops[$m[3][$i]] = $m[5][$i];
}
// Add back links this time as targets (gradients)
for ($i = 0; $i < count($links[0]); $i++) {
$def = $links[1][$i] . ' ' . $links[4][$i] . '>' . $stops[$links[3][$i]] . '</' . $links[2][$i] . '>';
// mPDF 4.5.010
$data = preg_replace('/<MYLINKS' . $links[5][$i] . '>/is', $def, $data);
// mPDF 4.5.010
}
}
// mPDF 4.4.003 - Removes <pattern>
$data = preg_replace('/<pattern.*?<\\/pattern>/is', '', $data);
// mPDF 4.4.003 - Removes <marker>
$data = preg_replace('/<marker.*?<\\/marker>/is', '', $data);
$this->svg_info['data'] = $data;
$this->svg_string = '';
//
// chargement unique des fonctions
if (!function_exists("xml_svg2pdf_start")) {
// mPDF 5.3.76
function xml_svg2pdf_start($parser, $name, $attribs)
{
//
// definition
global $svg_class, $last_gradid;
// mPDF 4.4.003
$svg_class->xbase = 0;
$svg_class->ybase = 0;
switch (strtolower($name)) {
// mPDF 5.0.039 - Don't output stuff inside <defs>
case 'defs':
$svg_class->inDefs = true;
return;
case 'svg':
$svg_class->svgOffset($attribs);
break;
case 'path':
$path = $attribs['d'];
// mPDF 4.4.003
preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([e ,\\-.\\d]+)*/', $path, $commands, PREG_SET_ORDER);
$path_cmd = '';
$svg_class->subPathInit = true;
// mPDF 4.4.003
// mPDF 5.0.039
$svg_class->pathBBox = array(999999, 999999, -999999, -999999);
foreach ($commands as $c) {
if (count($c) == 3 || $c[2] == '') {
list($tmp, $command, $arguments) = $c;
} else {
list($tmp, $command) = $c;
$arguments = '';
}
$path_cmd .= $svg_class->svgPath($command, $arguments);
}
// mPDF 5.0.039
if ($svg_class->pathBBox[2] == -1999998) {
$svg_class->pathBBox[2] = 100;
}
if ($svg_class->pathBBox[3] == -1999998) {
$svg_class->pathBBox[3] = 100;
}
if ($svg_class->pathBBox[0] == 999999) {
$svg_class->pathBBox[0] = 0;
}
if ($svg_class->pathBBox[1] == 999999) {
$svg_class->pathBBox[1] = 0;
}
//.........这里部分代码省略.........
示例5: ReadCSS
//.........这里部分代码省略.........
$tmpCSSstr = implode(' ', $CSSblock[1]);
$regexpem = '/(background[^;]*url\\s*\\(\\s*[\'\\"]{0,1})([^\\)\'\\"]*)([\'\\"]{0,1}\\s*\\))/si';
$xem = preg_match_all($regexpem, $tmpCSSstr, $cxtem);
if ($xem) {
for ($i = 0; $i < count($cxtem[0]); $i++) {
$embedded = $cxtem[2][$i];
if (!preg_match('/^data:image/i', $embedded)) {
// mPDF 5.5.13
//$this->mpdf->GetFullPath($embedded); /* Blue Liquid Designs Removed to allow both URL and PATHs to images */
$tmpCSSstr = preg_replace('/' . preg_quote($cxtem[0][$i], '/') . '/', $cxtem[1][$i] . $embedded . $cxtem[3][$i], $tmpCSSstr);
}
}
}
$CSSstr .= ' ' . $tmpCSSstr;
}
// Remove comments
$CSSstr = preg_replace('|/\\*.*?\\*/|s', ' ', $CSSstr);
$CSSstr = preg_replace('/[\\s\\n\\r\\t\\f]/s', ' ', $CSSstr);
if (preg_match('/@media/', $CSSstr)) {
preg_match_all('/@media(.*?)\\{(([^\\{\\}]*\\{[^\\{\\}]*\\})+)\\s*\\}/is', $CSSstr, $m);
for ($i = 0; $i < count($m[0]); $i++) {
if ($this->mpdf->CSSselectMedia && !preg_match('/(' . trim($this->mpdf->CSSselectMedia) . '|all)/i', $m[1][$i])) {
$CSSstr = preg_replace('/' . preg_quote($m[0][$i], '/') . '/', '', $CSSstr);
} else {
$CSSstr = preg_replace('/' . preg_quote($m[0][$i], '/') . '/', ' ' . $m[2][$i] . ' ', $CSSstr);
}
}
}
// Replace any background: url(data:image... with temporary image file reference
preg_match_all("/(url\\(data:image\\/(jpeg|gif|png);base64,(.*?)\\))/si", $CSSstr, $idata);
// mPDF 5.7.2
if (count($idata[0])) {
for ($i = 0; $i < count($idata[0]); $i++) {
$file = _MPDF_TEMP_PATH . '_tempCSSidata' . RAND(1, 10000) . '_' . $i . '.' . $idata[2][$i];
//Save to local file
file_put_contents($file, base64_decode($idata[3][$i]));
// $this->mpdf->GetFullPath($file); // ? is this needed - NO mPDF 5.6.03
$CSSstr = str_replace($idata[0][$i], 'url("' . $file . '")', $CSSstr);
// mPDF 5.5.17
}
}
$CSSstr = preg_replace('/(<\\!\\-\\-|\\-\\->)/s', ' ', $CSSstr);
if ($CSSstr) {
preg_match_all('/(.*?)\\{(.*?)\\}/', $CSSstr, $styles);
for ($i = 0; $i < count($styles[1]); $i++) {
// SET array e.g. $classproperties['COLOR'] = '#ffffff';
$stylestr = trim($styles[2][$i]);
$stylearr = explode(';', $stylestr);
foreach ($stylearr as $sta) {
if (trim($sta)) {
// Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
list($property, $value) = explode(':', $sta, 2);
$property = trim($property);
$value = preg_replace('/\\s*!important/i', '', $value);
$value = trim($value);
if ($property && ($value || $value === '0')) {
// Ignores -webkit-gradient so doesn't override -moz-
if ((strtoupper($property) == 'BACKGROUND-IMAGE' || strtoupper($property) == 'BACKGROUND') && preg_match('/-webkit-gradient/i', $value)) {
continue;
}
$classproperties[strtoupper($property)] = $value;
}
}
}
$classproperties = $this->fixCSS($classproperties);
$tagstr = strtoupper(trim($styles[1][$i]));
示例6: AdjustHTML
function AdjustHTML($html, $tabSpaces=8) {
//Try to make the html text more manageable (turning it into XHTML)
if (PHP_VERSION_ID < 50307) {
if (strlen($html) > 100000) {
if (PHP_VERSION_ID < 50200) $this->Error("The HTML code is more than 100,000 characters. You should use WriteHTML() with smaller string lengths.");
else ini_set("pcre.backtrack_limit","1000000");
}
}
/*-- ANNOTATIONS --*/
preg_match_all("/(<annotation.*?>)/si", $html, $m);
if (count($m[1])) {
for($i=0;$i<count($m[1]);$i++) {
$sub = preg_replace("/\n/si", "\xbb\xa4\xac", $m[1][$i]);
$html = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $html);
}
}
/*-- END ANNOTATIONS --*/
preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
if (count($svgi[0])) {
for($i=0;$i<count($svgi[0]);$i++) {
$file = _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.$i.'.svg';
//Save to local file
file_put_contents($file, $svgi[0][$i]);
$html = str_replace($svgi[0][$i], '<img src="'.$file.'" />', $html); // mPDF 5.5.18
}
}
//Remove javascript code from HTML (should not appear in the PDF file)
$html = preg_replace('/<script.*?<\/script>/is','',$html);
//Remove special comments
$html = preg_replace('/<!--mpdf/i','',$html);
$html = preg_replace('/mpdf-->/i','',$html);
//Remove comments from HTML (should not appear in the PDF file)
$html = preg_replace('/<!--.*?-->/s','',$html);
$html = preg_replace('/\f/','',$html); //replace formfeed by nothing
$html = preg_replace('/\r/','',$html); //replace carriage return by nothing
// Well formed XHTML end tags
$html = preg_replace('/<(br|hr)\/>/i',"<\\1 />",$html);
// Get rid of empty <thead></thead>
$html = preg_replace('/<thead>\s*<\/thead>/i','',$html);
$html = preg_replace('/<tfoot>\s*<\/tfoot>/i','',$html);
$html = preg_replace('/<table[^>]*>\s*<\/table>/i','',$html);
$html = preg_replace('/<tr>\s*<\/tr>/i','',$html);
// Remove spaces at end of table cells
$html = preg_replace("/[ \n\r]+<\/t(d|h)/",'</t\\1',$html); // mPDF 5.5.09
$html = preg_replace("/[ ]*<dottab\s*[\/]*>[ ]*/",'<dottab />',$html);
// Concatenates any Substitute characters from symbols/dingbats
$html = str_replace('</tts><tts>','|',$html);
$html = str_replace('</ttz><ttz>','|',$html);
$html = str_replace('</tta><tta>','|',$html);
$html = preg_replace('/<br \/>\s*/is',"<br />",$html);
$html = preg_replace('/<wbr[ \/]*>\s*/is',"­",$html); // mPDF 5.6.04
// Preserve '\n's in content between the tags <pre> and </pre>
if (preg_match('/<pre/',$html)) {
$html_a = preg_split('/(\<\/?pre[^\>]*\>)/', $html, -1, 2);
$h = array();
$c=0;
foreach($html_a AS $s) {
if ($c>1 && preg_match('/^<\/pre/i',$s)) { $c--; $s=preg_replace('/<\/pre/i','</innerpre',$s); }
else if ($c>0 && preg_match('/^<pre/i',$s)) { $c++; $s=preg_replace('/<pre/i','<innerpre',$s); }
else if (preg_match('/^<pre/i',$s)) { $c++; }
else if (preg_match('/^<\/pre/i',$s)) { $c--; }
array_push($h, $s);
}
$html = implode("", $h);
}
$thereispre = preg_match_all('#<pre(.*?)>(.*?)</pre>#si',$html,$temp);
// Preserve '\n's in content between the tags <textarea> and </textarea>
$thereistextarea = preg_match_all('#<textarea(.*?)>(.*?)</textarea>#si',$html,$temp2);
$html = preg_replace('/[\n]/',' ',$html); //replace linefeed by spaces
$html = preg_replace('/[\t]/',' ',$html); //replace tabs by spaces
// Converts < to < when not a tag
$html = preg_replace('/<([^!\/a-zA-Z])/i','<\\1',$html);
$html = preg_replace("/[ ]+/",' ',$html);
$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',$html);
$html = preg_replace('/\/(u|o)l>\s+<\/li/i','/\\1l></li',$html);
$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',$html);
$html = preg_replace('/\/li>\s+<li/i','/li><li',$html);
$html = preg_replace('/<(u|o)l([^>]*)>[ ]+/i','<\\1l\\2>',$html);
$html = preg_replace('/[ ]+<(u|o)l/i','<\\1l',$html);
$iterator = 0;
while($thereispre) //Recover <pre attributes>content</pre>
{
$temp[2][$iterator] = preg_replace("/^([^\n\t]*?)\t/me", "stripslashes('\\1') . str_repeat(' ', ( $tabSpaces - (mb_strlen(stripslashes('\\1')) % $tabSpaces)) )",$temp[2][$iterator]);
$temp[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp[2][$iterator]);
//.........这里部分代码省略.........
示例7: ImageSVG
function ImageSVG($data)
{
// Try to clean up the start of the file
// removing DOCTYPE fails with this:
/*
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd"
[
<!ELEMENT Paragraph (#PCDATA)>
]>
*/
//$data = preg_replace('/<!DOCTYPE.*? >/is', '', $data);
//$data = preg_replace('/<\?xml.*? >/is', '', $data);
$data = preg_replace('/^.*?<svg([> ])/is', '<svg\\1', $data);
// mPDF 5.7.4
$data = preg_replace('/<!--.*?-->/is', '', $data);
// mPDF 5.7.4
// Converts < to < when not a tag
$data = preg_replace('/<([^!?\\/a-zA-Z_:])/i', '<\\1', $data);
// mPDF 5.7.4
if (_SVG_AUTOFONT) {
$data = $this->markScriptToLang($data);
}
$this->svg_info = array();
$last_gradid = '';
// mPDF 6
$last_svg_fontid = '';
// mPDF 6
$last_svg_fontdefw = '';
// mPDF 6
$last_svg_fontstyle = '';
// mPDF 6
if (preg_match('/<!ENTITY/si', $data)) {
// Get User-defined entities
preg_match_all('/<!ENTITY\\s+([a-z]+)\\s+\\"(.*?)\\">/si', $data, $ent);
// Replace entities
for ($i = 0; $i < count($ent[0]); $i++) {
$data = preg_replace('/&' . preg_quote($ent[1][$i], '/') . ';/is', $ent[2][$i], $data);
}
}
if (preg_match('/xlink:href\\s*=/si', $data)) {
// GRADIENTS
// Get links
preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href\\s*=\\s*["\']#(.*?)["\'](.*?)\\/>/si', $data, $links);
if (count($links[0])) {
$links[5] = array();
}
// Delete links from data - keeping in $links
for ($i = 0; $i < count($links[0]); $i++) {
$links[5][$i] = 'tmpLink' . RAND(100000, 9999999);
$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', '<MYLINKS' . $links[5][$i] . '>', $data);
}
// Get targets
preg_match_all('/<(linearGradient|radialgradient)([^>]*)id\\s*=\\s*["\'](.*?)["\'](.*?)>(.*?)<\\/(linearGradient|radialgradient)>/si', $data, $m);
$targets = array();
$stops = array();
// keeping in $targets
for ($i = 0; $i < count($m[0]); $i++) {
$stops[$m[3][$i]] = $m[5][$i];
}
// Add back links this time as targets (gradients)
for ($i = 0; $i < count($links[0]); $i++) {
$def = $links[1][$i] . ' ' . $links[4][$i] . '>' . $stops[$links[3][$i]] . '</' . $links[2][$i] . '>';
$data = preg_replace('/<MYLINKS' . $links[5][$i] . '>/is', $def, $data);
}
// mPDF 5.7.4
// <TREF>
preg_match_all('/<tref ([^>]*)xlink:href\\s*=\\s*["\']#([^>]*?)["\']([^>]*)\\/>/si', $data, $links);
for ($i = 0; $i < count($links[0]); $i++) {
// Get the item to use from defs
$insert = '';
if (preg_match('/<text [^>]*id\\s*=\\s*["\']' . $links[2][$i] . '["\'][^>]*>(.*?)<\\/text>/si', $data, $m)) {
$insert = $m[1];
}
if ($insert) {
$data = preg_replace('/' . preg_quote($links[0][$i], '/') . '/is', $insert, $data);
}
}
// mPDF 5.7.2
// <USE>
preg_match_all('/<use ([^>]*)xlink:href\\s*=\\s*["\']#([^>]*?)["\']([^>]*)\\/>/si', $data, $links);
for ($i = 0; $i < count($links[0]); $i++) {
// Get the item to use from defs
$insert = '';
if (preg_match('/<([a-zA-Z]*) [^>]*id\\s*=\\s*["\']' . $links[2][$i] . '["\'][^>]*\\/>/si', $data, $m)) {
$insert = $m[0];
}
if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\\s*=\\s*["\']' . $links[2][$i] . '["\']/si', $data, $m)) {
if (preg_match('/<' . $m[1] . '[^>]*id\\s*=\\s*["\']' . $links[2][$i] . '["\'][^>]*>.*?<\\/' . $m[1] . '>/si', $data, $m)) {
$insert = $m[0];
}
}
if ($insert) {
$inners = $links[1][$i] . ' ' . $links[3][$i];
// Change x,y coords to translate()
if (preg_match('/y\\s*=\\s*["\']([^>]*?)["\']/', $inners, $m)) {
$y = $m[1];
} else {
$y = 0;
}
if (preg_match('/x\\s*=\\s*["\']([^>]*?)["\']/', $inners, $m)) {
//.........这里部分代码省略.........
示例8: contact_bank_dynamic_settings_form
$control_settings = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . contact_bank_dynamic_settings_form() . " WHERE dynamicId = %d", $form_fields[$flag]->control_id));
for ($flag1 = 0; $flag1 < count($control_settings); $flag1++) {
$column_dynamicId = $form_fields[$flag]->column_dynamicId;
$control_settings_array[$column_dynamicId][$control_settings[$flag1]->dynamic_settings_key] = $control_settings[$flag1]->dynamic_settings_value;
}
}
$form_settings = $wpdb->get_results($wpdb->prepare("SELECT form_message_key,form_message_value FROM " . contact_bank_form_settings_Table() . " WHERE form_id = %d", $form_id));
for ($flag2 = 0; $flag2 < count($form_settings); $flag2++) {
$form_settings_array[$form_id][$form_settings[$flag2]->form_message_key] = $form_settings[$flag2]->form_message_value;
}
$forms_layout_settings = $wpdb->get_results($wpdb->prepare("SELECT form_settings_key,form_settings_value FROM " . contact_bank_layout_settings_Table() . " WHERE form_id = %d", $form_id));
for ($flag3 = 0; $flag3 < count($forms_layout_settings); $flag3++) {
$layout_settings_array[$form_id][$forms_layout_settings[$flag3]->form_settings_key] = $forms_layout_settings[$flag3]->form_settings_value;
}
$forms_email_settings = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . contact_bank_email_template_admin() . " WHERE form_id = %d", $form_id));
$rand_value = RAND(10, 10000);
?>
<div class="cb_form_wrapper" id="cb_form_wrapper_<?php
echo $form_id;
?>
">
<form id="ux_frm_front_end_form_<?php
echo $form_id . "_" . $rand_value;
?>
" class="form-horizontal" method="post" action="#">
<div id="form_success_message_frontend_<?php
echo $rand_value;
?>
" class="custom-message success_message" style="display: none;margin-bottom: 10px;">
<span class="sucess_message_text" >
示例9: RAND
include_once '../Template/Header.php';
?>
<div id="body" class="section">
<div class="content-box">
<h2>
<?php
echo $title;
?>
</h2>
<h3> Description : </h3>
<p>
Creating an array os months and an array of moons, using a random number generator to get a random month and its corresponding moon.
</p>
<p>
<?php
$rand_num = RAND(0, 11);
?>
<table>
<tr>
<td>
Month
</td>
<td>
Moon
</td>
</tr>
<tr>
<td>
<?php
echo $months[$rand_num];
?>
示例10: rand
$morehits = 400 - $alexahitstoday;
}
if ($alexahitstoday >= 400) {
$bonus = 30;
$morehits = -1;
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlexaToolbar') !== false) {
$iminstalled = 1;
} else {
$iminstalled = 0;
}
$randclicker = rand(1, 4);
$siteurlll = "http://likesplanet.com/?reff" . rand(1, 1000);
$backlinksdata0 = mysql_query("SELECT * FROM `alexagoogle` WHERE (`points` > '0') ORDER BY RAND() LIMIT 0, 1 ");
$verificareNum = mysql_num_rows($backlinksdata0);
$randommmi = RAND(1, 100);
if ($verificareNum == 1 && $randommmi >= 25) {
$backlinksdata = mysql_fetch_object($backlinksdata0);
$siteurlll = $backlinksdata->url;
mysql_query("UPDATE `alexagoogle` SET `traffic`=`traffic`+'1', `traffic_total`=`traffic_total`+'1', `points`=`points`-'1' WHERE (`id` = '{$backlinksdata->id}') ");
} else {
$surff10 = mysql_query("SELECT * FROM `surf` WHERE (`active` = '0' AND `points` > '0') ORDER BY RAND() DESC LIMIT 0, 1");
$extb = mysql_num_rows($surff10);
if ($extb == 1 && $randommmi >= 25) {
$backlinksdata2 = mysql_fetch_object($surff10);
$siteurlll = $backlinksdata2->surf;
mysql_query("UPDATE `surf` SET `total`=`total`+'1' WHERE `id`='{$backlinksdata2->id}'");
if ($randommmi >= 50) {
mysql_query("UPDATE `surf` SET `likes`=`likes`+'1', `points`=`points`-'0.25' WHERE `id`='{$backlinksdata2->id}'");
}
unset($backlinksdata);
示例11: _convImage
//.........这里部分代码省略.........
}
}
else { // Indexed
$pos = strpos($t,chr(0));
if (is_int($pos)) {
$pal = imagecolorsforindex($im, $pos);
$r = $pal['red'];
$g = $pal['green'];
$b = $pal['blue'];
$trns=array($r,$g,$b); // ****
$trnsrgb = $trns;
if ($targetcs=='DeviceCMYK') {
$col = $this->rgb2cmyk(array(3,$r,$g,$b));
$c1 = intval($col[1]*2.55);
$c2 = intval($col[2]*2.55);
$c3 = intval($col[3]*2.55);
$c4 = intval($col[4]*2.55);
$trns = array($c1,$c2,$c3,$c4);
}
else if ($targetcs=='DeviceGray') {
$c = intval(($r * .21) + ($g * .71) + ($b * .07));
$trns = array($c);
}
}
}
}
}
for ($i = 0; $i < $h; $i++) {
for ($j = 0; $j < $w; $j++) {
$rgb = imagecolorat($im, $j, $i);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if ($colspace=='Indexed') {
$pal = imagecolorsforindex($im, $rgb);
$r = $pal['red'];
$g = $pal['green'];
$b = $pal['blue'];
}
if ($targetcs=='DeviceCMYK') {
$col = $this->rgb2cmyk(array(3,$r,$g,$b));
$c1 = intval($col[1]*2.55);
$c2 = intval($col[2]*2.55);
$c3 = intval($col[3]*2.55);
$c4 = intval($col[4]*2.55);
if ($trnsrgb) {
// original pixel was not set as transparent but processed color does match
if ($trnsrgb!=array($r,$g,$b) && $trns==array($c1,$c2,$c3,$c4)) {
if ($c4==0) { $c4=1; } else { $c4--; }
}
}
$imgdata .= chr($c1).chr($c2).chr($c3).chr($c4);
}
else if ($targetcs=='DeviceGray') {
$c = intval(($r * .21) + ($g * .71) + ($b * .07));
if ($trnsrgb) {
// original pixel was not set as transparent but processed color does match
if ($trnsrgb!=array($r,$g,$b) && $trns==array($c)) {
if ($c==0) { $c=1; } else { $c--; }
}
}
$imgdata .= chr($c);
}
else if ($targetcs=='DeviceRGB') {
$imgdata .= chr($r).chr($g).chr($b);
}
if ($mask) {
// mPDF 5.7.2 Gamma correction
$alpha = ($rgb & 0x7F000000) >> 24;
if ($alpha < 127) { $mimgdata .= chr(255-($alpha * 2)); }
else { $mimgdata .= chr(0); }
}
}
}
if ($targetcs=='DeviceGray') { $ncols = 1; }
else if ($targetcs=='DeviceRGB') { $ncols = 3; }
else if ($targetcs=='DeviceCMYK') { $ncols = 4; }
$imgdata = gzcompress($imgdata);
$info = array('w'=>$w,'h'=>$h,'cs'=>$targetcs,'bpc'=>8,'f'=>'FlateDecode','data'=>$imgdata, 'type'=>'png',
'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
if ($dpi) { $info['set-dpi'] = $dpi; }
if ($mask) {
$mimgdata = gzcompress($mimgdata);
$minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png',
'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
if ($dpi) { $minfo['set-dpi'] = $dpi; }
$tempfile = '_tempImgPNG'.md5($file).RAND(1,10000).'.png';
$imgmask = count($this->images)+1;
$minfo['i']=$imgmask ;
$this->images[$tempfile] = $minfo;
$info['masked'] = $imgmask;
}
else if ($trns) { $info['trns'] = $trns; }
imagedestroy($im);
}
return $info;
}
示例12: sbscrbr_register_user
function sbscrbr_register_user($user_id)
{
global $wpdb;
$prefix = is_multisite() ? $wpdb->base_prefix : $wpdb->prefix;
$wpdb->update($prefix . 'sndr_mail_users_info', array('unsubscribe_code' => MD5(RAND()), 'subscribe_time' => time()), array('id_user' => $user_id));
}
示例13: postRelacionados
/**
* @funcionalidad obtenemos los post relacionados a partir del título
* @param type obtenemos el texto del post a partir del cuál comparar
* @return type devolvemos un array con los datos obtenidos
*/
function postRelacionados($dato)
{
global $psDb, $psCore, $psUser;
$consulta = "SELECT p.post_id, p.post_title, c.c_seo FROM p_posts AS p LEFT JOIN u_miembros AS u ON u.user_id = p.post_user LEFT JOIN p_categorias AS c ON c.cid = p.post_category WHERE p.post_status = :status ";
$valores['status'] = 0;
if (!$psUser->admod && $psCore->settings['c_see_mod'] != 1) {
$consulta .= 'AND u.user_activo = :activo AND u.user_baneado = :ban';
$valores['activo'] = 1;
$valores['ban'] = 0;
}
$consulta .= " AND MATCH(p.post_title) AGAINST(:dato IN BOOLEAN MODE) ORDER BY :rand DESC";
$valores['dato'] = $dato;
$valores['rand'] = RAND();
$datos = $psDb->resultadoArray($psDb->db_execute($consulta, $valores));
return $datos;
}
示例14: header
header("Content-type: application/json; charset=utf-8");
$con = new mysqli("localhost", "root", "trinity1346", "kichwa2");
if ($con->connect_errno) {
die("Connection failed:" . $con->connect_error);
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
//DEFINING VARIABLES
$nuevo_grados = array();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
//mayor porejemplo
$scale_name = $request->nombre;
$scale_grades = $request->grados;
//$scale_origin=$request->origin;
//$scale_id=FLOOR(RAND() * 4001);
$scale_id = FLOOR(RAND() * 4001);
//var_dump($scale_name);
//var_dump($scale_id);
//first to find the scale
$insert_scale_name_query = "INSERT INTO numeros(numero_id,numero_name) VALUES('{$scale_id}','{$scale_name}')";
if ($con->query($insert_scale_name_query) === TRUE) {
echo "inserted id:" . $scale_id . " scale_name: " . $scale_name . "\n";
} else {
echo "Error: " . $insert_scale_name_query . "<br>" . $con->error . "\n";
}
foreach ($scale_grades as $index => $value) {
if ((int) $value >= (int) 10) {
$nuevo_grados[$index] = "C0" . $value;
} else {
$nuevo_grados[$index] = "C00" . $value;
}
示例15: mysqli_connect
<!--link to Search-->
<li><a href="Dinos_Search.php">Search</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div> <!-- end navigation bar-->
<!-- In order to access the information, we have the login and opening of the connection -->
<?php
$host = "localhost";
$user = "dino";
$password = "dinosaur";
$database = "dino";
$link = mysqli_connect($host, $user, $password, $database);
//Randomize the information pulled but make sure it is all associated; some is hidden for verifying the correct answer
$rand = RAND(1, 25);
//only relevant data pulled from the database; Laura determined which ones apply to this question
$input = array("1", "4", "7", "12", "9", "13", "17", "21", "25");
$rand_key = array_rand($input);
$randtax = $input[$rand_key];
//our retrieved data from our tables
//since this website will be used in the future, certain changes to what is displayed for the flashcards such as hints or dinosaur names could be included
$searchq = "SELECT dinotaxon.dinotaxon_id, dinosaur.dinosaur_id, dinosaur.dinosaur_name, dinosaur.image_url, taxon.taxon_id, taxon.taxon, dinotaxon.prime FROM dinotaxon, dinosaur, \ntaxon WHERE dinosaur.dinosaur_id=dinotaxon.dinosaur_id AND dinotaxon.taxon_id=taxon.taxon_id AND taxon.taxon_id LIKE (?) GROUP BY dinosaur.dinosaur_id ORDER BY RAND()";
$listresult = mysqli_prepare($link, $searchq);
// Below command binds variables for the parameter markers in the SQL statement that was passed to above command
//corresponding variable type string so use letter s
mysqli_stmt_bind_param($listresult, 's', $randtax);
mysqli_stmt_bind_result($listresult, $dinotaxon_id, $dinosaur_id, $dinosaur_name, $image_url, $taxon_id, $taxon, $prime);
mysqli_stmt_execute($listresult);
// Once it is prepared and determined to be correct, then it can be executed
//The above protects this page from mysqli injections