Exemple #1
0
 public function errorAction($exception)
 {
     $debugs = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 50);
     $log = [];
     $log[] = '[' . $exception->getCode() . ']' . $exception->getMessage();
     $log[] = '------------------------------------------------------------';
     $log[] = sprintf("%-4s%-20s%-6s%-s", '#', 'File', 'Line', 'Method');
     $i = 1;
     foreach ($debugs as $row) {
         $method = (!empty($row['class']) ? $row['class'] . $row['type'] : '') . $row['function'];
         $method .= '(';
         foreach ($row['args'] as $arg) {
             if (is_array($arg)) {
                 $method .= 'array, ';
             } elseif (is_object($arg)) {
                 $method .= 'object, ';
             } else {
                 $method .= $arg . ', ';
             }
         }
         $method .= 'NULL)';
         $log[] = sprintf("%-4s%-20s%-6s%-s", $i, str_replace(MAIN_PATH, '', $row['file']), $row['line'], $method);
         $i++;
     }
     \yk\log::runlog(implode("\n", $log), 'exception', true);
     $this->appendData(['code' => $exception->getCode(), 'msg' => $exception->getMessage()]);
 }
Exemple #2
0
     $ret = $func($dstim, MAIN_PATH . '/data/tmp/' . $file);
     imagedestroy($dstim);
     imagedestroy($im);
     return $ret;
 }
 public static function movetmp2upload(&$file)
 {
     $tmp = MAIN_PATH . '/data/tmp/' . $file;
     if (file_exists($tmp)) {
         $path = self::_create();
         $file = $path . $file;
         if (rename($tmp, MAIN_PATH . '/public/' . $file)) {
             return true;
         } else {
             \yk\log::runlog('file upload error: move failure src:' . $file . ', dst: ' . $file, 'upload');
             return false;
         }
Exemple #3
0
 public static function query($id, $sql, $args = null, $silent = false)
 {
     if (!empty($args)) {
         $newsql = '';
         $i = 0;
         $pos = 0;
         $count = count($args);
         for ($i = 0, $len = strlen($sql); $i < $len; $i++) {
             if ($sql[$i] != '%') {
                 $newsql .= $sql[$i];
             } else {
                 switch ($sql[$i + 1]) {
                     case 't':
                         $newsql .= '`' . $args[$pos] . '`';
                         break;
                     case 'd':
                         $newsql .= intval($args[$pos]);
                         break;
                     case 's':
                         $newsql .= self::quote(is_array($args[$pos]) ? serialize($args[$pos]) : $args[$pos]);
                         break;
                     case 'f':
                         $newsql .= sprintf('%f', $args[$pos]);
                         break;
                     case 'i':
                         $newsql .= $args[$pos];
                         break;
                     case 'n':
                         $newsql .= is_array($args[$pos]) ? implode(',', self::quote($args[$pos])) : self::quote($args[$pos]);
                         break;
                     default:
                         $newsql .= $sql[$i] . $sql[$i + 1];
                         $pos--;
                         break;
                 }
                 $pos++;
                 $i++;
             }
         }
         $sql = $newsql;
     } else {
         $newsql = $sql;
     }
     //echo $newsql, PHP_EOL;
     $result = self::link($id)->query($newsql);
     if (!$result && !$silent) {
         $error = self::link($id)->error;
         //free trans
         if (!empty(self::$_transactiones)) {
             foreach (self::$_transactiones as $_id => $status) {
                 if ($status) {
                     self::link($_id)->query("rollback");
                 }
             }
         }
         \yk\log::runlog($newsql, 'sql');
         throw new \yk\error($error);
     }
     return $result;
 }