/**
  * Read HL7 file
  * @param $fileName Filename
  */
 function readFile($fileName)
 {
     $message = new CHL7v2Message();
     try {
         $fileContents = file_get_contents($fileName);
         $message->parse($fileContents);
     } catch (Exception $e) {
         exceptionHandler($e);
         return;
     }
     return $message;
 }
示例#2
0
             // get tokens
             try {
                 $twitterLib = new TwitterLib(CONSUMER_KEY, CONSUMER_SECRET);
                 $response = $twitterLib->oAuthAccessToken($oauth_token, $oauth_verifier);
             } catch (Exception $e) {
                 exceptionHandler($e);
             }
             if (isset($response) && isset($response['oauth_token'])) {
                 // Save data returned
                 $twit->setTokens($response['oauth_token'], $response['oauth_token_secret']);
                 $twit->setDetails($response['user_id'], $response['screen_name']);
                 // Poll and eat it so we don't flood
                 try {
                     $twit->poll();
                 } catch (Exception $e) {
                     exceptionHandler($e);
                 }
                 // Notify the user
                 send($sock, "PRIVMSG {$nick} :Registration complete!");
                 // Save the object
                 $twit->save(SAVE_DIR . "/{$twit->name}.save");
                 unset($response);
             } else {
                 send($sock, "PRIVMSG {$nick} :Pin incorrect. Please try again!");
             }
         }
     }
     break;
 case 'addchan':
     if (count($words) < 4 || trim($words[3]) == '') {
         send($sock, "PRIVMSG {$nick} :Syntax: !addchan <bot_username> <bot_password> <channel>");
示例#3
0
function errorHandler($errno_, $errstr_, $errfile_, $errline_)
{
    $errortype = array(E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', E_DEPRECATED => 'E_DEPRECATED', E_USER_DEPRECATED => 'E_USER_DEPRECATED');
    exceptionHandler(new \ErrorException($errortype[$errno_] . ' - ' . $errstr_, $errno_, 1, $errfile_, $errline_));
}
示例#4
0
 /**
  * Index pages recursively and get an array (list) of pages slug
  *
  * @param boolean ($listHidden) List hidden files & folders
  * @param string ($pagesPath) Pages path
  * @throws IOException If the pages directory does not exists
  * @return array Array of pages paths
  */
 public function index($listHidden = false, $pagesPath = '')
 {
     $pages = [];
     try {
         // Filter secret (.*) and hiddent files (_*)
         $filter = function ($current) use($listHidden) {
             return ($listHidden || $current->getFilename()[0] !== '_') && $current->getFilename()[0] !== '.';
         };
         $ext = $this->fileExtension;
         (new Files($this->folder))->index($pagesPath, function (\SplFileInfo $file, $dir) use(&$pages, $ext) {
             $currExt = '.' . $file->getExtension();
             // If files have the right extension
             if ($currExt === $ext) {
                 if ($dir) {
                     $dir = trim($dir, '/\\') . '/';
                 }
                 $pages[] = $dir . $file->getBasename($currExt);
                 // page path
             }
         }, $filter);
         return $pages;
     } catch (IOException $e) {
         exceptionHandler($e);
     }
 }
示例#5
0
        $configUser = posix_getpwuid(fileowner(OC::$configDir . 'config.php'));
        if ($user['name'] !== $configUser['name']) {
            echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
            echo "Current user: "******"Owner of config.php: " . $configUser['name'] . PHP_EOL;
            echo "Try adding 'sudo -u " . $configUser['name'] . " ' to the beginning of the command (without the single quotes)" . PHP_EOL;
            exit(0);
        }
    }
    $oldWorkingDir = getcwd();
    if ($oldWorkingDir === false) {
        echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
        echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL;
    } else {
        if ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) {
            echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
            echo "Can't change to ownCloud root directory." . PHP_EOL;
            exit(1);
        }
    }
    if (!function_exists('pcntl_signal') && !in_array('--no-warnings', $argv)) {
        echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php" . PHP_EOL;
    }
    $application = new Application(\OC::$server->getConfig(), \OC::$server->getEventDispatcher(), \OC::$server->getRequest());
    $application->loadCommands(new ArgvInput(), new ConsoleOutput());
    $application->run();
} catch (Exception $ex) {
    exceptionHandler($ex);
} catch (Error $ex) {
    exceptionHandler($ex);
}
 /**
  * Proceed the synchronisation of this mouvement
  * 
  * @param bool $mark Tell wether it shoud generate a trigger mark
  * 
  * @return bool Job-done value
  */
 function proceed($mark = true)
 {
     // Pre trace
     $this->trace($this->data, "Données à traiter dans le mouvement");
     $this->trace(join(" ", $this->changedFields), "Données modifiées");
     // Main syncing bloc
     try {
         $this->synchronize();
         $return = true;
     } catch (Exception $e) {
         if (self::$verbose) {
             exceptionHandler($e);
         }
         $return = false;
     }
     // Generate trigger mark
     if ($mark) {
         $this->markRow();
     }
     // Post trace
     $this->trace($this->data, "Données non traitées dans le mouvement");
     return $return;
 }
