public function Install()
 {
     $appPath = _::getParamValue('appPath');
     if ($appPath == "") {
         echo "Pleasy specify an absolute path for the new application \"appPath=/xxx/xxx/xxx\"" . NL;
         die;
     }
     $appName = _::getParamValue('appName');
     if ($appName == "") {
         echo "Pleasy specify a valid name for the new application \"appName=MyNewApp\"" . NL;
         die;
     }
     $fullPath = $appPath . '/' . $appName;
     if (!file_exists($appPath)) {
         echo "The specified app path ({$appPath}) doesn't exist. Can't continue." . NL;
         die;
     }
     if (!file_exists($appPath)) {
         echo "The specified app path ({$appPath}) doesn't exist. Can't continue." . NL;
         die;
     }
     if (file_exists($fullPath)) {
         echo "The app folder ({$appName}) exists below app path ({$appPath}). Please, remove it or create an app with a different name." . NL;
         die;
     }
     if (!is_writable($appPath)) {
         echo "Can't write into specified folder ({$appPath})." . NL;
         die;
     }
     //Installation begins here
     //Create folder for application
     Pokelio_file::makedir($fullPath);
     //Create CLTV folder
     //...
 }
 public static function deployVendors()
 {
     $webRscPath = realpath(_::getConfig("WEB_RSC_PATH"));
     if (file_exists(POKELIO_ROOT_PATH . '/Vendors')) {
         Pokelio_File::makedir($webRscPath . '/Vendors');
         Pokelio_File::copyDir(POKELIO_ROOT_PATH . '/Vendors', $webRscPath . '/Vendors');
     }
 }
Exemple #3
0
 public function __construct()
 {
     $this->vars['rscUrl'] = _::getConfig("WEB_RSC_URL");
     $this->vars['htmlCss'] = array();
     $this->vars['htmlJs'] = array();
     $this->vars['htmlLang'] = _::getConfig('HTML')->lang;
     $this->vars['htmlCharset'] = _::getConfig('HTML')->charset;
 }
 public static function set($msg, $error_lvl, $deep = 2)
 {
     if (self::is_stop($error_lvl)) {
         die(self::format_message($msg, self::get_real_line($deep), $error_lvl, self::get_trace($deep)));
     } else {
         if (_::isDebug()) {
             echo self::format_message($msg, self::get_real_line($deep), $error_lvl, self::get_trace($deep));
         }
     }
 }
