/** * 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.')); } }
function processMedium(&$medium, &$gallery) { $mime = $medium->getMimeType(); zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper'); $ok = true; if (zmgMimeHelper::isImage($mime, true)) { zmgimport('org.zoomfactory.var.plugins.toolbox.tools.imageTool'); $ok = zmgImageTool::process($medium, $gallery); if (!$ok) { zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not create thumbnail of image file')); //TODO: cleanup } } else { if (zmgMimeHelper::isDocument($mime, true) && zmgMimeHelper::isIndexable($mime, true)) { zmgimport('org.zoomfactory.var.plugins.toolbox.tools.documentTool'); $ok = zmgDocumentTool::process($medium, $gallery); if (!$ok) { zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not index document')); //TODO: cleanup } } else { if (zmgMimeHelper::isVideo($mime, true) && zmgMimeHelper::isThumbnailable($mime, true)) { zmgimport('org.zoomfactory.var.plugins.toolbox.tools.videoTool'); $ok = zmgVideoTool::process($medium, $gallery); if (!$ok) { zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not create thumbnail of video file')); //TODO: cleanup } } else { if (zmgMimeHelper::isAudio($mime, true)) { zmgimport('org.zoomfactory.var.plugins.toolbox.tools.audioTool'); $ok = zmgAudioTool::process($medium, $gallery); if (!$ok) { zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Audio file not supported')); //TODO: cleanup } } else { zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Unsupported medium type.')); } } } } return $ok; }
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(); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }