Exemplo n.º 1
0
 public static function table($table)
 {
     $q = \maverick\query::getInstance(true);
     if (!strlen($table)) {
         error::log('Table not specified', true);
     } else {
         $q->set_from_table($table);
     }
     return $q;
 }
Exemplo n.º 2
0
 public function createNewIPBlock($start_ip, $size)
 {
     list($start_ip, $size) = db::prepare(func_get_args());
     $type = self::getIPType($start_ip);
     $ending_ip = self::ipToLong(self::findEndOfIPBlock($start_ip, $size));
     $start_ip = self::ipToLong(self::expandIP($start_ip));
     $hr_start = self::longToIP($start_ip);
     $hr_end = self::longToIP($ending_ip);
     try {
         if (!self::ipBlockFree($start_ip, $ending_ip, $type)) {
             throw new exception('IP block already exists in database. Unable to create block.');
         } else {
             if ($start_ip == '' || $ending_ip == '' || $type == '') {
                 throw new exception('One or more arguments is empty, and the query cannot be run.');
             }
             $num_size = self::countIPsInBlock($size, $type);
             $date = date(CURRENT_DATE_FORMAT);
             $sql = "INSERT INTO `ip_blocks` \n\t\t\t\t\t\t\t(\t`starting_ip`,\n\t\t\t\t\t\t\t\t`ending_ip`,\n\t\t\t\t\t\t\t\t`hr_start`,\n\t\t\t\t\t\t\t\t`hr_end`,\n\t\t\t\t\t\t\t\t`ip_type`,\n\t\t\t\t\t\t\t\t`block_size`,\n\t\t\t\t\t\t\t\t`created_on`\n\t\t\t\t\t\t\t) VALUES\n\t\t\t\t\t\t\t(\t'{$start_ip}',\n\t\t\t\t\t\t\t\t'{$ending_ip}',\n\t\t\t\t\t\t\t\t'{$hr_start}',\n\t\t\t\t\t\t\t\t'{$hr_end}',\n\t\t\t\t\t\t\t\t'{$type}',\n\t\t\t\t\t\t\t\t'{$num_size}',\n\t\t\t\t\t\t\t\t'{$date}'\n\t\t\t\t\t\t\t)";
             if (db::query($sql, null, 1)) {
                 error::log("New IPv{$type} block '{$hr_start}{$size}' created, range: {$hr_start} - {$hr_end}.");
                 return true;
             } else {
                 throw new Exception("IP block starting with IP {$start_ip} unable to be created.");
             }
         }
     } catch (Exception $e) {
         error::log($e->getMessage(), __FUNCTION__, __LINE__);
     }
     return false;
 }
Exemplo n.º 3
0
 public function fullHalt($message, $function = null, $line = null)
 {
     if (!error::log($message, $function, $line, 1)) {
         die($message);
     }
 }