Exemplo n.º 1
0
function hasMemoryForImage($serverFilename)
{
    // find out how much total memory this script can access
    $memoryAvailable = return_bytes(@ini_get('memory_limit'));
    // if memory is unlimited, it will return -1 and we don’t need to worry about it
    if ($memoryAvailable == -1) {
        return true;
    }
    // find out how much memory we are already using
    $memoryUsed = memory_get_usage();
    $imgsize = @getimagesize($serverFilename);
    // find out how much memory this image needs for processing, probably only works for jpegs
    // from comments on http://www.php.net/imagecreatefromjpeg
    if (is_array($imgsize) && isset($imgsize['bits']) && isset($imgsize['channels'])) {
        $memoryNeeded = round(($imgsize[0] * $imgsize[1] * $imgsize['bits'] * $imgsize['channels'] / 8 + Pow(2, 16)) * 1.65);
        $memorySpare = $memoryAvailable - $memoryUsed - $memoryNeeded;
        if ($memorySpare > 0) {
            // we have enough memory to load this file
            return true;
        } else {
            // not enough memory to load this file
            $image_info = sprintf('%.2fKB, %d × %d %d bits %d channels', filesize($serverFilename) / 1024, $imgsize[0], $imgsize[1], $imgsize['bits'], $imgsize['channels']);
            Log::addMediaLog('Cannot create thumbnail ' . $serverFilename . ' (' . $image_info . ') memory avail: ' . $memoryAvailable . ' used: ' . $memoryUsed . ' needed: ' . $memoryNeeded . ' spare: ' . $memorySpare);
            return false;
        }
    } else {
        // assume there is enough memory
        // TODO find out how to check memory needs for gif and png
        return true;
    }
}
Exemplo n.º 2
0
 public function processData(\IRequestObject $requestObject)
 {
     $params = $requestObject->getParams();
     //		$objectId = $params["messageObjectId"];
     //		$object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectId);
     //var_dump($params);
     $dialog = new \Widgets\Dialog();
     $dialog->setTitle("Portfolio Importieren");
     $dialog->setPositionX($this->params["mouseX"]);
     $dialog->setPositionY($this->params["mouseY"]);
     $ajaxUploader = new \Widgets\AjaxUploader();
     $imgWidget = new \Widgets\RawHtml();
     $imgWidget->setHtml("Um ein Portfolio zu importieren ziehen sie die Datei auf dieses Feld oder doppelklicken sie hier.<br>");
     //$ajaxUploader->setPreview($imgWidget);
     //		}
     $ajaxUploader->setSizeLimit(return_bytes(ini_get('post_max_size')));
     $ajaxUploader->setNamespace("Portfolio");
     $ajaxUploader->setCommand("UploadImport");
     $ajaxUploader->setDestId($params["id"]);
     $ajaxUploader->setMultiUpload(false);
     //		$ajaxUploader->setOnComplete("function(id, fileName, responseJSON){document.getElementById('uploaderArtefact').src = '" . PATH_URL . "download/document/' + responseJSON.oid; jQuery('#uploaderArtefact').addClass('saved')}");
     $ajaxUploader->setOnComplete("function(id, fileName, responseJSON){location.reload();}");
     $dialog->addWidget($ajaxUploader);
     //		$dialog->addWidget($raw);
     $dialog->addWidget(new \Widgets\Clearer());
     $this->dialog = $dialog;
 }
Exemplo n.º 3
0
 function _init_env()
 {
     error_reporting(E_ERROR);
     if (PHP_VERSION < '5.3.0') {
         set_magic_quotes_runtime(0);
     }
     /*vot*/
     if (!defined('DISCUZ_ROOT')) {
         /*vot*/
         define('DISCUZ_ROOT', preg_replace("/^\\w\\:/i", '', str_replace("\\", '/', substr(dirname(__FILE__), 0, -12))));
         /*vot*/
     }
     define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
     define('ICONV_ENABLE', function_exists('iconv'));
     define('MB_ENABLE', function_exists('mb_convert_encoding'));
     define('EXT_OBGZIP', function_exists('ob_gzhandler'));
     define('TIMESTAMP', time());
     $this->timezone_set();
     /*vot*/
     if (!defined('DISCUZ_CORE_FUNCTION') && !@(include_once DISCUZ_ROOT . './source/function/function_core.php')) {
         exit('function_core.php is missing');
     }
     if (function_exists('ini_get')) {
         $memorylimit = @ini_get('memory_limit');
         if ($memorylimit && return_bytes($memorylimit) < 33554432 && function_exists('ini_set')) {
             ini_set('memory_limit', '128m');
         }
     }
     define('IS_ROBOT', checkrobot());
     foreach ($GLOBALS as $key => $value) {
         if (!isset($this->superglobal[$key])) {
             $GLOBALS[$key] = null;
             unset($GLOBALS[$key]);
         }
     }
     global $_G;
     $_G = array('uid' => 0, 'username' => '', 'adminid' => 0, 'groupid' => 1, 'sid' => '', 'formhash' => '', 'timestamp' => TIMESTAMP, 'starttime' => dmicrotime(), 'clientip' => $this->_get_client_ip(), 'referer' => '', 'charset' => '', 'gzipcompress' => '', 'authkey' => '', 'timenow' => array(), 'PHP_SELF' => '', 'siteurl' => '', 'siteroot' => '', 'siteport' => '', 'config' => array(), 'setting' => array(), 'member' => array(), 'group' => array(), 'cookie' => array(), 'style' => array(), 'cache' => array(), 'session' => array(), 'lang' => array(), 'my_app' => array(), 'my_userapp' => array(), 'fid' => 0, 'tid' => 0, 'forum' => array(), 'thread' => array(), 'rssauth' => '', 'home' => array(), 'space' => array(), 'block' => array(), 'article' => array(), 'action' => array('action' => APPTYPEID, 'fid' => 0, 'tid' => 0), 'mobile' => '');
     $_G['PHP_SELF'] = htmlspecialchars($this->_get_script_url());
     $_G['basescript'] = CURSCRIPT;
     $_G['basefilename'] = basename($_G['PHP_SELF']);
     $sitepath = substr($_G['PHP_SELF'], 0, strrpos($_G['PHP_SELF'], '/'));
     if (defined('IN_API')) {
         $sitepath = preg_replace("/\\/api\\/?.*?\$/i", '', $sitepath);
     } elseif (defined('IN_ARCHIVER')) {
         $sitepath = preg_replace("/\\/archiver/i", '', $sitepath);
     }
     $_G['siteurl'] = htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $sitepath . '/');
     $url = parse_url($_G['siteurl']);
     $_G['siteroot'] = isset($url['path']) ? $url['path'] : '';
     $_G['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT'];
     if (defined('SUB_DIR')) {
         $_G['siteurl'] = str_replace(SUB_DIR, '/', $_G['siteurl']);
         $_G['siteroot'] = str_replace(SUB_DIR, '/', $_G['siteroot']);
     }
     /*vot*/
     $_G['siteurl'] = str_replace("\\", '/', $_G['siteurl']);
     /*vot*/
     $_G['siteroot'] = str_replace("\\", '/', $_G['siteroot']);
     $this->var =& $_G;
 }
Exemplo n.º 4
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     // list of valid extensions, ex. array("jpeg", "xml", "bmp")
     $allowedExtensions = array();
     // max file size in bytes
     $sizeLimit = return_bytes(ini_get('post_max_size'));
     $destId = $_REQUEST["destid"];
     $destObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $destId);
     //remove old image
     $oldImageId = $destObject->get_attribute("bid:portlet:msg:picture_id");
     if ($oldImageId !== 0) {
         $oldImage = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $oldImageId);
         if ($oldImage instanceof \steam_document) {
             $destObject->delete_attribute("bid:portlet:msg:picture_id");
             $oldImage->delete();
         }
     }
     // upload image
     $envid = $destObject->get_environment()->get_id();
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $envid);
     $result = $uploader->handleUpload(PATH_TEMP);
     // set new image
     $destObject->set_attribute("bid:portlet:msg:picture_id", $result["oid"]);
     // to pass data through iframe you will need to encode all html tags
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     die;
     //$ajaxResponseObject->setStatus("ok");
     //return $ajaxResponseObject;
 }
