本文整理汇总了PHP中generateId函数的典型用法代码示例。如果您正苦于以下问题:PHP generateId函数的具体用法?PHP generateId怎么用?PHP generateId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generateId函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DoUpload
function DoUpload($n, $p, $u, $i, $a, $m, $ai)
{
$ret = "";
$str = "";
if ($m == 1) {
// update
$db = openConnection();
$sql = "update root_tools_recommand set name='{$n}',icon_url='{$i}',download_url='{$a}' where package_name='{$p}'";
$str = query($db, $sql);
closeConnection($db);
} else {
// add
$id = generateId("root_tools_recommand", "id");
$db = openConnection();
$sql = "insert into root_tools_recommand (id, name, package_name, main_activity, icon_url, download_url, unix_name, app_order) values ({$id}, '{$n}', '{$p}', 'null', '{$i}', '{$a}', '{$u}', 0)";
$str = query($db, $sql);
closeConnection($db);
}
if ($str == "0") {
$ret = "1";
} else {
$ret = "0";
}
return $ret;
}
示例2: uploadImage
/**
* Insert image data to database (recoreded_data and thumbnail).
* First generate an unique image id, then insert image to recoreded_data and resized image to thubnail along with
* other given data
*/
function uploadImage($conn, $sensor_id, $date_created, $description)
{
$image_id = generateId($conn, "images");
if ($image_id == 0) {
return;
}
$image2 = file_get_contents($_FILES['file_image']['tmp_name']);
$image2tmp = resizeImage($_FILES['file_image']);
$image2Thumbnail = file_get_contents($image2tmp['tmp_name']);
// encode the stream
$image = base64_encode($image2);
$imageThumbnail = base64_encode($image2Thumbnail);
$sql = "INSERT INTO images (image_id, sensor_id, date_created, description, thumbnail, recoreded_data)\n VALUES(" . $image_id . ", " . $sensor_id . ", TO_DATE('" . $date_created . "', 'DD/MM/YYYY hh24:mi:ss'), '" . $description . "', empty_blob(), empty_blob())\n RETURNING thumbnail, recoreded_data INTO :thumbnail, :recoreded_data";
$result = oci_parse($conn, $sql);
$recoreded_dataBlob = oci_new_descriptor($conn, OCI_D_LOB);
$thumbnailBlob = oci_new_descriptor($conn, OCI_D_LOB);
oci_bind_by_name($result, ":recoreded_data", $recoreded_dataBlob, -1, OCI_B_BLOB);
oci_bind_by_name($result, ":thumbnail", $thumbnailBlob, -1, OCI_B_BLOB);
$res = oci_execute($result, OCI_DEFAULT) or die("Unable to execute query");
if ($recoreded_dataBlob->save($image) && $thumbnailBlob->save($imageThumbnail)) {
oci_commit($conn);
} else {
oci_rollback($conn);
}
oci_free_statement($result);
$recoreded_dataBlob->free();
$thumbnailBlob->free();
echo "New image is added with image_id ->" . $image_id . "<br>";
}
示例3: showPollOptions
function showPollOptions($options, $alreadyVoted, $totalVoted, $polid)
{
if ($alreadyVoted) {
$maxVoted = $totalVoted;
foreach ($options as $optData) {
$maxVoted = $optData["polOVotes"];
break;
}
foreach ($options as $optData) {
?>
<table cellspacing="0" cellpadding="0" border="0"><tr>
<td class="wide">
<?php
echo formatText($optData["polOOption"]);
?>
</td>
<td class="smalltext disable_wrapping" style="vertical-align: bottom">
(<?php
echo fuzzy_number($optData["polOVotes"]);
?>
)
</td>
</tr></table>
<?php
showPollBar($optData["polOVotes"], $maxVoted, $totalVoted);
}
} else {
$options = array();
$result2 = sql_query("SELECT * FROM `pollOptions` " . "WHERE `polOPoll` = '" . $polid . "' ORDER BY `polOid` LIMIT 20");
while ($optData = mysql_fetch_assoc($result2)) {
$options[$optData["polOid"]] = $optData;
}
foreach ($options as $optData) {
?>
<div>
<input class="checkbox" type="checkbox" id="<?php
echo $chkid = generateId();
?>
" name="option<?php
echo $optData["polOid"];
?>
" />
<label for="<?php
echo $chkid;
?>
">
<?php
echo formatText($optData["polOOption"]);
?>
</label>
</div>
<?php
}
}
}
示例4: doLog
function doLog($d, $m, $o, $mail, $b, $action)
{
$nid = generateId("root_tools_log", "id");
date_default_timezone_set("Asia/Hong_Kong");
$sql = "insert into root_tools_log values ('" . $nid . "', '" . $d . "', '" . $m . "', '" . $o . "', '" . $mail . "', '" . $b . "', '" . $action . "', '" . date("Y-m-d h:i a") . "')";
$db = openConnection();
$str = query($db, $sql);
closeConnection($db);
$str = "{\"result\":\"" . $str . "\"}";
return $str;
}
示例5: doLog
function doLog($d, $m, $o, $mail, $b, $comment, $app)
{
$nid = generateId("root_tools_feedback", "id");
date_default_timezone_set("Asia/Hong_Kong");
$sql = "insert into root_tools_feedback(id,deviceId,module,os_version,mail,build_desc,comment,comment_time,app_version) values ('" . $nid . "', '" . $d . "', '" . $m . "', '" . $o . "', '" . $mail . "', '" . $b . "', '" . $comment . "', '" . date("Y-m-d h:i a") . "', '{$app}')";
$db = openConnection();
$str = query($db, $sql);
closeConnection($db);
$str = "{\"result\":\"" . $str . "\"}";
return $str;
}
示例6: doLog
function doLog($d, $m, $o, $mail, $b, $crash, $a)
{
$nid = generateId("root_tools_crash", "id");
date_default_timezone_set("Asia/Hong_Kong");
$sql = "insert into root_tools_crash values ('{$nid}', '{$d}', '{$m}', '{$o}', '{$mail}', '{$b}', '{$crash}', '" . date("Y-m-d h:i a") . "', '{$a}')";
$db = openConnection();
$str = query($db, $sql);
closeConnection($db);
$str = "{\"result\":\"" . $str . "\"}";
return $str;
}
示例7: generateId
function generateId()
{
$ci =& get_instance();
$ci->load->database();
$id = rand(1, 999);
$query = $ci->db->query("select * from berita where id_berita='{$id}'");
if ($query->num_rows > 1) {
generateId();
} else {
return $id;
}
}
示例8: generateFlipBox
function generateFlipBox($atts, $content = null)
{
$effects = array('right' => array('my-page-item-right', 'back-side-item-right'), 'left' => array('my-page-item-left', 'back-side-item-left'), 'up' => array('my-page-item-up', 'back-side-item-up'), 'down' => array('my-page-item-down', 'back-side-item-down'));
extract(shortcode_atts(array('style' => 'style1', 'id' => 0, 'content' => '', 'font_color' => '', 'effect' => 'right', 'title' => '', 'front_content' => '', 'back_title' => '', 'back_content' => '', 'link_text' => '', 'link' => '', 'color_front' => '', 'color_back' => '', 'border_color_front' => '', 'border_color_back' => '', 'front_text_color' => '', 'back_text_color' => '', 'circle_color' => '', 'link_color' => '', 'link_text_color' => ''), $atts));
$postId = 0;
if ($id != 0) {
$imgObj = wp_get_attachment_image_src($id, 'full');
// var_dump($imgObj);
$imgSrc = $imgObj[0];
} else {
$imgSrc = '' . plugins_url() . '/motoPostStyler/img/xparty1.png.pagespeed.ic.UyqFIK62E3.webp';
}
$flipBoxStructure = new FlipBoxStructure();
$chosenEffect = $effects[$effect];
$arguments = array('style' => $style, 'imgSrc' => $imgSrc, 'content' => $content, 'font_color' => $font_color, 'effect' => $chosenEffect, 'title' => $title, 'front_content' => $front_content, 'back_title' => $back_title, 'back_content' => $back_content, 'link_text' => $link_text, 'link' => $link, 'color_front' => $color_front, 'color_back' => $color_back, 'border_color_front' => $border_color_front, 'border_color_back' => $border_color_back, 'front_text_color' => $front_text_color, 'back_text_color' => $back_text_color, 'circle_color' => $circle_color, 'link_color' => $link_color, 'link_text_color' => $link_text_color);
// var_dump($arguments['link_color']);
$boxId = generateId($style, $content, $imgSrc, $color_front, $color_back, $font_color);
return $flipBoxStructure->generateFlipBoxLayout($arguments, $boxId);
}
示例9: save
public function save()
{
$this->form_validation->set_rules('judul', 'Judul', 'trim|required|xss_clean');
$this->form_validation->set_rules('editor1', 'Isi', 'trim|required|xss_clean');
if ($this->form_validation->run() == false) {
redirect('post/add');
} else {
if ($this->input->post('submit') == 'update') {
$id = $this->input->post('id');
$data = array('judul' => $this->input->post('judul'), 'isi_berita' => $this->input->post('editor1'), 'tanggal' => date('Y-m-d H:i:s'));
$result = $this->M_post->update($data, $id);
} elseif ($this->input->post('submit') == 'tambah') {
$data = array('id_berita' => generateId(), 'judul' => $this->input->post('judul'), 'isi_berita' => $this->input->post('editor1'), 'tanggal' => date('Y-m-d H:i:s'));
$result = $this->M_post->save($data);
}
if ($result) {
redirect('post');
}
}
}
示例10: doAddRecommand
function doAddRecommand($n, $jm, $ju, $jt, $img, $qr)
{
$extend = get_extend($img["name"]);
if ($extend === "") {
return "0";
}
$filename = "file_" . date("YYmmddhhiiss") . "." . $extend;
move_uploaded_file($img["tmp_name"], "./recommand/" . $filename);
$qr_extend = get_extend($qr["name"]);
$qr_filename = "";
if ($qr_extend != "") {
$qr_filename = "qr_" . date("YYmmddhhiiss") . "." . $qr_extend;
move_uploaded_file($qr["tmp_name"], "./recommand/" . $qr_filename);
}
$id = generateId("yugioh_recommand", "id");
$sql = "insert into yugioh_recommand (id,name,jump_mode,jump_url,jump_text,image_name,big_qr) values ({$id},'{$n}',{$jm},'{$ju}','{$jt}','{$filename}','{$qr_filename}')";
$db = openConnection();
$result = query($db, $sql);
closeConnection($db);
return $result;
}
示例11: addTask
function addTask($name, $description = "")
{
global $TASKS_DIR;
if (!findTask($name)) {
$id = generateId();
$date = date("Y-m-d");
$task = new stdClass();
$task->id = $id;
$task->nome = $name;
$task->descricao = $description;
$task->concluida = false;
$task->criacao = $date;
$task->modificada = $date;
try {
writeJson("{$TASKS_DIR}/{$id}.json", $task);
} catch (Exception $e) {
echo "Erro ao serializar";
echo $e;
return false;
}
return $task;
}
return false;
}
示例12: pyBoxHandler
function pyBoxHandler($options, $content)
{
//echo "PB[[[".$content."]]]";
// given a shortcode, print out the html for the user,
// and save the relevant grader options in a hash file.
$id = generateId();
if ($options == FALSE) {
$options = array();
}
// wordpress does a weird thing where valueless
for ($i = 0; array_key_exists($i, $options); $i++) {
// attributes map like [0]=>'attname'.
$options[$options[$i]] = "Y";
// these lines change it to
unset($options[$i]);
// 'attname'=>'Y'
}
$shortcodeOptions = json_encode($options);
// this will be put into DB.
/// do some cleaning-up and preprocessing of options, and create the problem info for grader
if (array_key_exists('translate', $options)) {
$GLOBALS['pb_translation'] = $options['translate'];
}
if (array_key_exists('pyexample', $options)) {
setSoft($options, 'grader', '*nograder*');
setSoft($options, 'readonly', 'Y');
setSoft($options, 'hideemptyinput', 'Y');
unset($options['pyexample']);
}
if (array_key_exists('code', $options)) {
// sugar: code is an alias for defaultcode
$options["defaultcode"] = $options["code"];
unset($options['code']);
}
$richreadonly = array_key_exists('richreadonly', $options);
// sugar
if ($richreadonly) {
$options['readonly'] = "Y";
unset($options['richreadonly']);
}
if (array_key_exists('nograder', $options)) {
// syntactic sugar for nograder option
if (array_key_exists('grader', $options)) {
pyboxlog('Warning: grader overwritten with *nograder*');
}
$options["grader"] = "*nograder*";
unset($options['nograder']);
}
foreach ($options as $optname => $optvalue) {
// syntactic sugar for inplace grader
if (preg_match('|tests|', $optname) > 0 || preg_match('|precode|', $optname) > 0) {
$options["inplace"] = "Y";
}
}
global $post, $lesson_reg_info;
// $lessonNumber is numeric (major) part of lesson number
// if lesson_reg_info is set we don't really care about displaying the pybox,
// but we'll do things for consistency anyway. NB: when displaying a problem
// in a place other than its original page (e.g., mail) this needs ot be fixed
$post_title = isset($lesson_reg_info) ? get_the_title($lesson_reg_info['id']) : $post->post_name;
if (preg_match('|^(\\d+).*|', $post_title, $matches) == 0) {
$lessonNumber = -1;
} else {
$lessonNumber = $matches[1];
}
$inplace = booleanize(getSoft($options, 'inplace', 'N'));
$scramble = booleanize(getSoft($options, 'scramble', 'N'));
// important booleans used to determine
$readonly = booleanize(getSoft($options, 'readonly', 'N'));
// other options... get them first
$showEditorToggle = booleanize(getSoft($options, 'showeditortoggle', 'N'));
unset($options['scramble']);
unset($options['readonly']);
// don't extract() these!
unset($options['inplace']);
if ($inplace) {
setSoft($options, 'hideemptyoutput', 'Y');
}
$defaultValues = array('defaultcode' => FALSE, 'autocommentline' => $lessonNumber > 3 && !($scramble || $readonly), 'console' => 'N', 'rows' => 10, 'allowinput' => $lessonNumber > 5 && !$scramble && !$readonly, 'disablericheditor' => ($lessonNumber > -1 && $lessonNumber < 7 || $scramble || $readonly) && !$richreadonly, 'usertni' => $inplace);
foreach ($defaultValues as $key => $value) {
if (!array_key_exists($key, $options)) {
$options[$key] = $defaultValues[$key];
}
}
extract($options);
$allowinput = booleanize($allowinput);
$disablericheditor = booleanize($disablericheditor);
$console = booleanize($console);
$autocommentline = booleanize($autocommentline);
$usertni = booleanize($usertni);
$facultative = isset($grader) && $grader == '*nograder*' || $console || $readonly;
if ($scramble || $readonly) {
$options['nolog'] = 'Y';
}
// for grader. note that if they are absent, their default values are 'N'
if ($facultative) {
$options['facultative'] = 'Y';
} else {
unset($options['facultative']);
}
//.........这里部分代码省略.........
示例13: showKeywordSubcat
function showKeywordSubcat($keywords, $parentId = 0, $parentKeyName = "", $parentLastKeyName = "")
{
global $requiredTabs, $firstKeywordId, $isInHeader, $previousFullname;
$noSubcats = true;
foreach ($keywords as $keyData) {
if (isset($keyData["subcats"])) {
$noSubcats = false;
break;
}
}
if ($parentLastKeyName != "") {
writeKeywordData(KWD_APP_HEADER, array("caption" => getKeywordCaption($parentLastKeyName)));
}
foreach ($keywords as $keyData) {
$tabid = generateId("");
$nonSelectable = preg_match('/\\@$/', $keyData["keyWord"]);
$keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
$keyWord = htmlspecialchars($keyData["keyWord"]);
if (!$firstKeywordId && $isInHeader) {
$firstKeywordId = "kwcache_tab" . $tabid;
}
$nameArr = preg_split('/\\"/', $parentKeyName . $keyWord, -1, PREG_SPLIT_NO_EMPTY);
$fullname = "'";
$first = true;
foreach ($nameArr as $name1) {
if ($name1 == $keyWord) {
continue;
}
$fullname .= ($first ? "" : ",") . getKeywordCaption($name1);
$first = false;
}
$fullname .= "'";
/*
if($fullname == $previousFullname)
$fullname = "";
else
$previousFullname = $fullname;
*/
$keywordSpace = $parentId != 0 && !$noSubcats ? 1 : 0;
// If it contains sub-keywords, display as tab.
if (isset($keyData["subcats"])) {
$params = array("keyword_space" => $keywordSpace, "id" => $tabid, "group" => $parentId, "target" => $keyData["keyid"], "caption" => getKeywordCaption($keyWord, formatText($keyData["keyDesc"])));
if (!($parentId != 0 && !$nonSelectable)) {
// If it's a root keyword or it's set as non-selectable, display as
// simple tab.
writeKeywordData(KWD_APP_TAB, $params);
} else {
// Otherwise, display as tab with a selectable keyword inside.
writeKeywordData(KWD_APP_KEYWORD_TAB, array_merge($params, array("fullname" => $fullname)));
}
} else {
// Otherwise, display as simple selectable keyword.
writeKeywordData(KWD_APP_KEYWORD, array("keyword_space" => $keywordSpace, "id" => $keyData["keyid"], "caption" => getKeywordCaption($keyWord, formatText($keyData["keyDesc"])), "fullname" => $fullname));
}
}
writeKeywordData(KWD_APP_CLEAR);
if ($isInHeader) {
writeKeywordData(KWD_APP_SWITCH);
$isInHeader = false;
}
foreach ($keywords as $keyData) {
$keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
unset($requiredTabs[$keyData["keyid"]]);
if (isset($keyData["subcats"])) {
writeKeywordData(KWD_APP_OPEN, array("id" => $keyData["keyid"]));
if ($keyData["keySubcat"] != 0) {
writeKeywordData(KWD_APP_HLINE);
}
showKeywordSubcat($keyData["subcats"], $keyData["keyid"], $parentKeyName . htmlspecialchars($keyData["keyWord"]) . '"', $parentId != 0 ? htmlspecialchars($keyData["keyWord"]) : "");
writeKeywordData(KWD_APP_CLOSE);
}
}
}
示例14: showKeywordSubcatEdit
function showKeywordSubcatEdit($keywords, $listId, $parentId = 0, $parentKeyName = "", $parentLastKeyName = "")
{
global $requiredTabs, $firstKeywordId;
$noSubcats = true;
foreach ($keywords as $keyData) {
if (isset($keyData["subcats"])) {
$noSubcats = false;
break;
}
}
if ($parentId == 0) {
?>
<div class="clear"> </div>
<div class="sep notsowide mar_left mar_bottom">
Add more keyword groups to the Root separated by ;
<br />
<input class="notsowide" name="addKeywordsUnder<?php
echo $parentId;
?>
" type="text" />
</div>
<?php
}
foreach ($keywords as $keyData) {
$tabid = generateId("kwcache_tab");
$keyName = "• " . $parentKeyName . $keyData["keyWord"];
$nonSelectable = preg_match('/\\@$/', $keyData["keyWord"]);
$keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
?>
<div class="f_left">
<div class="tab normaltext" id="<?php
echo $tabid;
?>
"
onclick="open_tab(this,'keywords_<?php
echo $parentId;
?>
','keywordTab_<?php
echo $keyData["keyid"];
?>
')">
<a href="<?php
echo url("keywords", array("delete" => $keyData["keyid"]));
?>
">
<?php
echo getIMG(url() . "images/emoticons/keydelete.gif", 'alt="del" title="' . _KEYWORDS_DELETE . '" ' . 'onmouseout="this.style.background=\'none\'" ' . 'onmouseover="this.style.background=\'#fff\'"');
?>
</a>
<a href="<?php
echo url("keywords", array("edit" => $keyData["keyid"]));
?>
">
<?php
echo getIMG(url() . "images/emoticons/keyedit.gif", 'alt="edit" title="' . _KEYWORDS_EDIT . '" ' . 'onmouseout="this.style.background=\'none\'" ' . 'onmouseover="this.style.background=\'#fff\'"');
?>
</a>
<?php
echo htmlspecialchars($keyData["keyWord"]);
if ($nonSelectable) {
echo "@";
}
?>
</div>
</div>
<?php
}
?>
<div class="clear"> </div>
<?php
foreach ($keywords as $keyData) {
$keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
unset($requiredTabs[$keyData["keyid"]]);
?>
<div style="display: none" id="keywordTab_<?php
echo $keyData["keyid"];
?>
">
<?php
iefixStart();
?>
<div class="hline"> </div>
<div class="hline"> </div>
<div class="sep notsowide_fix mar_left mar_bottom">
Add more keywords to the group
<b><?php
echo $parentKeyName . htmlspecialchars($keyData["keyWord"]);
?>
</b>
separated by ;
<br />
<input class="notsowide_fix" name="addKeywordsUnder<?php
echo $keyData["keyid"];
?>
" type="text" />
</div>
<div class="clear"> </div>
<?php
iefixEnd();
//.........这里部分代码省略.........
示例15: sql_query
<?php
echo _ANIMATION;
?>
</a>
</acronym>
<?php
$first = false;
}
if (isLoggedIn() && !$isExtras && $useData["useid"] != $_auth["useid"]) {
if (!$first) {
echo " · ";
}
$result = sql_query("SELECT `favObj` FROM `favourites` " . "WHERE `favObj` = '{$objid}' AND `favCreator` = '" . $_auth["useid"] . "' LIMIT 1");
$faved = mysql_num_rows($result) > 0;
$favId = generateId();
$unfavId = generateId();
$favScript = "add_operation( 'f{$objid}' ); " . "var el = get_by_id( '{$favId}' ); " . "if( el ) el.style.display = 'none'; " . "el = get_by_id( '{$unfavId}' ); " . "if( el ) el.style.display = 'inline'; " . "el = get_by_id( '{$favAddedId}' ); " . "if( el ) el.style.display = 'block'; " . "return false;";
$unfavScript = "add_operation( 'fu{$objid}' ); " . "var el = get_by_id( '{$unfavId}' ); " . "if( el ) el.style.display = 'none'; " . "el = get_by_id( '{$favId}' ); " . "if( el ) el.style.display = 'inline'; " . "el = get_by_id( '{$favAddedId}' ); " . "if( el ) el.style.display = 'none'; " . "return false;";
?>
<span id="<?php
echo $unfavId;
?>
" <?php
echo $faved ? "" : 'style="display: none"';
?>
>
<acronym title="<?php
echo _FAV_REMOVE;
?>
">
<a onclick="<?php