Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified app/Controller/ApiController.php
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AppController extends Controller {
'Session',
'DebugKit.Toolbar',
'Image',
'CheckCmd',
'Paginator',
'Auth' => array(
'authenticate' => array(
Expand Down
13 changes: 13 additions & 0 deletions app/Controller/Component/CheckCmdComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

App::uses('Component', 'Controller');

class CheckCmdComponent extends Component{

public function is_shell_exec_available($cmd) {
if (in_array('shell_exec', explode(',',ini_get('disable_functions')))){
return shell_exec($cmd);
}
return false;
}
}
16 changes: 12 additions & 4 deletions app/Controller/Component/ImageComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class ImageComponent extends Component{

public $components = array('CheckCmd');

private static $useGD = TRUE;
private static $jpeg_quality = 90;
private static $png_quality = 9;
Expand All @@ -12,7 +14,13 @@ public function resize($img, $to, $width = 0, $height = 0){

$dimensions = getimagesize($img);
$ratio = $dimensions[0] / $dimensions[1];
$exif = exif_read_data($img);
$extension = substr($img, 0, -strpos($img, '.'));
if (in_array($extension,array('jpeg','jpg','gif')) ) {
$exif = exif_read_data($img);
} else {
$exif['Orientation'] = 1;
}

$rotation = 0;

if(isset($exif['Orientation'])){
Expand Down Expand Up @@ -84,12 +92,12 @@ public function resize($img, $to, $width = 0, $height = 0){
imagejpeg($pattern, $to, self::$jpeg_quality);
}
return TRUE;
}else{
}else {
$cmd = '/usr/bin/convert -resize '.$dimX.'x'.$dimY.' "'.$img.'" "'.$to.'"';
shell_exec($cmd);
$this->CheckCmd->is_shell_exec_available($cmd);

$cmd = '/usr/bin/convert -gravity Center -quality '.self::$quality.' -crop '.$width.'x'.$height.'+0+0 -page '.$width.'x'.$height.' "'.$to.'" "'.$to.'"';
shell_exec($cmd);
$this->CheckCmd->is_shell_exec_available($cmd);
}
return TRUE;
}
Expand Down
5 changes: 4 additions & 1 deletion app/Controller/InstallersController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
App::uses('File', 'Utility');
App::uses('ConnectionManager', 'Model');
App::uses('SchemaShell', 'Console/Command');
App::uses('Component', 'Controller');

/**
* Class InstallationsController
Expand All @@ -16,6 +17,8 @@ class InstallersController extends AppController {
var $uses = array();
var $layout = 'installer';

public $components = array('CheckCmd');

public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow();
Expand All @@ -29,7 +32,7 @@ public function beforeFilter() {
public function index() {
$this->view = "index";
$gd = extension_loaded('gd');
$libavtools = shell_exec('which avconv') != '';
$libavtools = $this->CheckCmd->is_shell_exec_available('which avconv') != '';
$is_config_writable = is_writable(APP.'Config');
$is_core_writable = is_writable(APP.'Config'.DS.'core.php');

Expand Down
Empty file modified app/Controller/PlaylistMembershipsController.php
100644 → 100755
Empty file.
Empty file modified app/Controller/PlaylistsController.php
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion app/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class SettingsController extends AppController {

public $helpers = array('FileSize');
public $components = array('CheckCmd');

/**
* This function manages the Sonerezh settings panel.
Expand Down Expand Up @@ -56,7 +57,7 @@ public function index(){
}

// Check if avconv shell command is available
$cmd = shell_exec("which avconv");
$cmd = $this->CheckCmd->is_shell_exec_available('which avconv');
$avconv = empty($cmd) ? false : true;

if (empty($this->request->data)) {
Expand Down