Exemple #5
0
function requestPage()
{
    $page = _::int('page', 0, $_GET);
    if ($page > 0) {
        return $page;
    }
    $page = strtolower(_::str('page', '', $_GET));
    if ($page !== '') {
        return $page;
    }
    return 0;
}
 private function extractParts()
 {
     $path = str_replace('\\', '/', $this->child);
     $parts = explode("/", $path);
     $trailPart = strlen($parts[sizeof($parts) - 1]) + strlen($parts[sizeof($parts) - 2]) + strlen($parts[sizeof($parts) - 3]) + 3;
     $this->modulePath = substr($this->child, 0, -$trailPart);
     $this->moduleName = $parts[sizeof($parts) - 3];
     if ($this->modulePath == POKELIO_MODULES_PATH) {
         $this->isPokelioModule == true;
         $this->rscUrl = _::getConfig("WEB_RSC_URL") . '/Pokelio/' . $this->moduleName;
     } else {
         $this->isPokelioModule == false;
         $this->rscUrl = _::getConfig("WEB_RSC_URL") . '/App/' . $this->moduleName;
     }
 }
 public static function view($templateSrc, $templateName, $moduleName)
 {
     $viewPath = _::getConfig("APP_VIEW_PATH");
     $cache = _::getConfig('USYNTAX_CACHE');
     $viewFile = $templateSrc;
     Pokelio_File::makedir($viewPath . '/' . $moduleName);
     $procViewFile = $viewPath . '/' . $moduleName . '/' . $templateName . 'Template.php';
     if (file_exists($procViewFile)) {
         if (filemtime($viewFile) > filemtime($procViewFile) || $cache == false) {
             self::processView($viewFile, $procViewFile);
         }
     } else {
         self::processView($viewFile, $procViewFile);
     }
     return $procViewFile;
 }
 protected function renderTemplate($templateName, $header = null, $footer = null)
 {
     //Get, if necessary, the default header and/or footer
     if ($header == null) {
         $header = _::getConfig('DEFAULT_HEADER_TEMPLATE_NAME');
     }
     if ($footer == null) {
         $footer = _::getConfig('DEFAULT_FOOTER_TEMPLATE_NAME');
     }
     //Import variables from varStore
     extract($this->view->getVars());
     //Initialize ouput buffer
     ob_start();
     //Require header file if specified
     if ($header != "") {
         $templateSrc = APP_TEMPLATE_PATH . '/' . $header . 'Template.php';
         if (_::getConfig('USE_USYNTAX')) {
             $view = Pokelio_uSyntax::view($templateSrc, $header, 'App');
         }
         require $view;
     }
     //Require JSEnabler if JSVar array contains variables
     $jsVars = $this->view->getJSVars();
     if (sizeof($jsVars) > 0) {
         $JSEnabler = APP_TEMPLATE_PATH . '/JSEnablerTemplate.php';
         require $JSEnabler;
     }
     //Require template file
     $template = _::getConfig('APP_VIEW_PATH') . '/' . $templateName . 'Template.php';
     $templateSrc = $this->modulePath . '/' . $this->moduleName . '/Template/' . $templateName . 'Template.php';
     if (_::getConfig('USE_USYNTAX')) {
         $view = Pokelio_uSyntax::view($templateSrc, $templateName, $this->moduleName);
     }
     require $view;
     //Require footer file if specified
     if ($footer != "") {
         $templateSrc = APP_TEMPLATE_PATH . '/' . $footer . 'Template.php';
         if (_::getConfig('USE_USYNTAX')) {
             $view = Pokelio_uSyntax::view($templateSrc, $footer, 'App');
         }
         require $view;
     }
     //Display buffered content and clean buffer
     $output = ob_get_clean();
     echo $output;
 }
Exemple #9
0
 public static function init($debug = true)
 {
     self::$debug = $debug;
     if ($debug) {
         ini_set('display_errors', true);
     } else {
         ini_set('display_errors', false);
         error_reporting(0);
     }
     self::declare_component('errorHandler');
     self::$view = self::declare_component('view');
     // raintpl?
     self::$db = self::declare_component('db');
     self::declare_component('orm');
     self::$post = self::parse_post();
     self::$get = self::parse_get();
     self::$request = self::parse_request();
     self::$session = self::parse_session();
     self::$cookie = self::parse_cookie();
     self::$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
     self::load_requires();
 }
 public static function execute()
 {
     $success = false;
     _::echoWriteInfo("Bsm installation started...");
     $dbm = new MyMangr_ObjectsModel();
     //Create user table
     if ($dbm->tableExists('BsmUser')) {
         _::echoWriteInfo("Dropping BsmUser table");
         $dbm->execute("DROP TABLE BsmUser");
     }
     _::echoWriteInfo("Creating BsmUser table");
     $sql = "CREATE TABLE BsmUser\n              (\n                     id_user         VARCHAR    (12)  NOT NULL COMMENT 'User id, like u001, 88124, ...',\n                     name            VARCHAR    (60)  NOT NULL COMMENT 'Name of the user',\n                     surname         VARCHAR   (120)  NOT NULL COMMENT 'Surname of the user',\n                     email           VARCHAR   (120)           COMMENT 'Email account',\n                     password        CHAR       (40)           COMMENT 'Password hash',\n                     status          CHAR      (100)  NOT NULL COMMENT 'Status: A-Active, D-Deactivated',\n                     auth_class      CHAR      (100)  NOT NULL COMMENT 'Class for authentication',\n                     auth_method     CHAR        (1)  NOT NULL COMMENT 'Method of Class for authentication',\n                     cli_allowed     TINYINT     (1)  NOT NULL COMMENT 'Is the user allowed to use CLI?',\n                     web_allowed     TINYINT     (1)  NOT NULL COMMENT 'Is the user allowed to use WEB?',\n                     ts_created      TIMESTAMP        NOT NULL COMMENT 'Timestamp of user creation',     \n                     ts_last_access  TIMESTAMP                 COMMENT 'Timestamp of user last access',\n                     PRIMARY KEY(\n                        id_user\n                     )\n              )";
     $dbm->execute($sql);
     if ($dbm->tableExists('BsmUser') == false) {
         _::echoWriteInfo("Unable to create BsmUser table. Exiting Bsm install.");
         return $success;
     } else {
         _::echoWriteInfo("Table BsmUser succesfullly created");
     }
     //Create profile table
     if ($dbm->tableExists('BsmProfile')) {
         _::echoWriteInfo("Dropping BsmProfile table");
         $dbm->execute("DROP TABLE BsmProfile");
     }
     _::echoWriteInfo("Creating BsmProfile table");
     $sql = "CREATE TABLE BsmProfile\n              (\n                     id_profile      INT        (11)  NOT NULL COMMENT 'Profile identificator',\n                     profile         VARCHAR    (60)  NOT NULL COMMENT 'Profile name',\n                     status          CHAR        (1)  NOT NULL COMMENT 'Status: A-Active, D-Deactivated',\n                     PRIMARY KEY(\n                        id_profile\n                     )\n              )";
     $dbm->execute($sql);
     if ($dbm->tableExists('BsmProfile') == false) {
         _::echoWriteInfo("Unable to create BsmProfile table. Exiting Bsm install.");
         return $success;
     } else {
         _::echoWriteInfo("Table BsmProfile succesfullly created");
     }
     $success = true;
     return $success;
 }
