| 1 |
<?php |
| 2 |
|
| 3 |
class RabbitLoader_21_Util_Core |
| 4 |
{ |
| 5 |
public static function get_param($name, $allowCase = false) |
| 6 |
{ |
| 7 |
$val = ''; |
| 8 |
if (isset($_GET[$name])) { |
| 9 |
$val = $_GET[$name]; |
| 10 |
} else if (isset($_POST[$name])) { |
| 11 |
$val = $_POST[$name]; |
| 12 |
} |
| 13 |
|
| 14 |
if (!empty($val)) { |
| 15 |
if ($allowCase) { |
| 16 |
$val = preg_replace('/[^A-Za-z0-9_\-.]/', '', $val); |
| 17 |
} else { |
| 18 |
$val = sanitize_key($val); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
return $val; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Same as file_put_contents with debug mode wrapper |
| 27 |
*/ |
| 28 |
public static function fpc($fp, &$data, $debug) |
| 29 |
{ |
| 30 |
$cache_dir = RL21UtilWP::get_cache_dir(''); |
| 31 |
if (!file_exists($cache_dir)) { |
| 32 |
@mkdir($cache_dir, 0755, true); |
| 33 |
} |
| 34 |
if ($debug) { |
| 35 |
$file_updated = file_put_contents($fp, $data, LOCK_EX); |
| 36 |
} else { |
| 37 |
$file_updated = @file_put_contents($fp, $data, LOCK_EX); |
| 38 |
} |
| 39 |
return $file_updated; |
| 40 |
} |
| 41 |
|
| 42 |
public static function get_request_type() |
| 43 |
{ |
| 44 |
return empty($_SERVER['REQUEST_METHOD']) ? '' : strtolower($_SERVER['REQUEST_METHOD']); |
| 45 |
} |
| 46 |
|
| 47 |
public static function isDev() |
| 48 |
{ |
| 49 |
return ((defined('RABBITLOADER_PLUG_ENV') && RABBITLOADER_PLUG_ENV == 'DEV') || (defined('RABBITLOADER_AC_PLUG_ENV') && RABBITLOADER_AC_PLUG_ENV == 'DEV')); |
| 50 |
} |
| 51 |
|
| 52 |
public static function serverURINoGet() |
| 53 |
{ |
| 54 |
return strtok($_SERVER["REQUEST_URI"], '?'); |
| 55 |
} |
| 56 |
|
| 57 |
public static function isRLPage() |
| 58 |
{ |
| 59 |
return self::get_param('page') === 'rabbitloader'; |
| 60 |
} |
| 61 |
} |
| 62 |
|