function add_post() { $this->bf_form_validation->set_rules('miUserId', 'Mi User Id', 'xss_clean|numeric|required|trim|is_natural_no_zero|_user_check'); $this->bf_form_validation->set_rules('userId', 'userId', 'xss_clean|trim|required|numeric|max_length[20]|is_natural_no_zero|_user_check'); $this->bf_form_validation->set_rules('diagCatId', 'Diagnostics Category Id', 'xss_clean|trim|numeric|max_length[11]|is_natural_no_zero'); $this->bf_form_validation->set_rules('familyId', 'Family Id', 'xss_clean|trim|numeric|max_length[11]|is_natural_no_zero'); $this->bf_form_validation->set_rules('timeSlotId', 'TimeSlotId', 'xss_clean|trim|numeric|max_length[11]|is_natural_no_zero'); $this->bf_form_validation->set_rules('preferedDate', 'Prefered Date', 'xss_clean|required|trim|max_length[11]|valid_date[y-m-d,-]|callback__check_current_date'); $this->form_validation->set_rules('prescription[]', 'prescription', 'required|xss_clean|trim|valid_base64_image'); $this->prescriptionPath = realpath(FCPATH . 'assets/prsImg') . '/'; if ($this->bf_form_validation->run($this) == FALSE) { // setup the input $response = array('status' => FALSE, 'message' => $this->validation_post_warning()); $this->response($response, 400); } else { $miUserId = isset($_POST['miUserId']) ? $this->input->post('miUserId') : ''; $userId = isset($_POST['userId']) ? $this->input->post('userId') : ''; $diagCatId = isset($_POST['diagCatId']) ? $this->input->post('diagCatId') : ''; $timeSlotId = isset($_POST['timeSlotId']) ? $this->input->post('timeSlotId') : ''; $familyId = isset($_POST['familyId']) ? $this->input->post('familyId') : ''; $preferedDate = isset($_POST['preferedDate']) ? $this->input->post('preferedDate') : ''; $prescription = isset($_POST['prescription']) ? $this->input->post('prescription') : ''; $option = array('data' => array('quotation_MiId' => $miUserId, 'quotation_userId' => $userId, 'quotation_familyId' => $familyId, 'quotation_diagnosticsCatId' => $diagCatId, 'quotation_timeSlotId' => $timeSlotId, 'quotation_dateTime' => $preferedDate != '' ? strtotime($preferedDate) : '', 'creationTime' => time()), 'table' => 'qyura_quotations'); $id = $this->common_model->customInsert($option); if ($id) { $updateOption = array('data' => array('quotation_unqId' => 'qu_' . $id . '_' . time()), 'table' => 'qyura_quotations', 'where' => array('quotation_id' => $id)); $isUpdate = $this->common_model->customUpdate($updateOption); $prescription = $this->input->post('prescription'); for ($i = 0; $i < count($prescription); $i++) { $imgName = 'qu_' . $id . '_' . $i . '_' . time() . '.png'; $img = isset($prescription[$i]) ? createImage($prescription[$i], $this->prescriptionPath, $imgName) : false; $image_name = $img ? $img : ''; $optionPrs = array('data' => array('quotationDetail_prescription' => $image_name, 'quotationDetail_quotationId' => $id, 'creationTime' => time()), 'table' => 'qyura_quotationDetail'); $this->common_model->customInsert($optionPrs); } $response = array('status' => TRUE, 'message' => 'Your Quotation request has been successfully send.You will receive the quotation from the MI shortly'); $this->response($response, 200); } else { $response = array('status' => FALSE, 'message' => 'Error in add record'); $this->response($response, 400); } } }
function createThumbNail($im, $dimension, $format) { if ($format === "png") { $thumb = createImage($dimension, $dimension); } else { $thumb = createImage($dimension, $dimension, true, "white"); } //$dimension = $dimension - 2; // as we add a border of 1px if (isPortrait($im)) { $resized = scaleImageToHeight($im, $dimension); } else { $resized = scaleImageToWidth($im, $dimension); } //$resized = borderImage($resized,1); $final_thumb = mergeImages($thumb, $resized, Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::GRAVITY_CENTER); //$final_thumb = borderImage($final_thumb,1); //$thumb->destroy(); //$resized->destroy(); return $final_thumb; }
function saveFileTo($name, $path, $width = 0, $height = 0) { if (!$_FILES[$name]) { return; } if ($_FILES[$name]["error"] != 0) { return; } $tempFile = $_FILES[$name]['tmp_name']; $fileName = $_FILES[$name]['name']; //$fileSize = $_FILES['Filedata']['size']; if (!is_dir(dirname($path))) { mkdir(dirname($path), true); chmod(dirname($path), 777); } if ($width == 0) { move_uploaded_file($tempFile, $path); } else { move_uploaded_file($tempFile, $tempFile . "." . getFileExtension($fileName)); createImage($tempFile . "." . getFileExtension($fileName), $path, $width, $height); } }
$maxnum = max($data); $width = ($twidth + $tspace) * $num + 4; //image's width $im = imagecreate($width + 40, $height + 20); $lineColor = imagecolorallocate($im, 12, 12, 12); $bgColor = imagecolorallocate($im, 255, 233, 233); $tColor = imagecolorallocate($im, 123, 200, 56); imagefill($im, 0, 0, $bgColor); imageline($im, 30, 0, 30, $height - 2, $lineColor); imageline($im, 30, $height - 2, $width + 30 - 2, $height - 2, $lineColor); while ($i < $num) { imagefilledrectangle($im, $i * ($tspace + $twidth) + 40, $height - $dataValue[$i], $i * ($tspace + $twidth) + 40 + $twidth, $height - 3, $tColor); imagestringup($im, 4, $i * ($tspace + $twidth) + $twidth / 2 + 30, $height - 10, $dataName[$i] . "(" . $dataValue[$i] . ")", $lineColor); $i++; } while ($j <= 500 / 10) { imagestringup($im, 4, 2, $height - $j * 10 + 10, $j * 10, $lineColor); $j = $j + 10; } while ($k <= 500 / 10) { if ($k != 0) { imageline($im, 28, $height - $k * 10, 32, $height - $k * 10, $lineColor); } $k = $k + 10; } imagepng($im); } header("content-type:image/png"); $data = array("Yahoo" => 100, "Google" => 260, "Microsoft" => 320, "IBM" => 250, "Sun System" => 150, "Inter" => 220); createImage($data, 50, 25, 500);
function thumb_crop($filename, $desired_width, $desired_height, $bordersize, $position) { // Get new dimensions $type = file_type($filename); list($width, $height) = getimagesize($filename); if ($desired_width / $desired_height > $width / $height) { $new_width = $desired_width; $new_height = $height * ($desired_width / $width); } else { $new_width = $width * ($desired_height / $height); $new_height = $desired_height; } // Resize $image_p = imagecreatetruecolor($new_width, $new_height); $image_f = imagecreatetruecolor($desired_width, $desired_height); $image = createImage($filename); if ($type == 'image/gif' or $type == 'image/png') { imagecolortransparent($image_p, imagecolorallocatealpha($image_p, 0, 0, 0, 127)); imagealphablending($image_p, false); imagesavealpha($image_p, true); imagecolortransparent($image_f, imagecolorallocatealpha($image_f, 0, 0, 0, 127)); imagealphablending($image_f, false); imagesavealpha($image_f, true); } imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Adjust position switch ($position) { case "topleft": $x = $bordersize; $y = $bordersize; break; case "topright": $x = $new_width - $desired_width + $bordersize; $y = $bordersize; break; case "bottomleft": $x = $bordersize; $y = $new_height - $desired_height + $bordersize; break; case "bottomright": $x = $new_width - $desired_width + $bordersize; $y = $new_height - $desired_height + $bordersize; break; case "center": $x = ($new_width - $desired_width) / 2 + $bordersize; $y = ($new_height - $desired_height) / 2 + $bordersize; break; } // Resample with 1px border imagecopyresampled($image_f, $image_p, $bordersize, $bordersize, $x, $y, $desired_width - 2 * $bordersize, $desired_height - 2 * $bordersize, $desired_width - 2 * $bordersize, $desired_height - 2 * $bordersize); return $image_f; }
public function insertUserProfile($users_id, $data = null) { $profData = array('patientDetails_patientName' => $this->input->post('name'), 'patientDetails_usersId' => $users_id, 'patientDetails_dob' => isset($_POST['dob']) ? strtotime($this->input->post('dob')) : '', 'patientDetails_gender' => isset($_POST['gender']) ? $this->input->post('gender') : '', 'patientDetails_unqId' => 'PNT' . random_string('alnumnew', 6), 'creationTime' => time()); $img = isset($_POST['image']) ? createImage($this->input->post('image'), $this->profImgPath) : false; $image_name = $img ? $img : ''; $profData['patientDetails_patientImg'] = $image_name; if ($data != null && is_array($data)) { $profData = array_merge($profData, $data); } return $this->ion_auth_api->setPatientProf($profData); }
function createAndSaveImage($config, $formulaPath, $formulaPathExtension, $imagePath) { $imageStream = createImage($config, $formulaPath, $formulaPathExtension, false); if (is_null($imageStream)) { return false; } file_put_contents($imagePath, $imageStream); return true; }
/** * Creates resized images for a single image * * @author Ross Carlson * @version 4/05/05 * @since 4/05/05 * @param $image string the FULL path to the image to resize * @param $dimensions string The size of the image to create * @return the name of the resized image if resize succeeded, or the original filename if it failed */ function SERVICE_RESIZE_IMAGE_gd2($image, $dimensions, $dest = false, $imageType = "audio") { global $include_path, $keep_porportions, $resize_images; // Let's make sure they have GD installed if (gd_version() < 2) { return $image; } // Now let's make sure this is a JPG #if (!stristr($image,".jpg") and !stristr($image,"ID3:")){return $image;} if (!(stristr($image, ".jpg") || stristr($image, ".gif")) and !stristr($image, "ID3:")) { return $image; } // Should we do this at all? if ($resize_images == "false") { return $image; } // Ok, let's get on with it... // First let's create our filenames $iArr = explode("/", $image); $imgName = $iArr[count($iArr) - 1]; // Now let's see where this is gonna go unset($iArr[count($iArr) - 1]); unset($iArr[0]); $name = implode("--", $iArr); $path = $name . "--"; if ($dest) { $destImage = $dest; } else { $destImage = $path . str_replace(".jpg", "", $imgName); $destImage = "data/images/" . md5($destImage) . "." . $dimensions . ".jpg"; } // Now let's create the images IF they don't exist if (!is_file($destImage)) { return createImage($image, $destImage, $dimensions); } else { return $destImage; } }
function saveFileToS3ByName($client, $name, $path, $s3bucket = "", $width = 0, $height = 0) { if (!$_FILES[$name]) { return; } if ($_FILES[$name]["error"] != 0) { return; } $tempFile = $_FILES[$name]['tmp_name']; $fileName = $_FILES[$name]['name']; if ($width == 0) { saveObjectToS3ByFile($client, $s3bucket, $path, $tempFile); } else { $tempName = $tempFile . "." . getFileExtension($fileName); $newName = $tempFile . "_new." . getFileExtension($path); move_uploaded_file($tempFile, $tempName); createImage($tempName, $newName, $width, $height); saveObjectToS3ByFile($client, $s3bucket, $path, $newName); unlink($newName); } }
$factory->define(App\Project::class, function (Faker\Generator $faker) { return ['title' => $faker->firstNameFemale, 'owner_id' => function () { return App\User::all()->random()->id; }, 'description' => $faker->realText(100), 'is_public' => $faker->boolean(), 'views' => $faker->numberBetween(0, 1000), 'likes' => $faker->numberBetween(0, 1000)]; }); $factory->define(App\Comment::class, function (Faker\Generator $faker) { return ['content' => $faker->realText(60), 'user_id' => function () { return App\User::all()->random()->id; }, 'project_id' => function () { return App\Project::all()->random()->id; }]; }); $factory->define(App\Color::class, function (Faker\Generator $faker) { return ['name' => $faker->word, 'rgb_hex' => $faker->hexColor]; }); $factory->define(App\Texture::class, function (Faker\Generator $faker) { return ['name' => $faker->word, 'image_id' => createImage()]; }); $factory->define(App\Font::class, function (Faker\Generator $faker) { return ['myfonts_id' => $faker->numberBetween(0, 1000)]; }); $factory->define(App\Tag::class, function (Faker\Generator $faker) { return ['name' => $faker->word]; }); $factory->define(App\Notification::class, function (Faker\Generator $faker) { return ['receiver_id' => function () { return App\User::all()->random()->id; }, 'sender_id' => function () { return App\User::all()->random()->id; }, 'message' => $faker->text(100), 'is_unread' => $faker->boolean(), 'action' => ['projects/', 'users/'][random_int(0, 1)] . App\User::all()->random()->id]; });
/** * This file is part of GrottoCenter. * * GrottoCenter is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GrottoCenter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with GrottoCenter. If not, see <http://www.gnu.org/licenses/>. * * @copyright Copyright (c) 2009-2012 Clément Ronzon * @license http://www.gnu.org/licenses/agpl.txt */ include "../conf/config.php"; include "../func/function.php"; include "declaration.php"; include "application_" . $_SESSION['language'] . ".php"; include "mailfunctions_" . $_SESSION['language'] . ".php"; $frame = "filter"; header("Content-type: text/plain"); $length = isset($_GET['l']) ? $_GET['l'] : 1; $size = isset($_GET['s']) ? $_GET['s'] : 1; deleteImage(); $_SESSION['userCheck'] = createImage($length, $size); echo "'" . $_SESSION['userCheck'] . "'";
echo JURI::root() . $dir . '/original/' . $image->file; ?> "/> <?php echo $aclose; ?> <div class="caption"> <?php echo base64_decode($image->caption); ?> </div> </div> <?php } else { createImage("{$dir}/original/{$image->file}", "{$dir}/slideshow/{$image->file}", $width, $height, true, 100); ?> <div class="swiper-slide"> <?php echo $ashka; ?> <img id="imgheight" unselectable="on" <?php echo $alt; ?> src="<?php echo JURI::root() . $dir . '/slideshow/' . $image->file; ?> "/> <?php echo $aclose; ?>
function processLinks($conn, $row, $href, $imgLink, $title, $time, &$imgIndex, $resizeImages, $imageGIF = false, $saveImage = true) { // Alguns links começam com "//" if (startsWith($href, "//") === FALSE) { // O link é relativo e não absoluto if (!startsWith($href, "http") || $href[0] == "/") { $urlTokens[] = explode("/", $row["SITE"]); $href = $urlTokens[0][0] . "//" . $urlTokens[0][2] . ($href[0] == "/" ? $href : "/{$href}"); unset($urlTokens); } } // Alguns endreços de imagem começam com "//". Nesses casos, acrescento a string "http:" if ($saveImage && $imgLink[0] == "/" && $imgLink[1] == "/") { $imgLink = "http:" . $imgLink; } // Link de imagem relativo if ($saveImage && !startsWith($imgLink, "http")) { $urlTokens[] = explode("/", $row["SITE"]); $imgLink = $urlTokens[0][0] . "//" . $urlTokens[0][2] . "/{$imgLink}"; unset($urlTokens); } // Verifica se o link já está cadastrado no banco de dados $sql = "SELECT ID FROM IMAGENS WHERE LINK = :link"; $stmtLink = $conn->prepare($sql); $stmtLink->bindValue(":link", $href, PDO::PARAM_STR); $stmtLink->execute(); $resultLinks = $stmtLink->fetchAll(PDO::FETCH_ASSOC); // Se o link não estiver adastrado... if (empty($resultLinks)) { if ($saveImage) { // Gera o nome da imagem antes de gravar na base if (stristr($imgLink, ".jpg") || stristr($imgLink, ".jpeg")) { $formato = ".jpg"; } else { if (stristr($imgLink, ".png")) { $formato = ".png"; } else { if ($imageGIF && stristr($imgLink, ".gif")) { $formato = ".gif"; } else { return; } } } $pasta = $time . "/"; $nomeImagem = $pasta . $row["ID_SITE"] . $imgIndex++ . $formato; } else { $nomeImagem = $imgLink; } // Grava os dados do link e imagem no banco de dados. Se houver algum erro, dá rollback try { $conn->beginTransaction(); $sql = "INSERT INTO IMAGENS (SITE_ID, LINK, ALT, CAMINHO_IMAGEM) VALUES (:site, :link, :alt, :imagem)"; $stmtLink = $conn->prepare($sql); $stmtLink->bindValue(":site", $row["ID_SITE"], PDO::PARAM_INT); $stmtLink->bindValue(":link", $href, PDO::PARAM_STR); $stmtLink->bindValue(":alt", trim($title) == "" ? $row["CATEGORIA"] : $title, PDO::PARAM_STR); $stmtLink->bindValue(":imagem", $nomeImagem, PDO::PARAM_STR); $stmtLink->execute(); if ($saveImage) { // Cria o arquivo com a imagem $fileStatus = createImage($nomeImagem, file_get_contents($imgLink)); if ($resizeImages) { // Cria o thumbnail da imagem generateThumbnail($nomeImagem); } if ($fileStatus === FALSE) { throw new Exception("Erro ao criar imagem"); } } $conn->commit(); echo $row["ID_SITE"] . " - {$href}: <span style='color:blue'>IMPORTADO</span><br />\n"; return true; } catch (Exception $exc) { $conn->rollBack(); echo $row["ID_SITE"] . " - {$href}: <span style='color:red'>ERRO: " . $exc->getMessage() . " - {$imgLink}</span><br />\n"; return false; } } else { //echo $row["ID_SITE"] . " - $href: <span style='color:orange'>EXISTENTE</span><br />\n"; return false; } }
flush(); foreach ($images as $k => $image) { $image = $link->getImageLink($productObj->link_rewrite, $image['id_image'], 'thickbox'); $image = (int) preg_replace('/\\D/', '', $image); $str = str_split($image); $filepath = "/var/www/indusdiva.com/img/p/"; $filepath = $filepath . implode("/", $str) . "/" . $image . "-thickbox.jpg"; $new_filename = "{$id_product}_{$count}.jpg"; $new_filename = "/var/www/indusdiva.com/gosf-images/" . $new_filename; $source_gd_image = createImageFromFile($filepath); $new_width = 483; $new_height = 660; $dest_gd_image = scaleImageToHeight($source_gd_image, $new_height); $background = createImage(990, 660); $background = mergeImages($background, $dest_gd_image, Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::GRAVITY_CENTER); $background->setImageFormat('jpg'); $background->writeImage($new_filename); $source_gd_image->destroy(); $dest_gd_image->destroy(); $background->destroy(); $count++; } } //LOGO $filepath = "/home/venu/Logo.jpg"; $source_gd_image = createImageFromFile($filepath); $dest_gd_image = scaleImageToWidth($source_gd_image, 990); $background = createImage(990, 660); $background = mergeImages($background, $dest_gd_image, Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::GRAVITY_CENTER); $background->setImageFormat('jpg'); $background->writeImage('/var/www/indusdiva.com/gosf-images/logo.jpg');
// | | // | This program is free software; you can redistribute it and/or | // | modify it under the terms of the MPL General Public License | // | as published by the Free Software Foundation; either version 1.1 | // | of the License, or (at your option) any later version. | // | | // | You should have received a copy of the MPL Mozilla Public License | // | along with this program; if not, write to the Open Source Initiative (OSI) | // | http://opensource.org | osi@opensource.org | // | | // ------------------------------------------------------------------------------- // Written by: Mark Henning (tirex) for Lostpw Mod if (!isset($_SESSION)) { session_start(); } createImage('image', array(229, 243, 252), array(0, 53, 92), 100, 20); function strrand($length) { $str = ""; while (strlen($str) < $length) { $random = rand(48, 122); if (ereg('[A-Za-z]', chr($random))) { $str .= chr($random); } } return $str; } function createImage($strSessionVar, $rgBgColor, $rgTextColor, $x, $y) { $iRandVal = strrand(10); $_SESSION[$strSessionVar] = $iRandVal;
function ODT() { global $title, $subtitle, $odtfile, $document, $ids, $files, $docs, $names, $output_text, $output_manifest, $output_meta, $tempdir, $msg, $lang, $template; $title = $this->title; $subtitle = $this->subtitle; $ids = $this->ids; $files = $this->files; $docs = $this->docs; $odtfile = "QSOS_" . $docs[0]->getkey("qsosappfamily") . ".odt"; $names = $this->names; $lang = $this->lang; $msg = $this->msg; $template = $this->template; function createTitle($level, $style, $text) { global $output_text; $title = $output_text->createElement("text:h", $text); $title->setAttribute("text:style-name", $style); $title->setAttribute("text:outline-level", $level); return $title; } function createFirstTitle1($text) { return createTitle("1", "P30", $text); } function createTitle1($text) { return createTitle("1", "Heading_20_1", $text); } function createTitle2($text) { return createTitle("2", "Heading_20_2", $text); } function createTitle3($text) { return createTitle("3", "Heading_20_3", $text); } function createSimpleP($text) { global $output_text; $p = $output_text->createElement("text:p", $text); $p->setAttribute("text:style-name", "Text_20_body"); return $p; } function createSimpleTODO($text) { global $output_text; $p = $output_text->createElement("text:p", $text); $p->setAttribute("text:style-name", "PHL"); return $p; } function createP($contents) { global $output_text; $p = $output_text->createElement("text:p"); $p->setAttribute("text:style-name", "Text_20_body"); foreach ($contents as $content) { switch ($content[0]) { case "t": $span = $output_text->createTextNode($content[1]); break; case "i": $span = $output_text->createElement("text:span", $content[1]); $span->setAttribute("text:style-name", "T1"); break; case "a": $span = $output_text->createElement("text:a", $content[1]); $span->setAttribute("xlink:type", "simple"); $span->setAttribute("xlink:href", $content[1]); break; } $p->appendChild($span); } return $p; } function createList($contents) { global $output_text; $list = $output_text->createElement("text:list"); $list->setAttribute("text:continue-numbering", "true"); $list->setAttribute("text:style-name", "List_20_1"); $item = $output_text->createElement("text:list-item"); if (is_array($contents)) { foreach ($contents as $subelement) { $item->appendChild(createList($subelement)); } } else { $p = $output_text->createElement("text:p", $contents); $p->setAttribute("text:style-name", "Liste_20_Hiérarchique"); $item->appendChild($p); } $list->appendChild($item); return $list; } function createBoldTitle($title) { global $output_text; $p = $output_text->createElement('text:p', $title); $p->setAttribute("text:style-name", "P16"); return $p; } function createImage($image) { global $tempdir, $output_text; if (substr($image, -3) == "png") { $ratio = 0.023291; //(ratio px <=> cm) //Get image dimensions $size = getimagesize($tempdir . "/" . $image); $width = $size[0] * $ratio; $height = $size[1] * $ratio; $style = "fr7"; } else { //Crop and scale image $ratio = 0.65; if ($image == "quadrant.svg") { $width = (26.457 - 1) * $ratio; $height = (15.874 - 5) * $ratio; $style = "frQuadrant"; } else { $width = (26.457 - 1) * $ratio; $height = (15.874 - 6) * $ratio; $style = "frSvg"; } } $p = $output_text->createElement('text:p'); $p->setAttribute("text:style-name", "P15"); $frame = $output_text->createElement('draw:frame'); $frame->setAttribute("draw:style-name", $style); $frame->setAttribute("text:anchor-type", "as-char"); $frame->setAttribute("svg:width", $width . "cm"); $frame->setAttribute("svg:height", $height . "cm"); $frame->setAttribute("draw:z-index", "191"); $svg = $output_text->createElement('draw:image'); $svg->setAttribute("xlink:href", "Pictures/{$image}"); $svg->setAttribute("xlink:type", "simple"); $svg->setAttribute("xlink:show", "embed"); $svg->setAttribute("xlink:actuate", "onLoad"); $frame->appendChild($svg); $p->appendChild($frame); return $p; } function createImageEmbedded($image, $width, $height) { global $output_text; $p = $output_text->createElement('text:p'); $p->setAttribute("text:style-name", "P15"); $frame = $output_text->createElement('draw:frame'); $frame->setAttribute("draw:style-name", "fr7"); $frame->setAttribute("text:anchor-type", "as-char"); $frame->setAttribute("svg:width", $width); $frame->setAttribute("svg:height", $height); $frame->setAttribute("draw:z-index", "191"); $svg = $output_text->createElement('draw:image'); $svg->setAttribute("xlink:href", "Pictures/{$image}"); $svg->setAttribute("xlink:type", "simple"); $svg->setAttribute("xlink:show", "embed"); $svg->setAttribute("xlink:actuate", "onLoad"); $frame->appendChild($svg); $p->appendChild($frame); return $p; } function createManifest() { global $output_manifest, $lang, $docs, $template; include "export/{$template}/settings-odt-{$lang}.php"; $manifest = $output_manifest->createElement('manifest:manifest'); $manifest->setAttribute("xmlns:manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"); $manifest->setAttribute("manifest:version", "1.2"); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "application/vnd.oasis.opendocument.text"); $file->setAttribute("manifest:version", "1.2"); $file->setAttribute("manifest:full-path", "/"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "image/png"); $file->setAttribute("manifest:full-path", "Thumbnails/thumbnail.png"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "application/binary"); $file->setAttribute("manifest:full-path", "layout-cache"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "text/xml"); $file->setAttribute("manifest:full-path", "settings.xml"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "text/xml"); $file->setAttribute("manifest:full-path", "content.xml"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "text/xml"); $file->setAttribute("manifest:full-path", "meta.xml"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "text/xml"); $file->setAttribute("manifest:full-path", "styles.xml"); $manifest->appendChild($file); foreach ($tpl_images as $image) { $tmp_array = array_reverse(explode(".", $image)); $ext = $tmp_array[0]; if ($ext == "jpg") { $mime = "image/jpeg"; } else { $mime = "image/{$ext}"; } if ($ext == "wmf") { $mime = ""; } $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "{$mime}"); $file->setAttribute("manifest:full-path", "Pictures/{$image}"); $manifest->appendChild($file); } foreach ($docs[0]->getTree() as $section) { $name = $section->name; $image = $name . ".svg"; $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "image/svg+xml"); $file->setAttribute("manifest:full-path", "Pictures/{$image}"); $manifest->appendChild($file); $image = "tpl-{$name}.png"; $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "image/png"); $file->setAttribute("manifest:full-path", "Pictures/{$image}"); $manifest->appendChild($file); for ($i = 0; $i < count($docs); $i++) { $image = "{$i}-{$name}.png"; $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "image/png"); $file->setAttribute("manifest:full-path", "Pictures/{$image}"); $manifest->appendChild($file); } } $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "image/svg+xml"); $file->setAttribute("manifest:full-path", "Pictures/quadrant.svg"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "application/rdf+xml"); $file->setAttribute("manifest:full-path", "manifest.rdf"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", ""); $file->setAttribute("manifest:full-path", "Configurations2/accelerator/current.xml"); $manifest->appendChild($file); $file = $output_manifest->createElement('manifest:file-entry'); $file->setAttribute("manifest:media-type", "application/vnd.sun.xml.ui.configuration"); $file->setAttribute("manifest:full-path", "Configurations2/"); $manifest->appendChild($file); return $manifest; } function createMeta() { global $output_meta, $lang, $docs, $title, $template; include "export/{$template}/settings-odt-{$lang}.php"; $meta = $output_meta->createElement('office:document-meta'); $meta->setAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0"); $meta->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); $meta->setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/"); $meta->setAttribute("xmlns:meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"); $meta->setAttribute("xmlns:ooo", "http://openoffice.org/2004/office"); $meta->setAttribute("xmlns:grddl", "http://www.w3.org/2003/g/data-view#"); $meta->setAttribute("office:version", "1.2"); $ometa = $output_meta->createElement('office:meta'); $ometa->appendChild($output_meta->createElement("meta:generator", "O3S")); $ometa->appendChild($output_meta->createElement("dc:title", $docs[0]->getkey("qsosappfamily"))); $ometa->appendChild($output_meta->createElement("dc:subject", $tpl_subject)); $ometa->appendChild($output_meta->createElement("meta:creation-date", Date('Y-m-d') . 'T' . Date('H:i:s'))); $ometa->appendChild($output_meta->createElement("meta:initial-creator", $tpl_creator)); $ometa->appendChild($output_meta->createElement("dc:date", Date('Y-m-d') . 'T' . Date('H:i:s'))); $ometa->appendChild($output_meta->createElement("dc:creator", $tpl_creator)); $ometa->appendChild($output_meta->createElement("meta:document-statistic")); $mud = $output_meta->createElement('meta:user-defined', $tpl_client1); $mud->setAttribute("meta:name", "Client 1"); $ometa->appendChild($mud); $mud = $output_meta->createElement('meta:user-defined', $tpl_client2); $mud->setAttribute("meta:name", "Client 2"); $ometa->appendChild($mud); $mud = $output_meta->createElement('meta:user-defined', Date('d-m-Y')); $mud->setAttribute("meta:name", "Date"); $ometa->appendChild($mud); $mud = $output_meta->createElement('meta:user-defined', $tpl_projet); $mud->setAttribute("meta:name", "Projet"); $ometa->appendChild($mud); $mud = $output_meta->createElement('meta:user-defined', "1"); $mud->setAttribute("meta:name", "Version Majeure"); $ometa->appendChild($mud); $mud = $output_meta->createElement('meta:user-defined', "0"); $mud->setAttribute("meta:name", "Version Mineure"); $ometa->appendChild($mud); $meta->appendChild($ometa); return $meta; } function createContent($contents) { global $output_text; if (!$contents) { return; } foreach ($contents as $content) { switch ($content[0]) { case "firsttitle1": $output_text->appendChild(createFirstTitle1($content[1])); break; case "title1": $output_text->appendChild(createTitle1($content[1])); break; case "title2": $output_text->appendChild(createTitle2($content[1])); break; case "title3": $output_text->appendChild(createTitle3($content[1])); break; case "todo": $output_text->appendChild(createSimpleTODO($content[1])); break; case "simplep": $output_text->appendChild(createSimpleP($content[1])); break; case "p": $output_text->appendChild(createP($content[1])); break; case "list": $output_text->appendChild(createList($content[1])); break; case "image": $output_text->appendChild(createImageEmbedded($content[1], $content[2], $content[3])); break; } } } //Finalize Document (on disk) $tempdir = $this->temp . uniqid(); mkdir($tempdir, 0755); //$output->save("$tempdir/content.xml"); copy("export/{$template}/template_odt.zip", "odf/{$odtfile}"); include 'libs/pclzip.lib.php'; $oofile = new PclZip("odf/{$odtfile}"); //Predefined XML elements $f = fopen("export/{$template}/odt.xml", "r"); $input = fread($f, filesize("export/{$template}/odt.xml")); fclose($f); //Contents include "export/{$template}/settings-odt-{$lang}.php"; $output_text = new DOMDocument('1.0', 'UTF-8'); //1. Introduction createContent($tpl_msg_content['Introduction']); //2. Template createContent($tpl_msg_content['Template']); $list = array(); //List of sections descriptions $section_title = array(); //List of sections titles $section_name = array(); //List of sections names $images = array(); //List of sections images (MindMap) foreach ($docs[0]->getTree() as $section) { $name = $section->name; $title = $section->title; $image = "tpl-" . $name; $this->exportTemplateSection($docs[0], $name, "{$tempdir}/{$image}"); $image = "{$image}.png"; $desc = $docs[0]->getTreeDesc($section->name); array_push($list, $desc); array_push($section_title, $title); array_push($section_name, $name); $v_list = $oofile->add("{$tempdir}/{$image}", PCLZIP_OPT_ADD_PATH, "Pictures", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 02: ODT generation " . $oofile->errorInfo(true)); } array_push($images, createImage($image)); } //List of sections $output_text->appendChild(createList($docs[0]->getTreeDesc())); //For each section display title, image and description $i = 0; foreach ($images as $image) { //$output_text->appendChild(createBoldTitle($section_title[$i])); $output_text->appendChild(createTitle2($section_title[$i])); $output_text->appendChild($image); $output_text->appendChild(createList($list[$i])); $i++; } //4. Solutions createContent($tpl_msg_content['Solutions_header']); $contents = array(); for ($i = 0; $i < count($ids); $i++) { array_push($contents, $names[$i] . " (" . $docs[$i]->getkey("url") . ") : " . $docs[$i]->getkey("desc")); } $output_text->appendChild(createList($contents)); createContent($tpl_msg_content['Solutions_header_todo']); for ($i = 0; $i < count($ids); $i++) { $output_text->appendChild(createTitle2($names[$i])); createContent($tpl_msg_content['Solutions_header_project']); $this->exportSection($docs[$i], $section_name[0], $tempdir . "/" . $i . "-" . $section_name[0]); $image = $i . "-" . $section_name[0] . ".png"; $v_list = $oofile->add("{$tempdir}/{$image}", PCLZIP_OPT_ADD_PATH, "Pictures", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 02: ODP generation " . $oofile->errorInfo(true)); } $output_text->appendChild(createImage($image)); createContent($tpl_msg_content['Solutions_footer_project']); createContent($tpl_msg_content['Solutions_header_coverage']); for ($k = 1; $k < count($section_title); $k++) { $output_text->appendChild(createBoldTitle($section_title[$k])); $this->exportSection($docs[$i], $section_name[$k], $tempdir . "/" . $i . "-" . $section_name[$k]); $image = $i . "-" . $section_name[$k] . ".png"; $v_list = $oofile->add("{$tempdir}/{$image}", PCLZIP_OPT_ADD_PATH, "Pictures", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 02: ODP generation " . $oofile->errorInfo(true)); } $output_text->appendChild(createImage($image)); createContent($tpl_msg_content['Solutions_footer_coverage']); } } //5. Synthesis createContent($tpl_msg_content['Analysis_header_comparison']); for ($i = 0; $i < count($section_name); $i++) { $image = $section_name[$i] . ".svg"; $this->setCriteria($section_name[$i]); $this->saveRadar("{$tempdir}/{$image}"); $v_list = $oofile->add("{$tempdir}/{$image}", PCLZIP_OPT_ADD_PATH, "Pictures", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 02: ODT generation " . $oofile->errorInfo(true)); } $output_text->appendChild(createBoldTitle($section_title[$i])); $output_text->appendChild(createImage($image)); createContent($tpl_msg_content['Analysis_footer_comparison']); } createContent($tpl_msg_content['Analysis_header_conclusion']); $image = "quadrant.svg"; $this->saveQuadrant("{$tempdir}/{$image}"); $v_list = $oofile->add("{$tempdir}/{$image}", PCLZIP_OPT_ADD_PATH, "Pictures", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 02: ODT generation " . $oofile->errorInfo(true)); } $output_text->appendChild(createImage($image)); createContent($tpl_msg_content['Analysis_footer_conclusion']); //6. Appendixes //QSOS createContent($tpl_msg_content['Appendixes_header']); //Sources or Credits createContent($tpl_msg_content['Sources']); createContent($tpl_msg_content['Credits']); $list = array(); $i = 0; foreach ($this->ids as $id) { $authors = ""; if ($tpl_msg_content['Credits']) { foreach ($docs[$i]->getauthors() as $author) { if ($author->name != "") { $authors .= $author->name . ","; } } if ($authors != "") { $authors = " (" . rtrim($authors, ",") . ")"; } } $tmp_array = array_reverse(explode("/", $files[$i])); array_push($list, $names[$i] . " : " . $tmp_array[0] . $authors); $i++; } $output_text->appendChild(createList($list)); //hack to remove XML declaration foreach ($output_text->childNodes as $node) { $fragment .= $output_text->saveXML($node) . "\n"; } $content = $input . "\n" . $fragment . "</office:text></office:body></office:document-content>"; $file_content = fopen("{$tempdir}/content.xml", 'w'); fwrite($file_content, $content); fclose($file_content); $v_list = $oofile->add("{$tempdir}/content.xml", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 03: ODT generation " . $oofile->errorInfo(true)); } //Manifest generation $output_manifest = new DOMDocument('1.0', 'UTF-8'); $output_manifest->appendChild(createManifest()); $output_manifest->save("{$tempdir}/manifest.xml"); $v_list = $oofile->add("{$tempdir}/manifest.xml", PCLZIP_OPT_ADD_PATH, "META-INF", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 04: ODT generation " . $oofile->errorInfo(true)); } //Meta generation $output_meta = new DOMDocument('1.0', 'UTF-8'); $output_meta->appendChild(createMeta()); $output_meta->save("{$tempdir}/meta.xml"); $v_list = $oofile->add("{$tempdir}/meta.xml", PCLZIP_OPT_REMOVE_PATH, $tempdir); if ($v_list == 0) { die("Error 05: ODT generation " . $oofile->errorInfo(true)); } //Return ODT file to the browser header("Location: odf/{$odtfile}"); exit; }
$query = $db->query($sql); $items = array(); while($row = $db->getRow($query)){ $items[] = $row; } if( isset( $_GET['id'] ) ) { $images = Note::getAll( array( "id" => $_GET['id'] ) ); } foreach($items as $item) { if( isset( $item['image_full'] ) ) createImage( $item, 'image_full' ); if( isset( $item['image_full_back'] ) ) createImage( $item, 'image_full_back', '_back' ); } function createImage( $item, $data_field, $suffix = '' ) { $defs = array ( array('ext'=>'tiny','height'=>30,'crop'=>false) ); if( is_null( $item[ $data_field ] ) || empty( $item[ $data_field ] ) ) return; $orig = imagecreatefromstring( $item[ $data_field ] ); $width_orig = imagesx($orig); $height_orig = imagesy($orig);
<?php $data = $_REQUEST["json"]; $data = str_replace("+", " ", $data); $data = str_replace("SUMAR", "+", $data); $nameFile = $_REQUEST["nameFile"]; saveJSON($data, $nameFile); createImage($data, $nameFile); function saveJSON($data, $nameFile) { $file = 'images/photo_' . $nameFile . '.txt'; $success = file_put_contents($file, $data); } function createImage($json, $nameFile) { header("Content-type: image/gif"); $obj = json_decode($json); $file = 'images/photo_' . $nameFile . '.jpg'; $success = file_put_contents($file, base64_decode($obj->{'json'})); }
{ print_r(getimagesize($imageName)); //获取原始图片的宽度、高度、类型(数字) list($src_w, $src_h, $src_type) = getimagesize($imageName); //获取mime $mime = image_type_to_mime_type($src_type); echo $mime; $createFunc = str_replace("/", "createfrom", $mime); //imagecreatefromjpeg函数 $outFunc = str_replace("/", null, $mime); //imagejpeg函数 //读取源图片(使用变量函数) //$src_img = $createFunc($imageName); //使用变量函数 $src_img = call_user_func($createFunc, $imageName); $dst_w = $scale * $src_w; $dst_h = $scale * $src_h; //创建目标图片 $dst_img = imagecreatetruecolor($dst_w, $dst_h); //复制图片 imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h); //输出图片 //$outFunc($dst_img, "small/" . $imageName); call_user_func($outFunc, $dst_img, "small/" . $imageName); //释放资源 imagedestroy($src_img); imagedestroy($dst_img); } $imageName = "1348626560988.jpg"; createImage($imageName, 0.3);
/** * i-MSCP - internet Multi Server Control Panel * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is "VHCS - Virtual Hosting Control System". * * The Initial Developer of the Original Code is moleSoftware GmbH. * Portions created by Initial Developer are Copyright (C) 2001-2006 * by moleSoftware GmbH. All Rights Reserved. * * Portions created by the ispCP Team are Copyright (C) 2006-2010 by * isp Control Panel. All Rights Reserved. * * Portions created by the i-MSCP Team are Copyright (C) 2010-2015 by * i-MSCP - internet Multi Server Control Panel. All Rights Reserved. */ // Include core library require_once 'imscp-lib.php'; require_once LIBRARY_PATH . '/Functions/LostPassword.php'; createImage('image');
/** * Judges the user submission for a language against the given hole configuration. * * @param array $hole The hole's configuration. @see loadHole() for details. * @param string $languageName One of the supported languages. * @param string $script The file path to the user's submission to test. * @return array The results of judging the submission and the details of the submission's last run. Included fields: * bool result Whether the submission passed the tests or not. * int exitStatus The exit status of the command. * string output The output, trimmed according to the rules of the hole. * string sample The expected output, trimmed according to the rules of the hole. * string stderr The stderr output. * array constants The constants' used, if any. */ function judge(array $hole, $languageName, $script) { $hole += ['constants' => [], 'disableFunctionality' => [], 'trim' => null]; $maxValues = 0; $allConstantValues = []; foreach ($hole['constants'] as $constantName => $constantValueFn) { $allConstantValues[$constantName] = is_callable($constantValueFn) ? call_user_func($constantValueFn) : $constantValueFn; $maxValues = max($maxValues, count($allConstantValues[$constantName])); } $allConstants = []; foreach ($allConstantValues as $constantName => $constantValues) { for ($i = 0; $i < $maxValues; $i++) { $allConstants[$i][$constantName] = $constantValues[$i % count($constantValues)]; } } if (empty($allConstants)) { $allConstants = [[]]; } foreach ($allConstants as $constants) { $sample = is_callable($hole['sample']) ? call_user_func_array($hole['sample'], $constants) : $hole['sample']; $image = createImage($languageName, $script, $constants); foreach ($hole['disableFunctionality'] as $functionality) { $image = $image['disableFunctionality']($image, $functionality); } $result = execute($image) + ['constants' => $constants, 'sample' => $sample]; dockerRequest('images/' . urlencode($image['tagName']), 'DELETE'); if ($hole['trim'] !== null) { $result['output'] = $hole['trim']($result['output']); $result['sample'] = $hole['trim']($result['sample']); } $result['result'] = $result['exitStatus'] === 0 && $result['output'] === $result['sample']; if (!$result['result']) { return $result; } } return $result; }
?> </textarea> </td> </tr> <tr> <td height="29"><div align="right"> <?php echo $require; ?> Mã xác nhận: </div></td> <td><input type="text" name="code" size="3" maxlength="10"> <?php echo createImage(); ?> </td> </tr> <tr> <td></td> <td><input name="Send" type="submit" value="Send"> </td> </tr> <tr> <td height="50" colspan="2"> </td> </tr> </table> </form>
function catchpa() { global $fontColor, $bgColor, $lineColor, $set, $out; $fontSize = 5; // font size (1 - 5) $fontColor = "000000"; // font color (RGB hexcode) $bgColor = "FFFFFF"; // background color (RGB hexcode) $lineColor = "B0B0B0"; // line color (RGB hexcode) srand((double) microtime() * 1000000); $secCode = ''; for ($i = 0; $i < 6; $i++) { $secCode .= rand(0, 9); } $_SESSION[session_id()] = $secCode; $ext = createImage($secCode, 71, 21, $fontSize); return "<input type=\"text\" name=\"secCode\" maxlength=\"6\" style=\"width:50px\" />\n <b>«</b> <img src=\"data/catchpa.{$ext}\" width=\"71\" height=\"21\" align=\"absmiddle\" />"; }
?> " size="20" maxlength="20" /> </td></tr><tr><td width="170" class="label"> <label for="f_caver_contact"> <img src="../images/icons/FlagRequired.gif" alt="*" /><convert>#label=197<convert><!--E-mail de contact--> </label> </td><td class="field"> <input class="input1" type="text" id="f_caver_contact" name="f_caver_contact" value="<?php echo $contact; ?> " size="20" maxlength="40" /> </td></tr><tr><td width="170" class="label"> <?php $_SESSION['do_check'] = $_SESSION['send_retry'] > 3; if ($_SESSION['do_check']) { $_SESSION['userCheck'] = createImage(6, 16); ?> <label for="check"> </label> </td><td class="field"> <img class="image1" name="check" id="check" src="<?php echo $_SESSION['userCheck']; ?> .gif" alt="image" /> </td></tr><tr><td width="170" class="label"> <label for="reload_btn"> <convert>#label=210<convert><!--Je ne peux pas lire le texte--> </label> </td><td class="field"> <input class="button1" onclick="JavaScript:reloadCaptcha(6, 16, this, 'check');" type="button" id="reload_btn" name="reload_btn" value="<convert>#label=108<convert>" /><!--Cliquez ici--> </td></tr><tr><td width="170" class="label">
foreach ($images as $image) { $temp_original_img = "{$dir}/original/{$image->file}"; if (JFile::exists($temp_original_img)) { $info = getimagesize($temp_original_img); $temp_relation = abs($info[0] / $info[1]); $good_relation = abs($seting_relation - $temp_relation); if ($good_relation < $best_relation) { $best_relation = $good_relation; $num_img = $i; } } $i++; } $i = 0; foreach ($images as $i => $image) { createImage("{$dir}/original/{$image->file}", "{$dir}/thumbnail/{$image->file}", $width, $height, true, 100); $alt = $image->alt ? " alt='" . $image->alt . "' title='" . $image->alt . "' " : ""; if ($i % $img_in_row == 0 && $i != 0) { echo '</div>'; } if ($i % $img_in_row == 0) { echo '<div class="rowImages">'; } ?> <a href="<?php echo JURI::root() . $dir . '/original/' . $image->file; ?> " rel="group" class="<?php echo $faxc_class; ?> "><!-- original img -->
<?php createImage(); exit; function createImage() { $firstNumber = rand(0, 9); $secondNumber = rand(0, 9); $thirdNumber = rand(0, 9); $securityCode = $firstNumber + $secondNumber + $thirdNumber; $hashedCode = hash("ripemd160", $securityCode); $imageString = $_GET['test'] . $firstNumber . " + " . $secondNumber . " - " . $thirdNumber . " = "; $_SESSION['captchaCode'] = $hashedCode; $width = 120; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageFill($image, 0, 0, $white); ImageString($image, 5, 10, 3, $imageString, $black); header("Content-Type: image/jpeg"); ImageJpeg($image); ImageDestroy($image); }
@ImageLine($img, $i, 0, $i, $height, $lineColor); } for ($i = 0; $i <= $height; $i += 5) { @ImageLine($img, 0, $i, $width, $i, $lineColor); } $hcenter = $width / 2; $vcenter = $height / 2; $x = round($hcenter - ImageFontWidth($font) * strlen($text) / 2); $y = round($vcenter - ImageFontHeight($font) / 2); ImageString($img, $font, $x, $y, $text, $fontColor); if (function_exists('ImagePNG')) { header('Content-Type: image/png'); @ImagePNG($img); } else { if (function_exists('ImageGIF')) { header('Content-Type: image/gif'); @ImageGIF($img); } else { if (function_exists('ImageJPEG')) { header('Content-Type: image/jpeg'); @ImageJPEG($img); } } } ImageDestroy($img); } } $secCode = substr(str_shuffle($string), 0, 5); $_SESSION[$name] = $secCode; createImage($secCode, 71, 21, $fontSize);