Exemple #11
0
<?php

// this function is deprecated since version 1.0.1, changed by _::define_autocall();
_::attach_header(function () {
    _::$view->show('header');
});
_::define_controller('registro2', function () {
    // todo: codigo promocional; seleccion de servidor
    define('EXTERA_PAGE', true);
    $nick = _::$post['username'];
    $email = _::$post['email'];
    $pass = _::$post['password'];
    $email = _::$post['email'];
    $pass2 = _::$post['passwordConfirm'];
    $error = null;
    // chequeamos que el nick sea razonable
    try {
        if ($nick->len() < 3 || $nick->len() > 32) {
            throw new exception('nick no valido, al menos 3 y menos de 32 caracteres');
        }
        if (!$email->isEmail()) {
            throw new exception('email no valido');
        }
        if ($pass->len() < 8) {
            throw new exception('La pass debe tener al menos 8 caracteres');
        }
        if ((string) $pass !== (string) $pass2) {
            throw new exception('Las pass no coinciden');
        }
        // bueno esta todo ok asique revisamos si existe alguien con este nick
        if (usuarios::exists((string) $nick)) {
            throw new exception('ya existe un usuario con este nick');
        }
        $user = new usuarios();
        $user->nick_usuario = (string) $nick;
        $user->pass_usuario = (string) $pass->hash();
        $user->plan_usuario = 0;
        // por cuanto tiempo?
        $fecha = new _date();
        $user->fecha_pago_usuario = $fecha->count();
        // si hay código de promoción
        if (isset(_::$post['codigopromocional'])) {
            // comprobamos si existe el código
            // evaluamos qué da
            $user->plan_usuario = 1;
            // dentro de 99 años, 11 meses
            $user->fecha_pago_usuario = $fecha->years(99)->months(11)->count();
        }
        if (isset(_::$post['referido'])) {
            $idref = usuarios::exists((string) _::$post['referido']);
            if ($idref) {
                $user->referido = $idref;
            } else {
                throw new Exception('el usuario referido no existe');
            }
        } else {
            $user->referido = 0;
        }
        $user->email_paypal = (string) $email;
        // DESIGNAMOS SERVIDOR
        $user->server_asignado = 1;
        $user->fondos_usuario = 0;
        $user->cuenta_activa = 1;
        // THIS SAVE THE NEW DATA IN THE OBJECT, DUMPING ALL DATA IN TABLE
        // like as INSERT or UPDATE depending if the object construct using parametter to specify primary key or not
        $user->save();
        // hay que enviar mail aquí
        _::$view->show('registro_ok');
    } catch (Exception $e) {
        _::$view->assign('error', $e->getMessage());
        _::$view->show('registro');
    }
});
Exemple #13
0
<?php

