コード例 #1
0
ファイル: BusinessLogic.php プロジェクト: laiello/time-travel
 public function moveUserPictures($parameters)
 {
     try {
         if (isset($_SESSION['username'])) {
             $username = $_SESSION["username"];
             error_log("username: "******"/temp/*.{jpg,gif,png,JPG,GIF,PNG}", GLOB_BRACE);
             foreach ($filenames as $filepath) {
                 set_time_limit(20);
                 $dest = $rootDir . '/main/' . basename($filepath);
                 if (!copy($filepath, $dest)) {
                     throw new Exception("026");
                 }
                 //we delete the temp
                 unlink($filepath);
                 //we delete the thumbnail
                 unlink($rootDir . '/thumbnails/' . basename($filepath));
             }
         } else {
             throw new Exception("026");
         }
     } catch (PDOException $e) {
         print "Error!: " . $e->getMessage() . "<br/>";
         throw new Exception('032');
     }
     $responder = new Responder();
     return $responder->constructResponse(null);
 }
コード例 #2
0
ファイル: Responder.php プロジェクト: hlag/svs
	public static function getInstance()
	{
		if (!isset(self::$instance))
		{
            self::$instance = new Responder();
        }
        return self::$instance;
	}
コード例 #3
0
 /**
  * Handles the Ajax action.
  */
 public function ajax_handler()
 {
     if ($this->utility->validate_nonce($this->handle) && $this->validator->validate_all()) {
         $callback_response = $this->utility->get_callback_response($this->handle, $this->handle_callback, $this->handle_callback_args);
         $this->responder->handle_response($callback_response);
     } else {
         http_response_code(403);
         // Forbidden.
     }
     die;
 }
コード例 #4
0
ファイル: Shortener.php プロジェクト: kamillos/ux9-api
 /**
  * @return mixed
  */
 private function parseResponse()
 {
     $res = new Responder($this->response);
     return $res->get($this->getFormat());
 }
コード例 #5
0
 public function setContent($content)
 {
     parent::setContent(json_encode($content));
 }
コード例 #6
0
ファイル: index.php プロジェクト: c4rl/ivraudiopoc
<?php

include './lib/Responder.php';
include './lib/AudibleString.php';
if (!isset($argv[1]) || !in_array($argv[1], ['text', 'audio'])) {
    die("ERROR You must supply an argument.\n    Usage:\n    \$ php -f index.php [text|audio]\n");
} else {
    $adaptor = $argv[1];
}
// Build dictionary.
$dictionary = [];
foreach (json_decode(file_get_contents('./script.json')) as $entry) {
    $dictionary[$entry->text] = $entry;
}
// Initialize responder.
$responder = new Responder($adaptor, $dictionary);
// Create some sample arguments and text.
$artwork = 'Garfield';
$balance = '$12345.67';
$responder->push('Hello');
$responder->push('Your @artwork card has balance of @balance', ['@artwork' => $artwork, '@balance' => AudibleString::currencyToWords($balance)]);
echo $responder->toXml();
コード例 #7
0
 public static function formatException(\Exception $e, $message = '', \Lampcms\I18n\Translator $Tr = null)
 {
     $message = !empty($message) ? $message : $e->getMessage();
     if ($e instanceof \Lampcms\DevException) {
         /**
          * @todo if Tr was passed here
          *       then we can translate string
          */
         $message = defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG ? $e->getMessage() : 'Error occurred. Administrator has been notified of the error. We will fix this as soon as possible';
         //$oTr->get('generic_error', 'exceptions');
     }
     /**
      * htmlspecialchars is for safety to prevent XSS injection in case
      * part of the error message comes from any type of user input
      * For example a string containing script injection (HTML tags) is passed in GET request
      * the error is then generated and the original string may before part of that
      * error message
      */
     if (!$e instanceof \Lampcms\UnactivatedException) {
         $message = \htmlspecialchars($message);
     }
     $aArgs = $e instanceof \Lampcms\Exception ? $e->getArgs() : null;
     $message = !empty($aArgs) ? \vsprintf($message, $aArgs) : $message;
     if ($Tr) {
         $message = $Tr[$message];
     }
     $sError = '';
     $sTrace = self::getExceptionTraceAsString($e) . "\n";
     $strFile = $e->getFile();
     $intLine = $e->getLine();
     $intCode = $e instanceof \ErrorException ? $e->getSeverity() : $e->getCode();
     $sLogMessage = 'Exception caught: ' . \get_class($e) . "\n" . $message . "\n" . 'error code: ' . $intCode . "\n" . 'file: ' . $strFile . "\n" . 'line: ' . $intLine . "\n" . 'stack: ' . $sTrace . "\n";
     d($sLogMessage . "\n" . '$_REQUEST: ' . \print_r($_REQUEST, true));
     if (!empty($_SESSION)) {
         d('$_SESSION: ' . print_r($_SESSION, 1));
     }
     $sError .= $message . "\n";
     if (defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG) {
         $sError .= "\nException Class: " . \get_class($e) . BR;
         $sError .= "\nError code: {$intCode}\n";
         $sError .= "\nFile: {$strFile}\n";
         $sError .= "\nLine: {$intLine}\n";
         if (!empty($sTrace)) {
             $sError .= "\nTrace: \n{$sTrace}\n";
         }
     }
     /**
      * If this exception has E_USER_WARNING error code
      * then it was thrown when parsing some ajax-based
      * request.
      *
      * We then need to only send json array with
      * only one key 'exception'
      */
     if (E_USER_NOTICE === $e->getCode() || Request::isAjax()) {
         /**
          * if this exception was thrown when uploading
          * file to iframe, then we need to add 'true' as
          * the last (2nd arg) to fnSendJson
          */
         $a = array('exception' => $sError, 'errHeader' => 'Error', 'type' => get_class($e));
         if ($e instanceof \Lampcms\FormException) {
             $a['fields'] = $e->getFormFields();
         }
         d('json array of exception: ' . print_r($a, 1));
         Responder::sendJSON($a);
     }
     return $sError;
 }
