Example #1
0
 public function testNumbersOnly1()
 {
     $this->assertEquals(numbers_only('123'), true);
     $this->assertEquals(numbers_only('0'), true);
     $this->assertEquals(numbers_only('12a'), false);
     $this->assertEquals(numbers_only('12.0'), false);
     $this->assertEquals(numbers_only(''), false);
 }
Example #2
0
             $keyword_sql .= "pro_addr1 LIKE '%{$keyword}%' OR pro_addr2 LIKE '%{$keyword}%' OR pro_addr3 LIKE '%{$keyword}%' OR ";
             $keyword_sql .= "pro_addr4 LIKE '%{$keyword}%' OR pro_addr5 LIKE '%{$keyword}%' OR pro_postcode LIKE '%{$keyword}%' OR ";
             $keyword_sql .= "dea_keywords LIKE '%{$keyword}%' OR dea_strapline LIKE '%{$keyword}%' OR are_title LIKE '%{$keyword}%' OR ";
             $keyword_sql .= "cli_fname LIKE '%{$keyword}%' OR cli_sname LIKE '%{$keyword}%' OR concat_ws(' ',cli_fname, cli_sname)  LIKE '%{$keyword}%' OR ";
         }
     }
     $keyword_sql = "(" . remove_lastchar($keyword_sql, "OR") . ") AND ";
     $q[] = $keyword_sql;
 }
 if ($_GET["price_min"] && $_GET["price_min"] !== '(minimum)') {
     $return["price_min"] = $_GET["price_min"];
     $q[] = "dea_marketprice > '" . numbers_only($_GET["price_min"]) . "' AND ";
 }
 if ($_GET["price_max"] && $_GET["price_max"] !== '(maximum)') {
     $return["price_max"] = $_GET["price_max"];
     $q[] = "dea_marketprice < '" . numbers_only($_GET["price_max"]) . "' AND ";
 }
 if ($_GET["branch"]) {
     $return["branch"] = $_GET["branch"];
     $q[] = "dea_branch = '" . $_GET["branch"] . "' AND ";
 }
 // status needs to be multi checkboxes
 if ($_GET["status"]) {
     $return["status"] = $_GET["status"];
     $q[] = "dea_status = '" . $_GET["status"] . "' AND ";
 }
 if ($_GET["bed"]) {
     $return["bed"] = $_GET["bed"];
     $q[] = "pro_bedroom >= '" . $_GET["bed"] . "' AND ";
 }
 if ($_GET["orderby"]) {
Example #3
0
$users_out = substr($update_out[2], strrpos($update_out[2], ' ') + 1);
$uptime_out = substr($update_out[2], 0, strrpos($update_out[2], ' ') - 2);
$load_out = str_replace(', ', ', <small>', $update_out[4]) . str_repeat('</small>', 2);
#HDD info
$harddrive = explode(' ', preg_replace('/\\s\\s+/', ' ', exec('df /dev/xvda1')));
$harddrive_out = format_bytes(kb2bytes($harddrive[2])) . '<small> / ' . format_bytes(kb2bytes($harddrive[1])) . ' <small>(' . calculate_percentage(kb2bytes($harddrive[2]), kb2bytes($harddrive[1])) . '% Free)</small></small>';
#bandwidth info
$vnstat = explode(';', shell_exec('vnstat --oneline'));
$vnstat[8] = '&#8595; ' . $vnstat[8];
$vnstat[9] = ' <small>&#8593; ' . $vnstat[9];
$vnstat[10] = ' <small>&#8597; ' . $vnstat[10];
$vnstat[11] = ' @ ~' . $vnstat[11];
#ram and swap
$memory = array('Total RAM' => 'MemTotal', 'Free RAM' => 'MemFree', 'Cached RAM' => 'Cached', 'Total Swap' => 'SwapTotal', 'Free Swap' => 'SwapFree');
foreach ($memory as $key => $value) {
    $memory[$key] = kb2bytes(numbers_only(exec('grep -E "^' . $value . '" /proc/meminfo')));
}
$memory['Used Swap'] = $memory['Total Swap'] - $memory['Free Swap'];
$memory['Used RAM'] = $memory['Total RAM'] - $memory['Free RAM'] - $memory['Cached RAM'];
$memory['RAM Percent Free'] = calculate_percentage($memory['Used RAM'], $memory['Total RAM']);
$memory['Swap Percent Free'] = calculate_percentage($memory['Used Swap'], $memory['Total Swap']);
$memory_out = format_bytes($memory['Used RAM']) . '<small> / ' . format_bytes($memory['Total RAM']) . ' <small> *' . format_bytes($memory['Cached RAM']) . ' Cached (' . $memory['RAM Percent Free'] . '% Free)</small></small>';
$swap_out = 'swap<span>' . format_bytes($memory['Used Swap']) . '<small> / ' . format_bytes($memory['Total Swap']) . ' <small>(' . $memory['Swap Percent Free'] . '% Free)</small></small></span>';
?>
<!DOCTYPE html>
<html>
	<head>
		<title>#/g/tv - Shell Server</title>
		<meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noodp" /> <!-- I f*****g hate robots... -->
		<meta name="description" content="Status page for #/g/tv shell server." />
		<meta charset="UTF-8" />
         $feature = array($feature);
     }
 }
 /*
 if ($_GET["keyword"]) {
 	$return["keyword"] = $_GET["keyword"];
 	$keyword = str_replace(" ",",",$_GET["keyword"]);
 	$keywords = explode(",",$keyword);
 	foreach ($keywords AS $keyword) {
 		$keyword = trim($keyword);
 		$q[] = "(cli_fname LIKE '%$keyword%' OR cli_sname LIKE '%$keyword%' OR cli_email LIKE '%$keyword%') OR cli_id = '$keyword' AND ";
 		}
 	}
 */
 if ($_GET["price"]) {
     $price = numbers_only($_GET["price"]);
     $return["price"] = $price;
     $return["term"] = $_GET["term"];
     if ($_GET["term"] == "pcm" && $scope == 'let') {
         // only use term for lettings, per week by default
         $price = pcm2pw($price);
     }
     $q[] = " (cli_" . $scope . "min <= {$price} AND cli_" . $scope . "max >= {$price}) AND ";
 }
 // type from simple select box - this is very messy, property types MUST be moved to link table
 if ($_GET["type"]) {
     $return["type"] = $_GET["type"];
     // get property types in array
     $sql_ptype = "SELECT * FROM ptype";
     $q_ptype = $db->query($sql_ptype);
     if (DB::isError($q_ptype)) {
 // dates should already be in the correct format
 $db_data["cli_created"] = $row["DateCreated"];
 // status (sales) L = live, S = not live
 if ($row["Status"] == 'L') {
     $db_data["cli_sales"] = 'Yes';
     $db_data["cli_saleemail"] = 'Yes';
 }
 //////////// lettings specific at end of table //////////////
 // property type sales
 $PropertyTypeLet = array('Any' => '4|5|6|7|8|9|10|22|25|11|12|13|19|20|21|23|14|15|16|17', 'House' => '4|5|6|7|8|9|10|22|25', 'Apartment' => '11|12|13|19|20|21|23', 'Commercial' => '14', 'Live/Work' => '10|21');
 if (array_key_exists($row["PropertyTypeLet"], $PropertyTypeLet)) {
     $db_data["cli_letptype"] = $PropertyTypeLet[$row["PropertyTypeLet"]];
 }
 $db_data["cli_letbed"] = $row["BedroomsLet"];
 $db_data["cli_letmin"] = numbers_only($row["MinPriceLet"]);
 $db_data["cli_letmax"] = numbers_only($row["MaxPriceLet"]);
 // status (lettings) L = live, S = not live
 if ($row["StatusLet"] == 'L') {
     $db_data["cli_lettings"] = 'Yes';
     $db_data["cli_letemail"] = 'Yes';
 }
 //////////// general fields, added after table was created //////////////
 $db_data["cli_branch"] = $row["Branch"];
 $db_data["cli_neg"] = $row["neg"];
 //cli_preferred
 if ($row["contact_method"] == "Email") {
     $db_data["cli_preferred"] = 'Email';
 } elseif ($row["contact_method"] == "Tel" || $row["contact_method"] == "Mobile") {
     $db_data["cli_preferred"] = 'Telephone';
 } else {
     // if not specified, set to email if there is an email address, else set to phone
 } elseif ($row["PropertyType"] == 'Flat/House' || $row["PropertyType"] == 'House/Flat') {
     $db_data["cli_saleptype"] = $PropertyType['House'] . '|' . $PropertyType['Apartment'];
 } elseif ($row["PropertyType"] == 'House') {
     $db_data["cli_saleptype"] = $PropertyType['House'];
 } elseif ($row["PropertyType"] == 'shop' || $row["PropertyType"] == 'shop commercial ?') {
     $db_data["cli_saleptype"] = "29";
 } elseif ($row["PropertyType"] == 'House Semi-detached') {
     $db_data["cli_saleptype"] = "5";
 } elseif ($row["PropertyType"] == 'House Terraced') {
     $db_data["cli_saleptype"] = "6";
 } else {
     $db_data["cli_saleptype"] = '';
 }
 // round prices to nearest 10000 to fit drop-downs
 $db_data["cli_salemin"] = round_to_nearest(numbers_only($row["StartRange"]), 10000);
 $db_data["cli_salemax"] = round_to_nearest(numbers_only($row["EndRange"]), 10000);
 $db_data["cli_salebed"] = $row["Beds"];
 // dates are not already be in the correct format
 $date = explode(" ", $row["DateReceived"]);
 $date_parts = explode("/", $date[0]);
 $DateReceived = $date_parts[2] . '-' . $date_parts[1] . '-' . $date_parts[0] . ' ' . $date[1];
 $db_data["cli_created"] = $DateReceived;
 // all these people are having email updates set to no
 // if they regsitered before 2006, they are set to inactive
 if ($date_parts[2] > 2005) {
     if ($row["Buying"] == 1) {
         $db_data["cli_sales"] = 'Yes';
         if ($db_data["cli_email"]) {
             $db_data["cli_saleemail"] = 'Yes';
         } else {
             $db_data["cli_saleemail"] = 'No';
Example #7
0
function is_digits($s)
{
    return numbers_only($s);
}
Example #8
0
 public static function stringForm($s)
 {
     if ($s && !is_string($s) && !is_numeric($s)) {
         d($s);
         throw new \Exception('not a string');
     }
     if (substr($s, 0, 1) == '0') {
         return 's';
     }
     if (is_numeric($s) && strpos($s, '.') !== false) {
         return 'd';
     }
     if (numbers_only($s)) {
         return 'i';
     }
     return 's';
 }