0xGA: Check-in [9b680fe510]

Yet another PHP framework, but made for org-mode and geeks.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Last commit on the php branch. Please now follow the python one, which will be much simpler. This commit BREAK the code. Do NOT use it in prod or you might risk severe damages. See you on the other branch
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:9b680fe51017e2d2f8b4a44e119024244159f4a5
User & Date: milouse 2014-04-30 23:27:55
Context
2014-04-30
23:27
Last commit on the php branch. Please now follow the python one, which will be much simpler. This commit BREAK the code. Do NOT use it in prod or you might risk severe damages. See you on the other branch Leaf check-in: 9b680fe510 user: milouse tags: trunk
2014-04-10
19:47
Create real man page for narv check-in: 752c1a57aa user: milouse tags: trunk
Changes

Changes to usr/bin/controller.php.

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        }

        $uristamp = str_replace('/','', $uri);
        if(!file_exists(BASE_SERVER_PATH
                . 'var/cache/' . $uristamp)){

            runServices('APP_INIT');
            $appname = ucfirst($appname);
            $app = new $appname();

            define('APPNAME', $appname);
            runServices('APP_INIT');

            runServices('APP_RUN');
            if($result = $app->run($args)){







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        }

        $uristamp = str_replace('/','', $uri);
        if(!file_exists(BASE_SERVER_PATH
                . 'var/cache/' . $uristamp)){

            runServices('APP_INIT');
            $appname = camelize($appname);
            $app = new $appname();

            define('APPNAME', $appname);
            runServices('APP_INIT');

            runServices('APP_RUN');
            if($result = $app->run($args)){

Changes to usr/bin/narv.

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221

        cleanup_installation

        echo "Update process finished."
        ;;
    streamindex)
        touch ${DESTDIR}/var/cache/streamindextoken
        wget -q -O /dev/null ${DOMAINNAME}stream/admin/index
        rm ${DESTDIR}/var/cache/streamindextoken
        ;;
    specs)
        mkdir /tmp/0xGA-specs
        cd /tmp/0xGA-specs

        TESTFILES=`ls -1 ${DESTDIR}/test/`







|







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221

        cleanup_installation

        echo "Update process finished."
        ;;
    streamindex)
        touch ${DESTDIR}/var/cache/streamindextoken
        wget -O - ${DOMAINNAME}stream/admin/index
        rm ${DESTDIR}/var/cache/streamindextoken
        ;;
    specs)
        mkdir /tmp/0xGA-specs
        cd /tmp/0xGA-specs

        TESTFILES=`ls -1 ${DESTDIR}/test/`

Changes to usr/bin/resource.php.

1
2
3
4
5
6
7
8
9
10
11
<?php
class Resource implements App {

    public function __construct(){}

