コード例 #1
0
 /**
  * Detect if GD is available on the system.
  *
  * @return void
  */
 function autoDetect()
 {
     $GDfuncList = get_extension_funcs('gd');
     ob_start();
     @phpinfo(INFO_MODULES);
     $output = ob_get_contents();
     ob_end_clean();
     $matches[1] = '';
     if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) {
         $gdversion = $matches[2];
     }
     $res = false;
     if ($GDfuncList) {
         if (in_array('imagegd2', $GDfuncList)) {
             zmgToolboxPlugin::registerError('GD 2.x', $gdversion . ' ' . T_('is available.'));
             $res = true;
         }
     }
     if (!$res) {
         zmgToolboxPlugin::registerError('GD 2.x', T_('could not be detected on your system.'));
     }
 }
コード例 #2
0
 function registerError($title, $descr)
 {
     $errors =& zmgToolboxPlugin::getErrors();
     $i = count($errors);
     $errors[$i]['title'] = $title;
     $errors[$i]['description'] = $descr;
     //return 'FALSE' to the callee, because it's an error after all
     return false;
 }
コード例 #3
0
 function finalizeUpload($gid = 0)
 {
     //finish the SwfUpload sequence...
     if ($gid === 0) {
         return zmgToolboxPlugin::registerError(T_('Upload media'), T_('No valid gallery ID provided'));
     }
     $session =& zmgFactory::getSession();
     $events =& zmgFactory::getEvents();
     $config =& zmgFactory::getConfig();
     $db =& zmgDatabase::getDBO();
     $gallery = new zmgGallery($db);
     $gallery->load($gid);
     //now we got the gallery and its data, retrieve the uploaded media
     $media = $session->get('uploadtool.fancyfiles');
     if (!is_array($media) || count($media) == 0) {
         return zmgToolboxPlugin::registerError(T_('Upload media'), T_('No media have been uploaded; nothing to do.'));
     }
     zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
     $src_path = ZMG_ABS_PATH . DS . "etc" . DS . "cache" . DS;
     $dest_path = zmgEnv::getRootPath() . DS . $config->get('filesystem/mediapath') . $gallery->dir . DS;
     foreach ($media as $medium) {
         $obj = new zmgMedium($db);
         $name = zmgSQLEscape(zmgGetParam($_REQUEST, 'zmg_upload_name', ''));
         $descr = zmgSQLEscape(zmgGetParam($_REQUEST, 'zmg_upload_descr', ''));
         $data = array('name' => $name, 'filename' => $medium, 'descr' => $descr, 'published' => 1, 'gid' => $gallery->gid);
         $obj->setGalleryDir($gallery->dir);
         //saves a SQL query later on...
         //do some additional validation of strings
         $data['name'] = $events->fire('onvalidate', $data['name']);
         if (!$data['name']) {
             $data['name'] = $name;
         }
         $data['descr'] = $events->fire('onvalidate', $data['descr']);
         if (!$data['descr']) {
             $data['descr'] = $descr;
         }
         if (!$obj->bind($data)) {
             zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be saved') . ': ' . $obj->getError());
         } else {
             if (!zmgFileHelper::copy($src_path . $medium, $dest_path . $medium)) {
                 zmgToolboxPlugin::registerError(T_('Upload media'), T_('Unable to copy file') . ' ' . $medium);
             } else {
                 if (!zmgFileHelper::delete($src_path . $medium)) {
                     zmgToolboxPlugin::registerError(T_('Upload media'), T_('Unable to delete temporary file') . ' ' . $medium);
                 } else {
                     if (!zmgToolboxPlugin::processMedium($obj, $gallery)) {
                         zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be processed') . ' ' . $medium);
                     } else {
                         if (!$obj->store()) {
                             //now save this medium in our DB
                             zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be saved') . ': ' . $obj->getError());
                         }
                     }
                 }
             }
         }
         //delete medium from session data: fourth parameter as TRUE
         $session->update('uploadtool.fancyfiles', $medium, ZMG_DATATYPE_ARRAY, true);
     }
     zmgToolboxPlugin::throwErrors();
 }
コード例 #4
0
 /**
  * Detect if NetPBM is available on the system.
  *
  * @return void
  */
 function autoDetect()
 {
     static $output, $status;
     //get the absolute location first:
     $path = zmgNetpbmTool::detectPath();
     //execute test command
     @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
     $res = false;
     if (!$status) {
         if (preg_match("/netpbm[ \t]+([0-9\\.]+)/i", $output[0], $matches)) {
             zmgToolboxPlugin::registerError('NetPBM', $matches[0] . ' ' . T_('is available.'));
             $res = true;
         }
     }
     if (!$res) {
         zmgToolboxPlugin::registerError('NetPBM', T_('could not be detected on your system.'));
     }
     unset($output, $status);
 }
コード例 #5
0
 /**
  * Detect if FFmpeg is available on the system.
  *
  * @return void
  */
 function autoDetect()
 {
     static $output, $status;
     //get the absolute location first:
     $path = zmgVideoTool::detectPath();
     //execute test command
     @exec($path . 'ffmpeg', $output, $status);
     $res = false;
     if (!empty($output[0])) {
         if (preg_match("/(ffmpeg).*/i", $output[0], $matches)) {
             zmgToolboxPlugin::registerError('FFmpeg', 'FFmpeg ' . T_('is available.'));
             $res = true;
         }
     }
     if (!$res) {
         zmgToolboxPlugin::registerError('FFmpeg', T_('could not be detected on your system.'));
     }
     unset($output, $status);
 }
コード例 #6
0
 /**
  * Detect if ImageMagick is available on the system.
  *
  * @return void
  */
 function autoDetect()
 {
     static $output, $status;
     //get the absolute location first:
     $path = zmgImagemagickTool::detectPath();
     //execute test command
     @exec('convert -version', $output, $status);
     $res = false;
     if (!$status) {
         if (preg_match("/imagemagick[ \t]+([0-9\\.]+)/i", $output[0], $matches)) {
             zmgToolboxPlugin::registerError('ImageMagick', $matches[0] . ' ' . T_('is available.'));
             $res = true;
         }
     }
     if (!$res) {
         zmgToolboxPlugin::registerError('ImageMagick', T_('could not be detected on your system.'));
     }
     unset($output, $status);
 }
コード例 #7
0
 /**
  * Detect if Xpdf is available on the system.
  *
  * @return void
  */
 function autoDetect()
 {
     static $output, $status;
     $bar = @exec(zmgDocumentTool::detectPath() . 'pdftotext -v', $output, $status);
     $res = false;
     if (!empty($output[0])) {
         if (preg_match("/pdftotext/i", $output[0], $matches)) {
             zmgToolboxPlugin::registerError(T_('Xpdf (or pdftotext)'), T_('is available.'));
             $res = true;
         }
     }
     if (!$res) {
         zmgToolboxPlugin::registerError(T_('Xpdf (or pdftotext)'), T_('could not be detected on your system.'));
     }
     unset($output, $status);
 }