コード例 #8
0
 public function logoutUser($parameters)
 {
     session_start();
     unset($_SESSION['username']);
     unset($_SESSION['password']);
     unset($_SESSION['userid']);
     unset($_SESSION["name"]);
     unset($_SESSION['access_token']);
     session_destroy();
     $responder = new Responder();
     return $responder->constructResponse(null);
 }
コード例 #9
0
ファイル: Module.php プロジェクト: hlag/svs
	public function getHiddenInputs() // JA
	{
		Responder::getInstance()->register('Module', $this->moduleName);
		return array("Module" => $this->moduleName);
	}
コード例 #10
0
ファイル: controller.php プロジェクト: laiello/time-travel
        $parameters["serviceClass"] = $action->serviceClass;
        Forker::doPost($parameters);
        return;
    }
    $responder = new Responder();
    $response = $classInstance->{$actionName}($parameters);
    if (is_string($response)) {
        echo $response;
    } else {
        echo $responder->constructResponse($response);
    }
    if (isset($_SESSION['mobile'])) {
        session_destroy();
    }
} catch (Exception $e) {
    $responder = new Responder();
    $errorCodes = new ErrorCodes();
    $errMessage = $errorCodes->getErrorMessage($e->getMessage());
    error_log("Controller Error Message: " . $errMessage);
    echo $responder->constructErrorResponse($errMessage);
}
function customError($errno, $errstr, $file, $line)
{
    if (!(error_reporting() & $errno)) {
        // This error code is not included in error_reporting
        error_log($errstr);
        return;
    }
    switch ($errno) {
        case E_USER_ERROR:
            error_log("Fatal error on line {$errline} in file {$errfile} {$errstr}");
コード例 #11
0
ファイル: index.php プロジェクト: kostyll/ekode
<?php

if (version_compare(PHP_VERSION, '5.1.0', '<')) {
    exit('Your current PHP version is: ' . PHP_VERSION . '. Haxe/PHP generates code for version 5.1.0 or later');
}
require_once dirname(__FILE__) . '/lib/php/Boot.class.php';
Responder::main();
コード例 #12
0
ファイル: Exception.php プロジェクト: netconstructor/LampCMS
 public static function formatException(\Exception $e, $sMessage = '', \Lampcms\I18n\Translator $Tr = null)
 {
     $sMessage = !empty($sMessage) ? $sMessage : $e->getMessage();
     //$sMessage = $e->getMessage();
     //$bHtml = ($e instanceof \Lampcms\Exception) ? $e->getHtmlFlag() : false;
     if ($e instanceof Lampcms\DevException) {
         $sMessage = defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG ? $e->getMessage() : 'Error occured';
         //$oTr->get('generic_error', 'exceptions');
     }
     // not sure why strip_tags was here
     //$sMessage = strip_tags($sMessage);
     $aArgs = $e instanceof \Lampcms\Exception ? $e->getArgs() : null;
     $sMessage = !empty($aArgs) ? vsprintf($sMessage, $aArgs) : $sMessage;
     if ($Tr) {
         $sMessage = $Tr[$sMessage];
     }
     $sError = '';
     $sTrace = nl2br(self::getExceptionTraceAsString($e)) . '<hr>';
     $strFile = $e->getFile();
     $intLine = $e->getLine();
     $intCode = $e instanceof \ErrorException ? $e->getSeverity() : $e->getCode();
     $sLogMessage = 'LampcmsError exception caught: ' . $sMessage . "\n" . 'error code: ' . $intCode . "\n" . 'file: ' . $strFile . "\n" . 'line: ' . $intLine . "\n" . 'stack: ' . $sTrace . "\n";
     d($sLogMessage . "\n" . '$_REQUEST: ' . print_r($_REQUEST, true));
     if (!empty($_SESSION)) {
         d('$_SESSION: ' . print_r($_SESSION, 1));
     }
     $sError .= $sMessage . "\n";
     if (defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG) {
         $sError .= 'error code: ' . $intCode . "\n";
         $sError .= 'file: ' . $strFile . "\n";
         $sError .= 'line: ' . $intLine . "\n";
         if (!empty($sTrace)) {
             $sError .= "\n<br><strong>Trace</strong>: \n<br>{$sTrace}\n<br>";
         }
     }
     d('cp');
     /**
      * If this exception has E_USER_WARNING error code
      * then it was thrown when parsing some ajax-based
      * request.
      *
      * We then need to only send json array with
      * only one key 'exception'
      */
     if (E_USER_NOTICE === $e->getCode() || Request::isAjax()) {
         /**
          * if this exception was thrown when uploading
          * file to iframe, then we need to add 'true' as
          * the last (2nd arg) to fnSendJson
          */
         $a = array('exception' => $sError, 'errHeader' => 'Error', 'type' => get_class($e));
         if ($e instanceof Lampcms\FormException) {
             $a['fields'] = $e->getFormFields();
         }
         d('json array of exception: ' . print_r($a, 1));
         Responder::sendJSON($a);
     }
     d('$sError: ' . $sError);
     return $sError;
 }
コード例 #13
0
 public function __construct(array $response)
 {
     parent::__construct($response);
     $this->fill();
 }
コード例 #14
0
ファイル: Controller.php プロジェクト: hejxing/jt
 /**
  * 启动控制器
  *
  * @param string $uri 路径
  *
  * @return Controller
  */
 public static function run($uri)
 {
     $c = new self($uri);
     $c->cutURI();
     $c->dispatch();
     try {
         $c->execute();
     } catch (\Exception $e) {
         Error::exceptionHandler($e);
     } finally {
         if ($c->outputAllow) {
             Responder::write();
         }
     }
     return $c;
 }
コード例 #15
0
ファイル: Error.php プロジェクト: hejxing/jt
 /**
  * 捕获到的错误
  *
  * @param        $code
  * @param string $msg
  * @param bool   $fatal 是否致命错误
  * @param array  $param 传递的其它参数
  */
 protected static function error($code, $msg, $fatal, $param = [])
 {
     if ($fatal) {
         $method = '_' . $code;
     } else {
         $method = 'client_error';
     }
     $action = self::getAction($method);
     $action->header('code', $code);
     $action->header('msg', $msg);
     if (Controller::current()->getMime() === 'html') {
         $action->out('title', $action->getFromData('title') ?: '有错误发生');
         $action->out('code', $code);
         $action->out('msg', $msg);
         Controller::current()->setTemplate('error/error');
     }
     if ($fatal && RUN_MODE === 'develop') {
         $action->out('trace', self::getTrace());
     }
     $action->{$method}(...$param);
     Responder::write();
     //致命错误
     //if($fatal){
     die;
     //}
 }
コード例 #16
0
ファイル: AssetCollection.php プロジェクト: creolab/assets
 /**
  * Display all assets in collection as HTML tags
  * @return string
  */
 public function show()
 {
     $responder = new Responder($this);
     return $responder->show();
 }