Phalcon Framework 3.3.2

Phalcon\Image\Exception: Installed GD does not support such images

phalcon/image/adapter/gd.zep (102)
#0Phalcon\Image\Adapter\Gd->__construct(files/thumbs/)
/usr/share/nginx/html/admin/app/controllers/GalleriesController.php (275)
<?php
 
class GalleriesController extends \Phalcon\Mvc\Controller
{
 
    public function indexAction()
    {
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $this->view->user = $user;
 
            $this->view->menu = Menu::render($user['tipo']);
 
            $list_fields = Galleries::get_list_fields();
 
            $this->view->list_fields = $list_fields;
 
            $this->view->class_name = 'galleries';
            $this->view->module_name = 'Galerias de Imagens';
            $this->view->op_act = 6;
 
            $query_records = Galleries::find(array(
                "conditions" => "id >= 1 ",
                "order" => "id ASC"
            ));
 
            $this->view->records = Galleries::listMyRecords($list_fields, $query_records);
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function addAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $this->view->user = $user;
 
            $this->view->menu = Menu::render($user['tipo']);
 
            $this->view->list_fields = Galleries::get_add_fields();
 
            $this->view->class_name = 'galleries';
            $this->view->module_name = 'Galerias de Imagens';
            $this->view->op_act = 6;
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function saveAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $request = new Phalcon\Http\Request();
 
            $gallery = new Galleries();
            
          $gallery->name = $request->getPost("name");
          $gallery->state = $request->getPost("state");
 
          if ($gallery->save()) {
            $this->response->redirect('galleries/edit/'.$gallery->id);
          } else {
              $this->dispatcher->forward(array(
                "controller" => "galleries",
                "action" => "add"
            ));
          }
 
      $this->view->disable();
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function editAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $this->view->user = $user;
            
            $id = $this->dispatcher->getParam("id");
            $this->view->id = $id;
            $this->view->menu = Menu::render($user['tipo']);
 
            $this->view->list_fields = Galleries::get_add_fields();
 
            $this->view->class_name = 'galleries';
            $this->view->module_name = 'Galerias de Imagens';
            $this->view->op_act = 6;
 
            $this->view->reg = Galleries::findFirst("id = ".$id);
 
            $this->view->container = GalleryContainer::find("gallery_id = '".$id."'");
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function updateAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $request = new Phalcon\Http\Request();
            $id = $this->dispatcher->getParam("id");
 
            $gallery = Galleries::findFirst("id = ".$id);
          $gallery->name = $request->getPost("name");
          $gallery->state = $request->getPost("state");
 
          if ($text->save()) {
            $this->response->redirect('galleries');
          } else {
              $this->dispatcher->forward(array(
                "controller" => "galleries",
                "action" => "edit",
                "params" => array('id' => $id),
            ));
          }
 
      $this->view->disable();
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function uploadAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $request = new Phalcon\Http\Request();
            $id = $this->dispatcher->getParam("id");
 
            $container = new GalleryContainer();
          $container->gallery_id = $id;
    $container->title = $request->getPost("file_title");
          
          if ($this->request->hasFiles() == true) {
              $baseLocation = 'files/';
              $thumbsLocation = 'files/thumbs/';
 
              foreach ($this->request->getUploadedFiles() as $file) {
                  $imagem = $file->getName();
                  $extention = explode('.', $imagem);
                  $ext = $extention[sizeof($extention)-1];
                  $filename = md5(time()).'.'.$ext;
 
                  $container->file = $filename;
                  $file->moveTo($baseLocation . $filename);
                    shell_exec('chmod 755 ' . $baseLocation . $filename);
 
                  $image = new Phalcon\Image\Adapter\GD($baseLocation . $filename);
                  $ori_width = $image->getWidth();
              $ori_height = $image->getHeight();
                  $image->resize(300, round($ori_height * (300/$ori_width), 2))->save($thumbsLocation . $filename);
                    shell_exec('chmod 755 ' . $thumbsLocation . $filename);
              }
          }
 
          if ($container->save()) {
            $this->response->redirect('galleries/edit/'.$id);
          } else {
              $this->dispatcher->forward(array(
                "controller" => "galleries",
                "action" => "edit",
                "params" => array('id' => $id),
            ));
          }
 
      $this->view->disable();
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function changeFaceAction(){
      $request = new Phalcon\Http\Request();
      $gal = $this->dispatcher->getParam("id");
      $img = $request->getPost("img");
 
      $old = GalleryContainer::findFirst("gallery_id = '".$gal."' AND face=1");
      if ($old) {
        $old->face = 0;
        $old->save();
      }
      $new = GalleryContainer::findFirst("id = '".$img."'");
      if ($new) {
        $new->face = 1;
        $new->save();
      }
 
      $this->view->disable();
      $response = new \Phalcon\Http\Response();
        $response->setStatusCode(200, "OK");
        $response->setContent('DONE');
        $response->send();
    }
 
    public function changeTitleAction() {
  $request = new Phalcon\Http\Request();
  $img = $request->getPost("id");
  $text = $request->getPost("text");
  
  $image = GalleryContainer::findFirst("id = '".$img."'");
  if ($image) {
      $image->title = $text;
      $image->save();
  }
 
  $this->view->disable();
        $response = new \Phalcon\Http\Response();
        $response->setStatusCode(200, "OK");
        $response->setContent('DONE');
        $response->send();
    }
 
    public function deleteAction(){
      if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $id = $this->dispatcher->getParam("id");
 
            $gallery = Galleries::findFirst("id = ".$id);
            $gallery->delete();
 
            $pics = GalleryContainer::find("gallery_id = '".$id."'");
            $baseLocation = 'files/';
            $thumbsLocation = 'files/thumbs/';
            
            foreach ($pics as $pic) {
                if (file_exists($baseLocation . $pic->file)) {
                    unlink($baseLocation . $pic->file);
                }
                if (file_exists($thumbsLocation . $pic->file)) {
                    unlink($thumbsLocation . $pic->file);
                }
                $pic->delete();
            }
 
          $this->response->redirect('galleries');
      $this->view->disable();
 
        } else {
          $this->dispatcher->forward(array(
              "controller" => "index",
              "action" => "index"
          ));
        }
    }
 