function errorHandler($no, $str, $file, $line)
{
    $e = new ErrorException($str, $no, 0, $file, $line);
    exceptionHandler($e);
}
示例#8
0
文件: Common.php 项目: miaokuan/wee
 public static function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
 {
     $l = error_reporting();
     if ($l & $errno) {
         $exit = false;
         switch ($errno) {
             case E_USER_ERROR:
                 $type = 'Fatal Error';
                 $exit = true;
                 break;
             case E_USER_WARNING:
             case E_WARNING:
                 $type = 'Warning';
                 break;
             case E_USER_NOTICE:
             case E_NOTICE:
             case @E_STRICT:
                 $type = 'Notice';
                 break;
             case @E_RECOVERABLE_ERROR:
                 $type = 'Catchable';
                 break;
             default:
                 $type = 'Unknown Error';
                 $exit = true;
                 break;
         }
         $exception = new \ErrorException($type . ': ' . $errstr, 0, $errno, $errfile, $errline);
         if ($exit) {
             exceptionHandler($exception);
             exit(1);
         } else {
             throw $exception;
         }
     }
     return false;
 }
示例#9
0
SW_DataStoreClass::create($dsinfo[0], $dsinfo[1], $scrapername, $runid, $attachables, $verification_key);
// the following might be the only way to intercept syntax errors
//$errors = array();
//parsekit_compile_file($script, $errors);
// intercept errors for stack dump
// refer to http://php.net/manual/en/function.set-error-handler.php
function errorHandler($errno, $errstr, $errfile, $errline)
{
    // if error has been surpressed with an @
    // see: http://php.net/manual/en/function.set-error-handler.php
    if (error_reporting() == 0) {
        return;
    }
    global $script;
    $etb = errorParserStack($errno, $errstr, $script);
    scraperwiki::sw_dumpMessage($etb);
    return true;
}
set_error_handler("errorHandler", E_ALL & ~E_NOTICE);
// this is for errors, not exceptions (eg 1/0)
error_reporting(E_NOTICE);
// don't display default error messages for ones we are sending via errorHandler, avoiding duplicates
set_time_limit(160);
date_default_timezone_set('Europe/London');
try {
    // works also as include or eval.  However no way to trap syntax errors
    require $script;
} catch (Exception $e) {
    $etb = exceptionHandler($e, $script);
    scraperwiki::sw_dumpMessage($etb);
}
示例#10
0
文件: Parvula.php 项目: zorca/parvula
 /**
  * Get user config
  * @return array
  */
 public static function getUserConfig()
 {
     try {
         $confFs = new Files(DATA);
         $config = $confFs->read(Config::get('userConfig') . '.' . Config::get('fileExtension'), 'parseConfigData');
     } catch (IOException $e) {
         exceptionHandler($e);
     }
     return $config;
 }