if (!defined('PHPQUERY_LOADER')) {
    include '../../index.html';
    die;
}
_::declare_component('property');
class ipn
{
    // usamos mi trait Property
    use Property;
    // atributos privados
    private $notify_validate_request_content = null;
    private $notify_validate_request_header = null;
    // variables.
    private $item_name = null;
    // nombre del producto
    private $payment_status = null;
    // estado del pago
    private $payment_amount = null;
    // precio pagado
    private $payment_currency = null;
    // ?
    private $transaction_id = null;
    // id de transacción de paypal
    private $receiver_email = null;
    // nuestro mail
    private $client_email = null;
    // mail del que compró
    private $error = false;
    private $error_msg = null;
<?php

// put this line if you use the userErrorHandler in all controllers in this file
//_::declare_component('userErrorHandler');
_::define_controller('ajax_example', function () {
    // you need load userErrorHandler component, the framework don't load by default this component, you load it if you use.
    _::declare_component('userErrorHandler');
    // you can put declaration line in index.php if you use the component in all controllers, or out of define_controller if you use in all controllers of this file.
    // first make a erros using a key word
    _e::set('KEY_WORD', 'this is a example');
    // now when you need error, use get function:
    try {
        // This is an error
        if (true) {
            throw new Exception(_e::get('KEY_WORD'));
        }
        // use _e::get('KEY_WORD'); to get json of error
    } catch (Exception $error) {
        // now, show the standarized error json.
        _::$view->ajax_plain($error->getMessage());
    }
    // the json error, have this structure
    /*
    
    {
    	code: 000,
    	key: "KEY_WORD",
    	message: "message of error"
    }
    
    code is number automatically generated.
Exemple #15
0
require 'phpquery/core.php';
// this set new values for the default configuration of DB
// see default config in phpquery/default_config/dbData.php
dbData::$host = 'localhost';
dbData::$user = '******';
dbData::$pass = '';
dbData::$db = 'adminwp';
// if you don't like .tpl extension in views, you set do you want
// you see default config in phpquery/default_config/tplData.php
//tplData::$extension = '.html';
// initialize the framework using debug mode (you can change the constant if like)
_::init(DEVMODE);
// the important, you need declare the controllers that exist
// first declare file (example.php), later you declare the controllers in the file
_::declare_controller('example', 'example', 'example_2', 'example_3', 'example_4');
// en general.php el controlador home
_::declare_controller('real_example', 'home', 'login', 'login2', 'registro', 'registro2');
// if you like add others definitions and declarations in external file
// you can require or include others files and declare it
require 'others/headers.php';
// REQUERIMOS TODAS LAS FUNCIONES QUE SE EJECUTARAN EN EL FOOTER
require 'others/footer.php';
// then set the variable for select controller (in this case "action")
$action = isset($_GET['action']) ? $_GET['action'] : 'home';
// execute the action (that is, call controller set in $action if exist)
_::execute($action);
// to end, show all views seted using _::$view->show();
_::$view->execute();
// SHOW TIME COST
var_dump(_::get_cost());
Exemple #16
0
 public function testSplit()
 {
     $this->assertEquals(['f', 'o', 'o'], _::split('foo')->toArray());
     $this->assertEquals(['f', 'o', 'o'], _::split('foo', '')->toArray());
     $this->assertEquals(['f', 'o', 'o'], _::split('foo', null)->toArray());
     $this->assertEquals(['foo', 'bar', 'baz'], _::split('foo bar baz', ' ')->toArray());
     $this->assertEquals(10, _::split('1234')->map(function ($n) {
         return (int) $n;
     })->reduce(function ($s, $n) {
         return $s + $n;
     }));
 }
<?php

_::define_controller('search', function () {
    _::declare_component('searcher');
    $toSearch = _::$post['q'];
    $search = new Buscador((string) $toSearch);
    // get querys to execute in db
    $querys = $search->getQuerys();
    foreach ($querys as $query) {
        $pdo = _::$db->prepare('SELECT id FROM posts WHERE title_post LIKE \'%' . $query . '%\'');
        $pdo->execute();
        $results = $pdo->fetchAll();
        // join all results
        $search->merge($results);
    }
    $LIMIT = 10;
    // limit of results
    // delete repeated results
    $results = $search->filterQuerys('id', $LIMIT);
    // $search->error (BOOLEAN)
    /* $search->error_id (ONE OF THIS CONSTANTS:
     * BUSCADOR_TEXTO_PEQUENIO, BUSCADOR_PALABRAS_PEQUENIAS, BUSCADOR_MUCHAS_PALABRAS
     * Little TEXT, little words, many words, respectively)
     */
    // now, in $results is array of results
}, true);
Exemple #18
0
<?php

require "include/connect.php";
// Соединение с БД
/** @section Бизнес-логика */
/** @section Обработка запросов */
$response = array();
$method = strtolower(_::str('method'));
switch ($method) {
    /** @subsection Обработка запросов к Api */
    /** @subsection Обработка ошибочного запроса */
    default:
        Api::error(0, $method . ' : Неверный запрос к Api');
        // Все прочие запросы игнорируются
}
Api::out($response);
Exemple #19
0
    _::redirect('example_3');
    // from here it doesn't execute.
    // if you like redirect client web browser, use:
    _::redirect('http://google.com', false);
    // this stop execution of current code.
    // if you need make all records of a table, you can use:
    $records = model::getAll();
    // this is SELECT * FROM TABLE;
    // if you like add limit, you can use second parammeter:
    $records = model::getAll('LIMIT 1');
    // in the second parammeter you can use WHERE clausule, ORDER BY and LIMIT.
    // getAll is a magic function of ORM, you don't need define it in the model.
    // now, $records get an Array of ids, you need make one object at each.
    // you can use foreach:
    /**
     $objects = array();
     foreach($records as $one_record)
     {
       $objects[] = new model($one_record['primary_key']);
     }
    */
    // OR YOU CAN USE FRAMEWORK TO MAKE EASY:
    $objects = _::factory($records, 'primary_key', 'model');
    // of course, you replace primary_key and model.
    // now you have one object each record.
    // and you can set new values, use the current values, delete the record, etc.
    // you can make new functions for check if exists record, and custom functions of getAll in the model using parent::getAll('query');
    // remember, the objets represents records, the class represent the table.
    // the static functions affect all records.
    // the functions of the object affect one record.
});
shuffle:
_::shuffle([1, 2, 3, 4, 5, 6]);
// => [4, 1, 6, 3, 5, 2]
sample:
_::sample([1, 2, 3, 4, 5, 6]);
// => 4
_::sample([1, 2, 3, 4, 5, 6], 3);
// => [1, 6, 2]
toArray:
$object = new stdClass();
$object->one = 1;
$object->two = 2;
$object->three = 3;
_::toArray($object);
// => ['one' => 1, 'two' => 2, 'three' => 3]
_::toArray(null);
// => []
_::toArray("hello");
// => ["hello"]
size:
$object = new stdClass();
$object->one = 1;
$object->two = 2;
$object->three = 3;
_::size($object);
// => 3
partition:
_::partition([0, 1, 2, 3, 4, 5], function ($num) {
    return $num % 2 != 0;
});
// => [[1, 3, 5], [0, 2, 4]]
Exemple #21
0
    if (!file_exists(__DIR__ . '/kernel.php')) {
        throw new Exception('<b>FATAL ERROR</b> kernel.php is\'nt exists');
    }
    if (!file_exists(__DIR__ . '/default_config/dbData.php')) {
        throw new Exception('<b>FATAL ERROR</b> default_config/dbData.php is\'nt exists');
    }
    if (!file_exists(__DIR__ . '/default_config/tplData.php')) {
        throw new Exception('<b>FATAL ERROR</b> default_config/tplData.php is\'nt exists');
    }
    if (!file_exists(__DIR__ . '/class.date.php')) {
        throw new Exception('<b>FATAL ERROR</b> class.date.php is\'nt exists');
    }
    if (!file_exists(__DIR__ . '/class.inputvars.php')) {
        throw new Exception('<b>FATAL ERROR</b> class.inputvars.php is\'nt exists');
    }
} catch (Exception $e) {
    die($e->getMessage());
}
// Load files //
// Default critical config
require 'default_config/coreData.php';
// Load kernel
require 'kernel.php';
// start stats
_::set_time();
// Default configs
require 'default_config/dbData.php';
require 'default_config/tplData.php';
// Core classes
require 'class.date.php';
require 'class.inputvars.php';
<?php