    public function renderAction(){
        $request = new Phalcon\Http\Request();
        $size = explode('x', $this->dispatcher->getParam("size"));
        $file = $this->dispatcher->getParam("file");
 
        $image = new Phalcon\Image\Adapter\GD("files/thumbs/".$file);
        $dest = '/tmp/'.uniqid().'.jpg';
 
        $ori_width = $image->getWidth();
        $ori_height = $image->getHeight();
 
        $new_height = $ori_height * ($size[0]/$ori_width);
 
        if ($new_height < $size[1]) { 
            $new_height = $size[1];
            $new_width = $ori_width * ($new_height/$ori_height);
        } else {
          $new_width = $size[0];
        }
 
        $image->resize($new_width, $new_height);
        $image->save($dest, 100);
        $image = new Phalcon\Image\Adapter\GD($dest);
        $image->crop($size[0], $size[1]);
 
        $response = new \Phalcon\Http\Response();
        $response->setStatusCode(200, "OK");
        $response->setHeader('Content-Type', 'image/jpeg');
        $response->setContent($image->render());
        $response->send();
 
        unlink($dest);
        $this->view->disable();
    }
 
    public function openAction(){
        $request = new Phalcon\Http\Request();
        $file = $this->dispatcher->getParam("id");
 
        $image = new Phalcon\Image\Adapter\GD("files/".$file);
  
  $response = new \Phalcon\Http\Response();
        $response->setStatusCode(200, "OK");
        $response->setHeader('Content-Type', 'image/jpeg');
        $response->setContent($image->render());
        $response->send();
 
        $this->view->disable();
    }
  
    public function change_stateAction(){
        if ($this->session->has("user")) {
            $user = $this->session->get("user");
            $id = $this->dispatcher->getParam("id");
 
            $request = new Phalcon\Http\Request();
            $status = $request->getPost("val");
 
            $gal = Galleries::findFirst("id = ".$id);
            if ($status == 1) $newS = 0;
            else $newS = 1;
            $gal->state = $newS;
            $gal->save();
 
            $this->view->disable();
 
            $response = new \Phalcon\Http\Response();
            $response->setStatusCode(200, "OK");
            $response->setContent('{"success": true, "val":'.$newS.'}');
            $response->send();
 
        } else {
            $this->dispatcher->forward(array(
                "controller" => "index",
                "action" => "index"
            ));
        }
    }
 
