function normalizeDir($dir, $stripslashes = false, $noleadslash = false) { if (!strlen($dir)) { return false; } $dir = str_replace('\\', '/', $dir); if (!$noleadslash and !preg_match('#[a-z]+://#i', $dir)) { $dir = preg_replace('|^/*(.*)|', '/$1', $dir); } $dir = SpawFm::addTrailingSlash($dir); if ($stripslashes) { return SpawVars::stripSlashes($dir); } return $dir; }
<?php require_once str_replace('\\\\', '/', dirname(__FILE__)) . '/../class/config.class.php'; require_once str_replace('\\\\', '/', dirname(__FILE__)) . '/../class/util.class.php'; // sets physical filesystem directory of web site root // if calculation fails (usually if web server is not apache) set this manually SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', str_replace("\\", "/", SpawVars::getServerVar("DOCUMENT_ROOT"))); if (!ereg('/$', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT'))) { SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT') . '/'); } // sets physical filesystem directory where spaw files reside // should work fine most of the time but if it fails set SPAW_ROOT manually by providing correct path SpawConfig::setStaticConfigItem('SPAW_ROOT', str_replace("\\", "/", realpath(dirname(__FILE__) . "/..") . '/')); // sets virtual path to the spaw directory on the server // if calculation fails set this manually SpawConfig::setStaticConfigItem('SPAW_DIR', '/' . str_replace(SpawConfig::getStaticConfigValue("DOCUMENT_ROOT"), '', SpawConfig::getStaticConfigValue("SPAW_ROOT"))); /* // semi-automatic path calculation // comment the above settings of DOCUMENT_ROOT, SPAW_ROOT and SPAW_DIR // and use this block if the above fails. // set SPAW_DIR manually. If you access demo page by http://domain.com/spaw2/demo/demo.php // then set SPAW_DIR to /spaw2/ SpawConfig::setStaticConfigItem('SPAW_DIR', '/spaw2/'); // and the following settings will be calculated automaticly SpawConfig::setStaticConfigItem('SPAW_ROOT', str_replace("\\","/",realpath(dirname(__FILE__)."/..").'/')); SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', substr(SpawConfig::getStaticConfigValue('SPAW_ROOT'),0,strlen(SpawConfig::getStaticConfigValue('SPAW_ROOT'))-strlen(SpawConfig::getStaticConfigValue('SPAW_DIR')))); */ /* // under IIS you will probably need to setup the above paths manually. it would be something like this SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', 'c:/inetpub/wwwroot/'); SpawConfig::setStaticConfigItem('SPAW_ROOT', 'c:/inetpub/wwwroot/spaw2/');
/** * Restores "secure" config items from session * @params string $scid Config id */ function restoreSecureConfig($scid) { $sec_cfg = SpawVars::getSessionVar("spaw_configs"); if ($sec_cfg != '' && is_array($sec_cfg[$scid])) { foreach ($sec_cfg[$scid] as $key => $cfg_item) { $this->setConfigItem($cfg_item->name, $cfg_item->value, $cfg_item->transfer_type); } } }
$dialog = SpawVars::getGetVar("dialog"); if (strpos($dialog, '/') || strpos($dialog, "\\")) { die("illegal dialog name"); } $lang = new SpawLang(SpawVars::getGetVar("lang")); $charset = $lang->getCharset(); if (SpawVars::getGetVar('charset') != '') { $charset = SpawVars::getGetVar('charset'); $lang->setOutputCharset($charset); } if (SpawVars::getGetVar("scid") != '' && session_id() == '') { session_start(); } $config = new SpawConfig(); $config->restoreSecureConfig(SpawVars::getGetVar("scid")); $theme = SpawTheme::getTheme(SpawVars::getGetVar("theme")); $htpl = $theme->getTemplateDialogHeader(); $htpl = str_replace('{SPAW DIALOG TITLE}', $lang->m('title', $dialog, $module), $htpl); $htpl = str_replace('{SPAW DIR}', SpawConfig::getStaticConfigValue('SPAW_DIR'), $htpl); $ftpl = $theme->getTemplateDialogFooter(); $ftpl = str_replace('{SPAW DIR}', SpawConfig::getStaticConfigValue('SPAW_DIR'), $ftpl); ob_start(); ?> <html> <head> <title><?php echo $lang->m('title', $dialog, $module); ?> </title> <meta http-equiv="content-type" content="text/html;charset=<?php
$res = @mkdir($spawfm->getCurrentFsDir() . $dir_name, $spawfm->getCurrentDirSetting('chmod_to')); } else { $res = @mkdir($spawfm->getCurrentFsDir() . $dir_name); } if (!$res) { $error_msg = $lang->m('error_create_directories_failed', 'spawfm'); } else { $onload_select = $dir_name; } } } else { $error_msg = $lang->m('error_create_directories_forbidden', 'spawfm'); } } // handle file upload if ($uplfile = SpawVars::getFilesVar('upload_file') and !empty($uplfile['size'])) { // check if upload is allowed if (!$spawfm->getCurrentDirSetting('allow_upload')) { $error_msg = $lang->m('error_upload_forbidden', 'spawfm'); } else { if (is_uploaded_file($uplfile['tmp_name'])) { // check filetype $ext = SpawFm::getFileExtension($uplfile['name']); $allowed_ext = $spawfm->getAllowedExtensions(); if (in_array('.*', $allowed_ext) or in_array($ext, $allowed_ext)) { // check filesize if (!$spawfm->getCurrentDirSetting('max_upload_filesize') or $uplfile['size'] <= $spawfm->getCurrentDirSetting('max_upload_filesize')) { $ok = true; $err = array(); /* check image dimensions: try to read image dimensions (this step is
/** * Returns constant representing user agent (browser) in SPAW terms * @returns integer * @static * @see SPAW_AGENT_UNSUPPORTED, SPAW_AGENT_IE, SPAW_AGENT_GECKO */ function getAgent() { $result = SPAW_AGENT_UNSUPPORTED; $browser = SpawVars::GetServerVar('HTTP_USER_AGENT'); //echo $browser; // check if msie if (preg_match("/MSIE[^;]*/i", $browser, $msie)) { // get version if (preg_match("/[0-9]+\\.[0-9]+/i", $msie[0], $version)) { // check version if ((double) $version[0] >= 5.5) { // finally check if it's not opera impersonating ie if (!preg_match("/opera/i", $browser)) { $result = SPAW_AGENT_IE; } } } } elseif (preg_match("/Gecko\\/([0-9]*)/", $browser, $build)) { // build date of Mozilla version 1.3 is 20030312 if ($build[1] > "20030312") { $result = SPAW_AGENT_GECKO; } } elseif (preg_match("/Opera\\/([0-9]*)/i", $browser, $opera)) { if ((double) $opera[1] >= 9) { $result = SPAW_AGENT_OPERA; } } elseif (preg_match("/Safari\\/([0-9]*)/i", $browser, $safari)) { // safari build 500 or higher (safari 3 or newer) if ((double) $safari[1] >= 500) { $result = SPAW_AGENT_SAFARI; } } return $result; }
/** * Returns constant representing user agent (browser) in SPAW terms * @returns integer * @static * @see SPAW_AGENT_UNSUPPORTED, SPAW_AGENT_IE, SPAW_AGENT_GECKO */ function getAgent() { $result = SPAW_AGENT_UNSUPPORTED; $browser = SpawVars::GetServerVar('HTTP_USER_AGENT'); // check if msie if (eregi("MSIE[^;]*", $browser, $msie)) { // get version if (eregi("[0-9]+\\.[0-9]+", $msie[0], $version)) { // check version if ((double) $version[0] >= 5.5) { // finally check if it's not opera impersonating ie if (!eregi("opera", $browser)) { $result = SPAW_AGENT_IE; } } } } elseif (ereg("Gecko/([0-9]*)", $browser, $build)) { // build date of Mozilla version 1.3 is 20030312 if ($build[1] > "20030312") { $result = SPAW_AGENT_GECKO; } } elseif (eregi("Opera/([0-9]*)", $browser, $opera)) { if ((double) $opera[1] >= 9) { $result = SPAW_AGENT_OPERA; } } return $result; }