_::define_controller('ipn_request', function () {
    _::declare_component('ipn');
    $data = new ipn();
    $data->transaction_id;
    $data->item_name;
    $data->payment_status;
    $data->amount;
    $data->currency;
    $data->receiver_email;
    $data->client_email;
}, true);
<?php

require_once __DIR__ . '/Underscore/Underscore.php';
require_once __DIR__ . '/Underscore/Bridge.php';
class_alias('Underscore\\Underscore', '_');
// register class forgery as autoloading function
spl_autoload_register(function ($classname) {
    try {
        // by your powers combined!
        return _::forge($classname);
    } catch (RuntimeException $e) {
        // ...we failed to summon Captain Planet :(
        return false;
    }
});
Exemple #24
0
<?php

// this function is execute after controllers.
// this DON'T EXECUTE IF YOU CALL REDIRECT IN CONTROLLER
_::attach_footer(function () {
    _::$view->show('footer');
});
Exemple #25
0
 /**
  * Show message of failed installation
  * 
  * @param string $moduleName Name of the installed module
  */
 private static function failedInstall($moduleName)
 {
     _::echoWriteInfo(NL . "Module " . $moduleName . " installation failed.");
 }
<?php

_::define_controller('download', function () {
    _::declare_component('file');
    // force download uploads/file.php
    $file = new file('uploads/', 'file.php');
    $file->download();
});
_::define_controller('upload', function () {
    _::declare_component('file');
    // for upload:
    $file = new file();
    $location = $file->upload('FIELD', 'uploads/', true, true, array('jpg', 'jpeg', 'png', 'gif'));
});
<?php

