','',''), array(' ', "\r\n",'_','_'), $sErr), $_SERVER['PHP_SELF'], $_GET['global']['path']). "Query string: ".$_SERVER['QUERY_STRING']; Logger::logItem(LOG_FILE_PATH, $text); if (1 == IS_SEND_ERRORS && Logger::filterSysEmail($text)) mail(SYS_ADMIN_MAIL, sprintf('Error occured at %s on %s (%s) ', $time, TITLE, $_SERVER['SERVER_NAME']), $text); } static function filterSysEmail($msg) { if (strpos($msg, 'Duplicate entry')) return false; return true; } } ?> 1) $str = substr($str, 0, -1); return $str; } static function String2Array($str) { return explode(',', $str); } static function UploadFile($inputFileName, $uploaddir, $file_name) { $inputFile = $_FILES[$inputFileName]; $is_ok = 'false'; $err = ''; if( isset($inputFile) && !Val::IsEmpty($inputFile['tmp_name']) ) { if(!is_dir($uploaddir)) mkdir($uploaddir); $uploadfile = $uploaddir . '/' . $file_name; if ( strlen($file_name) ) { if (@move_uploaded_file($inputFile['tmp_name'], $uploadfile)) { $is_ok = 'true'; @chmod ("$uploadfile", 0644); } else { $err = ERR_UPLOAD_IMG; switch ($inputFile['error']) { case UPLOAD_ERR_INI_SIZE: $err .= ERR_UPLOAD_ERR_INI_SIZE; break; case UPLOAD_ERR_FORM_SIZE: $err .= ERR_UPLOAD_ERR_FORM_SIZE; break; case UPLOAD_ERR_PARTIAL: $err .= ERR_UPLOAD_ERR_PARTIAL; break; case UPLOAD_ERR_NO_FILE: $err .= ERR_UPLOAD_ERR_NO_FILE; break; } if (trim($err) != '') return $err; /*{ echo UI::GetBlockError($err); return false; }*/ } } } return $err; } static function getFileSize($fileName, $autodetect = false, $range = 0, $round = null) { $round = (null === $round) ? 3 : $round; if (!file_exists($fileName)) return '0 байт'; $size = filesize($fileName); //$sizes = array('b', 'Kb', 'Mb', 'Gb'); if ($autodetect) { if($size < pow(1024, 1)) return $size." байт"; elseif($size < pow(1024, 2)) return round($size/pow(1024, 1), $round)." КБ"; elseif($size < pow(1024, 3)) return round($size/pow(1024, 2), $round)." МБ"; elseif($size < pow(1024, 4)) return round($size/pow(1024, 3), $round)." ГБ"; } else { if($range == 'b') return $size." байт"; elseif($range == 'Kb') return round($size/pow(1024, 1), $round)." КБ"; elseif($range == 'Mb') return round($size/pow(1024, 2), $round)." МБ"; elseif($range == 'Gb') return round($size/pow(1024, 3), $round)." ГБ"; } } static function getNonExistentFilename($path) { if (!file_exists($path)) return $path; $ext = pathinfo($path, PATHINFO_EXTENSION); $i = 1; while(true == file_exists(str_replace('.'.$ext, '', $path).'_'.$i.'.'.$ext)) { $i++; } return str_replace('.'.$ext, '', $path).'_'.$i.'.'.$ext; } static function translit($s, $params = array()) { $map = array( 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'e', 'ж' => 'g', 'з' => 'z', 'и' => 'i', 'й' => 'i', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'y', 'ф' => 'f', 'х' => 'h', 'ц' => 'ts', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sh', 'ь' => '', 'ы' => 'i', 'ъ' => '', 'э' => 'e', 'ю' => 'u', 'я' => 'ia', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'E', 'Ж' => 'G', 'З' => 'Z', 'И' => 'I', 'Й' => 'I', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'Y', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'Ts', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sh', 'Ь' => '', 'Ы' => 'I', 'Ъ' => '', 'Э' => 'E', 'Ю' => 'U', 'Я' => 'Ia', ); $s = str_replace(array_keys($map), array_values($map), $s); if(isset($params['tolower']) && $params['tolower'] == true) $s = strtolower($s); if(isset($params['symbols'])) { $s = preg_replace('/[^a-z0-9A-Z'.$params['symbols'].']/', '_', $s); $s = preg_replace('/_{2,}/','_', $s); $s = trim($s, '_'); } return $s; } } ?>