} /** * This function rearranges the words in a string according to the given new * order. * * @author kalmer * @param string $parameters['origin'] * the original text * @param int[] $parameters['newOrder'] * the new order */ function rearrange($parameters) { $arrayOfOrigin = explode(' ', $parameters['origin']); $arrayOfResult = array(); foreach ($parameters['newOrder'] as $order) { $arrayOfResult[] = $arrayOfOrigin[$order]; } echo ' 76: ', implode(' ', $arrayOfResult); } rearrange(array('origin' => 'külmast tulest langes pime leek', 'newOrder' => array(2, 1, 0, 4, 3))); // XSS if (isset($_GET) && isset($_GET['say'])) { echo '<br/>', $_GET['say']; } ?> <a href="?say=kalmer">say "kalmer"</a> <a href="?say=%3Cscript%3Ealert%28%27Oh%20no%21%27%29%3C/script%3E">say something else</a> </body> </html>
echo strlen($tekst); //34 echo '<br>'; echo str_word_count($tekst); //6 echo '<pre>'; var_dump(explode); // explode $sentence = "külmast tulest langes pime leek"; echo "<pre>"; var_dump(explode(" ", $sentence)); echo "<br /><br />"; $muutuja4 = explode(" ", $sentence); echo $muutuja4[2] . " " . $muutuja4[1] . " " . $muutuja4[0] . " " . $muutuja4[4] . " " . $muutuja4[3]; echo "<br /><br />"; function rearraange($parameters) { $arrayOfrigin = explode(' ', $parameters['orgin']); $arrayOfResult[] = array(); foreach ($parameters['newOeder'] as $order) { $arrayOfResult[] = $arrayOfOrign[$order]; } echo ' 76 ', implode(' ', $arrayOfResult); } rearrange(array("orign" => 'külmast tulest langes pime leek', ' "newOrder' => array(2, 1, 0, 4, 3))); if (statement) { echo '<button style="background: green;">BUTTON</button>'; } else { echo '<button style="background: red;">BUTTON</button>'; }
imagejpeg($dest, $path_to_90_directory . $date . ".jpg"); //сохраняем изображение формата jpg в нужную папку, именем будет текущее время. Сделано, чтобы у аватаров не было одинаковых имен. //почему именно jpg? Он занимает очень мало места + уничтожается анимирование gif изображения, которое отвлекает пользователя. Не очень приятно читать его комментарий, когда краем глаза замечаешь какое-то движение. $art_img = $path_to_90_directory . $date . ".jpg"; //заносим в переменную путь до аватара. $delfull = $path_to_90_directory . $filename; unlink($delfull); //удаляем оригинал загруженного изображения, он нам больше не нужен. Задачей было - получить миниатюру. } else { //в случае несоответствия формата, выдаем соответствующее сообщение exit("Only <strong>JPG,GIF or PNG</strong> is suitable!"); } //конец процесса загрузки и присвоения переменной $avatar адреса загруженной авы } if (!empty($_FILES['gallery'])) { $file_ary = rearrange($_FILES['gallery']); $folder = str_replace(' ', '_', $title); $folder = str_replace(':', '', $folder); $folder = str_replace('!', '', $folder); $folder = Translit::str2url($folder); if (!is_dir("../images/galleries/{$folder}")) { mkdir("../images/galleries/{$folder}"); } $path_to_gallery = "../images/galleries/{$folder}/"; $pics = ""; foreach ($file_ary as $file) { if (preg_match('/[.](JPG)|(jpg)|(gif)|(GIF)|(png)|(PNG)$/', $file['name'])) { $filename = $file['name']; $source = $file['tmp_name']; $target = $path_to_gallery . $filename; move_uploaded_file($source, $target);
<?php $id = !empty($_POST["letters_setting_id"]) ? $_POST["letters_setting_id"] : absint($_GET["id"]); $config = empty($id) ? array("meta" => array(), "is_active" => true) : TemplateData::get_letters_feed($id); $is_validation_error = false; $config["form_id"] = rgpost("letters_submit") ? absint(rgpost("letters_form")) : rgar($config, "form_id"); $config["is_active"] = rgpost("letters_submit") ? absint(rgpost("letters_isactive")) : rgar($config, "is_active"); $count = 0; if (isset($config['meta']['files'])) { $count = count($config['meta']['files']); } $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); if (rgpost("letters_submit")) { $newfiles = rearrange($_FILES['letters_file']); $count = count($newfiles); if (!empty($config['meta'])) { $config['meta']['files'] = array_merge($config['meta']['files']); if (isset($_POST['edit_file_enable'])) { $needles = $_POST['edit_file_enable']; } else { $needles = array(); } if (count(rgpost("edit_file_ids"))) { foreach ($config['meta']['files'] as $key => $val) { if (in_array($val['file_id'], $needles)) { $config['meta']['files'][$key]['enable'] = 1; } else { $config['meta']['files'][$key]['enable'] = 0; } $index = array_search($val['file_id'], rgpost("edit_file_ids")); if (count($index)) {
<link rel="stylesheet" type="text/css" href="list.css"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body onload="loadListIntoJavascript()" onpageshow="search()"> <a href="../hub"><< Back to the hub</a> <h1>Video list</h1> <?php // Load names.php and count videos/series // Includes include_once "../names.php"; include_once "../backend/includes/sort.php"; $videosnumber = count($names); // Rearrange by series $series = rearrange($names); $seriesnumber = count($series); echo '<p>We currently serve <span style="color:#2ECC40">' . $videosnumber . '</span> videos from <span style="color:#2ECC40">' . $seriesnumber . '</span> series.</p>'; ?> <a onmousedown="document.getElementById('searchURL').href = '?s=' + document.getElementById('searchbox').value;" id="searchURL" href="">Search: </a> <input id="searchbox" type="text" onkeyup="search()"><br /><br /> <div id="NoResultsMessage" hidden> <p>We could not find any shows matching your search query.</p> <ol> <li>Is it spelled correctly?</li> <li>Have you tried using the Japanese title?</li> <li>Have you tried using the English title?</li> </ol> <p>If you still can't find the video you are looking for, we probably don't have it yet. In this case, you have two options:</p>
?> </div> <?php } else { ?> <div class="alert alert-success"> <?php echo $idioma['DatosGuardadosError']; ?> </div> <?php } if (empty($_FILES)) { exit; } $files = rearrange($_FILES['files']); foreach ($files as $f) { $CodClasesArchivos = $clasesarchivos->estadoTabla(); $CodClasesArchivos = $CodClasesArchivos['Auto_increment']; if ($nombreArchivo = subirArchivo($f, "documentos/clases/", "", $CodClasesArchivos)) { $valoresArchivo = array("CodClases" => $CodClases, "NombreArchivo" => "'{$nombreArchivo}'", "Tipo" => "'" . $f['type'] . "'"); //print_r($valoresArchivo); //echo "<br>"; $clasesarchivos->insertarRegistro($valoresArchivo); } } //print_r($archivos); } function rearrange($arr) { foreach ($arr as $key => $all) {
function psp_attach_uploads($uploads, $post_id = 0) { $files = rearrange($uploads); if ($files[0]['name'] == '') { return false; } foreach ($files as $file) { $upload_file = wp_handle_upload($file, array('test_form' => false)); $attachment = array('post_mime_type' => $upload_file['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($upload_file['file'])), 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $upload_file['file'], $post_id); $attach_array[] = $attach_id; require_once ABSPATH . 'wp-admin/includes/image.php'; $attach_data = wp_generate_attachment_metadata($attach_id, $upload_file['file']); wp_update_attachment_metadata($attach_id, $attach_data); } return $attach_array; }
<?php $id = !empty($_POST["invoices_setting_id"]) ? $_POST["invoices_setting_id"] : absint($_GET["id"]); $config = empty($id) ? array("meta" => array(), "is_active" => true) : TemplateData::get_invoices_feed($id); $is_validation_error = false; $config["form_id"] = rgpost("invoices_submit") ? absint(rgpost("invoices_form")) : rgar($config, "form_id"); $config["is_active"] = rgpost("invoices_submit") ? absint(rgpost("invoices_isactive")) : rgar($config, "is_active"); $count = 0; if (isset($config['meta']['files'])) { $count = count($config['meta']['files']); } $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); if (rgpost("invoices_submit")) { $newfiles = rearrange($_FILES['invoices_file']); $count = count($newfiles); if (!empty($config['meta'])) { $config['meta']['files'] = array_merge($config['meta']['files']); if (isset($_POST['edit_file_enable'])) { $needles = $_POST['edit_file_enable']; } else { $needles = array(); } if (count(rgpost("edit_file_ids"))) { foreach ($config['meta']['files'] as $key => $val) { if (in_array($val['file_id'], $needles)) { $config['meta']['files'][$key]['enable'] = 1; } else { $config['meta']['files'][$key]['enable'] = 0; } $index = array_search($val['file_id'], rgpost("edit_file_ids")); if (count($index)) {
<?php function rearrange($params) { $arrayOfOrigin = explode(' ', $params['origin']); $arrayOfResult = array(); echo $params['neworder']; foreach (explode(",", $params['neworder']) as $order) { $arrayOfResult[] = $arrayOfOrigin[$order]; } echo implode(" ", $arrayOfResult); } rearrange(array("origin" => "külmast tulest langes pime leek", "neworder" => "2,1,0,4,3")); ?>
<?php $id = !empty($_POST["templatemerge_setting_id"]) ? $_POST["templatemerge_setting_id"] : absint($_GET["id"]); $config = empty($id) ? array("meta" => array(), "is_active" => true) : TemplateData::get_feed($id); $is_validation_error = false; $config["form_id"] = rgpost("templatemerge_submit") ? absint(rgpost("templatemerge_form")) : rgar($config, "form_id"); $config["is_active"] = rgpost("templatemerge_submit") ? absint(rgpost("templatemerge_isactive")) : rgar($config, "is_active"); $count = count($config['meta']['files']); $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); if (rgpost("templatemerge_submit")) { $newfiles = rearrange($_FILES['templatemerge_file']); $count = count($newfiles); if (!empty($config['meta'])) { $config['meta']['files'] = array_merge($config['meta']['files']); if (isset($_POST['edit_file_enable'])) { $needles = $_POST['edit_file_enable']; } else { $needles = array(); } if (count(rgpost("edit_file_ids"))) { foreach ($config['meta']['files'] as $key => $val) { if (in_array($val['file_id'], $needles)) { $config['meta']['files'][$key]['enable'] = 1; } else { $config['meta']['files'][$key]['enable'] = 0; } $index = array_search($val['file_id'], rgpost("edit_file_ids")); if (count($index)) { $config['meta']['files'][$key]['position'] = $_POST['edit_file_position'][$index]; $config['meta']['files'][$key]['level'] = $_POST['edit_file_level'][$index]; $config['meta']['files'][$key]['form_field'] = $_POST['edit_form_field'][$index];