Ejemplo n.º 1
0
 /**
  * Defines necessary plugins for the plugin to load correctly
  */
 function _define_constants()
 {
     // NextGEN by Photocrati Constants
     define('NGG_PLUGIN', basename($this->directory_path()));
     define('NGG_PLUGIN_BASENAME', plugin_basename(__FILE__));
     define('NGG_PLUGIN_DIR', $this->directory_path());
     define('NGG_PLUGIN_URL', $this->path_uri());
     define('NGG_TESTS_DIR', implode(DIRECTORY_SEPARATOR, array(rtrim(NGG_PLUGIN_DIR, "/\\"), 'tests')));
     define('NGG_PRODUCT_DIR', implode(DIRECTORY_SEPARATOR, array(rtrim(NGG_PLUGIN_DIR, "/\\"), 'products')));
     define('NGG_MODULE_DIR', implode(DIRECTORY_SEPARATOR, array(rtrim(NGG_PRODUCT_DIR, "/\\"), 'photocrati_nextgen', 'modules')));
     define('NGG_PRODUCT_URL', path_join(str_replace("\\", '/', NGG_PLUGIN_URL), 'products'));
     define('NGG_MODULE_URL', path_join(str_replace("\\", '/', NGG_PRODUCT_URL), 'photocrati_nextgen/modules'));
     define('NGG_PLUGIN_STARTED_AT', microtime());
     define('NGG_PLUGIN_VERSION', '2.0.66.27');
     if (!defined('NGG_HIDE_STRICT_ERRORS')) {
         define('NGG_HIDE_STRICT_ERRORS', TRUE);
     }
     // Should we display E_STRICT errors?
     if (NGG_HIDE_STRICT_ERRORS) {
         $level = error_reporting();
         if ($level != 0) {
             error_reporting($level & ~E_STRICT);
         }
     }
     // Should we display NGG debugging information?
     if (!defined('NGG_DEBUG')) {
         define('NGG_DEBUG', FALSE);
     }
     self::$debug = NGG_DEBUG;
     // User definable constants
     if (!defined('NGG_IMPORT_ROOT')) {
         $path = WP_CONTENT_DIR;
         define('NGG_IMPORT_ROOT', $path);
     }
     // Should the Photocrati cache be enabled
     if (!defined('PHOTOCRATI_CACHE')) {
         define('PHOTOCRATI_CACHE', TRUE);
     }
     if (!defined('PHOTOCRATI_CACHE_TTL')) {
         define('PHOTOCRATI_CACHE_TTL', 3600);
     }
     // Cron job
     if (!defined('NGG_CRON_SCHEDULE')) {
         define('NGG_CRON_SCHEDULE', 1800);
     }
     // Don't enforce interfaces
     if (!defined('EXTENSIBLE_OBJECT_ENFORCE_INTERFACES')) {
         define('EXTENSIBLE_OBJECT_ENFORCE_INTERFACES', FALSE);
     }
     // Fix jquery
     if (!defined('NGG_FIX_JQUERY')) {
         define('NGG_FIX_JQUERY', TRUE);
     }
 }
