for ($i = 0; $i < $center_width; $i++) { AddImage('n', $gx, 0); } AddImage('ne', $gx, 0); $y = $padding['top']; $gx = 0; AddImage('w', $gx, $y, null, $center_height); AddImage('c', $gx, $y, $center_width, $center_height); AddImage('e', $gx, $y, null, $center_height); $gx = 0; $y = $padding['top'] + $center_height; AddImage('sw', $gx, $y); for ($i = 0; $i < $center_width; $i++) { AddImage('s', $gx, $y); } AddImage('se', $gx, $y); $y = 0; for ($row = 0; $row < $_rows; $row++) { $y = $row * ($icon_size['height'] + $icon_margin['top'] + $icon_margin['bottom']) + $padding['top'] + $content_margin['top']; if ($row > 0) { $y += $icon_margin['bottom']; } $gx = $padding['left'] + $content_margin['left']; for (; $gx + $padding['right'] <= $width;) { $gx += $icon_margin['left']; AddImage('icon', $gx, $y); $gx += $icon_margin['right']; } } imagepng($image); imagedestroy($image);
/** * Обработчик действия: Отдает таблицу с элементами текущего уровня. */ function getGrid() { $form = new A_Form("module_pages_grid.tpl"); $curdir = (int) A_Session::get(SECTION . "_cid", 0); $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20); $form->data['seo'] = getStructureByPlugin('seo'); $form->data['title'] = $this->getPath($curdir); $form->data['pages'] = array(); $pager = new A_Pager($rows, "gopage"); $pager->query("SELECT * FROM " . SECTION . " WHERE idker={$curdir} ORDER BY sort"); if ($curdir > 0 && ($row = A::$DB->getRowById($curdir, SECTION))) { $grow[0] = " "; $grow[1] = AddImageButton("/templates/admin/images/back.gif", "indir({$row['idker']})", "Уровень выше", 16, 16); $grow[2] = AddClickText("...", "indir({$row['idker']})"); $grow[3] = $grow[5] = $grow[6] = $grow[7] = $grow[8] = " "; $grow[4] = 0; $form->data['sub'] = true; $form->data['pages'][] = $grow; } else { $form->data['sub'] = false; } $crows = 0; while ($row = $pager->fetchRow()) { $grow[0] = "<input type=\"checkbox\" id=\"checkp{$crows}\" name=\"checkpages[]\" value=\"{$row['id']}\"/>"; $grow['link'] = pages_createItemLink($row['id'], SECTION); if ($row['type'] == 'dir') { $grow[1] = AddImage("/templates/admin/images/dir.gif", 16, 16); $grow[2] = AddLink(truncate($row['name'], 100), "javascript:indir({$row['id']})", "Войти в подраздел"); $grow[3] = " "; $grow[4] = $row['date']; $grow[5] = AddImageButton("/templates/admin/images/edit.gif", "geteditdirform({$row['id']})", "Редактировать", 16, 16); $grow[6] = AddImageButtonLink("/templates/admin/images/browse.gif", $grow['link'], "Просмотр на сайте", 16, 16, ' target="_blank"'); } else { $grow[1] = AddImage("/templates/admin/images/text.gif", 16, 16); $grow[2] = AddLink(truncate($row['name'], 100), "javascript:geteditpageform({$row['id']})", "Редактировать"); $grow[3] = "<a href=\"javascript:edittpl('{$row['template']}')\" title=\"Редактировать шаблон\">{$row['template']}</a>"; $grow[4] = $row['date']; $grow[5] = " "; $grow[6] = AddImageButtonLink("/templates/admin/images/browse.gif", $grow['link'], "Просмотр на сайте", 16, 16, ' target="_blank"'); } $grow[7] = AddImageButton("/templates/admin/images/move.gif", "getmoveform({$row['id']})", "Переместить", 16, 16); $grow[8] = AddImageButton("/templates/admin/images/del.gif", "delitem({$row['id']},'{$row['urlname']}')", "Удалить", 16, 16); $grow['id'] = $row['id']; $grow['active'] = $row['active']; $form->data['pages'][] = $grow; $crows++; } $pager->free(); $form->data['pager'] = $pager; $this->RESULT['html'] = $form->getContent(); }
$petid = intval($_GET['id']); if ($petid < 0 || $petid > 1000) { die; } $petid = 5000000 + $petid; $images_location = 'http://static_images.mapler.me/Inventory/Pet/'; // Add ID to image location $images_location .= $petid . '.img/'; $image = imagecreatetruecolor(256, 256); imagesavealpha($image, true); $trans = imagecolorallocatealpha($image, 0, 0, 0, 127); imagefill($image, 0, 0, $trans); $x = 128; $y = 128 - 10; $info = GetItemWZInfo($petid, CURRENT_LOCALE); $image_offset = array(0, 0); if ($info['stand0'] !== null) { $origin = $info['stand0']['0']['origin']; $image_offset[0] = $origin['X']; $image_offset[1] = $origin['Y']; } AddImage('stand0.0.png', $x - $image_offset[0], $y - $image_offset[1]); imagepng($image); imagedestroy($image); function AddImage($url, $x, $y) { global $image, $images_location; $img = @imagecreatefrompng($images_location . $url) or die('image not found'); imagecopyresampled($image, $img, $x, $y, 0, 0, imagesx($img), imagesy($img), imagesx($img), imagesy($img)); imagealphablending($img, true); }
<?php session_start(); ?> <?php header('Content-Type: application/json'); include 'classes.php'; $jsonResult = new JSON(array(), null, array()); $config = $jsonResult->GetAccesToken(); if ($config !== null) { AddImage($config, $jsonResult); } else { $jsonResult->json_data['result_code'] = JSON::$resultCodes['token_error']; } print $jsonResult->PrepareJSON(); function AddImage($config, $jsonResult) { $conn = new connection($config); $product_id = $_POST['product_id']; $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok']; $img_file = $_FILES['file']['name']; $img_file_tmp = $_FILES['file']['tmp_name']; $extension = pathinfo($img_file, PATHINFO_EXTENSION); $error = null; try { $conn->query("INSERT INTO photo(product_id , extension) VALUES('" . $product_id . "' , '" . $extension . "');"); } catch (PDOException $e) { $error = $e; $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception']; }