Example #1
0
 public static function execTime($set = false)
 {
     if ($set) {
         self::$execTime = microTime(true);
         return;
     }
     if (!self::$execTime) {
         return;
     }
     $newTime = microTime(true);
     $tDiff = $newTime - self::$execTime;
     self::$execTime = $newTime;
     return self::formatTime($tDiff * 1000, true);
 }
Example #2
0
 private function setLatestUpdateTime()
 {
     $time = explode(' ', microTime());
     // yields [seconds,microseconds] both in seconds, e.g. ["1322761879", "0.85629400"]
     $microseconds = substr($time[0], 2, 6);
     // we drop the leading "0." and trailing "00"  from the microseconds
     $seconds = $time[1] . $microseconds;
     $date = date("j-M-Y, H:i:s.") . $microseconds;
     $this->Exe("INSERT INTO `__History__` (`Seconds`,`Date`) VALUES ('{$seconds}','{$date}')");
 }
Example #3
0
 public static function createNewAtom($concept)
 {
     if (strpos($concept, '_AUTOINCREMENT') !== false) {
         // TODO: change to type definition when Ampersand is supporting IT-TYPE
         $database = Database::singleton();
         $tableInfo = Concept::getConceptTableInfo($concept);
         $table = $tableInfo['table'];
         $col = $tableInfo['cols'][0];
         $query = "SELECT MAX(`{$col}`) as `MAX` FROM `{$table}`";
         $result = array_column($database->Exe($query), 'MAX');
         if (empty($result)) {
             $atomId = 1;
         } else {
             $atomId = $result[0] + 1;
         }
     } else {
         $time = explode(' ', microTime());
         // yields [seconds,microseconds] both in seconds, e.g. ["1322761879", "0.85629400"]
         $atomId = $concept . '_' . $time[1] . "_" . substr($time[0], 2, 6);
         // we drop the leading "0." and trailing "00"  from the microseconds
     }
     return $atomId;
 }
Example #4
0
 /**
  * 	Возвращает UNIX TIMESTAMP с учетом микросекунд
  * 	@return		float
  */
 function time()
 {
     return array_sum(explode(" ", microTime()));
 }
Example #5
0
 /**
  * Returns time diffrence between now and initialize
  *
  * @access private
  * @return float Time diffrence
  * @static 
  */
 private static function getTime()
 {
     if (!isset(self::$startTime)) {
         self::$startTime = microTime(true);
     }
     return microtime(true) - self::$startTime;
 }
