Example #1
0
 public function invoke(URLComponent $url)
 {
     $class_name = $url->getController();
     $method = $url->getAction();
     $class = $this->app . '\\action\\' . $class_name;
     //Response对象
     $response = Response::getInstance();
     //Request对象
     $request = Request::getInstance();
     #实例化控制器,使用反射
     $reflection = new \ReflectionClass($class);
     $instacne = $reflection->newInstance();
     //先执行初始化方法init
     if ($reflection->hasMethod('init')) {
         $init = $reflection->getMethod('init');
         $data = $init->invokeArgs($instacne, array($request, $response));
         if ($data) {
             //如果有返回数据则输出
             $response->setBody($data);
             $response->send();
             return true;
         }
     }
     if ($reflection->hasMethod($method)) {
         $method = $reflection->getMethod($method);
     } elseif ($reflection->hasMethod('getMiss')) {
         $method = $reflection->getMethod('getMiss');
     } else {
         throw new RouteException('Method does not exist.');
     }
     $data = $method->invokeArgs($instacne, array($request, $response));
     #输出
     $response->setBody($data);
     $response->send();
 }
Example #2
0
    public function js()
    {
        $row = $this->input->getInt('row');
        $col = $this->input->getInt('col');
        $uid = $this->input->getInt('uid');
        $count = $row * $col;
        $sql = 'SELECT
		    ads.*
		  FROM ck_ads as ads
		  JOIN ck_packages as pack
		    ON(ads.package_id=pack.id)
		  WHERE
		    ads.status="approve"   AND
		    ads.clicked < pack.max_click
		  ORDER BY RAND()
		  LIMIT ' . $count;
        $query = $this->db->query($sql);
        $tmpl = Template::getInstance('empty.tpl');
        $tmpl->loadPage('jsAds');
        fb($col, 'row');
        for ($i = 0; $i < $row; ++$i) {
            $tmp = array();
            for ($j = 0; $j < $col; ++$j) {
                $tmp[] = $query->fetch();
            }
            $data[] = $tmp;
        }
        fb($data);
        $tmpl->assign('uid', $uid);
        $tmpl->assign('row', $row);
        $tmpl->assign('col', $col);
        $tmpl->assign('data', $data);
        Response::getInstance()->setTemplate($tmpl);
    }
Example #3
0
 /**
  * ---
  */
 public function __construct()
 {
     $this->db = Db::getInstance();
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
 }
Example #4
0
 static function exceptionHandler(\Exception $exception)
 {
     self::$exception = $exception;
     $request = Request::getInstance();
     $refererURL = $request->getReferer();
     $requestURI = \ManiaLib\Utils\URI::getCurrent();
     $debug = \ManiaLib\Application\Config::getInstance()->debug;
     if ($exception instanceof SilentUserException) {
         $message = static::computeShortMessage($exception) . '  ' . $requestURI;
         $userMessage = $exception->getMessage();
     } elseif ($exception instanceof UserException) {
         $message = static::computeShortMessage($exception) . '  ' . $requestURI;
         \ManiaLib\Utils\Logger::user($message);
         $userMessage = $exception->getMessage();
     } else {
         $requestURILine = sprintf(static::$messageConfigs['default']['line'], 'Request URI', $requestURI);
         $message = static::computeMessage($exception, static::$messageConfigs['default'], array($requestURILine));
         \ManiaLib\Utils\Logger::error($message);
         $userMessage = null;
     }
     $response = Response::getInstance();
     if ($message) {
         $response->message = $debug ? $message : $userMessage;
     }
     if ($debug) {
         $response->width = 300;
         $response->height = 150;
     }
     $response->backLink = $refererURL;
     $response->registerErrorView();
     $response->registerException($exception);
 }
Example #5
0
 public static function redirect($url)
 {
     if (!$url instanceof Url) {
         $url = new Url($url);
     }
     Response::getInstance()->setRedirect($url->__toString());
 }
Example #6
0
 function run()
 {
     if ($this->running) {
         throw new \Exception(get_called_class() . '::run() was previously called!');
     }
     $this->running = true;
     $request = Request::getInstance();
     if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
         $this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
         $request->delete(self::PATH_INFO_OVERRIDE_PARAM);
     } else {
         $this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
     }
     list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
     $this->calledURL = $request->createLink();
     $viewsNS =& Config::getInstance()->viewsNS;
     $currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
     if (!in_array($currentViewsNS, $viewsNS)) {
         array_unshift($viewsNS, $currentViewsNS);
     }
     try {
         Controller::factory($this->controller)->launch($this->action);
         Response::getInstance()->render();
     } catch (\Exception $e) {
         call_user_func(Bootstrapper::$errorHandlingCallback, $e);
         Response::getInstance()->render();
     }
 }
