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; }
/** * 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>"; }
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 } } }
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; }
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; }
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; }
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; } }
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); }
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'); } } }
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; }
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; }
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']); } if ($allowinput) { $options['allowinput'] = 'Y'; } else { unset($options['allowinput']); } if ($scramble) { $options['scramble'] = 'Y'; } // already unset if ($readonly) { $options['readonly'] = 'Y'; } if ($inplace) { $options['inplace'] = 'Y'; } if ($usertni) { $options['usertni'] = 'Y'; } else { unset($options['usertni']); } $cosmeticOptions = array('defaultcode', 'autocommentline', 'console', 'rows', 'disablericheditor', 'scramble', 'readonly', 'showeditortoggle', 'title', 'placeholder'); $copyForGrader = array(); foreach ($options as $optname => $optvalue) { if (!in_array($optname, $cosmeticOptions)) { $copyForGrader[$optname] = $optvalue; } } if (array_key_exists('maxeditdistance', $options)) { $copyForGrader['originalcode'] = $defaultcode; } $optionsJson = json_encode($copyForGrader); $hash = md5($shortcodeOptions . $optionsJson); $slug = getSoft($options, 'slug', 'NULL'); registerPybox($id, $slug, $scramble ? "scramble" : "code", $facultative, getSoft($options, 'title', NULL), $content, $shortcodeOptions, $hash, $optionsJson); if (isMakingDatabases()) { $res = do_short_and_sweetcode($content); // faster db generation with accurate count $GLOBALS['pb_translation'] = NULL; return $res; } /// we've delivered options to the grader. get on with producing html if ($defaultcode === FALSE && $scramble && $solver !== FALSE) { $lines = explode("\n", trim(softSafeDereference($solver))); shuffle($lines); $defaultcode = implode("\n", $lines); } if ($defaultcode !== FALSE) { try { $defaultcode = softSafeDereference($defaultcode); } catch (PyboxException $e) { $GLOBALS['pb_translation'] = NULL; return pberror("PyBox error: defaultcode file " . $defaultcode . " not found."); } $defaultcode = ensureNewlineTerminated($defaultcode); } /// actually start outputting here. part 1: headers and description $r = ''; $readyScripts = ''; $r .= '<form class="pbform" action="#" id="pbform' . $id . '" method="POST">' . "\n"; if ($scramble) { $c = "scramble"; } else { if (debugEnabled()) { $c = "debug"; } else { $c = ""; } } if ($facultative) { $c .= " facultative"; } $r .= "<div class='pybox modeNeutral {$c}' id='pybox{$id}'>\n"; if (!$facultative && !array_key_exists("slug", $options)) { pyboxlog("Hash " . $hash . " not read-only, but needs a slug", TRUE); $r .= slugwarn(); } if ($facultative) { if ($console) { unset($options["title"]); $r .= heading("Console", $options); } else { $r .= heading(__t('Example'), $options); } } else { $r .= checkbox($slug); $r .= heading($scramble ? __t('Scramble Exercise') : __t('Coding Exercise'), $options); //if ($scramble) // $r .= "<b>Note (Dec 13)</b>: scramble exercises are temporarily broken — sorry!<br>"; } $r .= do_short_and_sweetcode($content); //instructions, problem description. process any shortcodes inside. // part 1.5: help box if (!$facultative && !$scramble) { $r .= '<div class="helpOuter" style="display: none;"><div class="helpInner">'; if (!is_user_logged_in()) { $r .= '<div style="text-align: center">' . __t('You need to create an account and log in to ask a question.') . '</div>'; } else { global $wpdb; $guru_login = get_the_author_meta('pbguru', get_current_user_id()); if ($guru_login != '') { $guruid = $wpdb->get_var($wpdb->prepare('SELECT ID from ' . $wpdb->prefix . 'users WHERE user_login = %s', $guru_login)); } $r .= '<div style="text-align: center">'; if ($guru_login != '' and $guruid !== NULL) { $r .= __t('Send a question by e-mail to: '); $r .= "<select class='recipient'>\n<option value='1'>" . __t("My guru") . " ({$guru_login})</option>\n<option value='-1'>" . __t("CS Circles Assistant") . "</option>\n</select></div>"; } else { $r .= __t('Send a question by e-mail to: '); $r .= "<select class='recipient'>\n<option value='-1'>" . __t("CS Circles Assistant") . "</option>\n<option value='0'>" . __t("(No guru specified in your profile)") . "</option>\n</select>"; $r .= '<br/></div>'; } $r .= __t("Enter text for the message below. <i>Be sure to explain where you're stuck and what you've tried so far. Your partial solution code will be automatically included with the message.</i>"); $r .= "<textarea style='font-family: serif'></textarea>"; $r .= "<table class='helpControls'><tr class='wp-core-ui'><td style='width: 50%'><a class='button' onclick='sendMessage({$id},\"{$slug}\")'>" . __t("Send this message") . "</a></td><td style='width: 50%'>\n <a class='button' onclick='helpClick({$id})'>" . __t("Cancel") . "</a></td></tr></table>"; } $r .= '</div></div>'; } /// part 2: code input if ($readonly) { $thecode = trim($defaultcode); $rows = count(explode("\n", $thecode)); } elseif ($console == "Y" && array_key_exists("consolecode", $_GET)) { $thecode = htmlspecialchars(html_entity_decode(stripslashes($_GET["consolecode"]))); $rows = count(explode("\n", $thecode)) + 1; } else { $thecode = $defaultcode; if ($autocommentline) { $thecode .= __t('# delete this comment and enter your code here') . "\n"; } if (array_key_exists('slug', $options) && $scramble === FALSE) { $savedCode = loadMostRecent($options['slug']); if ($savedCode !== NULL) { $thecode = $savedCode; } } } if ($scramble) { $r .= '<ul class="pyscramble" name="pyscramble" id="pyscramble' . $id . '">' . "\n"; foreach (explode("\n", rtrim($thecode)) as $s) { if (strpos($s, 'delete this comment') === FALSE) { // fix an old bug -- got stuck in database $r .= ' <li class="pyscramble">' . (trim($s) == '' ? ' ' : htmlspecialchars(html_entity_decode($s))) . "</li>\n"; } } $r .= "</ul>\n"; $r .= "<input type='hidden' id='usercode{$id}' name='usercode{$id}'/>\n"; } else { // $r .= "<div class='acecontain ace_hide' id='acecontain$id' ><div class='aceinner' id='ace$id'></div></div>"; $px = $rows * 26 + 6; //+6 for border, padding in weird box model $h = $px; if (!$readonly) { $h = max(50, $h); } $h = " style='height: {$h}px;'"; $ro = $readonly ? "readonly='readonly'" : ""; $c = $readonly ? "RO" : "RW"; $p = $readonly ? " style = 'height : {$px}px;' " : ""; $s = $readonly ? "" : "resizy"; //cols=... required for valid html but width actually set by css //height is set explicitly since it's the only way for IE to render the textarea at the correct height $pl = array_key_exists("placeholder", $options) ? "placeholder='" . $options['placeholder'] . "'" : ""; $r .= "<div class='pyboxTextwrap pyboxCodewrap {$c} {$s}' {$h}><textarea wrap='off' name='usercode{$id}' id='usercode{$id}' {$pl} cols=10 rows={$rows} {$ro} {$p} class='pyboxCode {$c}'>\n"; $r .= $thecode; $r .= '</textarea></div>' . "\n"; } // part 2.5 history container $r .= "<div id='pbhistory{$id}' class='flexcontain' style='display:none;'></div>\n"; /// part 3: stdin if ($allowinput) { if ($usertni === TRUE) { $description = __t('Enter testing statements like <tt>print(myfunction("test argument"))</tt> below.'); } else { $description = __t("You may enter input for the program in the box below."); } $r .= '<div name="pyinput" id="pyinput' . $id . '">'; $r .= $description; $r .= '<div class="pyboxTextwrap resizy" style="height: 102px;" ><textarea wrap="off" name="userinput" class="pyboxInput" cols=10 rows=4></textarea></div>'; $r .= '</div>' . "\n"; //cols=10 required for valid html but width actually set by css } /// part 4: controls $tni = $usertni ? 'Y' : 'N'; $actions = array(); if ($allowinput) { $actions['switch'] = array('id' => "switch{$id}", 'value' => 'Input Switch', 'onclick' => "pbInputSwitch({$id},'{$tni}')"); } if (!$disablericheditor) { // $userLikesRich = (!is_user_logged_in()) || ("true"!==get_the_author_meta( 'pbplain', get_current_user_id())); $userLikesRich = TRUE; if ($showEditorToggle || $richreadonly) { $actions['CMtoggle'] = array('value' => __t('Rich editor'), 'id' => "toggleCM{$id}", 'onclick' => "pbToggleCodeMirror({$id})"); } if ($userLikesRich) { $readyScripts .= "jQuery(function(){pbToggleCodeMirror({$id});});"; } } if (!$scramble && !$console && ($lessonNumber >= 4 || $lessonNumber < 0)) { $actions['consolecopy'] = array('value' => __t('Open in console'), 'onclick' => "pbConsoleCopy({$id})"); } if (!$scramble && ($lessonNumber >= 4 || $lessonNumber < 0)) { $actions['visualize'] = array('value' => __t('Visualize'), 'onclick' => "pbVisualize({$id},'{$tni}')"); } if (!$readonly && !$scramble) { //$actions['save'] = array('value'=>'Save without running', 'onclick'=>"pbSave($id)"); if (array_key_exists("slug", $options)) { $historyAction = "historyClick({$id},'{$slug}')"; $actions['history'] = array('value' => __t('History'), 'onclick' => $historyAction); } if (!($readonly === "Y") && $defaultcode != '' && $defaultcode !== FALSE) { // prepare the string for javaScript enclosure // we put in single-quotes, rather than json's default double quotes, for compatibility with // our $button usage $dc = substr(json_encode(htmlspecialchars_decode($defaultcode, ENT_QUOTES), JSON_HEX_APOS), 1, -1); $r .= "<input type='hidden' id='defaultCode{$id}' value='{$dc}'></input>\n"; $actions['default'] = array('value' => __t('Reset code to default'), 'onclick' => "pbSetText({$id},descape(\$('#defaultCode{$id}').val()))"); } } if (!$facultative && !$scramble && !get_option('cscircles_hide_help')) { $actions['help'] = array('value' => __t('Help'), 'onclick' => "helpClick({$id});"); } if ($richreadonly) { $actions = array('CMtoggle' => $actions['CMtoggle']); } // get rid of all other options $r .= "<div class='pyboxbuttons'><table><tr>\n"; if (!$richreadonly) { $r .= "<td><input type='submit' name='submit' id='submit{$id}' value=' '/></td>\n"; } $mb = 3; //maximum number of buttons, not counting 'submit' $i = 0; foreach ($actions as $name => $atts) { $i++; if ($i <= $mb) { $r .= button($name, $atts); continue; } if ($i == 1 + $mb) { $r .= "</tr></table><select id='pbSelect{$id}' class='selectmore'><option name='more'>" . __t("More actions...") . "</option>\n"; } $r .= option($name, $atts); } if (count($actions) > $mb) { $r .= "</select></div>\n"; } else { $r .= "</tr></table></div>\n"; } if (isset($cpulimit) && $cpulimit != 1) { $timeout = (WALLFACTOR * $cpulimit + WALLBUFFER + 2) * 1000; // + 2 seconds for network latency each way $r .= "<input type='hidden' name='timeout' value='{$timeout}'/>\n"; } $r .= '<input type="hidden" name="lang" value="' . currLang4() . '"/>'; $r .= '<input type="hidden" id="inputInUse' . $id . '" name="inputInUse" value="Y"/>' . "\n"; $r .= '<input type="hidden" name="pyId" value="' . $id . '"/>' . "\n"; $r .= '<input type="hidden" name="hash" value="' . $hash . '"/>' . "\n"; // although inputInUse starts as Y, the next script sets it to N and fixes the button labels $readyScripts .= $allowinput ? 'pbInputSwitch(' . $id . ',"' . ($usertni ? 'Y' : 'N') . '");' : 'document.getElementById("submit' . $id . '").value = "' . __t('Run program') . '";' . 'document.getElementById("inputInUse' . $id . '").value = "N";'; /// part 5 : results area, and footers $c = count($actions) > $mb ? ' avoidline' : ''; $r .= "<div id='pbresults{$id}' class='pbresults{$c}'></div>\n"; $r .= problemSourceWidget(array('hash' => $hash), count($actions) > $mb); $r .= '</div>' . "\n"; $r .= '</form>' . "\n"; if ($readyScripts != '') { $r .= "<script type='text/javascript'>{$readyScripts}</script>\n"; } $GLOBALS['pb_translation'] = NULL; return $r; }
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); } } }
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(); ?> <?php if (isset($keyData["subcats"])) { iefixStart(); showKeywordSubcatEdit($keyData["subcats"], $listId, $keyData["keyid"], $parentKeyName . htmlspecialchars($keyData["keyWord"]) . " – ", $parentId != 0 ? htmlspecialchars($keyData["keyWord"]) : ""); iefixEnd(); } ?> <div class="clear"> </div> </div> <?php } }
<?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
function ajax_saveLink($selector = 'new', $id1 = '', $id2 = '', $label = '', $what = '', $overwrite = TRUE) { $resultText = ''; $resultOK = ''; $resultKO = ''; $collection_id = explode('/', str_ireplace('xml://', '', $id1)); $collection_id = $collection_id[0]; if ($collection_id != '') { $thePath = DCTL_PROJECT_PATH . $collection_id . SYS_PATH_SEP; // $f = fopen('/tmp/diocaro.log', 'a'); // fwrite($f, "------------------\n\n" . $thePath); switch ($what) { case 'lnk': $thePath .= DCTL_FILE_LINKER; break; case 'map': $thePath .= DCTL_FILE_MAPPER; break; default: $resultKO .= 'ERROR: CASE UNIMPLEMENTED IN ' . __FUNCTION__; break; } if (is_file($thePath)) { // fwrite($f, "------------------\n\n" . $thePath); switch ($selector) { case 'new': case 'add': case 'mod': case 'ovw': $file_content = file_get_contents($thePath); //fwrite($f, "--------1111111111----------\n\n"); $file_content = preg_replace('/' . WS . '+/', ' ', $file_content); //fwrite($f, "------2222222222------------\n\n"); $text_head = substr($file_content, 0, stripos($file_content, '%BEGIN%')) . '%BEGIN% -->'; $text_foot = '<!-- ' . substr($file_content, stripos($file_content, '%END%')); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; forceUTF8($thePath); if ($dom->load($thePath, DCTL_XML_LOADER)) { $xpath = new DOMXPath($dom); switch ($selector) { case 'new': $type = 'link'; $thisID = $collection_id . '-' . generateId(); $head = $label; $query = 'id("placeholder")'; $entries = $xpath->query($query); foreach ($entries as $entry) { $newNode = $dom->createElement('ref', $head); $newNode = $entry->parentNode->insertBefore($newNode, $entry); $newNode->setAttribute('xml:id', $thisID); $newNode->setAttribute('type', $type); $newNode->setAttribute('n', $label); $newNode->setAttribute('target', $id1 . ' ' . $id2); $newNode = $dom->createComment(' '); $newNode = $entry->parentNode->insertBefore($newNode, $entry); } break; case 'add': $query = 'id("' . $id2 . '")'; $entries = $xpath->query($query); foreach ($entries as $entry) { $target = $entry->getAttribute('target'); if (stripos($target, $id1) === FALSE) { $entry->setAttribute('target', $id1 . ' ' . $target); } else { $resultKO .= 'L\'ID "' . $id1 . '" è gia nel collegamento'; } } break; case 'mod': $query = 'id("' . $id2 . '")'; $entries = $xpath->query($query); foreach ($entries as $entry) { $entry->setAttribute('n', $label); if ((string) $entry->nodeValue == '') { $entry->nodeValue = $label; } } break; case 'ovw': //fwrite($f, "------ $query: pronti a morire? ------------ [[".memory_get_usage()."]]"); //fwrite($f, "------ 11 ?! ------------[".$entry->namespaceURI."]-- [[".memory_get_usage()."]]\n\n"); $entry = $dom->getElementById($id2); //fwrite($f, "------ 22 ?! ------------ ".$entry->getAttribute('n')." > $label [[".memory_get_usage()."]]\n\n"); $entry->setAttribute('target', $id1); //fwrite($f, "------ 33 ?! ------------[[".memory_get_usage()."]]\n\n"); if ($entry->getAttribute('n') != $label) { //fwrite($f, "------ 33 AA ?! ------(".$entry->getAttribute('n').")------[[".memory_get_usage()."]]\n\n"); $entry->setAttributeNode(new DOMAttr('n', $label)); } //fwrite($f, "------ 44 ?! ------------[[".memory_get_usage()."]]\n\n"); if ((string) $entry->nodeValue == '') { $entry->nodeValue = $label; } /* $query = 'id("'.$id2.'")'; $entries = $xpath->query($query); foreach ($entries as $entry) { $entry->setAttribute('n', $label); $entry->setAttribute('target', $id1); fwrite($f, "------ dentro foreach, o sono gia' morto? :| ------------\n\n"); if ((string) $entry->nodeValue == '') $entry->nodeValue = $label; }; */ break; } if ($resultKO == '') { //fwrite($f, "------ Si salva vai!! ------------[[".memory_get_usage()."]]\n\n"); $file_content = $dom->saveXML(); $file_content = preg_replace('/' . WS . '+/', ' ', $file_content); $from = stripos($file_content, '%BEGIN%') + strlen('%BEGIN% -->'); $to = stripos($file_content, '%END%') - strlen('<-- ') - $from - 1; $text_content = substr($file_content, $from, $to); $file_content = $text_head . $text_content . $text_foot; if ($overwrite) { doBackup($thePath); if (file_put_contents($thePath, forceUTF8($file_content), LOCK_EX) === false) { $resultKO .= 'Impossibile scrivere il file "' . basename($thePath) . '"'; } else { @chmod($thePath, CHMOD); $resultOK .= 'Modifica eseguita con successo ("' . $label . '")'; } } else { $resultOK .= 'Simulazione eseguita con successo ("' . $label . '")'; } } } else { $resultKO .= 'Impossibile leggere il file "' . basename($thePath) . '"'; } break; default: $resultKO .= '?' . $selector . '?'; break; } } else { $resultKO .= 'Impossibile trovare "' . basename($thePath) . '"'; } } else { $resultKO .= 'Impossibile trovare la collection...'; } if ($resultKO != '') { $resultText .= '<span class="error">' . cleanWebString($resultKO) . '</span>'; } else { $resultText .= '<span class="ok">' . cleanWebString($resultOK) . '</span>'; } return $resultText; }
function showFileInputWithPreview($name, $tiledHName, $tiledVName, $tiledHChecked, $tiledVChecked) { global $errors; $previewContainerId = generateId(); $previewImageId = generateId(); $previewMessageId = generateId(); $tileHId = generateId(); $tileVId = generateId(); ?> <div> <input accept="image/jpeg" onchange="make_visible('<?php echo $previewContainerId; ?> '); show_preview_image('<?php echo $previewImageId; ?> ', '<?php echo $previewMessageId; ?> ', this.value)" name="<?php echo $name; ?> " size="60" type="file" /> <input type="checkbox" class="checkbox" id="<?php echo $tileHId; ?> " <?php echo $tiledHChecked ? 'checked="checked"' : ""; ?> name="<?php echo $tiledHName; ?> " /> <label title="Horizontal tiling" for="<?php echo $tileHId; ?> ">H.Tiling</label> <input type="checkbox" class="checkbox" id="<?php echo $tileVId; ?> " <?php echo $tiledVChecked ? 'checked="checked"' : ""; ?> name="<?php echo $tiledVName; ?> " /> <label title="Vertical tiling" for="<?php echo $tileVId; ?> ">V.Tiling</label> </div> <?php if (isset($errors[$name])) { notice($errors[$name]); } /* ?> <table><tr><td> <div style="display: none" id="<?= $previewContainerId ?>"> <div class="sep caption"><?= _PREVIEW ?>:</div> <div class="container2 a_center"> <img alt="preview" style="display: none" id="<?= $previewImageId ?>" src="" /> <div id="<?= $previewMessageId ?>"><?= _SUBMIT_SELECT_FILE ?></div> </div> </div> </td></tr></table> <? */ }
function eLog($action) { global $valid_entry; global $commit; $elog_date = date("Y-m-d H:i:s"); $elog_user = $_SESSION['EU_ID']; //START: Generate ID do { $generatedId = generateId(); $sql_id = "SELECT * FROM `electro_log` WHERE ELOG_ID='" . $generatedId . "'"; $query_id = mysql_query($sql_id); $rows = mysql_num_rows($query_id); } while ($rows); //END: Generate ID $sql_elog = "INSERT INTO `electro_log` VALUES ('{$generatedId}','{$elog_date}','{$elog_user}','{$action}')"; $query_elog = mysql_query($sql_elog); if (!$query_elog) { $valid_entry = 0; $commit = "rollback"; } }
$pieces = explode(",", $line); echo "Size ->".count($pieces)."<br>"; echo $pieces[0]."|".$pieces[1]."|".$pieces[2]."|".$pieces[3]."<br>------<br>"; } */ $i = 0; // number of rows while (($line = fgets($fp)) != false) { // check if there are enough values $pieces = explode(",", $line); if (count($pieces) != 3) { echo "Not enough data<br>"; continue; } // generate an unique scalar_id $scalar_id = generateId($conn, "scalar_data"); if ($scalar_id == 0) { // Unable to generate more unique id, return return; } // sensor_id $sensor_id = intval($pieces[0]); if (checkSensorId($conn, $sensor_id) != 0) { continue; } // date $date = $pieces[1]; // value $value = intval($pieces[2]); $sql = "INSERT INTO scalar_data VALUES (" . $scalar_id . ", " . $sensor_id . ", TO_DATE('" . $date . "', 'DD/MM/YYYY hh24:mi:ss'), " . $value . ")"; $stid = oci_parse($conn, $sql);
<?php if (@$_POST['submit']) { //collecting userinfo $pName = formItemValidation($_POST['pName']); $pBarCode = formItemValidation($_POST['pBarCode']); $pBuyingPrice = formItemValidation($_POST['pBuyingPrice']); $pSellingPrice = formItemValidation($_POST['pSellingPrice']); $pQuantity = formItemValidation($_POST['pQuantity']); $cId = $_POST['cId']; //current time now $nowTime = date("Y-m-d H:i:s"); //need to insert data $myNewId = generateId(); //logged in user ID $loggedInUser = $_SESSION['uId']; $qry = mysql_query("INSERT INTO product VALUES(\n '',\n '" . $cId . "',\n '" . $pBarCode . "',\n '" . $pName . "',\n '" . $pBuyingPrice . "',\n '" . $pSellingPrice . "',\n '" . $pQuantity . "',\n '" . $loggedInUser . "',\n '" . $nowTime . "'\n )") or die(mysql_error()); if ($qry) { $insertSuccess = 1; } else { $insertError = 1; } } ?> <div id="page-wrapper">
echo _ABUSE_DECISION_VIOLATION; ?> </option> <option value="+">+ <?php echo _ABUSE_DECISION_COMPLIANT; ?> </option> </select> <?php if ($accessLevel == 2 && $objData["abuMod"] == "-" || $accessLevel == 3) { ?> <div class="caption"> Action: </div> <select id="<?php echo $actionId = generateId(); ?> " name="action" size="3"> <option value="-">– <?php echo _ABUSE_DECISION_DELETE; ?> </option> <option value="*">* Flag for Grace Period</option> <option value="+">+ <?php echo _ABUSE_DECISION_RESTORE; ?> </option> </select> <?php
function displayDir(SongDir $dir, $displayedDir, $level = 1) { echo '<div id="' . generateId($dir) . '" '; if ($level != 1 && ($displayedDir === null || strncmp($dir->getPath(), $displayedDir->getPath(), strlen($dir->getPath())) != 0)) { echo 'style="display:none;"'; } echo '>'; $subdirs = $dir->getSubdirs(); foreach ($subdirs as $subdir) { for ($i = 0; $i < $level; ++$i) { echo '-- '; } echo "\n"; echo '<a href="#" onClick="show(\'' . generateId($subdir) . '\');return(false)" id="plus">' . "\n"; echo ' <img src="img/folder.png" alt="folder" /> '; echo basename($subdir->getPath()); echo '</a> ' . "\n"; echo '<a href="?play=' . urlencode($subdir->getPath()) . '/' . '">' . "\n"; echo ' <img src="img/play.png" alt="play" />'; echo '</a>'; echo '<br />' . "\n"; displayDir($subdir, $displayedDir, $level + 1); } $songs = $dir->getSongs(); foreach ($songs as $song) { for ($i = 0; $i < $level; ++$i) { echo '-- '; } echo "\n"; echo '<img src="img/music.png" alt="folder" /> ' . "\n"; echo ' ' . $song->getTitle(); echo ' <a href="?play=' . urlencode($song->getPath()) . '">' . "\n"; echo ' <img src="img/play.png" alt="play" />' . "\n"; echo '</a>' . "\n"; echo ' <a href="' . $song->getPath() . '" target="_blank">' . "\n"; echo ' <img src="img/download.png" alt="download" />' . "\n"; echo '</a>' . '<br />' . "\n"; } echo '</div>'; }
<?php // Fetch paramter form querystring $type = $_GET['t']; switch ($type) { case 'createGame': // Create pseudo-unique ID for new game generateId(); break; case 'joinGame': // Join an already created game $joinId = $_GET['id']; break; default: // break; } function generateId() { $base = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); shuffle($base); $id = ''; foreach (array_rand($base, 5) as $k) { $id .= $base[$k]; } $time = time(); $timeOut = $time + 30; echo $id; echo "<br>" . $time; echo "<br>" . $timeOut; return $id;
} else { $src = $isExtras ? $objData["objThumbURL"] : urlf() . applyIdToPath("files/thumbs/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . ".jpg"; } $useData = getUserData($objData["objCreator"]); $objTitle = formatText($objData["objTitle"], false, true) . '</div><div> '; if ($objData["objCollab"] > 0) { $objTitle .= sprintf(_BY_AND, getUserLink($objData["objCreator"]), getUserLink($objData["objCollab"])); } else { $objTitle .= sprintf(_BY, getUserLink($objData["objCreator"])); } if ($objData["objForClub"] > 0) { $result = sql_query("SELECT `cluName` FROM `clubs` " . "WHERE `cluid` = '" . $objData["objForClub"] . "'"); $club = '<a href="' . url("club/" . $objData["objForClub"]) . '">' . mysql_result($result, 0) . '</a>'; $objTitle .= '</div><div> ' . sprintf(_IN, $club); } $id = generateId("au_v"); $all_ids[] = $id; $divId = ""; $starId = ""; echo '<div ' . $divId . ' class="gallery_col a_center"' . ($view == 1 ? ' style="width: 31%"' : "") . '>' . '<div class="padded ' . ($cols < 3 ? " mar_right" : "") . '">' . '<a href="' . $anchor . '">'; echo '<img alt="' . htmlspecialchars(strip_tags($objTitle)) . '" class="thumb' . ($objData["objMature"] ? " mature" : "") . '" src="' . $src . '" title="' . htmlspecialchars(strip_tags($objTitle)) . '" width="' . $objData["objThumbWidth"] . '" height="' . $objData["objThumbHeight"] . '" /></a>'; echo '</div><div>'; echo '<input class="checkbox" id="' . $id . '" name="' . $key . '" type="checkbox" />'; if (in_array($objData["objExtension"], array("txt", "html"))) { echo getIMG(url() . "images/emoticons/pm.png", 'alt="' . $objData["objExtension"] . '"') . ' '; } else { echo getIMG(url() . "images/emoticons/submission.png", 'alt="' . $objData["objExtension"] . '"') . ' '; } echo $objTitle . '</div></div>'; $cols++; if ($cols >= $maxcols) {
if (in_array($form_bits, $allowed_bits)) { $bits = $form_bits; } } $code = 0; if (isset($_POST['code'])) { $code = 1; } // generate hash for this file $hash = generateId($target_file); $target_hash = $target_dir . $hash; // append parameters to filename $target_hash .= '_' . $bits . '_' . $code; // Check if file already exists to avoid collisions while (file_exists($target_hash)) { $hash = generateId($target_file); $target_hash = $target_dir . $hash; $target_hash .= '_' . $bits . '_' . $code; } // actually move the file if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_hash)) { echo 'Get file after conversion from <a href="' . $_SERVER['PHP_SELF'] . '?f=' . $hash . '" target="_blank">here</a>'; } else { echo 'Sorry, there was an error uploading your file.<br/>'; } } } ?> <!DOCTYPE html> <html>
if (!isset($commentNoEmoticons)) { $commentNoEmoticons = isLoggedIn() && $_auth["useNoEmoticons"]; } if (!isset($commentNoOptions)) { $commentNoOptions = false; } if (!isset($commentNoSig)) { $commentNoSig = isLoggedIn() && $_auth["useNoSig"]; } if (!isset($commentRows)) { $commentRows = 7; } if (!isset($commentWide)) { $commentWide = true; } $commentId = generateId(); ?> <script type="text/javascript"> //<![CDATA[ _IR = { commentId: '<?php echo $commentId; ?> ', commentName: '<?php echo $commentName; ?> ', commentDefault: <?php echo json_encode($commentDefault);
function makeFloatingThumb($title, $src, $width, $height, $isMature, $isThumb, &$onmouseover, &$onmouseout) { global $_addToFooter; $floaterId = generateId("thumbFloat"); $title = strip_tags(formatText($title)); $_addToFooter .= '<div id="' . $floaterId . '" class="floating_thumb" ' . 'style="width: ' . ($width + ($isThumb ? 6 : 0)) . 'px; height: ' . ($height + ($isThumb ? 6 : 0)) . 'px">' . getIMG($src, 'alt="' . $title . '" class="' . ($isThumb ? "thumb " : "") . ($isMature ? " mature" : "") . '" title="' . $title . '"') . '</div>' . "\n"; $onmouseover = "current_floater = get_by_id('{$floaterId}'); this.onmousemove = move_to_element;"; $onmouseout = "el=get_by_id('{$floaterId}'); if(el) { make_invisible('{$floaterId}'); current_floater = 0; }"; }
//Verify type $haserror = true; foreach ($accounts->getTypes() as $type) { if ($data['transType'] == $type['id']) { $haserror = false; break; } } if ($haserror) { RestUtils::sendResponse('406', array('data' => 'transType', 'message' => 'O tipo de conta não existe.')); } //Connect $sql = new DataBase(); $sql->connect(); //Generate ID $transactionId = generateId(); //Get all tags to compare $allTagsCompare = array(); foreach ($tags->get() as $tag) { $tag = strtolower(clearUTF($tag['name'])); array_push($allTagsCompare, $tag); } //Get all tags of transaction $transactionTags = explode(',', $data['tags']); $i = 0; foreach ($transactionTags as $tag) { if ($tag == "" || $tag == " " || $tag == "," || $tag == ", ") { unset($transactionTags[$i]); } $i++; }
imagedestroy($thumb_black); //Upload the user's file and return validation if (!move_uploaded_file($uploadedfile, $uploadfile)) { $valid_entry = 0; } } //Database entry if ($valid_entry) { require "db_connect.php"; include "functions.php"; //Begin Transaction $commit = "commit"; mysql_query("begin", $con); //START: Generate ID do { $generatedId = generateId(); $sql_id = "SELECT * FROM `files` WHERE F_ID = '" . $generatedId . "'"; $query_id = mysql_query($sql_id); $rows = mysql_num_rows($query_id); } while ($rows); //END: Generate ID $sql_img = "INSERT INTO `files` VALUES ('{$generatedId}','','{$new_file_name}','{$ext}',0,'',0)"; $query_img = mysql_query($sql_img); if (!$query_img) { $valid_entry = 0; $commit = "rollback"; } $last_id = $generatedId; $sql_gf = "INSERT INTO `galleries-files` VALUES ('{$id}','{$last_id}',0)"; $query_gf = mysql_query($sql_gf); if (!$query_gf) {
reset($objList); $togo = $limit; $useids = array(); foreach ($objList as $objData) { if (isset($objData["objCreator"])) { $useids[] = $objData["objCreator"]; } } prefetchUserData(array_unique($useids)); foreach ($objList as $objData) { $togo--; if ($togo < 0) { break; } $microId = generateId(); $thumbId = generateId(); $u = getUserData($objData["objCreator"]); $objTitle = formatText($objData["objTitle"]) . ' <br />'; if ($objData["objCollab"] > 0) { $objTitle .= sprintf(_BY_AND, getUserLink($u["useid"]), getUserLink($objData["objCollab"])); } else { $objTitle .= sprintf(_BY, getUserLink($u["useid"])); } if ($objData["objThumbDefault"]) { $src = urlf() . "images/litthumb.png"; } else { $src = urlf() . applyIdToPath("files/thumbs/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . ".jpg"; } $url = url("view/" . $objData["objid"]); if ($limit > 1) { echo '<span id="' . $microId . '" ' . "onmouseover=\"open_tab(this,'{$tabsId}','{$thumbId}')\">" . '<a href="' . $url . '">' . '<img alt="' . _ALT_THUMB . '" class="microthumb' . ($objData["objMature"] ? " mature" : "") . ($objData["objPending"] ? " pending" : "") . ($objData["objDeleted"] ? " deleted" : "") . '" src="' . $src . '" title="' . strip_tags($objTitle) . '" />' . '</a></span>' . "\n";