Exemplo n.º 5
0
function js_drag_n_drop_handle($a)
{
    $max_file_size = min(return_bytes(ini_get('upload_max_filesize')), return_bytes(ini_get('post_max_size')));
    $sc = '

// upload next file
function uploadNext() {
	if (list.length) {
		document.getElementById(\'count\').classList.add(\'showed\');
		var nextFile = list.shift();
		if (nextFile.size >= ' . $max_file_size . ') {
			var respdiv = document.getElementById(nextFile.locId);
			respdiv.querySelector(\'.uploadstatus\').appendChild(document.createTextNode(\'File too big\'));
			respdiv.classList.remove(\'pending\');
			respdiv.classList.add(\'failure\');
			uploadNext();
		} else {
			var respdiv = document.getElementById(nextFile.locId);
			respdiv.querySelector(\'.uploadstatus\').textContent = \'Uploading\';
			uploadFile(nextFile);
		}
	} else {
		document.getElementById(\'count\').classList.remove(\'showed\');
		nbDraged = false;
		// reactivate the "required" attribute of file input
		document.getElementById(\'fichier\').required = true;
	}
}

';
    if ($a == 1) {
        $sc = "\n" . '<script type="text/javascript">' . "\n" . $sc . "\n" . '</script>' . "\n";
    }
    return $sc;
}
Exemplo n.º 6
0
function max_file_upload_in_bytes()
{
    //select maximum upload size
    $max_upload = return_bytes(ini_get('upload_max_filesize'));
    //select post limit
    $max_post = return_bytes(ini_get('post_max_size'));
    //select memory limit
    $memory_limit = return_bytes(ini_get('memory_limit'));
    // return the smallest of them, this defines the real limit
    return min($max_upload, $max_post, $memory_limit);
}
Exemplo n.º 7
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $ajaxResponseObject->setStatus("ok");
     $ajaxUploader = new \Widgets\AjaxUploader();
     $ajaxUploader->setSizeLimit(return_bytes(ini_get('post_max_size')));
     $ajaxUploader->setBackend(PATH_URL . "portfolio/");
     $ajaxUploader->setEnvId($this->id);
     $ajaxUploader->setCommand("UploadImport");
     $ajaxUploader->setNamespace("Portfolio");
     $ajaxResponseObject->addWidget($ajaxUploader);
     return $ajaxResponseObject;
 }
Exemplo n.º 8
0
 private function _init_env()
 {
     error_reporting(E_ERROR);
     if (PHP_VERSION < '5.3.0') {
         set_magic_quotes_runtime(0);
     }
     define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
     define('ICONV_ENABLE', function_exists('iconv'));
     define('MB_ENABLE', function_exists('mb_convert_encoding'));
     define('EXT_OBGZIP', function_exists('ob_gzhandler'));
     define('TIMESTAMP', time());
     $this->timezone_set();
     if (!defined('DZZ_CORE_FUNCTION') && !@(include DZZ_ROOT . './core/function/function_core.php')) {
         exit('function_core.php is missing');
     }
     if (function_exists('ini_get')) {
         $memorylimit = @ini_get('memory_limit');
         if ($memorylimit && return_bytes($memorylimit) < 33554432 && function_exists('ini_set')) {
             ini_set('memory_limit', '128m');
         }
     }
     define('IS_ROBOT', checkrobot());
     foreach ($GLOBALS as $key => $value) {
         if (!isset($this->superglobal[$key])) {
             $GLOBALS[$key] = null;
             unset($GLOBALS[$key]);
         }
     }
     global $_G;
     $_G = array('uid' => 0, 'username' => '', 'adminid' => 0, 'groupid' => 1, 'sid' => '', 'formhash' => '', 'connectguest' => 0, 'timestamp' => TIMESTAMP, 'starttime' => microtime(true), 'clientip' => $this->_get_client_ip(), 'referer' => '', 'charset' => '', 'gzipcompress' => '', 'authkey' => '', 'timenow' => array(), 'PHP_SELF' => '', 'siteurl' => '', 'siteroot' => '', 'siteport' => '', 'config' => array(), 'setting' => array(), 'member' => array(), 'group' => array(), 'cookie' => array(), 'style' => array(), 'cache' => array(), 'session' => array(), 'lang' => array(), 'rssauth' => '');
     $_G['PHP_SELF'] = dhtmlspecialchars($this->_get_script_url());
     $_G['basescript'] = CURSCRIPT . 'php';
     $_G['basefilename'] = basename($_G['PHP_SELF']);
     $sitepath = substr($_G['PHP_SELF'], 0, strrpos($_G['PHP_SELF'], '/'));
     if (defined('IN_API')) {
         $sitepath = preg_replace("/\\/api\\/?.*?\$/i", '', $sitepath);
     } elseif (defined('IN_ARCHIVER')) {
         $sitepath = preg_replace("/\\/archiver/i", '', $sitepath);
     }
     $_G['isHTTPS'] = $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off' ? true : false;
     $_G['siteurl'] = dhtmlspecialchars('http' . ($_G['isHTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $sitepath . '/');
     $url = parse_url($_G['siteurl']);
     $_G['siteroot'] = isset($url['path']) ? $url['path'] : '';
     $_G['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':' . $_SERVER['SERVER_PORT'];
     if (defined('SUB_DIR')) {
         $_G['siteurl'] = str_replace(SUB_DIR, '/', $_G['siteurl']);
         $_G['siteroot'] = str_replace(SUB_DIR, '/', $_G['siteroot']);
     }
     $_G['browser'] = helper_browser::getbrowser();
     $_G['platform'] = helper_browser::getplatform();
     $this->var =& $_G;
 }
Exemplo n.º 9
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $allowedExtensions = array("zip");
     $sizeLimit = return_bytes(ini_get('post_max_size'));
     //		$envid = $_REQUEST["envid"];
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $envid);
     $result = $uploader->handleUpload(PATH_TEMP);
     // to pass data through iframe you will need to encode all html tags
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     die;
     //$ajaxResponseObject->setStatus("ok");
     //return $ajaxResponseObject;
 }
Exemplo n.º 10
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     $ajaxResponseObject->setStatus("ok");
     $ajaxUploader = new \Widgets\AjaxUploader();
     $ajaxUploader->setSizeLimit(return_bytes(ini_get('post_max_size')));
     $ajaxUploader->setNamespace("Explorer");
     $ajaxUploader->setDestId($this->id);
     $rawHTML = new \Widgets\RawHtml();
     $rawHTML->setHtml("<div style=\"float:right\"><a class=\"button pill negative\" onclick=\"closeDialog();return false;\" href=\"#\">Schließen</a></div>");
     $ajaxResponseObject->addWidget($ajaxUploader);
     $ajaxResponseObject->addWidget($rawHTML);
     return $ajaxResponseObject;
 }
Exemplo n.º 11
0
    public function processData(\IRequestObject $requestObject)
    {
        $params = $requestObject->getParams();
        $objectId = $params["messageObjectId"];
        $object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectId);
        $oldImageId = $object->get_attribute("bid:portlet:msg:picture_id");
        $dialog = new \Widgets\Dialog();
        $dialog->setTitle("Meldungsbild bearbeiten");
        $dialog->setPositionX($this->params["mouseX"]);
        $dialog->setPositionY($this->params["mouseY"]);
        //$dialog->setWidth(450);
        $emptyImageUrl = PATH_URL . "portletMsg/asset/empty.jpg";
        $ajaxUploader = new \Widgets\AjaxUploader();
        if ($oldImageId !== 0) {
            $imgWidget = new \Widgets\RawHtml();
            $imgWidget->setHtml("Um ein Bild hochzuladen ziehen sie eine Datei auf dieses Feld oder doppelklicken sie hier.<br><img id=\"uploaderImage\" src=\"" . PATH_URL . "download/document/{$oldImageId}\"></img>");
            $ajaxUploader->setPreview($imgWidget);
        } else {
            $imgWidget = new \Widgets\RawHtml();
            $imgWidget->setHtml("Um ein Bild hochzuladen ziehen sie eine Datei auf dieses Feld oder doppelklicken sie hier.<br><img id=\"uploaderImage\" src=\"{$emptyImageUrl}\"></img>");
            $ajaxUploader->setPreview($imgWidget);
        }
        $ajaxUploader->setSizeLimit(return_bytes(ini_get('post_max_size')));
        $ajaxUploader->setNamespace("PortletMsg");
        $ajaxUploader->setCommand("UploadImage");
        $ajaxUploader->setDestId($object->get_id());
        $ajaxUploader->setMultiUpload(false);
        $ajaxUploader->setOnComplete("function(id, fileName, responseJSON){document.getElementById('uploaderImage').src = '" . PATH_URL . "download/document/' + responseJSON.oid; jQuery('#uploaderImage').addClass('saved')}");
        $dialog->addWidget($ajaxUploader);
        $raw = new \Widgets\RawHtml();
        $raw->setHtml(<<<END
\t\t<a href="#" class="button pill negative" onclick="sendRequest('DeleteImage', {'id':{$object->get_id()}}, '', 'data', null, function() {document.getElementById('uploaderImage').src = '{$emptyImageUrl}'; jQuery('#uploaderImage').addClass('saved')}, 'PortletMsg');">Bild löschen</a>
END
);
        $dialog->addWidget($raw);
        $dialog->addWidget(new \Widgets\Clearer());
        $radioButton = new \Widgets\RadioButton();
        $radioButton->setLabel("Bildposition");
        $radioButton->setOptions(array(array("name" => "links", "value" => "left"), array("name" => "nicht umfließend", "value" => "none"), array("name" => "rechts", "value" => "right")));
        $radioButton->setData($object);
        $radioButton->setContentProvider(\Widgets\DataProvider::attributeProvider("bid:portlet:msg:picture_alignment"));
        $dialog->addWidget($radioButton);
        $dialog->addWidget(new \Widgets\Clearer());
        $sizeInput = new \Widgets\TextInput();
        $sizeInput->setLabel("Bildbreite");
        $sizeInput->setData($object);
        $sizeInput->setContentProvider(\Widgets\DataProvider::attributeProvider("bid:portlet:msg:picture_width"));
        $dialog->addWidget($sizeInput);
        $this->dialog = $dialog;
    }
Exemplo n.º 12
0
 private function _init_env()
 {
     error_reporting(E_ERROR);
     if (PHP_VERSION < '5.3.0') {
         set_magic_quotes_runtime(0);
     }
     define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
     define('ICONV_ENABLE', function_exists('iconv'));
     define('MB_ENABLE', function_exists('mb_convert_encoding'));
     define('EXT_OBGZIP', function_exists('ob_gzhandler'));
     define('TIMESTAMP', time());
     $this->timezone_set();
     if (!defined('DISCUZ_CORE_FUNCTION') && !@(include DISCUZ_ROOT . './source/function/function_core.php')) {
         exit('function_core.php is missing');
     }
     if (function_exists('ini_get')) {
         $memorylimit = @ini_get('memory_limit');
         if ($memorylimit && return_bytes($memorylimit) < 33554432 && function_exists('ini_set')) {
             ini_set('memory_limit', '128m');
         }
     }
     define('IS_ROBOT', checkrobot());
     foreach ($GLOBALS as $key => $value) {
         if (!isset($this->superglobal[$key])) {
             $GLOBALS[$key] = null;
             unset($GLOBALS[$key]);
         }
     }
     global $_G;
     $_G = array('uid' => 0, 'username' => '', 'adminid' => 0, 'groupid' => 1, 'sid' => '', 'formhash' => '', 'connectguest' => 0, 'timestamp' => TIMESTAMP, 'starttime' => microtime(true), 'clientip' => $this->_get_client_ip(), 'remoteport' => $_SERVER['REMOTE_PORT'], 'referer' => '', 'charset' => '', 'gzipcompress' => '', 'authkey' => '', 'timenow' => array(), 'widthauto' => 0, 'disabledwidthauto' => 0, 'PHP_SELF' => '', 'siteurl' => '', 'siteroot' => '', 'siteport' => '', 'pluginrunlist' => !defined('PLUGINRUNLIST') ? array() : explode(',', PLUGINRUNLIST), 'config' => array(), 'setting' => array(), 'member' => array(), 'group' => array(), 'cookie' => array(), 'style' => array(), 'cache' => array(), 'session' => array(), 'lang' => array(), 'my_app' => array(), 'my_userapp' => array(), 'fid' => 0, 'tid' => 0, 'forum' => array(), 'thread' => array(), 'rssauth' => '', 'home' => array(), 'space' => array(), 'block' => array(), 'article' => array(), 'action' => array('action' => APPTYPEID, 'fid' => 0, 'tid' => 0), 'mobile' => '', 'notice_structure' => array('mypost' => array('post', 'pcomment', 'activity', 'reward', 'goods', 'at'), 'interactive' => array('poke', 'friend', 'wall', 'comment', 'click', 'sharenotice'), 'system' => array('system', 'myapp', 'credit', 'group', 'verify', 'magic', 'task', 'show', 'group', 'pusearticle', 'mod_member', 'blog', 'article'), 'manage' => array('mod_member', 'report', 'pmreport'), 'app' => array()), 'mobiletpl' => array('1' => 'mobile', '2' => 'touch', '3' => 'wml', 'yes' => 'mobile'));
     $_G['PHP_SELF'] = dhtmlspecialchars($this->_get_script_url());
     $_G['basescript'] = CURSCRIPT;
     $_G['basefilename'] = basename($_G['PHP_SELF']);
     $sitepath = substr($_G['PHP_SELF'], 0, strrpos($_G['PHP_SELF'], '/'));
     if (defined('IN_API')) {
         $sitepath = preg_replace("/\\/api\\/?.*?\$/i", '', $sitepath);
     } elseif (defined('IN_ARCHIVER')) {
         $sitepath = preg_replace("/\\/archiver/i", '', $sitepath);
     }
     $_G['isHTTPS'] = $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off' ? true : false;
     $_G['siteurl'] = dhtmlspecialchars('http' . ($_G['isHTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $sitepath . '/');
     $url = parse_url($_G['siteurl']);
     $_G['siteroot'] = isset($url['path']) ? $url['path'] : '';
     $_G['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':' . $_SERVER['SERVER_PORT'];
     if (defined('SUB_DIR')) {
         $_G['siteurl'] = str_replace(SUB_DIR, '/', $_G['siteurl']);
         $_G['siteroot'] = str_replace(SUB_DIR, '/', $_G['siteroot']);
     }
     $this->var =& $_G;
 }
Exemplo n.º 13
0
function php_iniChecks()
{
    global $successful_Check;
    $checks = array('display_errors' => false, 'expose_php' => false, 'allow_url_include' => false, 'allow_url_fopen' => false, 'sql.safe_mode' => true, 'post_max_size' => 1024, 'max_execution_time' => 30, 'max_input_time' => 30, 'memory_limit' => 40 * 1024 * 1024, 'register_globals' => false, 'session.cookie_httponly' => true, 'session.hash_function' => true);
    foreach ($checks as $key => $value) {
        if (is_bool($value) && (bool) ini_get($key) !== $value) {
            $successful_Check = false;
            echo "The directive " . $key . " is set to <b>" . ($value ? "false" : "true") . "</b>. You should set it to <b>" . ($value ? "true" : "false") . "</b>. <br />";
        } elseif (is_int($value) && intval(return_bytes(ini_get($key))) > $value) {
            $successful_Check = false;
            echo "The directive " . $key . " is set to <b>" . intval(return_bytes(ini_get($key))) . "</b>. You should set it to <b>" . $value . "</b>. <br />";
        }
    }
}
Exemplo n.º 14
0
 function __construct($sUploadTypeNC = 'Common')
 {
     parent::__construct();
     $this->sTempFilename = '';
     $this->sUploadTypeNC = $sUploadTypeNC;
     $this->sUploadTypeLC = strtolower($this->sUploadTypeNC);
     $this->_iOwnerId = $this->_getAuthorId();
     $this->_sJsPostObject = 'o' . $this->sUploadTypeNC . 'Upload';
     $this->sSendFileInfoFormCaption = '';
     $GLOBALS['oSysTemplate']->addJsTranslation(array('_bx_' . $this->sUploadTypeLC . 's_val_title_err', '_bx_' . $this->sUploadTypeLC . 's_val_descr_err'));
     //--- Get Extras ---//
     $this->_aExtras = array();
     if (!empty($_POST)) {
         $this->_aExtras = $this->_getExtraParams($_POST);
     }
     $this->iMaxFilesize = min(return_bytes(ini_get('upload_max_filesize')), return_bytes(ini_get('post_max_size')));
     //max allowed from php.ini
 }
Exemplo n.º 15
0
 public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
 {
     // list of valid extensions, ex. array("jpeg", "xml", "bmp")
     //		var_dump($this->params);
     //		die;
     $allowedExtensions = array();
     // max file size in bytes
     $sizeLimit = return_bytes(ini_get('post_max_size'));
     $destId = $_REQUEST["destid"];
     $destObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $destId);
     $envid = $destObject->get_id();
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $envid);
     $result = $uploader->handleUpload(PATH_TEMP);
     // to pass data through iframe you will need to encode all html tags
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     die;
     //$ajaxResponseObject->setStatus("ok");
     //return $ajaxResponseObject;
 }
Exemplo n.º 16
0
 function BxDolFilesUploader($sUploadTypeNC = 'Common')
 {
     parent::BxDolTemplate();
     $this->sTempFilename = '';
     $this->sUploadTypeNC = $sUploadTypeNC;
     $this->sUploadTypeLC = strtolower($this->sUploadTypeNC);
     $this->_iOwnerId = $this->_getAuthorId();
     $this->_sJsPostObject = 'o' . $this->sUploadTypeNC . 'Upload';
     $this->sSendFileInfoFormCaption = '';
     $GLOBALS['oSysTemplate']->addJsTranslation(array('_bx_' . $this->sUploadTypeLC . 's_val_title_err', '_bx_' . $this->sUploadTypeLC . 's_val_descr_err'));
     //--- Get Extras ---//
     $this->_aExtras = array();
     if (!empty($_POST)) {
         $this->_aExtras = $this->_getExtraParams($_POST);
     }
     $this->iMaxFilesize = min(return_bytes(ini_get('upload_max_filesize')), return_bytes(ini_get('post_max_size')));
     //max allowed from php.ini
     $this->sMultiUploaderParams = array('accept_file' => '', 'multi' => 'true', 'auto' => 'true', 'accept_format' => '*.*', 'accept_format_desc' => 'All Files', 'file_size_limit' => $this->iMaxFilesize, 'file_upload_limit' => '10', 'file_queue_limit' => '5', 'button_image_url' => $GLOBALS['oSysTemplate']->getImageUrl('button_sprite.png'));
 }
Exemplo n.º 17
0
 public function editar($acta = 0, $curso = 0)
 {
     $filter = new stdClass();
     $filter->acta = $acta;
     $filter->order_by = array("f.PERSC_ApellidoPaterno" => "asc", "f.PERSC_ApellidoMaterno" => "asc", "f.PERSC_Nombre" => "asc");
     $actaexposiciones = $this->actaexposicion_model->listar($filter);
     $item = 1;
     $lista = array();
     if (count($actaexposiciones) > 0) {
         foreach ($actaexposiciones as $indice => $value) {
             $lista[$indice] = new stdClass();
             $lista[$indice]->codigo = $value->ACTAEXPOSP_Codigo;
             $lista[$indice]->profesor = $value->PERSC_ApellidoPaterno . " " . $value->PERSC_ApellidoMaterno . " " . $value->PERSC_Nombre;
             $lista[$indice]->curso = $value->PROD_Nombre;
             $lista[$indice]->tema = $value->TEMAC_Descripcion;
             $lista[$indice]->descripcion = $value->ACTAEXPOSC_Descripcion;
             $lista[$indice]->duracion = $value->ACTAEXPOSC_Duracion;
             $lista[$indice]->archivo = $value->ACTAEXPOSC_Archivo;
         }
     }
     /*Cargo el formulario*/
     $data['titulo'] = "Listado de exposiciones";
     $data['upload_max_filesize'] = return_bytes(ini_get('upload_max_filesize')) / (1024 * 1024);
     $data['form_open'] = form_open(base_url() . "index.php/ventas/actaexposicion/grabar", array("name" => "frmPersona", "id" => "frmPersona", "enctype" => "multipart/form-data", "onsubmit" => "return valida_frm_exposicion();"));
     $data['form_profesor'] = form_input(array("name" => "profesor", "id" => "profesor", "value" => "", "class" => "cajaMedia"));
     $filter = new stdClass();
     $filter->curso = $curso;
     $filter->order_by = array("d.PERSC_ApellidoPaterno" => "asc", "d.PERSC_ApellidoMaterno" => "asc", "d.PERSC_Nombre" => "asc");
     $data['form_profesor'] = form_dropdown('profesor', $this->profesor_model->seleccionar("0", $filter), "", "id='profesor' class='comboMedio'");
     $filter = new stdClass();
     $filter->curso = $curso;
     $filter->order_by = array("c.TEMAC_Descripcion" => "asc");
     $data['form_tema'] = form_dropdown('tema', $this->tema_model->seleccionar("0", $filter), "", "id='tema' class='comboMedio'");
     $data['form_descripcion'] = form_input(array("name" => "descripcion", "id" => "descripcion", "value" => "", "class" => "cajaMedia"));
     $data['form_duracion'] = form_input(array("name" => "duracion", "id" => "duracion", "value" => "", "class" => "cajaMinima", "type" => "time"));
     $data['form_close'] = form_close();
     $data['lista'] = $lista;
     $data['oculto'] = form_hidden(array("curso" => $curso, "acta" => $acta, "max_filesize" => $data['upload_max_filesize']));
     $this->load->view("ventas/actaexposicion_nuevo", $data);
 }
Exemplo n.º 18
0
 /></td>
	   <td class="v10" bgcolor="#E7E8EB"><label for="cguestbook_imgupload">&nbsp;<?php 
echo $BL['be_on'];
?>
</label>&nbsp;&nbsp;</td>
	   <td>&nbsp;&nbsp;</td>
	   <td class="chatlist">&nbsp;&nbsp;<?php 
echo $BL['be_cnt_filesize'];
?>
:&nbsp;</td>
	   <td ><input name="cguestbook_maximgsize" type="text" class="f11b" id="cguestbook_maximgsize" style="width: 100px;" size="20" maxlength="20" value="<?php 
echo $content["guestbook"]["max_image_filesize"];
?>
" /></td>
	   <td class="chatlist">&nbsp;(<?php 
echo return_bytes($content["guestbook"]["max_image_filesize"]);
?>
 Byte)</td>
	   <td><img src="img/leer.gif" alt="" width="1" height="22" /></td>
	  </tr>
	  </table></td>
</tr>

<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="6" /></td></tr>

<tr>
  <td align="right" class="chatlist"><?php 
echo $BL['be_cnt_sorting'];
?>
:&nbsp;</td>
  <td><table border="0" cellpadding="0" cellspacing="0" bgcolor="#E7E8EB" summary="">
Exemplo n.º 19
0
function fileHandler($file, $type, $max_width, $max_height)
{
    // filesize check
    function return_bytes($val)
    {
        $val = trim($val);
        $last = strtolower($val[strlen($val) - 1]);
        switch ($last) {
            // The 'G' modifier is available since PHP 5.1.0
            case 'g':
                $val *= 1024;
            case 'm':
                $val *= 1024;
            case 'k':
                $val *= 1024;
        }
        return $val;
    }
    if ($file['size'] >= return_bytes(ini_get('post_max_size'))) {
        header('location:dash.php?3');
        exit;
    }
    $upload_flag = 0;
    if ($type != "img") {
        //$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
        //echo "Extension : ".$ext;
        $abs_path = $type . "_" . md5(time());
        $path = "../files/" . $abs_path;
        if ($file['type'] == "application/pdf" || $file['type'] == "application/rtf" || $file['type'] == "application/msword" || $file['type'] == "message/rfc822" || $file['type'] == "message/rfc822" || $file['type'] == "text/html" || $file['type'] == "text/plain" || $file['type'] == "image/gif" || $file['type'] == "image/jpeg" || $file['type'] == "image/x-png" || $file['type'] == "image/pjpeg" || $file['type'] == "image/png" || $file['type'] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
            if ($file["name"] != "") {
                if ($file["error"] > 0) {
                    $debug = "Return Code: " . $file["error"] . "<br>";
                    echo "new";
                } else {
                    $debug .= "Upload: " . $file["name"] . ",";
                    $debug .= "Type: " . $file["type"] . ",";
                    $debug .= "Size: " . $file["size"] / 1024 . " kB,";
                    $debug .= "Temp media: " . $file["tmp_name"] . ",";
                    if (file_exists($path)) {
                        $debug .= $file["name"] . " already exists. ";
                    } else {
                        move_uploaded_file($file["tmp_name"], $path) or die("file error");
                        $debug .= "Stored in: " . $path;
                        $upload_flag = 1;
                    }
                }
                return $abs_path;
            } else {
                return 0;
            }
        }
    } else {
        //$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
        $abs_path = $type . "_" . md5(time()) . ".png";
        $path = "img/profiles/" . $abs_path;
        if ($file['type'] == "image/jpeg" || $file['type'] == "image/x-png" || $file['type'] == "image/png") {
            $arr_image_details = getimagesize($file["tmp_name"]);
            $width = $arr_image_details[0];
            print_r($arr_image_details);
            $height = $arr_image_details[1];
            echo $width;
            echo $height;
            if ($width != 150 && $height != 150) {
                return 'File Dimensions incorrect.';
            }
            // converting to grayscale
            switch ($file['type']) {
                case 'image/jpeg':
                    $im = imagecreatefromjpeg($file["tmp_name"]);
                    break;
                case 'image/png':
                case 'image/x-png':
                    $im = imagecreatefrompng($file["tmp_name"]);
                    break;
            }
            if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) {
                echo 'Image converted to grayscale.';
                imagepng($im, $file["tmp_name"]);
            } else {
                return 'Conversion to grayscale failed.';
            }
            imagedestroy($im);
            if ($file["name"] != "") {
                if ($file["error"] > 0) {
                    $debug = "Return Code: " . $file["error"] . "<br>";
                    return 'There was an error processing the file.';
                } else {
                    $debug .= "Upload: " . $file["name"] . ",";
                    $debug .= "Type: " . $file["type"] . ",";
                    $debug .= "Size: " . $file["size"] / 1024 . " kB,";
                    $debug .= "Temp media: " . $file["tmp_name"] . ",";
                    if (file_exists($path)) {
                        $debug .= $file["name"] . " already exists. ";
                    } else {
                        /*if (makeThumbnails('../img/thumbnails/', $file["tmp_name"], $abs_path, $max_width, $max_height)) {
                          }*/
                        move_uploaded_file($file["tmp_name"], $path) or die("file error");
                        $debug .= "Stored in: " . $path;
                        $upload_flag = 1;
                    }
                }
            }
            return $abs_path;
        } else {
            return 'File Type Incorrect!';
        }
    }
    //handling done
    //echo $upload_flag;
}
Exemplo n.º 20
0
function printEntryFileList($attachments, $param)
{
    $context = Model_Context::getInstance();
    $spacerURL = $context->getProperty('service.path') . $context->getProperty('panel.skin') . '/image/spacer.gif';
    $blogid = getBlogId();
    if (empty($attachments) || strpos($attachments[0]['name'], '.gif') === false && strpos($attachments[0]['name'], '.jpg') === false && strpos($attachments[0]['name'], '.png') === false) {
        $fileName = $spacerURL;
    } else {
        $fileName = $context->getProperty('service.path') . "/attach/{$blogid}/" . $attachments[0]['name'];
    }
    ?>
    <div id="previewSelected" style="width: 120px; height: 90px;"><span class="text"><?php 
    echo _t('미리보기');
    ?>
</span>
    </div>

    <div id="attachManagerSelectNest">
												<span id="attachManagerSelect">
													<select id="TCfilelist" name="TCfilelist" multiple="multiple"
                                                            size="8" onchange="selectAttachment();">
                                                        <?php 
    $initialFileListForFlash = '';
    $enclosureFileName = '';
    foreach ($attachments as $i => $attachment) {
        if (strpos($attachment['mime'], 'application') !== false) {
            $class = 'class="MimeApplication"';
        } else {
            if (strpos($attachment['mime'], 'audio') !== false) {
                $class = 'class="MimeAudio"';
            } else {
                if (strpos($attachment['mime'], 'image') !== false) {
                    $class = 'class="MimeImage"';
                } else {
                    if (strpos($attachment['mime'], 'message') !== false) {
                        $class = 'class="MimeMessage"';
                    } else {
                        if (strpos($attachment['mime'], 'model') !== false) {
                            $class = 'class="MimeModel"';
                        } else {
                            if (strpos($attachment['mime'], 'multipart') !== false) {
                                $class = 'class="MimeMultipart"';
                            } else {
                                if (strpos($attachment['mime'], 'text') !== false) {
                                    $class = 'class="MimeText"';
                                } else {
                                    if (strpos($attachment['mime'], 'video') !== false) {
                                        $class = 'class="MimeVideo"';
                                    } else {
                                        $class = '';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!empty($attachment['enclosure']) && $attachment['enclosure'] == 1) {
            $style = 'style="background-color:#c6a6e7; color:#000000"';
            $enclosureFileName = $attachment['name'];
        } else {
            $style = '';
        }
        $value = htmlspecialchars(getAttachmentValue($attachment));
        $label = htmlspecialchars(getPrettyAttachmentLabel($attachment));
        $initialFileListForFlash .= escapeJSInAttribute($value . '(_!' . $label . '!^|');
        ?>
                                                            <option  <?php 
        echo $style;
        ?>
                                                                value="<?php 
        echo $value;
        ?>
"><?php 
        echo $label;
        ?>
</option>
                                                        <?php 
    }
    ?>
                                                    </select>
												</span>
											</div>

											<script type="text/javascript">
												//<![CDATA[
												  function addAttachment() {
<?php 
    if (!defined('__TEXTCUBE_GAE__')) {
        ?>
														var uploadPath = "<?php 
        echo $param['singleUploadPath'];
        ?>
" + entryManager.entryId;
<?php 
    } else {
        ?>
                            var request = new HTTPRequest("POST", "<?php 
        echo $blogURL;
        ?>
/owner/api/uploadurl", false);
														request.send("target=<?php 
        echo $param['singleUploadPath'];
        ?>
" + entryManager.entryId);
														var uploadPath = request.getText('/response/url');
<?php 
    }
    ?>
												    var attachHidden = document.getElementById('attachHiddenNest');
														attachHidden.contentDocument.forms[0].action = uploadPath;
														attachHidden.contentDocument.forms[0].attachment.click();
													}

													function deleteAttachment() {
														var fileList = document.getElementById('TCfilelist');

														if (fileList.selectedIndex < 0) {
															alert("<?php 
    echo _t('삭제할 파일을 선택해 주십시오\\t');
    ?>
");
															return false;
														}

														try {

															var targetStr = '';
															deleteFileList = new Array();
															for(var i=0; i<fileList.length; i++) {
																if(fileList[i].selected) {
																	var name = fileList[i].value.split("|")[0];
																	targetStr += name+'!^|';
																	deleteFileList.push(i);
																}
															}
														} catch(e) {
															alert("<?php 
    echo _t('파일을 삭제하지 못했습니다');
    ?>
 ::"+e.message);
														}

														var request = new HTTPRequest("POST", "<?php 
    echo $param['deletePath'];
    ?>
"+entryManager.entryId);
														request.onVerify = function () {
															return true
														}

														request.onSuccess = function() {
															for(var i=deleteFileList.length-1; i>=0; i--) {
																fileList.remove(deleteFileList[i]);
															}

															if (fileList.options.length == 0)
																document.getElementById('previewSelected').innerHTML = '';
															else {
																fileList.selectedIndex = 0;
																selectAttachment();
															}
															refreshAttachFormSize();
															refreshFileSize();
														}

														request.onError = function() {
															alert("<?php 
    echo _t('파일을 삭제하지 못했습니다');
    ?>
");
														}
														request.send("names="+targetStr);
													}

													function selectAttachment() {
														try {
														width = document.getElementById('previewSelected').clientWidth;
														height = document.getElementById('previewSelected').clientHeight;
														var code = '';
														var fileList = document.getElementById('TCfilelist');
														if (fileList.selectedIndex < 0)
															return false;
														var fileName = fileList.value.split("|")[0];

														if((new RegExp("\\.(gif|jpe?g|png)$", "gi").exec(fileName))) {
															try {
																var width = new RegExp('width="(\\d+)').exec(fileList.value);
																width = width[1];
																var height = new RegExp('height="(\\d+)').exec(fileList.value);
																height = height[1];
																if(width > 120) {
																	height = 120 / width * height;
																	width = 120;
																}
																if(height > 90) {
																	width = 90 / height * width;
																	height = 90;
																}
																document.getElementById('previewSelected').innerHTML = '<img src="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'?randseed='+Math.random()+'" width="' + parseInt(width) + '" height="' + parseInt(height) + '" alt="" style="margin-top: ' + ((90-height)/2) + 'px" onerror="if (this.src != \'<?php 
    echo $spacerURL;
    ?>
\') { this.src=\'<?php 
    echo $spacerURL;
    ?>
\' }"/>';
															}
															catch(e) { }
															return false;
														}

														if((new RegExp("\\.(mp3)$", "gi").exec(fileName))) {
															var str = getEmbedCode("<?php 
    echo $context->getProperty('service.path');
    ?>
/resources/script/jukebox/flash/mini.swf","100%","100%", "jukeBox0Flash","#FFFFFF", "sounds=<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/"+fileName+"&autoplay=false", "false");
															writeCode(str, 'previewSelected');
															return false;
														}

														if((new RegExp("\\.(swf)$", "gi").exec(fileName))) {

															code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%"><param name="movie" value="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'"/><param name="allowscriptAccess" value="sameDomain" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF"/>';
															code += '<!--[if !IE]> <--><object type="application/x-shockwave-flash" data="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'" width="100%" height="100%"><param name="allowscriptAccess" value="sameDomain" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF"/><\/object><!--> <![endif]--><\/object>';

															writeCode(code,'previewSelected');
															return false;
														}

														if((new RegExp("\\.(mov)$", "gi").exec(fileName))) {
															code = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+width+'" height="'+height+'"><param name="src" value="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'"/><param name="controller" value="true"><param name="autoplay" value="false"><param name="scale" value="Aspect">';
															code += '<!--[if !IE]> <--><object type="video/quicktime" data="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'" width="'+width+'" height="'+height+'" showcontrols="true" TYPE="video/quicktime" scale="Aspect" nomenu="true"><param name="showcontrols" value="true"><param name="autoplay" value="false"><param name="scale" value="ToFit"><\/object><!--> <![endif]--><\/object>';
															writeCode(code,'previewSelected');
															return false;
														}

														if((new RegExp("\\.(mp2|wma|mid|midi|mpg|wav|avi|mp4)$", "gi").exec(fileName))) {
															code ='<object width="'+width+'" height="'+height+'" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading for you" type="application/x-oleobject" align="middle">';
															code +='<param name="FileName" value="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'">';
															code +='<param name="ShowStatusBar" value="False">';
															code +='<param name="DefaultFrame" value="mainFrame">';
															code +='<param name="autoplay" value="false">';
															code +='<param name="showControls" value="true">';
															code +='<embed type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" src="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'" align="middle" width="'+width+'" height="'+height+'" showControls="true" defaultframe="mainFrame" showstatusbar="false" autoplay="false"><\/embed>';
															code +='<\/object>';

															writeCode(code,'previewSelected');

															return false;
														}

														if((new RegExp("\\.(rm|ram)$", "gi").exec(fileName))) {
														/*
															code = '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+width+'" height="'+height+'"><param name="src" value="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'"/><param name="CONTROLS" value="imagewindow"><param name="AUTOGOTOURL" value="FALSE"><param name="CONSOLE" value="radio"><param name="AUTOSTART" value="TRUE">';
															code += '<!--[if !IE]> <--><object type="audio/x-pn-realaudio-plugin" data="<?php 
    echo $context->getProperty('service.path');
    ?>
/attach/<?php 
    echo $blogid;
    ?>
/'+fileName+'" width="'+width+'" height="'+height+'" ><param name="CONTROLS" value="imagewindow"><param name="AUTOGOTOURL" value="FALSE"><param name="CONSOLE" value="radio"><param name="AUTOSTART" value="TRUE"><\/object><!--> <![endif]--><\/object>';
														*/
														}

														if (code == undefined || code == '') {
															document.getElementById('previewSelected').innerHTML = "<table width=\"100%\" height=\"100%\"><tr><td valign=\"middle\" align=\"center\"><?php 
    echo _t('미리보기');
    ?>
<\/td><\/tr><\/table>";
															return true;
														}



														return false;
														} catch (e) {
															document.getElementById('previewSelected').innerHTML = "<table width=\"100%\" height=\"100%\"><tr><td valign=\"middle\" align=\"center\"><?php 
    echo _t('미리보기');
    ?>
<\/td><\/tr><\/table>";
															alert(e.message);
															return true;
														}
													}

													function downloadAttachment() {
														try {
															var fileList = document.getElementById('TCfilelist');
															if (fileList.selectedIndex < 0) {
																return false;
															}
															for(var i=0; fileList.length; i++) {
																if (fileList[i].selected) {
																	var fileName = fileList[i].value.split("|")[0];
																	if(STD.isIE) {
																		document.getElementById('fileDownload').innerHTML='<iframe style="display:none;" src="'+blogURL+'\/attachment\/'+fileName+'"><\/iframe>';

																	} else {
																		window.location = blogURL+'/attachment/'+fileName;
																	}
																	break;
																}
															}
														} catch(e) {
															alert(e.message);
														}
													}

													STD.addEventListener(window);
													window.addEventListener("beforeunload", PageMaster.prototype._onBeforeUnload, false);

													function stripLabelToValue(fileLabel) {
														var pos = fileLabel.lastIndexOf('(');
														return fileLabel.substring(0,pos-1);
													}

													function refreshAttachFormSize() {
														fileListObj = document.getElementById('TCfilelist');
														fileListObj.setAttribute('size',Math.max(8,Math.min(fileListObj.length,30)));
													}

													function refreshAttachList() {
														var request = new HTTPRequest("POST", "<?php 
    echo $param['refreshPath'];
    ?>
"+entryManager.entryId);
														request.onVerify = function () {
															return true
														}
														request.onSuccess = function() {
															var fileListObj = document.getElementById("attachManagerSelect");
															fileListObj.innerHTML = this.getText();
															refreshAttachFormSize();
															//getUploadObj().setAttribute('width',1)
															//getUploadObj().setAttribute('height',1)


															refreshFileSize();
															entryManager.delay     = true;
															entryManager.nowsaving = false;
														}
														request.onError = function() {
															entryManager.delay     = true;
															entryManager.nowsaving = false;

														}
														request.send();
													}

													function uploadProgress(target,loaded, total) {
														loaded = Number(loaded);
														total = Number(total);
														var fileListObj = document.getElementById("TCfilelist");
														for(var i=0; i<fileListObj.length; i++) {
															if (fileListObj[i].getAttribute("value") == target) {
																fileListObj[i].innerHTML = target+" "+(Math.ceil(100*loaded/total))+"%";
																break;
															}
														}
													}

													function uploadComplete(target,size) {
														loaded = Number(loaded);
														total = Number(total);
														var fileListObj = document.getElementById("TCfilelist");
														for(var i=0; i<fileListObj.length; i++) {
															if (fileListObj[i].getAttribute("value") == target) {
																fileListObj[i].innerHTML = target+" "+(Math.ceil(100*loaded/total))+"%";
																break;
															}
														}
													}

													/**
													*
													*  Base64 encode / decode
													*  http://www.webtoolkit.info/
													*
													**/

													var Base64 = {

														// private property
														_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

														// public method for encoding
														encode : function (input) {
															var output = "";
															var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
															var i = 0;

															input = Base64._utf8_encode(input);

															while (i < input.length) {

																chr1 = input.charCodeAt(i++);
																chr2 = input.charCodeAt(i++);
																chr3 = input.charCodeAt(i++);

																enc1 = chr1 >> 2;
																enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
																enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
																enc4 = chr3 & 63;

																if (isNaN(chr2)) {
																	enc3 = enc4 = 64;
																} else if (isNaN(chr3)) {
																	enc4 = 64;
																}

																output = output +
																this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
																this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

															}

															return output;
														},

														// public method for decoding
														decode : function (input) {
															var output = "";
															var chr1, chr2, chr3;
															var enc1, enc2, enc3, enc4;
															var i = 0;

															input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

															while (i < input.length) {

																enc1 = this._keyStr.indexOf(input.charAt(i++));
																enc2 = this._keyStr.indexOf(input.charAt(i++));
																enc3 = this._keyStr.indexOf(input.charAt(i++));
																enc4 = this._keyStr.indexOf(input.charAt(i++));

																chr1 = (enc1 << 2) | (enc2 >> 4);
																chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
																chr3 = ((enc3 & 3) << 6) | enc4;

																output = output + String.fromCharCode(chr1);

																if (enc3 != 64) {
																	output = output + String.fromCharCode(chr2);
																}
																if (enc4 != 64) {
																	output = output + String.fromCharCode(chr3);
																}

															}

															output = Base64._utf8_decode(output);

															return output;

														},

														// private method for UTF-8 encoding
														_utf8_encode : function (string) {
															string = string.replace(/\r\n/g,"\n");
															var utftext = "";

															for (var n = 0; n < string.length; n++) {

																var c = string.charCodeAt(n);

																if (c < 128) {
																	utftext += String.fromCharCode(c);
																}
																else if((c > 127) && (c < 2048)) {
																	utftext += String.fromCharCode((c >> 6) | 192);
																	utftext += String.fromCharCode((c & 63) | 128);
																}
																else {
																	utftext += String.fromCharCode((c >> 12) | 224);
																	utftext += String.fromCharCode(((c >> 6) & 63) | 128);
																	utftext += String.fromCharCode((c & 63) | 128);
																}

															}

															return utftext;
														},

														// private method for UTF-8 decoding
														_utf8_decode : function (utftext) {
															var string = "";
															var i = 0;
															var c = c1 = c2 = 0;

															while ( i < utftext.length ) {

																c = utftext.charCodeAt(i);

																if (c < 128) {
																	string += String.fromCharCode(c);
																	i++;
																}
																else if((c > 191) && (c < 224)) {
																	c2 = utftext.charCodeAt(i+1);
																	string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
																	i += 2;
																}
																else {
																	c2 = utftext.charCodeAt(i+1);
																	c3 = utftext.charCodeAt(i+2);
																	string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
																	i += 3;
																}

															}

															return string;
														}

													}



													function addFileList(list) {

														var list = Base64.decode(list);
														var fileListObj = document.getElementById("TCfilelist");
														var listTemp = list.split("!^|");
														var fileLabel = listTemp[0];
														var fileValue = listTemp[1];
														for(var i=0; i<fileListObj.length; i++) {
															if (stripLabelToValue(fileLabel).indexOf(fileListObj[i].getAttribute("value")) != -1) {
																var oOption = document.createElement("option");
																oOption.innerHTML= fileLabel;
																oOption.setAttribute("value",fileValue);
																fileListObj.replaceChild(oOption,fileListObj[i]);
																break;
															}
														}
													}

													function newLoadItem(fileValue) {
														var fileListObj = document.getElementById("TCfilelist");
														for(var i=0; i<fileListObj.length; i++) {
															if (fileValue.indexOf(fileListObj[i].getAttribute("value")) != -1) {
																fileListObj[i].style.backgroundColor="#C8DAF3";
																break;
															}
														}
													}

													function setFileList() {
														try {
															list = getUploadObj().GetVariable("/:listStr");
														} catch(e) {
															alert(e.message);
														}
														var fileListObj = document.getElementById("TCfilelist");
														var listTemp = list.split("!^|");
														for(var i=0; i<listTemp.length; i++) {
															temp = listTemp[i].split('(_!');
															var fileName = temp[0];
															var fileSize = temp[1];
															if(fileName == undefined || fileSize == undefined)
																continue;
															var oOption = document.createElement("option");
															oOption.innerHTML= fileName+' ('+Math.ceil((fileSize/1024))+'KB) <?php 
    echo _t('대기 중..');
    ?>
';
															oOption.setAttribute("value",fileName);
															oOption.style.backgroundColor="#A4C3F0";
															fileListObj.insertBefore(oOption,fileListObj[i]);
															if(i == 0) {
																newLoadItem(fileName);
															}
														}
														fileListObj.setAttribute('size',Math.max(8,Math.min(fileListObj.length,30)));
													}

													function selectFileList(value) {
														selectedFiles = value.split("!^|");
														var fileListObj = document.getElementById("TCfilelist");
														for(var i=0; i<fileListObj.length; i++) {
															for(var j=0; j<selectedFiles.length; j++) {
																if (fileListObj[i].getAttribute("value") == selectedFiles[j]) {
																	fileListObj[i].setAttribute("selected","selected");
																	selectAttachment();
																	break;
																}

																fileListObj[i].setAttribute("selected","");
															}
														}
														refreshAttachFormSize();
													}

													function disabledDeleteBtn() {
														if(document.getElementById('TCfilelist').length>0) {
															document.getElementById('deleteBtn').disabled = false;
														} else {
															document.getElementById('deleteBtn').disabled = true;
														}
													}

													function removeUploadList(list) {
														selectedFiles = list.split("!^|");
														var fileListObj = document.getElementById("TCfilelist");
														for(var j=0; j<selectedFiles.length; j++) {
															for(var i=0; i<fileListObj.length; i++) {
																if(selectedFiles[j] == undefined)
																	continue;
																if (fileListObj[i].getAttribute("value") == selectedFiles[j]) {
																	fileListObj.remove(i);
																	break;
																}
															}
														}
														refreshAttachFormSize();
													}

													function browser() {
														entryManager.delay     = true;
														entryManager.nowsaving = true;
														getUploadObj().SetVariable('/:openBrowser','true');
														getUploadObj().browser();
													}

													function stopUpload() {
														getUploadObj().SetVariable('/:stopUpload','true');
													}

													function refreshFileSize() {
														try {
															var request = new HTTPRequest("POST", "<?php 
    echo $param['fileSizePath'];
    ?>
"+entryManager.entryId);
															request.onVerify = function () {
																return true;
															}

															request.onSuccess = function() {
																try {
																	var result = this.getText("/response/result");
																	document.getElementById('fileSize').innerHTML = result;
																} catch(e) {

																}
															}

															request.onError = function() {
															}
															request.send();

														} catch(e) {
															alert(e.message);
														}
													}

													function getUploadObj() {
														try {
															var result;
															if(isIE)
																result = document.getElementById("uploader");
															else
																result = document.getElementById("uploader2");
															if (result == null)
																return false;
															else
																return result;
														} catch(e) {
															return false;
														}
													}
													refreshAttachFormSize();
												//]]>
											</script>

<?php 
    require_once ROOT . '/resources/script/detectFlash.inc';
    $maxSize = min(return_bytes(ini_get('upload_max_filesize')), return_bytes(ini_get('post_max_size')));
    ?>

												<script type="text/javascript">
													//<![CDATA[
<?php 
    if (defined('__TEXTCUBE_GAE__')) {
        ?>
													function getMultiUploadUrl() {
														var request = new HTTPRequest("POST", "<?php 
        echo $blogURL;
        ?>
/owner/api/uploadurl", false);
														request.send("target=<?php 
        echo $param['uploadPath'];
        ?>
" + entryManager.entryId + "?TSSESSION=<?php 
        echo $_COOKIE[Session::getName()];
        ?>
");
														return request.getText('/response/url');
													}
<?php 
    }
    ?>
													var uploaderStr = '';
													function reloadUploader() {
														var requiredMajorVersion = 8;
														var requiredMinorVersion = 0;
														var requiredRevision = 0;
														var jsVersion = 1.0;
														var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
<?php 
    if (!defined('__TEXTCUBE_GAE__')) {
        ?>
  													var uploadPath = "<?php 
        echo $param['uploadPath'];
        ?>
" + entryManager.entryId;
<?php 
    } else {
        ?>
														var uploadPath = '';
<?php 
    }
    ?>
	                          uploadPath = uploadPath.replace(/=/g, '%3D').replace(/\?/g, '%3F').replace(/&/g, '%26').replace(/"/g, '%22').replace(/'/g, '%27');
														uploaderStr = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="uploader"'
															+ 'width="400" height="400"'
															+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
															+ '<param name="movie" value="<?php 
    echo $context->getProperty('service.path');
    ?>
/resources/script/uploader/uploader.swf?<?php 
    echo rand();
    ?>
" />'
															+ '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="scale" value="noScale" />'
															+ '<param name="wmode" value="transparent" />'
															+ '<param name="FlashVars" value="uploadPath=' + uploadPath
																+ '&uploadStr=<?php 
    echo _t('파일 업로드');
    ?>
&uploadStopStr=<?php 
    echo _t('업로드 중지');
    ?>
&deleteStr=<?php 
    echo _t('삭제하기');
    ?>
'
																+ '&labelingPath=<?php 
    echo $param['labelingPath'];
    ?>
' + entryManager.entryId
																+ '&maxSize=<?php 
    echo $maxSize;
    ?>
&sessionName=TSSESSION&sessionValue=<?php 
    echo $_COOKIE[Session::getName()];
    ?>
" />'
															+ '<embed id="uploader2" src="<?php 
    echo $context->getProperty('service.path');
    ?>
/resources/script/uploader/uploader.swf?<?php 
    echo rand();
    ?>
"'
																+ 'flashvars="uploadPath=' + uploadPath
															  + '&uploadStr=<?php 
    echo _t('파일 업로드');
    ?>
&uploadStopStr=<?php 
    echo _t('업로드 중지');
    ?>
&deleteStr=<?php 
    echo _t('삭제하기');
    ?>
'
															  + '&labelingPath=<?php 
    echo $param['labelingPath'];
    ?>
' + entryManager.entryId
															  + '&maxSize=<?php 
    echo $maxSize;
    ?>
&sessionName=TSSESSION&sessionValue=<?php 
    echo $_COOKIE[Session::getName()];
    ?>
" width="400" height="40" align="middle" wmode="transparent" quality="high" bgcolor="#ffffff" scale="noScale" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
															  +'<\/embed><\/object>';

														if (hasRightVersion && (isMoz || isIE || isMinSafari3)) {
															if(<?php 
    echo $context->getProperty('service.flashuploader') ? 'true' : 'false';
    ?>
) { writeCode(uploaderStr,'uploaderNest'); }
														}
														window.uploader= document.getElementById('uploader');
														refreshUploadButton();
													}
													//]]>
												</script>
											<div id="uploaderNest">
											</div>
<?php 
}
Exemplo n.º 21
0
        }
    }
}
// No errors, attemp to do the upload process
if (!$error) {
    require_once __CHV_PATH_CLASSES__ . 'class.upload.php';
    $api_upload = new Upload($to_upload);
    if ($api_remote_upload) {
        $api_upload->is_remote = true;
    }
    $api_upload->img_upload_path = __CHV_PATH_IMAGES__;
    $api_upload->storage = chevereto_config('storage');
    $api_upload->resize_width = $to_resize;
    $api_upload->thumb_width = chevereto_config('thumb_width');
    $api_upload->thumb_height = chevereto_config('thumb_height');
    $api_upload->max_size = return_bytes(chevereto_config('max_filesize'));
    /*** Do the thing? ***/
    if ($api_upload->process()) {
        $api_status_code = 200;
        $api_status_txt = 'OK';
        // Build the data array
        $api_data_array = $api_upload->image_info;
        if ($api_upload->is_remote) {
            $api_data_array['source'] = $to_upload;
        } else {
            $api_data_array['source'] = 'base64 image string';
        }
        $api_data_array['resized'] = check_value($to_resize) ? '1' : '0';
        $api_txt_output = $api_upload->image_info['image_url'];
        // Short URL generation
        if (is_config_short_url()) {
Exemplo n.º 22
0
/**
 * check_config
 * This checks the script configuration... Like upload limit, thumbs, etc. 
 */
function check_config()
{
    global $config, $install_errors;
    if (!defined('HTTP_HOST')) {
        $install_errors[] = 'Can\'t resolve <code>HTTP_HOST</code>. Please check at the bottom of <code>config.php</code>';
    }
    // Upload limit vs php.ini value -> http://php.net/manual/ini.php
    $ini_upload_bytes = return_bytes(trim(ini_get('upload_max_filesize')) . 'B');
    $max_size_bytes = return_bytes($config['max_filesize']);
    if (!is_numeric($max_size_bytes)) {
        $install_errors[] = 'Invalid numeric value in <code>$config[\'max_filesize\']</code>';
    } else {
        if ($ini_upload_bytes < $max_size_bytes) {
            $install_errors[] = 'Max. image size (' . $config['max_filesize'] . ') is greater than the value in <code>php.ini</code> (' . format_bytes($ini_upload_bytes) . ')';
        }
    }
    if (!is_int($config['thumb_width'])) {
        $install_errors[] = 'Invalid thumb size width in <code>$config[\'thumb_width\']</code>';
    }
    if (!is_int($config['thumb_height'])) {
        $install_errors[] = 'Invalid thumb size height in <code>$config[\'thumb_height\']</code>';
    }
    if (!is_int($config['min_resize_size']) || $config['min_resize_size'] < 0) {
        $install_errors[] = 'Invalid minimum resize size in <code>$config[\'min_resize_size\']</code>';
    }
    if (!is_int($config['max_resize_size']) || $config['max_resize_size'] < 0) {
        $install_errors[] = 'Invalid maximum resize size in <code>$config[\'max_resize_size\']</code>';
    }
    if (is_int($config['min_resize_size']) && is_int($config['max_resize_size']) && $config['min_resize_size'] > $config['max_resize_size']) {
        $install_errors[] = 'Minimum resize size can\'t be larger than maximum resize size. Please check <code>$config[\'min_resize_size\']</code> and <code>$config[\'max_resize_size\']</code>';
    }
    if (!conditional_config('multiupload')) {
        $config['multiupload_limit'] = 1;
    } else {
        if ($config['multiupload_limit'] <= 0 || $config['multiupload_limit'] == '') {
            $config['multiupload_limit'] = 0;
        }
    }
    if (!check_value(chevereto_config('file_naming')) || !in_array(chevereto_config('file_naming'), array('original', 'random', 'mixed'))) {
        $config['file_naming'] = 'original';
    }
    if (!is_numeric($config['multiupload_limit']) && !is_bool($config['multiupload_limit'])) {
        $install_errors[] = 'Invalid multiupload limit value in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['multiupload_limit'] > 100) {
        $install_errors[] = 'Multiupload limit value can\'t be higher than 100 in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['short_url_service'] == 'bitly') {
        $bitly_status = fetch_url('http://api.bit.ly/v3/validate?x_login='******'short_url_user'] . '&x_apiKey=' . $config['short_url_keypass'] . '&apiKey=' . $config['short_url_keypass'] . '&login='******'short_url_user'] . '&format=json');
        $bitly_json = json_decode($bitly_status);
        if ($bitly_json->data->valid !== 1) {
            $install_errors[] = 'The <a href="http://bit.ly/" target="_blank">bit.ly</a> user/api is invalid. bitly server says <code>' . $bitly_json->status_txt . '</code>. Please double check your data.';
        }
    }
    // Facebook comments
    if (use_facebook_comments() && !check_value($config['facebook_app_id'])) {
        $install_errors[] = 'You are are trying to use Facebook comments but <code>$config[\'facebook_app_id\']</code> is not setted.';
    }
    // Virtual folders
    foreach (array('virtual_folder_image', 'virtual_folder_uploaded') as $value) {
        if (!check_value($config[$value])) {
            $install_errors[] = '<code>$config[\'' . $value . '\']</code> is not setted.';
        }
    }
    // Passwords
    if ($config['user_password'] == $config['admin_password']) {
        $install_errors[] = 'Admin and user passwords must be different. Please check <code>$config[\'admin_password\']</code> and <code>$config[\'user_password\']</code>';
    }
    // Flood report email?
    if (check_value($config['flood_report_email']) && !check_email_address($config['flood_report_email'])) {
        $install_errors[] = 'It appears that <code>$config[\'flood_report_email\']</code> has a invalid email address';
    }
    // Watermark
    if (conditional_config('watermark_enable')) {
        define('__CHV_WATERMARK_FILE__', __CHV_ROOT_DIR__ . ltrim($config['watermark_image'], '/'));
        if (!is_int($config['watermark_margin'])) {
            $install_errors[] = 'Watermark margin must be integer in <code>$config[\'watermark_margin\']</code>';
        }
        if (!is_int($config['watermark_opacity'])) {
            $install_errors[] = 'Watermark opacity must be integer in <code>$config[\'watermark_opacity\']</code>';
        }
        if ($config['watermark_opacity'] > 100 or $config['watermark_opacity'] < 0) {
            $install_errors[] = 'Watermark opacity value out of limis (' . $config['watermark_opacity'] . '). <code>$config[\'watermark_opacity\']</code> must be in the range 0 to 100';
        }
        // Watermark position
        if (!check_value($config['watermark_position'])) {
            $config['watermark_position'] = 'center center';
        }
        $watermark_position = explode(' ', strtolower($config['watermark_position']));
        if (!isset($watermark_position[1])) {
            $watermark_position[1] = 'center';
        }
        if (preg_match('/^left|center|right$/', $watermark_position[0])) {
            $config['watermark_x_position'] = $watermark_position[0];
        } else {
            $install_errors[] = 'Invalid watermark horizontal position in <code>$config[\'watermark_position\']</code>';
        }
        if (preg_match('/^top|center|bottom$/', $watermark_position[1])) {
            $config['watermark_y_position'] = $watermark_position[1];
        } else {
            $install_errors[] = 'Invalid watermark vertical position in <code>$config[\'watermark_position\']</code>';
        }
        if (!file_exists(__CHV_WATERMARK_FILE__)) {
            $install_errors[] = 'Watermark image file doesn\'t exists. Please check the path in <code>$config[\'watermark_image\']</code>';
        } else {
            $watermark_image_info = get_info(__CHV_WATERMARK_FILE__);
            if ($watermark_image_info['mime'] !== 'image/png') {
                $install_errors[] = 'Watermark image file must be a PNG image in <code>$config[\'watermark_image\']</code>';
            }
        }
    }
    // Flood limits
    $flood_limits = array('minute', 'hour', 'day', 'week', 'month');
    $flood_value_error = false;
    foreach ($flood_limits as $value) {
        if (!check_value($config['max_uploads_per_' . $value]) || !is_numeric($config['max_uploads_per_' . $value])) {
            $install_errors[] = 'Invalid config value in <code>$config[\'' . $value . '\']</code>';
            $flood_value_error = true;
        }
    }
    if ($flood_value_error == false) {
        $flood_lower_than = array('minute' => array('hour', 'day', 'week', 'month'), 'hour' => array('day', 'week', 'month'), 'day' => array('week', 'month'), 'week' => array('month'));
        foreach ($flood_lower_than as $period => $lower_than) {
            foreach ($lower_than as $value) {
                if ($config['max_uploads_per_' . $period] >= $config['max_uploads_per_' . $value]) {
                    $install_errors[] = '<code>max_uploads_per_' . $period . '</code> must be lower than <code>max_uploads_per_' . $value . '</code>';
                }
            }
        }
    }
    // dB settings
    foreach (array('db_host', 'db_name', 'db_user') as $value) {
        if (!check_value($config[$value])) {
            $install_errors[] = '<code>$config[\'' . $value . '\']</code>';
        }
    }
    if (count($install_errors) == 0) {
        require_once __CHV_PATH_CLASSES__ . 'class.db.php';
        $dB = new dB();
        if ($dB->dead) {
            chevereto_die('<code>' . $dB->error . '</code>', 'Database error', array('The system has encountered a error when it try to connect to the database server.', 'Please note this error and if you need help go to <a href="http://chevereto.com/support/">Chevereto support</a>.'));
        } else {
            // Check maintenance mode
            if ($dB->get_option('maintenance') && !defined('SKIP_MAINTENANCE')) {
                $config['maintenance'] = true;
            }
        }
    }
    return count($install_errors) == 0 ? true : false;
}
			<input
				type="file"
				id="OphCoTherapyapplication_FileCollection_files"
				class="OphCoTherapyapplication_FileCollection_file"
				name="OphCoTherapyapplication_FileCollection_files[]"
			  multiple="multiple"
			  data-count-limit="<?php 
echo return_bytes(ini_get('max_file_uploads'));
?>
"
				data-max-filesize="<?php 
echo return_bytes(ini_get('upload_max_filesize'));
?>
"
				data-total-max-size="<?php 
echo return_bytes(ini_get('post_max_size'));
?>
" />
			<!--
			if non-html5 browser being used, this could be reinstated to add multiple files
			<button class="addFile classy green mini" type="button">
				<span class="button-span button-span-green">Add File</span>
			</button>
			-->
		</div>
		<div class="field-info">
			Maximum file size is <?php 
echo ini_get('upload_max_filesize');
?>
<br />
			Maximum number of files is <?php 
function check_memory($tc_count)
{
    $memory_available = return_bytes(ini_get("memory_limit"));
    // 67108864 = 64M
    if ($memory_available <= 67108864 && $tc_count > 5000) {
        // should be >= 128M
        $new_limit = "384M";
        // attempt to set the memory_limit to $new_limit to avoid problems
        if (false == ini_set("memory_limit", $new_limit)) {
            print_msg("</div><h1><center>You have {$tc_count} testcases and a memory limit of " . ini_get("memory_limit") . " <br />" . "Try increasing your memory_limit to " . "at least 128M in your php.ini</center></h1>");
            // this is pretty harsh but it has been shown to not work so its probably better than
            //blowing up in the middle of the conversion process. Remove at your own risk!
            exit(1);
        } else {
            print_msg("Increased your memory_limit to {$new_limit}");
        }
    }
}
Exemplo n.º 25
0
	$file_name = $file_name['jsonObject'];
  }
*/
$file_name = $_REQUEST['file_name'];
$filesize = '';
if (file_exists($file_name)) {
    //$fh = fopen($file_name, 'r');
    //$license_contents = fread($fh, filesize($file_name));
    //fclose($fh);
    $filesize = filesize($file_name);
}
//$GLOBALS['log']->fatal($file_name);
$response = '';
//$GLOBALS['log']->fatal('file name '.$file_name);
//$GLOBALS['log']->fatal('file size loaded '.filesize($file_name));
//if($filesize > ini_get("upload_max_filesize"))
//$GLOBALS['log']->fatal(substr(ini_get("upload_max_filesize"), 0, strlen( ini_get("upload_max_filesize")) - 1));
//get the file size defined in php.ini
//$uploadSizeIni = substr(ini_get("upload_max_filesize"), 0, strlen( ini_get("upload_max_filesize")) - 1);
//$GLOBALS['log']->fatal('Upload php setting Size '.return_bytes(ini_get("upload_max_filesize")));
if ($filesize != null) {
    if ($filesize > return_bytes(ini_get("upload_max_filesize")) || $filesize > return_bytes(ini_get("post_max_size"))) {
        $response = $filesize;
        //$response= "<script>alert('File size is bigger than the max_upload-size setting in php.ini. Upgrade attempt will fail. Increase the upload_max_size in php.ini to greater than ')</script>";
    }
}
if (!empty($response)) {
    echo $response;
}
sugar_cleanup();
exit;
Exemplo n.º 26
0
            // leaves zip file in "uploaded" state
            $sugar_config = uninstallLanguagePack();
            break;
        case 'remove':
            removeLanguagePack();
            break;
        default:
            break;
    }
}
////    END HANDLE FILE UPLOAD AND PROCESSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////    PRELOAD DISPLAY DATA
$upload_max_filesize = ini_get('upload_max_filesize');
$upload_max_filesize_bytes = return_bytes($upload_max_filesize);
$fileMaxSize = '';
if (!defined('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
    define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024);
}
if ($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
    $GLOBALS['log']->debug("detected upload_max_filesize: {$upload_max_filesize}");
    $fileMaxSize = '<p class="error">' . $mod_strings['ERR_UPLOAD_MAX_FILESIZE'] . "</p>\n";
}
$availablePatches = getLangPacks(true);
$installedLanguagePacks = getInstalledLangPacks();
$errs = '';
if (isset($validation_errors)) {
    if (count($validation_errors) > 0) {
        $errs = '<div id="errorMsgs">';
        $errs .= "<p>{$mod_strings['LBL_SYSOPTS_ERRS_TITLE']}</p>";
Exemplo n.º 27
0
						<TD align="left">
        					<textarea name="observa" id="observa" cols=70 rows=3 class=tex_area></textarea>
						</TD>
					</TR>
				</table>
				</center>
				<input type=hidden name=enviar value=enviarsi>
				<input type=hidden name=enviara value='9'>
				<input type=hidden name=carpeta value=12>
				<input type=hidden name=carpper value=10001>
				</td>
			</tr>
			<tr>
				<td colspan=5 align="center">
  					<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo return_bytes(ini_get('upload_max_filesize'));
?>
"><br>
					<span class="leidos">Seleccione un Archivo (pdf o tif   Tama&ntilde;o Max. <?php 
echo ini_get('upload_max_filesize');
?>
)<input type="file" name="upload" size="50" class=tex_area></span>
					<input type="hidden" name="replace" value="y">
					<input type="hidden" name="valRadio" value="<?php 
echo $valRadio;
?>
">
					<input name="check" type="hidden" value="y" checked>
  				</td>
  			</tr>
		</TABLE>
Exemplo n.º 28
0
 /**
  * Get max file size allowed for current user, it checks user quota, object quota, site quota and php setting
  * @param $iProfileId profile id to check quota for
  * @return quota size in bytes
  */
 public function getMaxUploadFileSize($iProfileId)
 {
     $iMin = PHP_INT_MAX;
     $aUserQuota = $this->_oDb->getUserQuota($iProfileId);
     if ($aUserQuota['max_file_size'] && $aUserQuota['max_file_size'] < $iMin) {
         $iMin = $aUserQuota['max_file_size'];
     }
     $aObjectQuota = $this->_oDb->getStorageObjectQuota();
     if ($aObjectQuota['max_file_size'] && $aObjectQuota['max_file_size'] < $iMin) {
         $iMin = $aObjectQuota['max_file_size'];
     }
     // TODO: get and check site quota
     if (!defined('BX_DOL_CRON_EXECUTE')) {
         $iUploadMaxFilesize = return_bytes(ini_get('upload_max_filesize'));
         if ($iUploadMaxFilesize && $iUploadMaxFilesize < $iMin) {
             $iMin = $iUploadMaxFilesize;
         }
     }
     return $iMin;
 }
Exemplo n.º 29
0
 /**
  * Update the index
  */
 function update()
 {
     global $conf;
     $data = array();
     if ($this->lock() == false) {
         $this->error('unable to get lock, bailing');
         exit(1);
         return;
     }
     $this->quietecho("Searching pages... ");
     if ($this->namespace) {
         $dir = $conf['datadir'] . '/' . str_replace(':', DIRECTORY_SEPARATOR, $this->namespace);
         $idPrefix = $this->namespace . ':';
     } else {
         $dir = $conf['datadir'];
         $idPrefix = '';
     }
     search($data, $dir, 'search_allpages', array('skipacl' => true));
     $this->quietecho(count($data) . " pages found.\n");
     $cnt = 0;
     $length = count($data);
     for ($i = $this->startOffset; $i < $length; $i++) {
         if ($this->index($idPrefix . $data[$i]['id'])) {
             $cnt++;
             $this->clean = false;
         }
         if ($this->exit) {
             exit;
         }
         if (memory_get_usage() > return_bytes(ini_get('memory_limit')) * 0.8) {
             // we've used up 80% memory try again.
             $this->error('Memory almost full, restarting');
             $this->restart($i + 1);
         }
         if ($this->maxRuns && $cnt >= $this->maxRuns) {
             $this->error('Max runs reached ' . $cnt . ', restarting');
             $this->restart($i + 1);
         }
     }
 }
    header("Location: installer.php?stage=" . ($stage + 1));
    exit;
} elseif (array_key_exists('moduleoperations', $session) && is_array($session['moduleoperations'])) {
    $session['stagecompleted'] = $stage;
} else {
    $session['stagecompleted'] = $stage - 1;
}
output("`@`c`bManage Modules`b`c");
output("Legend of the Green Dragon supports an extensive module system.");
output("Modules are small self-contained files that perform a specific function or event within the game.");
output("For the most part, modules are independant of each other, meaning that one module can be installed, uninstalled, activated, and deactivated without negative impact on the rest of the game.");
output("Not all modules are ideal for all sites, for example, there's a module called 'Multiple Cities,' which is intended only for large sites with many users online at the same time.");
output("`n`n`^If you are not familiar with Legend of the Green Dragon, and how the game is played, it is probably wisest to choose the default set of modules to be installed.");
output("`n`n`@There is an extensive community of users who write modules for LoGD at <a href='http://dragonprime.net/'>http://dragonprime.net/</a>.", true);
$phpram = ini_get("memory_limit");
if (return_bytes($phpram) < 12582912 && $phpram != -1 && !$session['overridememorylimit'] && !$session['dbinfo']['upgrade']) {
    // 12 MBytes
    // enter this ONLY if it's not an upgrade and if the limit is really too low
    output("`n`n`\$Warning: Your PHP memory limit is set to a very low level.");
    output("Smaller servers should not be affected by this during normal gameplay but for this installation step you should assign at least 12 Megabytes of RAM for your PHP process.");
    output("For now we will skip this step, but before installing any module, make sure to increase you memory limit.");
    output("`nYou can proceed at your own risk. Be aware that a blank screen indicates you *must* increase the memory limit.");
    output("`n`nTo override click again on \"Set Up Modules\".");
    $session['stagecompleted'] = "8";
    $session['overridememorylimit'] = true;
    $session['skipmodules'] = true;
} else {
    if (isset($session['overridememorylimit']) && $session['overridememorylimit']) {
        output("`4`n`nYou have been warned... you are now working on your own risk.`n`n");
        $session['skipmodules'] = false;
    }