/** * Proccess render * * @param string $layout * @param string $content_for_layout * @param string $helpers * @param object $request * @return string rendered view */ public function process($layout, $content_for_layout, $helpers = array(), &$request = null) { if ($this->gzip && ini_get('zlib.output_compression') != 1) { ob_start('ob_gzhandler'); // TODO: if 304 Not Modified dont use this } if ($this->view_file_path === false) { return; } $this->load_helpers($helpers, $request); // Render view if dont have content if ($content_for_layout === null) { // Se não começar com / então chama a convenção do framework. if ($this->view_file_path[0] != '/') { $this->view_file_path = '/app/views/' . $this->view_file_path; } $content_for_layout = $this->render_file(APP_PATH . $this->view_file_path . '.php'); } // Render layout if ($layout) { $this->add('content_for_layout', $content_for_layout . PHP_EOL); $html = $this->render_file(APP_PATH . '/app/views/layouts/' . $layout . '.php'); $app = App::get_instance(); $app->fire_event('after_render_layout', array('layout' => &$html)); return $html; } else { return $content_for_layout; } }
private function __construct() { try { $app = App::get_instance(); self::$db = new PDO('mysql:host=' . $app['db']['server'] . ';dbname=' . $app['db']['database'], $app['db']['username'], $app['db']['password']); self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch (PDOException $e) { echo "Database error: " . $e->getMessage(); } }
public function scrape($url = '') { if ($url != '') { $this->url = $url; } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); $app = App::get_instance(); curl_setopt($curl, CURLOPT_USERAGENT, $app['user-agent']); $this->data = curl_exec($curl); curl_close($curl); }
/** * Translate text to defined language using lazy loading. * * @param string $key * @param array $options * @return string */ function t($key, $options = array()) { // Merge options with defaults $options = array_merge(array('from' => 'application'), $options); // Load translation file $app = App::get_instance(); if (!isset($app->translations_cache[$options['from']])) { $app->translations_cache[$options['from']] = (include APP_PATH . '/config/locales/' . LANGUAGE . '/' . $options['from'] . '.php'); } // Setup important variables $translations = $app->translations_cache[$options['from']]; $keys = explode('.', $key); $end_key = end($keys); $text = $options['from'] . '.' . $key; // Get last array key values foreach ($keys as $key) { $is_end = $key == $end_key; if (isset($translations[$key])) { if (is_array($translations[$key]) && !$is_end) { $translations = $translations[$key]; } } } // Get correct pluralization translation word if (isset($options['count'])) { if (isset($translations[$end_key][$options['count']])) { $text = $translations[$end_key][$options['count']]; } elseif (isset($translations[$end_key]['*'])) { $text = str_replace("{count}", $options['count'], $translations[$end_key]['*']); } else { $text .= '.*'; } } else { // Get translation value $text = isset($translations[$end_key]) ? $translations[$end_key] : $text; } // Replace variables words foreach ($options as $key => $value) { if ($key != 'from' && $key != 'count') { $text = str_replace('{' . $key . '}', $value, $text); } } return $text; }
<?php ST::deployTemplate('heads/ui_timepicker.inc'); $init = App::get_instance(); RenderEngine::MenuChanger(); //login out from system if (isset($_GET['drop'])) { setcookie("Auth", "", time() - 3600); ST::redirectToRoute("Index/index"); } ?> <div class='container'> <div class=' col-md-offset-2 col-md-8 block-border-shadow'> <div class='col-md-offset-3 col-md-9'> <form class='form-horizontal' method='post' action="<?php echo ST::route("AuthNew/loginProcess"); ?> "> <div class='form-group'> <h3>Войти в систему</h3> <hr> <div class="alert alert-danger"> Нет учетной записи? <a class='btn btn-link text-primary' href="<?php echo ST::route('AuthNew/register'); ?> ">Зарегистрироваться можно тут <span class="glyphicon glyphicon-link"></span></a> <hr> </div>
include_once __DIR__ . '/credentials.php'; //rabbitmq query require_once '../config/_definitions.php'; //load main node config require_once CORE_REPOSITORY_REAL_PATH . 'config/_version.php'; //version require_once CORE_APP_PATH . 'config/_definitions.php'; //central planner Load require_once NODE_REAL_PATH . 'config/config.php'; //local config require_once NODE_REAL_PATH . 'config/autoloader.php'; //local autoloader require_once CORE_REPOSITORY_REAL_PATH . 'vendor/autoload.php'; //vendor $app = App::get_instance($params); require_once NODE_REAL_PATH . 'init.php'; $app->user = new Auth(); $app->node = MY_NODE; //------------------------ !main load end!------------------ ini_set("max_execution_time", 0); $connection = new AMQPConnection($credentials); $connection->connect(); //Create and declare channel $channel = new AMQPChannel($connection); //AMQPC Exchange is the publishing mechanism $vc = new Vks_controller(); $callback_func = function (AMQPEnvelope $message, AMQPQueue $q) use(&$max_consume, $vc) { $data = json_decode($message->getBody()); print '---------------query--------------' . "\r\n"; echo sprintf(" QueueName: %s", $q->getName()), PHP_EOL;
* for those components. As for my code, it's Creative * Commons Attribution-NonCommercial-ShareAlike 3.0 * United States. (http://creativecommons.org/licenses/by-nc-sa/3.0/us/). * For more information, contact Ian Monroe: ian@ianmonroe.com * * @author Ian Monroe <*****@*****.**> * @copyright 2016 * @version 0.1 ALPHA UNSTABLE * @link http://www.ianmonroe.com * @since File included in initial release * */ // bootstrap the rest of the codebase. require_once '../config.php'; csfr_protection(); $app = App::get_instance(); $db = Database::get_instance(); $action = NULL; if (isset($_POST['action'])) { $action = trim($_POST['action']); } if (isset($action)) { switch ($action) { case "add_aspect_to_subject": // do something. $output = ''; // do we have an upload to process? $handle = new upload($_FILES['aspect_binary']); if ($handle->uploaded) { $output .= 'entered uploaded routine' . PHP_EOL; $output .= 'filename: ' . $handle->file_src_name . PHP_EOL;
public function __construct() { $this->task_lists = array(); $app = App::get_instance(); $this->service = new Google_Service_Tasks($app['google']['client']); $taskLists = $this->service->tasklists->listTasklists(); foreach ($taskLists->getItems() as $taskList) { $this->task_lists[] = array($taskList->getId, $taskList->getTitle()); } }
<?php /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | First we need to get an application instance. This creates an instance | of the application / container and bootstraps the application so it | is ready to receive HTTP / Console requests from the environment. | */ $app = (require __DIR__ . '/../bootstrap/app.php'); require_once '../../config/config.php'; require_once '../../vendor/autoload.php'; $appVks = App::get_instance(); require_once '../../init.php'; $appVks->user = new Auth(); /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $request = Illuminate\Http\Request::capture(); $app->run($request);
public function create_custom_aspect_class() { echo "entered Custom Class" . PHP_EOL; $app = App::get_instance(); $new_classname = code_safe_name($this->aspect_name); $new_classname = $new_classname . 'Aspect'; $output = "// default custom class created automatically." . PHP_EOL . PHP_EOL; $output .= 'class ' . $new_classname . ' extends Aspect{' . PHP_EOL; $output .= "\t" . 'public function display_aspect(){' . PHP_EOL; $output .= "\t" . "\t" . '$output = parent::display_aspect();' . PHP_EOL; $output .= "\t" . "\t" . 'return $output;' . PHP_EOL; $output .= '}' . PHP_EOL; $output .= "\t" . 'public function parse(){}' . PHP_EOL; $output .= '}' . PHP_EOL; $output .= PHP_EOL . PHP_EOL; $output .= '// end file'; $path_to_custom_aspects = $app['model_path'] . '/CustomAspects_class.php'; $file_contents = file_get_contents($path_to_custom_aspects); $file_contents = str_replace('// end file', $output, $file_contents); if (file_put_contents($path_to_custom_aspects, $file_contents)) { return "Put properly."; } else { return "did not put properly."; } }
// Snoopy class require_once $APP['src_path'] . '/third_party/Snoopy.class.php'; // Composer Autoloader: require __ROOT__ . '/vendor/autoload.php'; /* end third party libraries ----------------------------------------------------------------- */ // Initialize the Google client with an oAuth call. session_start(); $client = new Google_Client(); $client->setAuthConfig($APP['google']['client_secret']); $client->setScopes(array("https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/contacts.readonly", "https://www.googleapis.com/auth/tasks", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile")); if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $client->setAccessToken($_SESSION['access_token']); if ($client->isAccessTokenExpired()) { $authUrl = $client->createAuthUrl(); header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); } } else { $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/coldreader/oauth2callback.php'; header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); } // Store the google client in the App array so we can access it elsewhere. $APP['google']['client'] = $client; // we're finished with the google client, and we've stored it in our app array. // let's see if we can get an email address from google, and confirm that you're good to go. $user_info_service = new Google_Service_Plus($APP['google']['client']); $user_info = $user_info_service->people->get("me"); $APP['user']['name'] = $user_info['name']['givenName']; $APP['user']['email'] = $user_info['emails'][0]['value']; // Initialize the app. $app = App::get_instance($APP); register_shutdown_function("fatal_handler");
function csfr_protection() { // This function should be included in EVERY CONTROLLER FILE. // Otherwise, you're just asking for trouble. // The goal here is to secure the site against cross-site forgeries. // we're using nonces associated with the logged in user to make sure everything's A-OK. If not, we throw a 403 and die. $app = App::get_instance(); if (verify_nonce()) { return true; } else { header('HTTP/1.0 403 Forbidden'); echo "Your pathetic attempt at cross-site forgery has been detected and logged. Your IP address is: " . $app['ana']->get_ip(); } }
public function display_aspect() { $app = App::get_instance(); $output = parent::display_aspect(); $output .= '<div class="image_aspect" id="id_' . $this->id . '" ><img src ="' . $app['upload_src_path'] . $this->aspect_data . '" style="max-width:100%;" /></div>'; return $output; }