TYPE-0 PERFECT SEIHA
Server Info:
FreeBSD scimitar.blueboard.cz 13.5-STABLE FreeBSD 13.5-STABLE stable/13-4f2925105 GENERIC amd64
Software:
Apache
User:
www
Crot
Crot File
Crot Dir
Crot Command
[LockSelf]
[HOME]
data
www
19068
fszoo_net
www
api
1
root
app
Rest
Search
Show Hidden Files
Edit File: /data/www/19068/fszoo_net/www/api/1/root/app/Rest/Search/Add.php
<?php /** * Copyright (c) Jan Pospisil (http://www.jan-pospisil.cz) */ namespace Rest\Search; use Nette\Database\Context; use Nette\DI\Container; use Nette\Utils\Image; use Nette\Utils\Random; use Nette\Utils\UnknownImageFileException; use RestServer\Exceptions\BadRequestException; use RestServer\Exceptions\MissingRequiredParameterException; use RestServer\IParametrs; use RestServer\IPresenter; use RestServer\Response; use Tracy\Debugger; /** * Add term to search spider. * @param ( * name = url, * type = string (url)), * required = 1 * ) * @param ( * name = title, * type = string, * required = 1 * ) * @param ( * name = description, * type = string, * required = 1 * ) * @param ( * name = priority, * type = string, * required = 1 * ) * @param ( * name = image, * type = string (url)), * required = 1 * ) * @param ( * name = update, * type = bool, * ) * @param ( * requires = 1, * name = api_key, * type = string * ) * @author Jan Pospisil * @author Jan Pospisil */ class Add extends \Nette\Object implements IPresenter { private $connection; private $tempDir; private $apiKeys; public function __construct(Context $context, Container $container){ $this->connection = $context; $this->tempDir = $container->parameters['tempDir']; } public function setApiKeys(array $apiKeys){ $this->apiKeys = $apiKeys; } public function run(IParametrs $parameters, Response $response) { $title = $parameters->post('title'); $description = $parameters->post('description'); $image = $parameters->post('image'); $update = $parameters->post('update'); $url = trim($parameters->post('url'), '/'); $priority = $parameters->post('priority'); $apiKey = $parameters->get('api_key'); if(!$apiKey) throw new MissingRequiredParameterException('Parameter api_key is required.'); if(!in_array($apiKey, $this->apiKeys)) throw new BadRequestException('Invalid api_key parameter.'); if(!$url) throw new MissingRequiredParameterException('Parameter url is required.'); if(!$title) throw new MissingRequiredParameterException('Parameter title is required.'); if(!$description) throw new MissingRequiredParameterException('Parameter description is required.'); if(!$image) throw new MissingRequiredParameterException('Parameter image is required.'); if(!$priority) throw new MissingRequiredParameterException('Parameter priority is required.'); Debugger::log($update, 'update'); try{ try{ $img = Image::fromFile($image); $img_140 = Image::fromFile($image); } catch (UnknownImageFileExceptionx $e) { throw new BadRequestException('Unable to save image. File not found.'.$image); } $img->resize(60, 60, Image::FILL); $img_140->resize(140, 140, Image::FILL); $img->crop((($img->width - 60)/2), (($img->height - 60)/2), 60, 60); $img_140->crop((($img_140->width - 140)/2), (($img_140->height - 140)/2), 140, 140); $name = Random::generate().'.jpg'; $name_140 = Random::generate().'.jpg'; $filename = $this->tempDir.DIRECTORY_SEPARATOR.$name; $filename_140 = $this->tempDir.DIRECTORY_SEPARATOR.$name_140; $img->save($filename); $img_140->save($filename_140); $path = $filename; $path_140 = $filename_140; $type = pathinfo($path, PATHINFO_EXTENSION); $type_140 = pathinfo($path_140, PATHINFO_EXTENSION); $data = file_get_contents($path); $data_140 = file_get_contents($path_140); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); $base64_140 = 'data:image/' . $type_140 . ';base64,' . base64_encode($data_140); $entry = array( 'title' => $title, 'url' => $url, 'description' => $description, 'image' => $base64, 'image140' => $base64_140, 'priority' => $priority ); if($update){ $row = $this->connection->table('search')->where('url', $url)->fetch(); if($row){ Debugger::log('Updating url '.$url, 'update'); $row->update($entry); } else { Debugger::log('Not found '.$url, 'update_error'); } } $this->connection->table('search')->insert($entry); } catch (\PDOException $e){ if($e->getCode() != 23000) throw $e; } } }
Crotin
Name
Size
Permissions
Modified
User/Group
Search.php
1941
0644
2016-02-18 20:19:01
Unknown/Unknown
Add.php
4275
0644
2016-02-22 19:01:20
Unknown/Unknown
NGANU
Rename
Hapus
Chmod
Chown
Touch
Zip
Unzip
Download
Crotin