Example #7
0
 final function __construct()
 {
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     $this->session = Session::getInstance();
     $this->onConstruct();
 }
Example #8
0
 /**
  * Instantiates the Request and Response variables (and Session if enabled in config file)
  */
 public function __construct()
 {
     $this->request = Request::getInstance();
     $this->response = Response::getInstance();
     // Use the 'use_sessions' setting to enable or disable the session class
     if (Config::get('use_sessions')) {
         $this->session = Session::getInstance();
     }
 }
 private function __construct()
 {
     include 'settings.php';
     date_default_timezone_set($settings->timezone);
     $this->request = Request::getInstance();
     $this->session = Session::getInstance();
     $this->response = Response::getInstance();
     $this->user = User::getUserById($this->session->userID);
 }
Example #10
0
 public static function sendValues($type_send = 'json')
 {
     $response = Response::getInstance();
     if ($type_send == 'json') {
         $response->sendJsonData();
     } elseif ($type_send == 'print') {
         $response->sendPrintData();
     } else {
         throw new \Exception("send type [" . $type_send . "] not found");
         //'"
     }
 }
 public static function send($path)
 {
     $response = Response::getInstance();
     $last_modified_time = filemtime($path);
     $etag = md5_file($path);
     if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || trim($_SERVER['HTTP_IF_NONE_MATCH']) == '"' . $etag . '"') {
         $response->addHeader('ETag', '"' . $etag . '"');
         $response->httpCode = 304;
         $response->body = '';
         return;
     }
     $response->addHeader('ETag', '"' . $etag . '"');
     $response->addHeader("Last-Modified", gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT");
     return file_get_contents($path);
 }
Example #12
0
 function show()
 {
     $this->respond->article_id = $this->input->getInt("article_id");
     $query = "SELECT name, content, time, email FROM wb_comment\n\t\t\t\t\tWHERE (article_id={$this->respond->article_id}\n\t\t\t\t\tAND private=0  AND status='approve')";
     fb($query);
     $result = $this->db->query($query)->fetchAll();
     $article_query = "SELECT title FROM wb_articles\n\t\t\t\t\t\t\tWHERE id={$this->respond->article_id}";
     $article_title = $this->db->query($article_query)->fetch()->title;
     fb($result, 'comments');
     $tmpl = Template::getInstance('empty.tpl');
     $tmpl->loadPage('comment');
     $tmpl->assign('comment_list', $result);
     $tmpl->assign('article_title', $article_title);
     $tmpl->assign('post_id', $this->respond->article_id);
     //require 'temp/comment_template.php';
     Session::getInstance()->Captcha = $this->randomString();
     Response::getInstance()->setTemplate($tmpl);
 }
Example #13
0
 public static function widget($name, $request = NULL, $params = NULL, $allowResponse = true)
 {
     $className = $name;
     if (!isset(self::$_widgetPool[$name])) {
         if (!class_exists($className)) {
             throw new HandleException($className);
         }
         if (!empty($request)) {
             $requestObject = new Request();
         } else {
             $requestObject = Request::getInstance();
         }
         $responseObject = $allowResponse ? Response::getInstance() : NULL;
         $widget = new $className($requestObject, $responseObject, $params);
         $widget->execute();
         self::$_widgetPool[$name] = $widget;
     }
     return self::$_widgetPool[$name];
 }
Example #14
0
 public function show()
 {
     Response::getInstance()->setContent('image/png');
     $str = $this->randomString();
     Session::getInstance()->Captcha = $str;
     $image_x = 100;
     $image_y = 40;
     $im = imagecreatetruecolor($image_x, $image_y);
     $bgcoolor = imagecolorallocate($im, rand(177, 255), rand(177, 255), rand(177, 255));
     imagefill($im, 0, 0, $bgcoolor);
     $cl = imagecolorallocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
     $f = imageloadfont('hadi.gdf');
     imagestring($im, $f, 10, 10, $str, $cl);
     $lineCount = rand(7, 12);
     while ($lineCount--) {
         $cl = imagecolorallocate($im, rand(0, 127), rand(0, 127), rand(0, 127));
         imageline($im, rand(0, $image_x), rand(0, $image_y), rand(0, $image_x), rand(0, $image_y), $cl);
     }
     imagepng($im);
 }