Ejemplo n.º 2
0
 /**
  * Image Resource ID for Watermark
  *
  * @var string
  *
  */
 function ngg_Thumbnail($fileName, $no_ErrorImage = false)
 {
     //make sure the GD library is installed
     if (!function_exists("gd_info")) {
         echo 'You do not have the GD Library installed.  This class requires the GD library to function properly.' . "\n";
         echo 'visit http://us2.php.net/manual/en/ref.image.php for more information';
         C_NextGEN_Bootstrap::shutdown();
     }
     //initialize variables
     $this->errmsg = '';
     $this->error = false;
     $this->currentDimensions = array();
     $this->newDimensions = array();
     $this->fileName = $fileName;
     $this->percent = 100;
     $this->maxWidth = 0;
     $this->maxHeight = 0;
     $this->watermarkImgPath = '';
     $this->watermarkText = '';
     //check to see if file exists
     if (!file_exists($this->fileName)) {
         $this->errmsg = 'File not found';
         $this->error = true;
     } elseif (!is_readable($this->fileName)) {
         $this->errmsg = 'File is not readable';
         $this->error = true;
     }
     //if there are no errors, determine the file format
     if ($this->error == false) {
         $data = @getimagesize($this->fileName);
         if (isset($data) && is_array($data)) {
             $extensions = array('1' => 'GIF', '2' => 'JPG', '3' => 'PNG');
             $extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
             if ($extension) {
                 $this->format = $extension;
             } else {
                 $this->errmsg = 'Unknown file format';
                 $this->error = true;
             }
         } else {
             $this->errmsg = 'File is not an image';
             $this->error = true;
         }
     }
     // increase memory-limit if possible, GD needs this for large images
     // @ini_set('memory_limit', '128M');
     if ($this->error == false) {
         // Check memory consumption if file exists
         $this->checkMemoryForImage($this->fileName);
     }
     //initialize resources if no errors
     if ($this->error == false) {
         switch ($this->format) {
             case 'GIF':
                 $this->oldImage = ImageCreateFromGif($this->fileName);
                 break;
             case 'JPG':
                 $this->oldImage = ImageCreateFromJpeg($this->fileName);
                 break;
             case 'PNG':
                 $this->oldImage = ImageCreateFromPng($this->fileName);
                 break;
         }
         if (!$this->oldImage) {
             $this->errmsg = 'Create Image failed. Check memory limit';
             $this->error = true;
         } else {
             $size = GetImageSize($this->fileName);
             $this->currentDimensions = array('width' => $size[0], 'height' => $size[1]);
             $this->newImage = $this->oldImage;
         }
     }
     if ($this->error == true) {
         if (!$no_ErrorImage) {
             $this->showErrorImage();
         }
         return;
     }
 }
Ejemplo n.º 3
0
function createNewThumb()
{
    global $ngg;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $crop_frame = array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h);
    $registry = C_Component_Registry::get_instance();
    $storage = C_Gallery_Storage::get_instance();
    // XXX NextGEN Legacy wasn't handling watermarks or reflections at this stage, so we're forcefully disabling them to maintain compatibility
    $params = array('watermark' => false, 'reflection' => false, 'crop' => true, 'crop_frame' => $crop_frame);
    $result = $storage->generate_thumbnail($id, $params);
    if ($result) {
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    C_NextGEN_Bootstrap::shutdown();
}
 /**
  * Executes an action of a particular controller
  * @param array $handler
  */
 function execute_route_handler($handler)
 {
     // Get action
     $action = $handler['action'];
     // Get controller
     $controller = $this->object->get_registry()->get_utility($handler['controller'], $handler['context']);
     // Call action
     $controller->{$action}();
     // Clean Exit (fastcgi safe)
     C_NextGEN_Bootstrap::shutdown();
 }
Ejemplo n.º 5
0
 /**
  * Checks the 'callback' parameter for possible ajax-like actions to take
  *
  * @param $wp
  */
 function check_request($wp)
 {
     $app = C_Component_Registry::get_instance()->get_utility('I_Router')->get_routed_app();
     if (!$app->get_parameter('callback')) {
         return;
     }
     switch ($app->get_parameter('callback')) {
         case 'imagerotator':
             require_once dirname(__FILE__) . '/xml/imagerotator.php';
             break;
         case 'json':
             require_once dirname(__FILE__) . '/xml/json.php';
             break;
         case 'image':
             require_once dirname(__FILE__) . '/nggshow.php';
             break;
         default:
             return;
     }
     C_NextGEN_Bootstrap::shutdown();
 }
