public function main() { $regedit = regedit::getInstance(); $config = mainConfiguration::getInstance(); include_once 'timezones.php'; $timezones['value'] = $config->get("system", "time-zone"); $params = array("globals" => array("string:keycode" => NULL, "boolean:chache_browser" => NULL, "boolean:disable_url_autocorrection" => NULL, "boolean:disable_captcha" => NULL, "int:max_img_filesize" => NULL, "status:upload_max_filesize" => NULL, "boolean:allow-alt-name-with-module-collision" => NULL, "boolean:allow-redirects-watch" => NULL, "int:session_lifetime" => NULL, "status:busy_quota_files_and_images" => NULL, "int:quota_files_and_images" => NULL, "boolean:search_morph_disabled" => NULL, "boolean:disable_too_many_childs_notification" => NULL, 'select:timezones' => NULL)); $upload_max_filesize = cmsController::getInstance()->getModule('data')->getAllowedMaxFileSize(); $mode = getRequest("param0"); if ($mode == "do") { $params = $this->expectParams($params); $regedit->setVar("//settings/chache_browser", $params['globals']['boolean:chache_browser']); $regedit->setVar("//settings/keycode", $params['globals']['string:keycode']); $regedit->setVar("//settings/disable_url_autocorrection", $params['globals']['boolean:disable_url_autocorrection']); $config->set('anti-spam', 'captcha.enabled', !$params['globals']['boolean:disable_captcha']); $maxImgFilesize = $params['globals']['int:max_img_filesize']; if ($maxImgFilesize <= 0 || $maxImgFilesize > $upload_max_filesize) { $maxImgFilesize = $upload_max_filesize; } $regedit->setVar("//settings/max_img_filesize", $maxImgFilesize); $config->set('kernel', 'ignore-module-names-overwrite', $params['globals']['boolean:allow-alt-name-with-module-collision']); $config->set('seo', 'watch-redirects-history', $params['globals']['boolean:allow-redirects-watch']); $config->set("system", "session-lifetime", $params['globals']['int:session_lifetime']); $quota = (int) $params['globals']['int:quota_files_and_images']; if ($quota < 0) { $quota = 0; } $config->set("system", "quota-files-and-images", $quota * 1024 * 1024); $config->set("system", "search-morph-disabled", $params['globals']['boolean:search_morph_disabled']); $config->set("system", "disable-too-many-childs-notification", $params['globals']['boolean:disable_too_many_childs_notification']); $config->set("system", "time-zone", $params['globals']['select:timezones']); $this->chooseRedirect(); } $params['globals']['boolean:chache_browser'] = $regedit->getVal("//settings/chache_browser"); $params['globals']['string:keycode'] = $regedit->getVal("//settings/keycode"); $params['globals']['boolean:disable_url_autocorrection'] = $regedit->getVal("//settings/disable_url_autocorrection"); $params['globals']['boolean:disable_captcha'] = !$config->get('anti-spam', 'captcha.enabled'); $params['globals']['status:upload_max_filesize'] = $upload_max_filesize; $max_img_filesize = $regedit->getVal("//settings/max_img_filesize"); $params['globals']['int:max_img_filesize'] = $max_img_filesize ? $max_img_filesize : $upload_max_filesize; $params['globals']['boolean:allow-alt-name-with-module-collision'] = $config->get('kernel', 'ignore-module-names-overwrite'); $params['globals']['boolean:allow-redirects-watch'] = $config->get('seo', 'watch-redirects-history'); $params['globals']['status:busy_quota_files_and_images'] = ceil(getBusyDiskSize() / (1024 * 1024)); $params['globals']['int:quota_files_and_images'] = (int) (getBytesFromString($config->get('system', 'quota-files-and-images')) / (1024 * 1024)); $params['globals']['int:session_lifetime'] = $config->get('system', 'session-lifetime'); $params['globals']['boolean:search_morph_disabled'] = $config->get('system', 'search-morph-disabled'); $params['globals']['boolean:disable_too_many_childs_notification'] = $config->get('system', 'disable-too-many-childs-notification'); $params['globals']['select:timezones'] = $timezones; $this->setDataType("settings"); $this->setActionType("modify"); if (is_demo()) { unset($params["globals"]['string:keycode']); } $data = $this->prepareData($params, "settings"); $this->setData($data); return $this->doData(); }
function check_autothumbs_bytes($dirs) { $max_size = getBytesFromString(mainConfiguration::getInstance()->get("system", "quota-files-and-images")); if ($max_size != 0) { $busy_size = 0; foreach ($dirs as $dir) { $busy_size += getDirSize($dir); } if ($busy_size >= $max_size) { header('Status: 404 Not Found', true, 404); header('HTTP/1.0 404 Not Found', true, 404); exit; } } }
protected function saveIncomingFile() { $file_name = getRequest('filename'); $buffer = outputBuffer::current('HTTPOutputBuffer'); $content = $buffer->getHTTPRequestBody(); if (!strlen($file_name)) { return "failure\nEmpty filename."; } list($dir_name, , $extension) = array_values(getPathInfo($file_name)); if (!strlen($extension) || !umiFile::isAllowedFileType($extension)) { return "failure\nUnknown file type."; } if (!isset($_SESSION['1c_latest_catalog-file'])) { $_SESSION['1c_latest_catalog-file'] = ""; } $i_flag = $_SESSION['1c_latest_catalog-file'] == $file_name ? FILE_APPEND : 0; $base_name = substr($file_name, 0, strlen($file_name) - strlen($extension) - 1); $temp_dir = self::$importDirectory; if (!is_dir($temp_dir)) { mkdir($temp_dir, 0777, true); } if (strtolower($extension) == "xml") { file_put_contents($temp_dir . $base_name . "." . $extension, $content, $i_flag); } else { $quota_byte = getBytesFromString(mainConfiguration::getInstance()->get('system', 'quota-files-and-images')); if ($quota_byte != 0) { $all_size = getBusyDiskSize(array('/files', '/images')); if ($all_size + strlen($content) >= $quota_byte) { return "failure\n max dirsize in /files and /images summary."; } } $images_dir = "./images/cms/data/" . $dir_name . "/"; if (!is_dir($images_dir)) { mkdir($images_dir, 0777, true); } file_put_contents("./images/cms/data/" . $file_name, $content, $i_flag); if (realpath("./images/cms/data/" . $file_name) != CURRENT_WORKING_DIR . "/images/cms/data/" . $file_name) { unlink("./images/cms/data/" . $file_name); return "failure\nWrong file path."; } } $_SESSION['1c_latest_catalog-file'] = $file_name; return "success"; }
public function uploadfile() { $this->flushAsXml('uploadfile'); $this->setupCwd(); $quota_byte = getBytesFromString(mainConfiguration::getInstance()->get('system', 'quota-files-and-images')); if ($quota_byte != 0) { $all_size = getBusyDiskSize(array('/files', '/images')); if ($all_size >= $quota_byte) { return array('attribute:folder' => substr($this->cwd, strlen(CURRENT_WORKING_DIR)), 'attribute:upload' => 'error', 'nodes:error' => array('Ошибка: превышено ограничение на размер дискового пространства')); } } if (is_demo()) { return array('attribute:folder' => substr($this->cwd, strlen(CURRENT_WORKING_DIR)), 'attribute:upload' => 'done'); } if (isset($_FILES['Filedata']['name'])) { foreach ($_FILES['Filedata'] as $k => $v) { $_FILES['Filedata'][$k] = array('upload' => $v); } $file = umiFile::upload('Filedata', 'upload', $this->cwd); } elseif (isset($_REQUEST['filename'])) { $file = umiFile::upload(false, false, $this->cwd); } $cwd = substr($this->cwd, strlen(CURRENT_WORKING_DIR)); $result = array('attribute:folder' => $cwd, 'attribute:upload' => 'done'); if ($file) { $item = $this->cwd . "/" . $file->getFileName(); // Collect some file info $imageExt = array("jpg", "jpeg", "gif", "png"); $sizeMeasure = array("b", "Kb", "Mb", "Gb", "Tb"); $name = $file->getFileName(); $type = strtolower($file->getExt()); $ts = $file->getModifyTime(); $time = date('g:i, d.m.Y', $ts); $size = $file->getSize(); $path = $file->getFilePath(true); if (isset($_REQUEST['imagesOnly']) && !in_array($type, $imageExt)) { unlink($item); return $result; } $file = array('attribute:name' => $name, 'attribute:type' => $type, 'attribute:size' => $size, 'attribute:ctime' => $time, 'attribute:timestamp' => $ts, 'attribute:path' => $path); $i = 0; while ($size > 1024.0) { $size /= 1024; $i++; } $convertedSize = (int) round($size); if ($convertedSize == 1 && (int) floor($size) != $convertedSize) { $i++; } $file['attribute:converted-size'] = $convertedSize . $sizeMeasure[$i]; if (in_array($type, $imageExt)) { if ($info = @getimagesize($item)) { umiImageFile::addWatermark("." . $cwd . "/" . $name); $file['attribute:mime'] = $info['mime']; $file['attribute:width'] = $info[0]; $file['attribute:height'] = $info[1]; } else { unlink($item); return $result; } } else { //$file['attribute:mime'] = mime_content_type($item); } $result["file"] = $file; } return $result; }
public function save($v0666f0acdeed38d4cd9084ade1739498, $v28e3d688a3c077b887921cea3fb1dbc7, $vb068931cc450442b63f5b3d276ea4297, $vdfff0a7fa1a55c8c1a4966c19f6da452 = 'upload') { if (($v736007832d2167baaae763fd3a3f3cf1 = $this->dir($v28e3d688a3c077b887921cea3fb1dbc7, true, true)) == false) { return $this->setError(elFinder::ERROR_TRGDIR_NOT_FOUND, '#' . $v28e3d688a3c077b887921cea3fb1dbc7); } if (!$v736007832d2167baaae763fd3a3f3cf1['write']) { return $this->setError(elFinder::ERROR_PERM_DENIED); } if (!$this->nameAccepted($vb068931cc450442b63f5b3d276ea4297)) { return $this->setError(elFinder::ERROR_INVALID_NAME, $vb068931cc450442b63f5b3d276ea4297); } $v28e3d688a3c077b887921cea3fb1dbc7 = $this->decode($v28e3d688a3c077b887921cea3fb1dbc7); if (strpos($v28e3d688a3c077b887921cea3fb1dbc7, CURRENT_WORKING_DIR . '/files/') !== false || strpos($v28e3d688a3c077b887921cea3fb1dbc7, CURRENT_WORKING_DIR . '/images/') !== false) { $v7079797cf8751efb52c390933238e7a8 = getBytesFromString(mainConfiguration::getInstance()->get('system', 'quota-files-and-images')); if ($v7079797cf8751efb52c390933238e7a8 != 0) { $v27fe800121fd9e812c6905f3bc8937dd = getBusyDiskSize(array('/images', '/files')); if ($v27fe800121fd9e812c6905f3bc8937dd >= $v7079797cf8751efb52c390933238e7a8) { return $this->setError(getLabel('error-files_quota_exceeded')); } } } $vc981ba9b125236385735528b5817ebf5 = method_exists($this, "_doSave_{$vdfff0a7fa1a55c8c1a4966c19f6da452}") ? "_doSave_{$vdfff0a7fa1a55c8c1a4966c19f6da452}" : "_doSave_unknown"; $vd6fe1d0be6347b8ef2427fa629c04485 = $this->{$vc981ba9b125236385735528b5817ebf5}($v0666f0acdeed38d4cd9084ade1739498, $v28e3d688a3c077b887921cea3fb1dbc7, $vb068931cc450442b63f5b3d276ea4297); $result = false; if ($vd6fe1d0be6347b8ef2427fa629c04485) { $result = $this->stat($vd6fe1d0be6347b8ef2427fa629c04485); } return $result; }
function checkAllowedDiskSize($v4b3a6218bb3e3a7303e8a171a60fcf92 = false, $v33030abc929f083da5f6c3f755b46034 = array('/images', '/files')) { if ($v4b3a6218bb3e3a7303e8a171a60fcf92 == false) { return false; } $v4290bf7e707d9552c735e5bcc4a8edb3 = mainConfiguration::getInstance()->get('system', 'quota-files-and-images'); if ($v4290bf7e707d9552c735e5bcc4a8edb3 == 0) { return true; } $v4290bf7e707d9552c735e5bcc4a8edb3 = getBytesFromString($v4290bf7e707d9552c735e5bcc4a8edb3); $v1105d5ffdd5622b43f4a0b16afb0e886 = getBusyDiskSize($v33030abc929f083da5f6c3f755b46034); return $v4290bf7e707d9552c735e5bcc4a8edb3 >= $v1105d5ffdd5622b43f4a0b16afb0e886 + $v4b3a6218bb3e3a7303e8a171a60fcf92; }
public function post() { if (defined('CURRENT_VERSION_LINE') && CURRENT_VERSION_LINE == 'demo') { $url = getRequest('ref_onsuccess'); if (!$url) { $url = $this->pre_lang . "/webforms/posted/"; } $this->redirect($url); } global $_FILES; $iOldErrorReportingLevel = error_reporting(~E_ALL & ~E_STRICT); $res = ""; $email_to = getRequest('email_to'); $message = getRequest('message'); $data = getRequest('data'); $domain = getRequest('domain'); $subject = cmsController::getInstance()->getCurrentDomain()->getHost(); $referer_url = $_SERVER['HTTP_REFERER']; $this->errorRegisterFailPage($referer_url); // check captcha if (isset($_REQUEST['captcha'])) { $_SESSION['user_captcha'] = md5((int) $_REQUEST['captcha']); } if (!umiCaptcha::checkCaptcha()) { $this->errorNewMessage("%errors_wrong_captcha%"); $this->errorPanic(); } $sRecipientName = "administrator"; if (is_numeric($email_to)) { $to = $this->guessAddressValue($email_to); if (intval($to) != $email_to) { $sRecipientName = $this->guessAddressName($email_to); } else { $oTCollection = umiObjectTypesCollection::getInstance(); $iTypeId = $oTCollection->getBaseType('webforms', 'address'); $oType = $oTCollection->getType($iTypeId); $iFieldId = $oType->getFieldId('insert_id'); $oSelection = new umiSelection(); $oSelection->addObjectType($iTypeId); $oSelection->addPropertyFilterEqual($iFieldId, $email_to); $aIDs = umiSelectionsParser::runSelection($oSelection); if (count($aIDs)) { $oObject = umiObjectsCollection::getInstance()->getObject($aIDs[0]); $to = $oObject->getValue('address_list'); $sRecipientName = $oObject->getValue('address_description'); } else { if (!defined("DB_DRIVER") || DB_DRIVER != "xml") { $sql = "SELECT email, descr FROM cms_webforms WHERE id={$email_to}"; $result = l_mysql_query($sql); list($to, $sRecipientName) = mysql_fetch_row($result); } else { $this->redirect($this->pre_lang . "/webforms/posted/?template=error_no_recipient"); } } } } else { $this->checkAddressExistence($email_to); $to = $email_to; } if (!$data['email_from'] && isset($data['email'])) { $data['email_from'] = $data['email']; } $someMail = new umiMail(); $arrMails = explode(",", $to); $arrMails = array_map("trim", $arrMails); foreach ($arrMails as $sEmail) { $someMail->addRecipient($sEmail, $sRecipientName); } $from = $data['fname'] . " " . $data['lname']; $someMail->setFrom($data['email_from'], $from); $mess = ""; if (is_array($data)) { if (isset($data['subject'])) { $subject = $data['subject']; } if (isset($data['fio'])) { $from = $data['fio']; } if ($data['fname'] || $data['lname'] || $data['mname']) { $from = $data['lname'] . " " . $data['fname'] . " " . $data['mname']; } if ($data['fio_frm']) { $from = $data['fio_frm']; } if ($email_from = $data['email_from']) { $email_from = $data['email_from']; } $mess = <<<END <table border="0" width="100%"> END; if (is_array($_FILES['data']['name'])) { $data = array_merge($data, $_FILES['data']['name']); } $uploadDir = CURRENT_WORKING_DIR . "/sys-temp/uploads"; if (!is_dir($uploadDir)) { mkdir($uploadDir); } $max_size = getBytesFromString(mainConfiguration::getInstance()->get('system', 'quota-files-and-images')); if ($max_size != 0) { $summary_size = getBusyDiskSize(array('/images', '/files', '/sys-temp/uploads')); } foreach ($data as $field => $cont) { if ($filename = $_FILES['data']['name'][$field]) { if ($max_size == 0 || $summary_size + $_FILES['data']['size'][$field] <= $max_size) { $file = umiFile::upload('data', $field, $uploadDir); if (!$file) { $this->errorNewMessage("%errors_wrong_file_type%"); $this->errorPanic(); } $someMail->attachFile($file); $summary_size += $_FILES['data']['size'][$field]; } else { $cont = def_module::parseTPLMacroses("%not_enough_space_for_load_file%"); } } if (!is_array($cont)) { $cont = str_replace("%", "%", $cont); } if (!$cont) { $cont = "—"; } if (is_array($cont)) { foreach ($cont as $i => $v) { $cont[$i] = str_replace("%", "%", $v); } $cont = implode(", ", $cont); } $label = $_REQUEST['labels'][$field] ? $_REQUEST['labels'][$field] : "%" . $field . "%"; $mess .= <<<END \t<tr> \t\t<td width="30%"> \t\t\t{$label}: \t\t</td> \t\t<td> \t\t\t{$cont} \t\t</td> \t</tr> END; } $mess .= <<<END </table> <hr /> END; } if ($from) { $user_fio_from = $from; } $message = str_replace("%", "%", $message); $mess .= nl2br($message); if (!$from) { $from = regedit::getInstance()->getVal("//settings/fio_from"); } if (!$from_email) { $from_email = regedit::getInstance()->getVal("//settings/email_from"); } $from = $from . "<" . $from_email . ">"; $someMail->setSubject($subject); $someMail->setContent($mess); $someMail->commit(); $someMail->send(); if ($template = (string) $_REQUEST['template']) { //Sending auto-reply list($template_mail, $template_mail_subject) = def_module::loadTemplatesForMail("webforms/" . $template, "webforms_reply_mail", "webforms_reply_mail_subject"); $template_mail = def_module::parseTemplateForMail($template_mail, $arr); $template_mail_subject = def_module::parseTemplateForMail($template_mail, $arr); $check_param = false; if (!is_array($template_mail)) { if ((bool) strlen($template_mail)) { $check_param = true; } } if ($check_param) { $email_from = regedit::getInstance()->getVal("//settings/email_from"); $fio_from = regedit::getInstance()->getVal("//settings/fio_from"); $replyMail = new umiMail(); $replyMail->addRecipient($data['email_from'], $from); $replyMail->setFrom($email_from, $fio_from); $replyMail->setSubject($template_mail_subject); $replyMail->setContent($template_mail); $replyMail->commit(); $replyMail->send(); } } $oEventPoint = new umiEventPoint("webforms_post"); $oEventPoint->setMode("after"); $oEventPoint->setParam("email", $data['email_from']); $oEventPoint->setParam("fio", $user_fio_from); $this->setEventPoint($oEventPoint); $url = getRequest('ref_onsuccess'); if (!$url) { $url = $this->pre_lang . "/webforms/posted/"; } if ($template) { $url .= (strpos($url, '?') === false ? '?' : '&') . "template=" . $template; } error_reporting($iOldErrorReportingLevel); $this->redirect($url); }