Example #15
0
File: App.php Project: elvyrra/hawk
 /**
  * Initialize the application
  */
 public function init()
 {
     // Load the application configuration
     $this->singleton('conf', Conf::getInstance());
     // Load the application error Handler
     $this->singleton('errorHandler', ErrorHandler::getInstance());
     // Load the application logger
     $this->singleton('logger', Logger::getInstance());
     // Load the filesystem library
     $this->singleton('fs', FileSystem::getInstance());
     // Load the application session
     $this->singleton('session', Session::getInstance());
     // Load the application router
     $this->singleton('router', Router::getInstance());
     // Load the application HTTP request
     $this->singleton('request', Request::getInstance());
     // Load the application HTTP response
     $this->singleton('response', Response::getInstance());
     // Load the application cache
     $this->singleton('cache', Cache::getInstance());
 }
Example #16
0
 public function __get($name)
 {
     switch ($name) {
         case "session":
             $this->session = Session::getInstance();
             break;
         case "request":
             $this->request = Request::getInstance();
             break;
         case "response":
             $this->response = Response::getInstance();
             break;
         case "acl":
             $this->acl = Acl::getInstance();
             break;
         case "userId":
             $this->userId = $this->session->get("userId");
             break;
         default:
             $this->{$name} = Model::factoryInstance($name);
     }
     return $this->{$name};
 }
Example #17
0
 public function dispatch()
 {
     $response = Response::getInstance();
     $url = new Url();
     $uri = $url->getPath();
     foreach (array_reverse($this->routes, true) as $route => $class) {
         if (preg_match("~^{$route}\$~", $uri, $params)) {
             $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
             if (!(false === $return)) {
                 //$response->setHeader('Content-Type', 'application/xhtml+xml');
                 $response->setHeader('Content-Type', 'text/html;charset=UTF-8');
                 $response->setBody($class, $return);
                 return true;
             }
         }
     }
     if ($response->getHttpResponseCode() == 200) {
         //$response->setHeader('HTTP/1.0 404 Not Found');
         $response->setHttpResponseCode(404);
         $response->setBody('404', 'Error 404');
     }
     return false;
 }
Example #18
0
 public function process()
 {
     if (Session::getInstance()->getAuthenticationManager()->isAuthenticated()) {
         Response::getInstance()->setPageTemplate('authenticated.php');
     }
 }
Example #19
0
 /**
  * Конструктор
  */
 public function __construct($config)
 {
     parent::__construct($config);
     $this->object(Response::getInstance());
 }
Example #20
0
 /**
  * Destroy session, unset all variables
  */
 public function destroy()
 {
     $_SESSION = array();
     if (isset($_COOKIE[session_name()])) {
         Response::getInstance()->setCookie(session_name(), '', time() - 42000, '/');
     }
     session_destroy();
 }