    public function run($query){
        switch(OUTPUT_FORMAT){
            case 'css':
            case 'js':
            case 'img':
                return $this->getResource($query);

|
<
<







1
2


3
4
5
6
7
8
9
<?php
class Resource extends BaseApp {



    public function run($query){
        switch(OUTPUT_FORMAT){
            case 'css':
            case 'js':
            case 'img':
                return $this->getResource($query);

Changes to usr/bin/stream.php.

1
2
3
4
5
6
7
8
9
10
11
12
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
...
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193



194
195
196
197
198
199
200
<?php
class stream implements App {

    public function __construct(){}


    public function run($query){

        if(empty($query)){
            $query = 'tag/index';
        }

................................................................................
                case 'tag' :
                    $out = $this->tag($args);
                    putInCache('stream', $query, serialize($out));
                    return $out;
                case 'feed' :
                    if(defined('FEEDPRESS_URL')
                        && strpos($_SERVER['HTTP_USER_AGENT'], 'FeedValidator') === false
                        && strpos($_SERVER['HTTP_USER_AGENT'], 'FeedPress') === false
                       ){
	                    header('Location: http://feedpress.me/' . FEEDPRESS_URL);
	                    exit;
                    }
                    $args = str_replace('.atom', '', $args);
                    $out = $this->tag($args, true);
                    putInCache('stream', $query, serialize($out));
                    return $out;


                case 'get' :
                    return $this->ajax('get', $args);
                case 'set' :
                    return $this->ajax('set', $args);
                case 'admin':
                    return $this->admin($args);
                case 'resource':
                    return $this->resource($args);
                case 'getorg':
                    return $this->getorg($args);
                default :
                    return false;
            }
        }

        if($query == 'admin'){
            return $this->admin();
        }

        $out = $this->displayPost($query);
        putInCache('stream', $query, serialize($out));

        return $out;
    }


    private function tag($query = 'index', $isAtomFeed = false){

        $tagname = strclean($query);
................................................................................
        $id->setLoginLine();

        return $entry;
    }


    private function parsePost($url, $pNumber = 0){


        $parser = new Parser();

        $url = BASE_SERVER_PATH . 'home/' . CURRENT_DOMAIN
             . '/Documents/' . USER . '/' . $url;
        $doc = new Streamdocument();
        if(!$doc->open($url)){




            $store = new Data('filesystem');
            $parser->parseFragment(
                $store->query('select 404 from srv/messages')
            );

            $error = array_merge(
                array(

|
<
<
<







 







|

|
|





>
>




<
<
<
<
<
<
<
<



|
|
<
<
|
|
>







 







<
>
|
<
|
|
|
|
|
>
>
>







1
2



3
4
5
6
7
8
9
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44








45
46
47
48
49


50
51
52
53
54
55
56
57
58
59
...
169
170
171
172
173
174
175

176
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
class Stream extends BaseApp {




    public function run($query){

        if(empty($query)){
            $query = 'tag/index';
        }

................................................................................
                case 'tag' :
                    $out = $this->tag($args);
                    putInCache('stream', $query, serialize($out));
                    return $out;
                case 'feed' :
                    if(defined('FEEDPRESS_URL')
                        && strpos($_SERVER['HTTP_USER_AGENT'], 'FeedValidator') === false
                       && strpos($_SERVER['HTTP_USER_AGENT'], 'FeedPress') === false
                       ){
	                header('Location: http://feedpress.me/' . FEEDPRESS_URL);
	                exit;
                    }
                    $args = str_replace('.atom', '', $args);
                    $out = $this->tag($args, true);
                    putInCache('stream', $query, serialize($out));
                    return $out;
                case 'admin':
                    return $this->admin($args);
                case 'get' :
                    return $this->ajax('get', $args);
                case 'set' :
                    return $this->ajax('set', $args);








            }
        }

        $out = parent::run($query);
        if (!$out){


            $out = $this->displayPost($query);
            putInCache('stream', $query, serialize($out));
        }
        return $out;
    }


    private function tag($query = 'index', $isAtomFeed = false){

        $tagname = strclean($query);
................................................................................
        $id->setLoginLine();

        return $entry;
    }


    private function parsePost($url, $pNumber = 0){

        $success = false;
        if (!empty($url)){

            $url = BASE_SERVER_PATH . 'home/' . CURRENT_DOMAIN
                 . '/Documents/' . USER . '/' . $url;
            $doc = new Streamdocument();
            $success = $doc->open($url);
        }

        $parser = new Parser();
        if(!$success){
            $store = new Data('filesystem');
            $parser->parseFragment(
                $store->query('select 404 from srv/messages')
            );

            $error = array_merge(
                array(

Added usr/lib/base_app.php.































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
interface App {
  public function run($args);
  public function index();
}

class BaseApp implements App {

  public function __construct(){}

  public function run($query){
    if(empty($query)){
      return $this->index();
    }

    if(strpos($query, '/') !== false){
      list($func, $args) = explode('/', $query, 2);
    } else {
      $func = $query;
      $args = '';
    }

    if(method_exists($this, $func)){
      return call_user_func(array($this, $func), $args);
    }
    return false;
  }

  public function index(){}
}
?>

Changes to usr/lib/core.php.

91
92
93
94
95
96
97








98
99
100
101
102
103
104
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258

function strtourl($string){
    $string = str_replace(' ', '-', $string);
    $string = str_replace("'", '', $string);
    $string = strtolower($string);
    return strtoascii($string);
}









function getAppName($app){
    global $routes;

    $pathdata = array_keys($routes, $app);
    if(!empty($pathdata[0])){
        if(substr($app, -2) == '/*'){
................................................................................
        }

        $services[$level]['Step'] = 'After';
    }
}

function autoloadClasses($class){
    if(file_exists(
            BASE_SERVER_PATH . 'usr/lib/'
            . strtolower($class) . '.php')){
        require_once BASE_SERVER_PATH . 'usr/lib/'
        . strtolower($class) . '.php';
    }else if(file_exists(
            BASE_SERVER_PATH . 'usr/bin/'
            . strtolower($class) . '.php')){
        require_once BASE_SERVER_PATH . 'usr/bin/'
        . strtolower($class) . '.php';
    }
}
interface App {
    public function run($args);
}
spl_autoload_register('autoloadClasses');

function autoloadServices($service){
    if(file_exists(
            BASE_SERVER_PATH . 'usr/bin/'
            . strtolower($service) . '.service.php')){
        require_once BASE_SERVER_PATH . 'usr/bin/'
        . strtolower($service) . '.service.php';
    }
}
spl_autoload_register('autoloadServices');

/**
 * Speed hack to let 0xGA deals between basic classes and services. As
 * this autoload function is called in last position, it only trigger
 * if no class, nor services exists with that name (so it's _really_)







>
>
>
>
>
>
>
>







 







|
|
<
|
<
<
|
<
|
<
|
<
<
<




|
|
<
|
<
|







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
229
230
231
232
233
234
235
236
237

238


239

240

241



242
243
244
245
246
247

248

249
250
251
252
253
254
255
256

function strtourl($string){
    $string = str_replace(' ', '-', $string);
    $string = str_replace("'", '', $string);
    $string = strtolower($string);
    return strtoascii($string);
}

function camelize($string){
  return str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
}

function decamelize($string){
  return preg_replace('#^_#', '', strtolower(preg_replace('#([A-Z])#', '_$1', str_replace(' ', '_', $string))));
}

function getAppName($app){
    global $routes;

    $pathdata = array_keys($routes, $app);
    if(!empty($pathdata[0])){
        if(substr($app, -2) == '/*'){
................................................................................
        }

        $services[$level]['Step'] = 'After';
    }
}

function autoloadClasses($class){
  $class = decamelize($class);
  if(file_exists(BASE_SERVER_PATH . 'usr/lib/' . $class . '.php')){

    require_once BASE_SERVER_PATH . 'usr/lib/' . $class . '.php';


  }else if(file_exists(BASE_SERVER_PATH . 'usr/bin/' . $class . '.php')){

    require_once BASE_SERVER_PATH . 'usr/bin/' . $class . '.php';

  }



}
spl_autoload_register('autoloadClasses');

function autoloadServices($service){
  $service = decamelize($service);
  if(file_exists(BASE_SERVER_PATH . 'usr/bin/' . $service . '.service.php')){

    require_once BASE_SERVER_PATH . 'usr/bin/' . $service . '.service.php';

  }
}
spl_autoload_register('autoloadServices');

/**
 * Speed hack to let 0xGA deals between basic classes and services. As
 * this autoload function is called in last position, it only trigger
 * if no class, nor services exists with that name (so it's _really_)