Example #6
0
function microtime_float()
{
    list($usec, $sec) = explode(' ', microTime());
    return (double) $usec + (double) $sec;
}
    die("Error setting sql_mode: " . mysqli_error($DB_link));
}
// Timestamp table
if ($columns = mysqli_query($DB_link, 'SHOW COLUMNS FROM `__History__`')) {
    mysqli_query($DB_link, 'DROP TABLE `__History__`');
}
mysqli_query($DB_link, "CREATE TABLE `__History__`\n                       ( `Seconds` VARCHAR(255) DEFAULT NULL\n                       , `Date` VARCHAR(255) DEFAULT NULL\n                       ) ENGINE=InnoDB DEFAULT CHARACTER SET UTF8 DEFAULT COLLATE UTF8_BIN");
if ($err = mysqli_error($DB_link)) {
    $error = true;
    echo $err . '<br />';
}
$sql = "SET SESSION sql_mode = 'ANSI,TRADITIONAL'";
if (!mysqli_query($DB_link, $sql)) {
    die("Error setting sql_mode: " . mysqli_error($DB_link));
}
$time = explode(' ', microTime());
// copied from DatabaseUtils setTimestamp
$microseconds = substr($time[0], 2, 6);
$seconds = $time[1] . $microseconds;
date_default_timezone_set("Europe/Amsterdam");
$date = date("j-M-Y, H:i:s.") . $microseconds;
mysqli_query($DB_link, "INSERT INTO `__History__` (`Seconds`,`Date`) VALUES ('{$seconds}','{$date}')");
if ($err = mysqli_error($DB_link)) {
    $error = true;
    echo $err . '<br />';
}
$sql = "SET SESSION sql_mode = 'ANSI,TRADITIONAL'";
if (!mysqli_query($DB_link, $sql)) {
    die("Error setting sql_mode: " . mysqli_error($DB_link));
}
// Signal table
function setTimestamp()
{
    $time = explode(' ', microTime());
    // yields [seconds,microseconds] both in seconds, e.g. ["1322761879", "0.85629400"]
    $microseconds = substr($time[0], 2, 6);
    // we drop the leading "0." and trailing "00"  from the microseconds
    $seconds = $time[1] . $microseconds;
    $date = date("j-M-Y, H:i:s.") . $microseconds;
    DB_doquer("INSERT INTO `__History__` (`Seconds`,`Date`) VALUES ('{$seconds}','{$date}')");
    // TODO: add error checking
}
Example #9
0
 /**
  * Generate a new atom identifier for this concept
  * @return string
  */
 public function createNewAtomId()
 {
     static $prevTime = null;
     if (strpos($this->name, '_AI') !== false && $this->isInteger()) {
         $firstCol = current($this->mysqlConceptTable->getCols());
         $query = "SELECT MAX(`{$firstCol->name}`) as `MAX` FROM `{$this->mysqlConceptTable->name}`";
         $result = array_column((array) $this->database->Exe($query), 'MAX');
         if (empty($result)) {
             $atomId = 1;
         } else {
             $atomId = $result[0] + 1;
         }
     } else {
         $now = explode(' ', microTime());
         // yields ["microseconds", "seconds"] both in seconds, e.g. ["0.85629400", "1322761879"]
         $time = $now[1] . substr($now[0], 2, 6);
         // we drop the leading "0." and trailing "00"  from the microseconds
         // Guarantee that time is increased
         if ($time <= $prevTime) {
             $time = ++$prevTime;
         } else {
             $prevTime = $time;
         }
         $atomId = $this->name . '_' . $time;
     }
     return $atomId;
 }
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
require_once "ImportParserController.php";
require_once "BildeendringController.php";
require_once "no/airdog/controller/Verktoy.php";
if (isset($_FILES['Filedata']) && isset($_GET['brukerEpost']) && isset($_GET['brukerPassord']) && isset($_GET['klubbId'])) {
    $MAKSSTORRELSE = 1024 * 1024 * 50;
    // 50MB
    $temp_navn = $_FILES['Filedata']['tmp_name'];
    $fil_navn = $_FILES['Filedata']['name'];
    $fil_storrelse = $_FILES['Filedata']['size'];
    $fil_type = $_FILES['Filedata']['type'];
    $info = pathinfo($fil_navn);
    $fil_ext = strtolower($info['extension']);
    if ($fil_storrelse <= $MAKSSTORRELSE && $fil_ext == "dat") {
        $sti = dirname(__FILE__) . "/temp_opplasting/" . $fil_navn . " - " . $_GET['klubbId'] . " - " . $_GET['brukerEpost'] . " - " . microTime() . "." . $fil_ext;
        if (file_exists($sti)) {
            unlink($sti);
        }
        if (move_uploaded_file($temp_navn, $sti)) {
            $ip = new importParserController();
            echo $ip->lagreDb($sti, $_GET["brukerEpost"], $_GET["brukerPassord"], $_GET["klubbId"]);
            unlink($sti);
        } else {
            echo 'Klarte ikke laste opp filen til. ' . $sti;
        }
    } else {
        if ($fil_storrelse <= $MAKSSTORRELSE && ($fil_ext == 'jpg' || $fil_ext == 'jpeg' || $fil_ext == 'gif' || $fil_ext == 'png')) {
            $sti = Verktoy::hoppBakover(dirname(__FILE__), 3) . "/images/";
            if (!file_exists($sti)) {
                mkdir($sti);
Example #11
0
 /**
  * Map URL to controller and action
  *
  * @return void
  */
 public function dispatch()
 {
     if (isset($_GET['route'])) {
         $_SERVER['PATH_INFO'] = $_GET['route'];
     }
     $_SERVER['PATH_INFO'] = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : (isset($_SERVER['REDIRECT_PATH_INFO']) ? $_SERVER['REDIRECT_PATH_INFO'] : ''));
     $uri = $_SERVER['PATH_INFO'];
     if (trim($uri, '/') == '') {
         $uri = '';
     } elseif (strncmp($uri, '/', 1) == 0) {
         $uri = explode('?', $uri, 2);
         $_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
         $uri = $uri[0];
     }
     $parsedRoute = $this->parseRoutes($uri);
     if ($parsedRoute) {
         $uri = $parsedRoute;
     }
     $uriArray = '' != $uri ? explode('/', trim($uri, '/')) : array();
     $_controller = $this->getController($uriArray);
     $_action = $this->getAction($uriArray);
     //Define some variables
     define('CONTROLLER_NAME', $_controller);
     define('ACTION_NAME', $_action);
     define('PUBLIC_DIR', Kotori_Request::getInstance()->getBaseUrl() . 'Public');
     unset($uriArray[0], $uriArray[1]);
     $controller = Kotori_Route::getInstance()->controller($_controller);
     if (!method_exists($controller, $_action)) {
         throw new Kotori_Exception('Request Action ' . $_action . ' is not Found.');
     }
     //Parse params from uri
     $params = $this->getParams($uriArray);
     //Do some final cleaning of the params
     $_GET = array_merge($params, $_GET);
     $_REQUEST = array_merge($_POST, $_GET, $_COOKIE);
     //Endtime
     define('END_TIME', microTime(true));
     define('RUN_TIME', END_TIME - START_TIME);
     header('X-Powered-By:Kotori');
     //Bind
     call_user_func_array(array($controller, $_action), $params);
 }