Example #21
0
if (!isset($_SESSION)) {
    session_start();
}
ini_set("display_errors", "off");
//debug mode
$db_username = "******";
$db_password = "******";
$link = new PDO("mysql:host=newpresenceus.ipagemysql.com;dbname=bb1;", $db_username, $db_password);
require_once "init.php";
define("APP_NAME", "BlueBabble");
define("SLOGAN", "Connect with strangers like yourself");
define("COMPANY", "A&D Softworks");
define("STARTER_BOTTLES", 1000000000);
define("DEBUG_MODE", false);
//debug mode (how obvious, lol)
//classes
require_once "obj/User_class.php";
//is a class
require_once "obj/Message_class.php";
//is a class
require_once "obj/Response_class.php";
//is an object
require_once "obj/Blacklist_class.php";
//is an object
//objects
$response = Response::getInstance();
$blacklist = Blacklist::getInstance();
//facebook SDK
require_once "facebook/facebook.php";
$config = array('appId' => '536887286364414', 'secret' => 'ce61c1a9a7b1e89c87d816cd97e700bb', 'fileUpload' => false, 'allowSignedRequest' => false);
$facebook = new Facebook($config);
Example #22
0
require_once __ROOT_PATH . DS . "class_routines.class.php";
require_once __ROOT_PATH . DS . "registry.class.php";
require_once __ROOT_PATH . DS . "response.class.php";
require_once __ROOT_PATH . DS . "dbMysql.class.php";
require_once __ROOT_PATH . DS . "config.class.php";
require_once __ROOT_PATH . DS . "Auth.class.php";
require_once __ROOT_PATH . DS . "text.class.php";
require_once __REQ_TEMPL_DIR . DS . "request_template.class.php";
require_once __ROOT_PATH . DS . "IObservable.interface.php";
require_once __ROOT_PATH . DS . "IObserver.interface.php";
require_once __ROOT_PATH . DS . "plugin" . DS . "pluginBase.class.php";
require_once __ROOT_PATH . DS . "controller" . DS . "ctrlBase.class.php";
require_once __ROOT_PATH . DS . "model" . DS . "model.class.php";
require_once __ROOT_PATH . DS . "model" . DS . "modelUser.class.php";
require_once __ROOT_PATH . DS . "model" . DS . "modelBase.class.php";
require_once __ROOT_PATH . DS . "model" . DS . "mGuestBook.class.php";
require_once __ROOT_PATH . DS . "view" . DS . "viewBase.class.php";
require_once __ROOT_PATH . DS . "view" . DS . "viewPlugin.class.php";
require_once __ROOT_PATH . DS . "node.class.php";
require_once __ROOT_PATH . DS . "tree.class.php";
require_once __ROOT_PATH . DS . "xmlNode.class.php";
require_once __ROOT_PATH . DS . "xmlTree.class.php";
require_once __ROOT_PATH . DS . "xmldocument.class.php";
require_once __ROOT_PATH . DS . "component" . DS . "componentBase.class.php";
$router = Router::getInstance();
if (!($controller = $router->getController())) {
    die;
}
if ($controller->process()) {
    echo Response::getInstance();
}
Example #23
0
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script type="text/javascript" src="/js/jquery/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="/js/jquery/jquery.validate.min.js"></script>
  <script type="text/javascript" src="/js/ajax.js"></script>
  
  <link rel="stylesheet" type="text/css" media="all" href="/css/reset.css" />
  <link rel="stylesheet" type="text/css" media="all" href="/css/core.css" />
  
  <link rel="icon" type="image/png" href="/images/favicon.ico"/>  
  
  <title><?php 
echo StaticContext::getSiteName() . ' | ' . Response::getInstance()->getPageTitle();
?>
</title>
</head>
<body>
      <?php 
if (isset($processingContent) && $processingContent != -1 && $processingContent != NULL && $processingContent != '') {
    echo $processingContent;
}
if ($content == -1) {
    include 'config/includes/pages/404.php';
} else {
    //display the page content as extracted from the db
    echo $content;
}
?>
Example #24
0
 public function run()
 {
     $router = Router::getInstance();
     $response = Response::getInstance();
     $response->send($router->dispatch());
 }
Example #25
0
 /**
  * Load the current search from an id.
  *
  * @return bool Success
  */
 public function load()
 {
     if (null == $this->getId()) {
         $message = Message::error(__('Missing information to load the search.'));
         $response = Response::getInstance();
         $response->setRequestStatus($message->isSuccess());
         $response->addJSON('fieldWithError', 'searchId');
         $response->addJSON('message', $message);
         exit;
     }
     $savedSearchesTbl = Util::backquote($this->_config['cfgRelation']['db']) . "." . Util::backquote($this->_config['cfgRelation']['savedsearches']);
     $sqlQuery = "SELECT id, search_name, search_data " . "FROM " . $savedSearchesTbl . " " . "WHERE id = '" . $GLOBALS['dbi']->escapeString($this->getId()) . "' ";
     $resList = PMA_queryAsControlUser($sqlQuery);
     if (false === ($oneResult = $GLOBALS['dbi']->fetchArray($resList))) {
         $message = Message::error(__('Error while loading the search.'));
         $response = Response::getInstance();
         $response->setRequestStatus($message->isSuccess());
         $response->addJSON('fieldWithError', 'searchId');
         $response->addJSON('message', $message);
         exit;
     }
     $this->setSearchName($oneResult['search_name'])->setCriterias($oneResult['search_data'], true);
     return true;
 }