Ejemplo n.º 6
0
        // check ratio to decide which side should be resized
        $ratio_h < $h || $ratio_w == $w ? $thumb->resize(0, $h) : $thumb->resize($w, 0);
        // get the best start postion to crop from the middle
        $ypos = ($thumb->currentDimensions['height'] - $h) / 2;
        $thumb->crop(0, $ypos, $w, $h);
    } else {
        $thumb->resize($w, $h);
    }
}
// Apply effects according to the mode parameter
if ($mode == 'watermark') {
    if ($ngg_options['wmType'] == 'image') {
        $thumb->watermarkImgPath = $ngg_options['wmPath'];
        $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
    } else {
        if ($ngg_options['wmType'] == 'text') {
            $thumb->watermarkText = $ngg_options['wmText'];
            $thumb->watermarkCreateText($ngg_options['wmColor'], $ngg_options['wmFont'], $ngg_options['wmSize'], $ngg_options['wmOpaque']);
            $thumb->watermarkImage($ngg_options['wmPos'], $ngg_options['wmXpos'], $ngg_options['wmYpos']);
        }
    }
} else {
    if ($mode == 'web20') {
        $thumb->createReflection(40, 40, 50, false, '#a4a4a4');
    }
}
// Show thumbnail
$thumb->show();
$thumb->destruct();
C_NextGEN_Bootstrap::shutdown();
Ejemplo n.º 7
0
 /**
  * Defines necessary plugins for the plugin to load correctly
  */
 function _define_constants()
 {
     // NextGEN by Photocrati Constants
     define('NEXTGEN_GALLERY_PLUGIN', basename($this->directory_path()));
     define('NEXTGEN_GALLERY_PLUGIN_BASENAME', plugin_basename(__FILE__));
     define('NEXTGEN_GALLERY_PLUGIN_DIR', $this->directory_path());
     define('NEXTGEN_GALLERY_PLUGIN_URL', $this->path_uri());
     define('NEXTGEN_GALLERY_I8N_DOMAIN', 'nggallery');
     define('NEXTGEN_GALLERY_TESTS_DIR', path_join(NEXTGEN_GALLERY_PLUGIN_DIR, 'tests'));
     define('NEXTGEN_GALLERY_PRODUCT_DIR', path_join(NEXTGEN_GALLERY_PLUGIN_DIR, 'products'));
     define('NEXTGEN_GALLERY_PRODUCT_URL', path_join(NEXTGEN_GALLERY_PLUGIN_URL, 'products'));
     define('NEXTGEN_GALLERY_MODULE_DIR', path_join(NEXTGEN_GALLERY_PRODUCT_DIR, 'photocrati_nextgen/modules'));
     define('NEXTGEN_GALLERY_MODULE_URL', path_join(NEXTGEN_GALLERY_PRODUCT_URL, 'photocrati_nextgen/modules'));
     define('NEXTGEN_GALLERY_PLUGIN_CLASS', path_join(NEXTGEN_GALLERY_PLUGIN_DIR, 'module.NEXTGEN_GALLERY_PLUGIN.php'));
     define('NEXTGEN_GALLERY_PLUGIN_STARTED_AT', microtime());
     define('NEXTGEN_GALLERY_PLUGIN_VERSION', '2.0.40');
     if (!defined('NGG_HIDE_STRICT_ERRORS')) {
         define('NGG_HIDE_STRICT_ERRORS', TRUE);
     }
     // Should we display E_STRICT errors?
     if (NGG_HIDE_STRICT_ERRORS) {
         $level = error_reporting();
         if ($level != 0) {
             error_reporting($level & ~E_STRICT);
         }
     }
     // Should we display NGG debugging information?
     if (!defined('NGG_DEBUG')) {
         define('NGG_DEBUG', FALSE);
     }
     self::$debug = NGG_DEBUG;
     // User definable constants
     if (!defined('NEXTGEN_GALLERY_IMPORT_ROOT')) {
         $path = WP_CONTENT_DIR;
         if (is_multisite()) {
             $uploads = wp_upload_dir();
             $path = $uploads['path'];
         }
         define('NEXTGEN_GALLERY_IMPORT_ROOT', $path);
     }
     // Should the Photocrati cache be enabled
     if (!defined('PHOTOCRATI_CACHE')) {
         define('PHOTOCRATI_CACHE', TRUE);
     }
 }