Example #1
0
File: Dow.php Project: Eupeodes/gh
 private function display($dow, $ext)
 {
     switch ($ext) {
         case 'json':
             header('Content-Type: application/json');
             echo json_encode($dow);
             break;
         case 'csv':
             header('Content-Type: text/csv');
             echo '"Date","Dow"' . "\r\n";
             if (is_array($dow)) {
                 foreach ($dow as $r) {
                     echo $r->date . ',' . $r->dow . "\r\n";
                 }
             } else {
                 echo $dow->date . ',' . $dow->dow . "\r\n";
             }
             break;
         default:
             if (is_array($dow)) {
                 \lib\Error::send(404, 'Display list not implemented');
             } else {
                 header('Content-Type: text/plain');
                 echo $dow->dow;
             }
     }
 }
Example #2
0
File: Text.php Project: Eupeodes/gh
 public function view($url)
 {
     strtok($url, '/');
     $file = strtok('/');
     if (array_key_exists($file, $this->files)) {
         switch ($this->files[$file]) {
             case 'md':
                 $parseDown = new \lib\external\parseDown\ParseDown();
                 $parseDown->setMarkupEscaped(true);
                 $text = $parseDown->text(file_get_contents(dirname(__FILE__) . '/../' . strtoupper($file) . '.md'));
                 preg_match('/^<h1?.*>(?P<title>.*)<\\/h1>\\n(?P<content>.*)$/ims', $text, $matches);
                 $title = $matches['title'];
                 $content = $matches['content'];
                 break;
             case 'tpl':
                 require_once dirname(__FILE__) . '/../template/' . strtolower($file) . '.tpl.php';
                 break;
         }
     } else {
         $output = \model\Page::get($file);
         $title = $output->title;
         $content = $output->content;
     }
     if (is_null($content)) {
         \lib\Error::send(404, 'Page not found');
     }
     header('Content-type: text/json');
     echo json_encode(['title' => $title, 'content' => $content]);
 }
Example #3
0
 public function save()
 {
     if ($this->name != NULL && $this->pass != NULL && $this->authlevel != NULL) {
         $this->db->query("INSERT INTO users (name, password, authlevel)\n\t\t\t\t\t\t\t  VALUES ('{$this->name}', '{$this->pass}', '{$this->authlevel}')\n\t\t\t\t\t\t\t\t ");
     } else {
         Error::saveFail();
     }
 }
Example #4
0
 function users()
 {
     if (Session::isSession('user')) {
         $user = new User();
         $usersData = $user->getAll();
         $this->view->addUsers($usersData);
         $this->view->forAjax('users');
     } else {
         Error::authFail();
     }
 }
 /**
  * Execute la requete.
  */
 public function run()
 {
     foreach ($this->serverCalls as $serverCall) {
         try {
             //On essaie d'executer l'action demandee
             $serverCall->run();
         } catch (Exception $e) {
             //En cas d'erreur
             Error::catchException($e);
         }
     }
     //On envoie la reponse HTTP
     $this->getHTTPResponse()->send();
 }
Example #6
0
 public static function get($route, $postdata = NULL)
 {
     self::$url = explode('/', $route);
     self::$path = self::$url[0];
     if (isset(self::$url[1])) {
         self::$arguments = self::$url[1];
     }
     if (count($postdata)) {
         self::$arguments = $postdata;
     }
     foreach (self::$routes as $route_url => $route_method) {
         if ($route_url === self::$path) {
             $route_array = explode('.', $route_method);
             self::$controller = $route_array[0];
             self::$method = $route_array[1];
         }
     }
     //útvonal helyességének ellenőrzése a kontrolleren
     if (file_exists(__CONTROLLERS__ . '/' . self::$controller . '.php')) {
         require __CONTROLLERS__ . '/' . self::$controller . '.php';
     } else {
         if (self::$controller === '') {
             $currentController = '';
         } else {
             Error::RouteNotFound(self::$url[0]);
         }
     }
     //kontroller létrehozása
     $currentController = new self::$controller();
     //kontroller metódusának ellenőrzése, argumentumkezelés
     if (method_exists($currentController, self::$method)) {
         $method = self::$method;
         $arguments = self::$arguments;
         $argument_array = new ReflectionMethod($currentController, $method);
         $argument_count = count($argument_array->getParameters());
         $argument_count > 0 ? $currentController->{$method}($arguments) : $currentController->{$method}();
     } else {
         Error::MethodNotExists(self::$controller, self::$method);
     }
 }
 /**
  * Initialise le log.
  * @param Error $error L'erreur a journaliser.
  */
 public function __construct(\lib\Error $error)
 {
     $this->log = $error->getFile() . ':' . $error->getLine() . ' [' . get_class($error) . '] ' . $error->getMessage();
 }
Example #8
0
			Haber Düzenleme <small>Preview</small>
		</h1>
		<ol class="breadcrumb">
			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
			<li><a href="#">Forms</a></li>
			<li class="active">General Elements</li>
		</ol>
	</section>

	<!-- Main content -->
	<section class="content">
		<div class="row">
		
		<?php 
echo \Lib\Session::pull('message');
echo \Lib\Error::display($error);
?>
		
    <div id="warning_error" style="display: none"
				class="alert alert-danger"></div>
			<div id="warning_ok" style="display: none"
				class="alert alert-success"></div>


			<!-- left column -->
			<div class="col-md-12">
				<div class="nav-tabs-custom">
					<!-- Tabs within a box -->
					<ul class="nav nav-tabs pull-right">
                        <?php 
$a = 0;
Example #9
0
File: Hash.php Project: Eupeodes/gh
    private function getGpx()
    {
        if ($this->wk) {
            \lib\Error::send(404, 'Week view for GPX is not (yet) implemented');
        } else {
            $this->doCalc();
            if ($this->global) {
                if (is_null($this->output['global'])) {
                    \lib\Error::send(404, 'Data not yet available');
                }
                $this->lat = $this->output['global']->lat;
                $this->lng = $this->output['global']->lng;
                $filename = 'global';
            } else {
                $hashData = $this->lng > -30 ? $this->output['east'] : $this->output['west'];
                if (is_null($hashData)) {
                    \lib\Error::send(404, 'Data not yet available');
                }
                $filename = $this->lat . '_' . $this->lng;
                $this->lat .= substr($hashData->lat, 1);
                $this->lng .= substr($hashData->lng, 1);
            }
            \lib\Cache::permanent();
            header('Content-type: text/xml');
            header('Content-type: application/force-download;charset=utf-8');
            header('Content-Disposition: attachment; filename="geohash_' . $this->date->format('Y-m-d') . '_' . $filename . '.gpx"');
            echo '<?xml version="1.0"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="geohashing.info">
<metadata>
	<name>Geohash ' . $this->date->format('Y-m-d') . '</name>
</metadata>
<wpt lat="' . $this->lat . '" lon="' . $this->lng . '">
	<name>GH ' . $this->date->format('Y-m-d') . ' ' . $this->graticule . '</name>
</wpt>
</gpx>';
        }
    }
 /**
  * Execute la requete.
  */
 public function run()
 {
     // On envoie une deuxieme fois l'instance au gestionnaire d'erreurs
     // (1e fois = Webos->__construct())
     // Important pour ServerCallGroup !
     Error::setErrorsWebos($this);
     try {
         //On essaie d'executer l'action demandee
         $this->process->run();
     } catch (Exception $e) {
         //En cas d'erreur
         Error::catchException($e);
     }
     //On envoie la reponse HTTP
     $this->getHTTPResponse()->send();
 }