Example #26
0
<?
    Response::getInstance()->setPageTitle('Home');
?>
<div class="grid_24">
	<br>
	<h3>Inform8 WEB helps you build web applications fast.</h3> 
	<br><br>
	
	<div>We have compiled some of the best APIs, frameworks and tools with Inform8 to bring you a featured packed web application platform. 
	 	We want to remove the burden of starting a new project and simplify database integration so you can build web applications 
		fast.</div>
	
	<br><br>
	
	<em>You've reached this far, that's great! Now you can start adding content, build in your logic and integrate.</em> We recommend the <a href="">Getting Started Guide</a>


	<br><br><br>
	Some other things that you might want to know about:<br><br>
</div>
<div class="clear"></div>

	
<div class="grid_8">
	<h3>Database Integration</h3>
	<div class="ft">Configure</div>
	<div class="ft">Integrate</div>
	<div class="ft">Transaction Integration</div>
	
</div>
<div class="grid_8">
Example #27
0
 public function deletepost()
 {
     //delete script
     $sql = 'DELETE FROM  wb_articles WHERE id=' . $this->input->getInt('id') . ' and weblog_id=' . Session::getInstance()->weblog_id;
     $this->db->execute($sql);
     Response::getInstance()->redirect(ResponseRegistery::getInstance()->baseURL . "/dashboard/post/oldpost");
 }
 /**
  * Sends an HTML response to the browser
  *
  * @static
  * @return void
  */
 public static function response()
 {
     $response = Response::getInstance();
     chdir($response->getCWD());
     $buffer = OutputBuffering::getInstance();
     if (empty($response->_HTML)) {
         $response->_HTML = $buffer->getContents();
     }
     if ($response->isAjax()) {
         $response->_ajaxResponse();
     } else {
         $response->_htmlResponse();
     }
     $buffer->flush();
     exit;
 }
 /**
  * Function to report all the collected php errors.
  * Must be called at the end of each script
  *      by the $GLOBALS['error_handler'] only.
  *
  * @return void
  */
 public function reportErrors()
 {
     // if there're no actual errors,
     if (!$this->hasErrors() || $this->countErrors() == $this->countUserErrors()) {
         // then simply return.
         return;
     }
     // Delete all the prev_errors in session & store new prev_errors in session
     $this->savePreviousErrors();
     $response = Response::getInstance();
     $jsCode = '';
     if ($GLOBALS['cfg']['SendErrorReports'] == 'always') {
         if ($response->isAjax()) {
             // set flag for automatic report submission.
             $response->addJSON('_sendErrorAlways', '1');
         } else {
             // send the error reports asynchronously & without asking user
             $jsCode .= '$("#pma_report_errors_form").submit();' . 'PMA_ajaxShowMessage(
                         PMA_messages["phpErrorsBeingSubmitted"], false
                     );';
             // js code to appropriate focusing,
             $jsCode .= '$("html, body").animate({
                             scrollTop:$(document).height()
                         }, "slow");';
         }
     } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'ask') {
         //ask user whether to submit errors or not.
         if (!$response->isAjax()) {
             // js code to show appropriate msgs, event binding & focusing.
             $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"]);' . '$("#pma_ignore_errors_popup").bind("click", function() {
                         PMA_ignorePhpErrors()
                     });' . '$("#pma_ignore_all_errors_popup").bind("click",
                         function() {
                             PMA_ignorePhpErrors(false)
                         });' . '$("#pma_ignore_errors_bottom").bind("click", function(e) {
                         e.preventDefaulut();
                         PMA_ignorePhpErrors()
                     });' . '$("#pma_ignore_all_errors_bottom").bind("click",
                         function(e) {
                             e.preventDefault();
                             PMA_ignorePhpErrors(false)
                         });' . '$("html, body").animate({
                         scrollTop:$(document).height()
                     }, "slow");';
         }
     }
     // The errors are already sent from the response.
     // Just focus on errors division upon load event.
     $response->getFooter()->getScripts()->addCode($jsCode);
 }
Example #30
0
 public function changePassword()
 {
     Factory::getUser()->authorise('edituser', Session::getInstance()->weblog_id);
     $tmp = Template::getInstance('userDashboard.tpl');
     $tmp->loadPage('changePassword');
     $this->reponse->setTitle('تعویض کلمه عبور');
     Response::getInstance()->setTemplate($tmp);
 }