<?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);
<?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 _::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 _::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);
<?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 // 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.