_::define_controller('mail', function () {
    // simple mail, not SMTP!
    _::declare_component('mailer');
    $html = 'hello <b>world</b>, go to mi site please <a href="http://google.com">mi site</a>';
    $mail = new mailer('*****@*****.**', '*****@*****.**', 'testing mailer', $html);
    $result = $mail->send();
    if (!$result) {
        die($mail->error_message);
    }
}, true);
 /**
  * Invokes App starting point
  */
 private function start()
 {
     $startClass = _::getParamValue('controller');
     $startMethod = _::getParamValue('action');
     if ($startClass == "") {
         echo NL . 'Please, specify a controller name controller=MyController' . NL;
         exit;
     }
     if ($startMethod == "") {
         echo NL . 'Please, specify an action name action=MyController' . NL;
         exit;
     } else {
         $startClass = $startClass . 'Controller';
         $class = new $startClass();
         $class->{$startMethod}();
     }
 }
Exemple #29
0
 public static function getRandObjects($pk, $whereSection = null, $cantidad = 1)
 {
     return _::factory(self::getRand($pk, $whereSection, $cantidad), $pk, self::tablename());
 }
Exemple #30
0
    case 'group.all':
        $response = Page::all();
        break;
    case 'group.get':
        $response = Group::get(_::int('group'));
        break;
    case 'group.student':
        $response = Group::student(_::int('group'), _::int('student'));
        break;
    case 'group.notify':
        $response = Group::notify(_::int('group'), _::int('author'), _::str('header'), _::str('text'));
        break;
    case 'page.add':
        $response = Page::add(_::str('title'), _::raw('text'), _::int('author'));
        break;
    case 'page.all':
        $response = Page::all();
        break;
    case 'page.get':
        $response = Page::get(_::int('id'));
        break;
    case 'page.edit':
        $response = Page::edit(_::int('id'), _::str('title'), _::raw('text'));
        break;
        /** @subsection Обработка ошибочного запроса */
    /** @subsection Обработка ошибочного запроса */
    default:
        Api::error(0, $method . ' : Неверный запрос к Api');
        // Все прочие запросы игнорируются
}
Api::out($response);