    public function removePicAction(){
        $request = new Phalcon\Http\Request();
        $gal = $this->dispatcher->getParam("id");
        $img = $request->getPost("img");
 
        $old = GalleryContainer::findFirst("id = '".$img."'");
        if ($old) {
            $baseLocation = 'files/';
            $thumbsLocation = 'files/thumbs/';
 
            if (file_exists($baseLocation . $old->file)) {
                unlink($baseLocation . $old->file);
            }
            if (file_exists($thumbsLocation . $old->file)) {
                unlink($thumbsLocation . $old->file);
            }
            $old->delete();
        }
 
        $this->view->disable();
        $response = new \Phalcon\Http\Response();
        $response->setStatusCode(200, "OK");
        $response->setContent('DONE');
        $response->send();
    }
}
 
#1GalleriesController->renderAction()
#2Phalcon\Dispatcher->callActionMethod(Object(GalleriesController), renderAction, Array([id] => (empty string)))
#3Phalcon\Dispatcher->dispatch()
#4Phalcon\Mvc\Application->handle()
/usr/share/nginx/html/admin/public/index.php (29)
<?php
 
error_reporting(E_ALL);
ini_set('display_errors', 1);
 
$debug = new \Phalcon\Debug();
$debug->listen();
  $dir = '/usr/share/nginx/html/admin/';
    /**
     * Read the configuration
     */
    $config = include $dir . "app/config/config.php";
 
    /**
     * Read auto-loader
     */
    include $dir . "app/config/loader.php";
 
    /**
     * Read services
     */
    include $dir . "app/config/services.php";
 
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);
 
    echo $application->handle()->getContent();
    
KeyValue
_url/galleries/render/
KeyValue
HOSTNAMEed5d790d396a
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD/var/www/dmiseev
SHLVL0
HOME/var/www
LYBERTEAM_TIME_ZONEEurope/Kiev
USERwww-data
HTTP_CDN_LOOPcloudflare
HTTP_CF_CONNECTING_IP193.136.192.149
HTTP_COOKIE__cfduid=d86d77e129e31f5d15aaf4df1038fff321552926488; [email protected]; ORA_OTD_JROUTE=UPFwzqzIjrIKKClP; PHPSESSID=3cv9cd2gmkhu0op6qr85bj45v2; PromocionId=; _am=web; domain=0j1ceu10afoq2ikdgbntv1c0u2; promoCode=; sck=XPDD2BNUUITZVU4WRKY3PP6PX6VA4BAKHLESBKQ
HTTP_USER_AGENTarquivo-web-crawler (compatible; heritrix/3.3.0-SNAPSHOT-2018-05-28T10:30:31Z +http://arquivo.pt)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_REFERERhttps://palhacosdopital.pt/pt/imagens
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_RAY4c8eff7faaa2ce7d-LHR
HTTP_X_FORWARDED_FOR193.136.192.149
HTTP_CF_IPCOUNTRYPT
HTTP_ACCEPT_ENCODINGgzip
HTTP_CONNECTIONKeep-Alive
HTTP_HOSTadmin.palhacosdopital.pt
SCRIPT_FILENAME/usr/share/nginx/html/admin/public/index.php
PATH_TRANSLATED/usr/share/nginx/html/admin/public
PATH_INFO
REDIRECT_STATUS200
SERVER_NAMEadmin.palhacosdopital.pt
SERVER_PORT443
SERVER_ADDR172.18.0.5
REMOTE_PORT41608
REMOTE_ADDR141.101.99.207
SERVER_SOFTWAREnginx/1.13.12
GATEWAY_INTERFACECGI/1.1
HTTPSon
REQUEST_SCHEMEhttps
SERVER_PROTOCOLHTTP/1.1
DOCUMENT_ROOT/usr/share/nginx/html/admin/public
DOCUMENT_URI/index.php
REQUEST_URI/galleries/render/
SCRIPT_NAME/index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHODGET
QUERY_STRING_url=/galleries/render/&
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1555510389.7685
REQUEST_TIME1555510389
#Path
0/usr/share/nginx/html/admin/public/index.php
1/usr/share/nginx/html/admin/app/config/config.php
2/usr/share/nginx/html/admin/app/config/loader.php
3/usr/share/nginx/html/admin/app/config/services.php
4/usr/share/nginx/html/admin/app/config/routes.php
5/usr/share/nginx/html/admin/app/controllers/GalleriesController.php
Memory
Usage2097152