ZsgsDesign /
NOJ
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||||
| 2 | |||||
| 3 | use Illuminate\Support\Str; |
||||
| 4 | use Illuminate\Support\Carbon; |
||||
| 5 | use Illuminate\Support\Facades\DB; |
||||
| 6 | use GrahamCampbell\Markdown\Facades\Markdown; |
||||
| 7 | use App\Models\Eloquent\Message; |
||||
| 8 | use App\Models\Eloquent\Tool\Theme; |
||||
| 9 | use App\Models\Eloquent\Tool\AppSettings; |
||||
| 10 | |||||
| 11 | if (!function_exists('version')) { |
||||
| 12 | function version() |
||||
| 13 | { |
||||
| 14 | $version=new Version( |
||||
| 15 | '0.0.0', |
||||
| 16 | base_path() |
||||
| 17 | ); |
||||
| 18 | return $version->getVersion(); |
||||
| 19 | } |
||||
| 20 | } |
||||
| 21 | |||||
| 22 | if (!function_exists('getCustomUrl')) { |
||||
| 23 | function getCustomUrl() |
||||
| 24 | { |
||||
| 25 | $customUrlCached=Cache::tags(['custom'])->get('url'); |
||||
| 26 | |||||
| 27 | if ($customUrlCached==null) { |
||||
| 28 | $urls=DB::table("custom_url")->where(["available"=>1])->get()->all(); |
||||
| 29 | Cache::tags(['custom'])->put('url', $urls, 1200); |
||||
| 30 | return $urls; |
||||
| 31 | } |
||||
| 32 | |||||
| 33 | return $customUrlCached; |
||||
| 34 | } |
||||
| 35 | } |
||||
| 36 | |||||
| 37 | if (!function_exists('emailVerified')) { |
||||
| 38 | function emailVerified() |
||||
| 39 | { |
||||
| 40 | if (Auth::guard('web')->check()) { |
||||
| 41 | return !is_null(Auth::guard('web')->user()->email_verified_at); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 42 | } |
||||
| 43 | |||||
| 44 | return null; |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 | |||||
| 48 | if (!function_exists('babel_path')) { |
||||
| 49 | /** |
||||
| 50 | * Get the path to the application folder. |
||||
| 51 | * |
||||
| 52 | * @param string $path |
||||
| 53 | * @return string |
||||
| 54 | */ |
||||
| 55 | function babel_path($path='') |
||||
| 56 | { |
||||
| 57 | return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
||||
|
0 ignored issues
–
show
Are you sure
app('path') of type Illuminate\Contracts\Foundation\Application|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 58 | } |
||||
| 59 | } |
||||
| 60 | |||||
| 61 | if (!function_exists('glob_recursive')) { |
||||
| 62 | /** |
||||
| 63 | * Find pathnames matching a pattern recursively. |
||||
| 64 | * |
||||
| 65 | * @param string $pattern The pattern. No tilde expansion or parameter substitution is done. |
||||
| 66 | * @param int $flags Valid flags: GLOB_MARK |
||||
| 67 | * @return array|false an array containing the matched files/directories, an empty array if no file matched or false on error. |
||||
| 68 | */ |
||||
| 69 | function glob_recursive($pattern, $flags=0) |
||||
| 70 | { |
||||
| 71 | $files=glob($pattern, $flags); |
||||
| 72 | foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
||||
| 73 | $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
||||
| 74 | } |
||||
| 75 | return $files; |
||||
| 76 | } |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | if (!function_exists('adminMenu')) { |
||||
| 80 | function adminMenu() |
||||
| 81 | { |
||||
| 82 | return json_decode(file_get_contents(app_path('Admin/menu.json')), true); |
||||
| 83 | } |
||||
| 84 | } |
||||
| 85 | |||||
| 86 | if (!function_exists('getOpenSearchXML')) { |
||||
| 87 | function getOpenSearchXML() |
||||
| 88 | { |
||||
| 89 | $url=config("app.url"); |
||||
| 90 | |||||
| 91 | return '<?xml version="1.0" encoding="UTF-8"?> |
||||
| 92 | <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> |
||||
| 93 | <ShortName>'.config('app.name').'</ShortName> |
||||
| 94 | <Description>Gracefully Searching '.config('app.displayName').' Problems and others.</Description> |
||||
| 95 | <InputEncoding>UTF-8</InputEncoding> |
||||
| 96 | <Image width="16" height="16" type="image/x-icon">'.$url.'/favicon.ico</Image> |
||||
| 97 | <Url type="text/html" method="get" template="'.$url.'/search/?q={searchTerms}&tab=problems&opensearch=1" /> |
||||
| 98 | <moz:SearchForm>'.$url.'/search</moz:SearchForm> |
||||
| 99 | </OpenSearchDescription>'; |
||||
| 100 | } |
||||
| 101 | } |
||||
| 102 | |||||
| 103 | if (!function_exists('delFile')) { |
||||
| 104 | function delFile($dirName) |
||||
| 105 | { |
||||
| 106 | if (file_exists($dirName) && $handle=opendir($dirName)) { |
||||
| 107 | while (false!==($item=readdir($handle))) { |
||||
| 108 | if ($item!="." && $item!="..") { |
||||
| 109 | if (file_exists($dirName.'/'.$item) && is_dir($dirName.'/'.$item)) { |
||||
| 110 | delFile($dirName.'/'.$item); |
||||
| 111 | } else { |
||||
| 112 | if (unlink($dirName.'/'.$item)) { |
||||
| 113 | return true; |
||||
| 114 | } |
||||
| 115 | } |
||||
| 116 | } |
||||
| 117 | } |
||||
| 118 | closedir($handle); |
||||
| 119 | } |
||||
| 120 | } |
||||
| 121 | } |
||||
| 122 | |||||
| 123 | if (!function_exists('convertMarkdownToHtml')) { |
||||
| 124 | function convertMarkdownToHtml($md) |
||||
| 125 | { |
||||
| 126 | return is_string($md) ?Markdown::convertToHtml($md) : ''; |
||||
| 127 | } |
||||
| 128 | } |
||||
| 129 | |||||
| 130 | if (!function_exists('sendMessage')) { |
||||
| 131 | function sendMessage($config) |
||||
| 132 | { |
||||
| 133 | return Message::send($config); |
||||
| 134 | } |
||||
| 135 | } |
||||
| 136 | |||||
| 137 | if (!function_exists('formatHumanReadableTime')) { |
||||
| 138 | function formatHumanReadableTime($date) |
||||
| 139 | { |
||||
| 140 | $periods=["second", "minute", "hour", "day", "week", "month", "year", "decade"]; |
||||
| 141 | $lengths=["60", "60", "24", "7", "4.35", "12", "10"]; |
||||
| 142 | |||||
| 143 | $now=time(); |
||||
| 144 | $unix_date=strtotime($date); |
||||
| 145 | |||||
| 146 | if (empty($unix_date)) { |
||||
| 147 | return __("helper.time.malformatter"); |
||||
| 148 | } |
||||
| 149 | |||||
| 150 | if ($now>$unix_date) { |
||||
| 151 | $difference=$now-$unix_date; |
||||
| 152 | $tense=__("helper.time.after"); |
||||
| 153 | } else { |
||||
| 154 | $difference=$unix_date-$now; |
||||
| 155 | $tense=__("helper.time.before"); |
||||
| 156 | } |
||||
| 157 | |||||
| 158 | for ($j=0; $difference>=$lengths[$j] && $j<count($lengths)-1; $j++) { |
||||
| 159 | $difference/=$lengths[$j]; |
||||
| 160 | } |
||||
| 161 | |||||
| 162 | $difference=round($difference); |
||||
| 163 | |||||
| 164 | if ($difference!=1) { |
||||
| 165 | $periods[$j]=__("helper.time.plural.$periods[$j]"); |
||||
| 166 | } else { |
||||
| 167 | $periods[$j]=__("helper.time.singular.$periods[$j]"); |
||||
| 168 | } |
||||
| 169 | |||||
| 170 | return __("helper.time.formatter", [ |
||||
| 171 | "time" => $difference, |
||||
| 172 | "unit" => $periods[$j], |
||||
| 173 | "tense" => $tense, |
||||
| 174 | ]); |
||||
| 175 | } |
||||
| 176 | } |
||||
| 177 | |||||
| 178 | if (!function_exists('formatProblemSolvedTime')) { |
||||
| 179 | function formatProblemSolvedTime($seconds) |
||||
| 180 | { |
||||
| 181 | if ($seconds>3600) { |
||||
| 182 | $hours=intval($seconds / 3600); |
||||
| 183 | $minutes=$seconds % 3600; |
||||
| 184 | $time=$hours.":".gmstrftime('%M:%S', $minutes); |
||||
| 185 | } else { |
||||
| 186 | $time=gmstrftime('%H:%M:%S', $seconds); |
||||
| 187 | } |
||||
| 188 | return $time; |
||||
| 189 | } |
||||
| 190 | } |
||||
| 191 | |||||
| 192 | if (!function_exists('vscodeLocale')) { |
||||
| 193 | function vscodeLocale() |
||||
| 194 | { |
||||
| 195 | $locale=Str::lower(App::getLocale()); |
||||
| 196 | $vscodelocale=''; |
||||
| 197 | if (in_array($locale, ['de', 'es', 'fr', 'it', 'ja', 'ko', 'ru', 'zh-cn', 'zh-tw'])) { |
||||
| 198 | $vscodelocale=$locale; |
||||
| 199 | } |
||||
| 200 | return $vscodelocale; |
||||
| 201 | } |
||||
| 202 | } |
||||
| 203 | |||||
| 204 | if (!function_exists('getTheme')) { |
||||
| 205 | function getTheme($id=null) |
||||
| 206 | { |
||||
| 207 | if (is_null($id)) { |
||||
| 208 | $id=config('app.theme'); |
||||
| 209 | } |
||||
| 210 | return Theme::getTheme($id); |
||||
| 211 | } |
||||
| 212 | } |
||||
| 213 | |||||
| 214 | if (!function_exists('setting')) { |
||||
| 215 | function setting($identifier, $default=null) |
||||
| 216 | { |
||||
| 217 | if (is_array($identifier)) { |
||||
| 218 | foreach ($identifier as $key=>$content) { |
||||
| 219 | AppSettings::set($key, $content); |
||||
| 220 | } |
||||
| 221 | return true; |
||||
| 222 | } |
||||
| 223 | return AppSettings::get($identifier, $default); |
||||
| 224 | } |
||||
| 225 | } |
||||
| 226 |