public static function newModle()
 {
     // $modArr = preg_split('/[_\/.]/', trim(BFW_Request::get($modTag) ? BFW_Request::get($modTag) : 'index'));
     $modArr = explode('.', trim(BFW_Request::get(MOD_TAG) ? BFW_Request::get(MOD_TAG) : 'index'));
     foreach ($modArr as $k => $v) {
         if (!trim($v)) {
             unset($modArr[$k]);
         } else {
             $modArr[$k] = ucfirst($v);
         }
     }
     $fun = end($modArr);
     if (isset($modArr[1])) {
         array_pop($modArr);
     }
     $mod = join('/', $modArr);
     try {
         $module = 'Mod_' . str_replace('/', '_', $mod);
         if (class_exists($module)) {
             $modClass = BFW_Func::apcNewClass($module);
             $modClass->modDir = MODULE_PATH . '/' . $mod;
             return $modClass;
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
示例#2
0
 private static function _execute($sql, $params)
 {
     try {
         if (!self::$sqlDebug) {
             self::$sqlDebug = BFW_Request::get('sqlDebug');
         }
         if (self::$sqlDebug) {
             $startTime = BFW_Func::getMicroTime();
         }
         self::$sth = self::$pdo[self::$db]->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
         self::$sth->execute($params);
         if (self::$sqlDebug) {
             $endTime = BFW_Func::getMicroTime();
             $times = $endTime - $startTime;
             if (preg_match('/^SELECT/i', $sql)) {
                 $sql = self::_getSelectSqlString($sql, $params);
                 $explain = self::_getExpain('EXPLAIN ' . $sql);
                 BFW_App::$appGlobal['sqlDebug'][self::$db][] = array('sql' => $sql, 'explain' => $explain, 'time' => number_format($times, 10));
             }
         }
     } catch (PDOException $e) {
         $traceArr = $e->getTrace();
         $content = '[' . date('Y-m-d H:i:s') . ']' . "\n";
         foreach ($traceArr as $k => $v) {
             $content .= '# Error in file "' . $v['file'] . '" on line "' . $v['line'] . "\"\n";
         }
         $content .= '# ' . $e->getMessage() . "\n" . '# SQL String: ' . $sql . "\n\n";
         die($content);
     }
 }
示例#3
0
 public static function run()
 {
     $initMemory = memory_get_usage();
     $mod = BFW_Request::get(MOD_TAG);
     if ($mod) {
         $modArr = explode('.', $mod);
         $module = end($modArr);
     }
     $method = strstr($mod, '.') ? $module : __FUNCTION__;
     $module = BFW_Controler::newModle();
     if ($module) {
         $module->{$method}();
     }
     self::_getSqlDebug();
     self::_getIncludeFile();
     BFW_Func::getUsedMemory($initMemory, get_class($module) . '::' . $method);
 }
示例#4
0
 private static function _getLink($groupId, $pageId, $totalPage, $totalGroup)
 {
     $language = 'language_' . BFW_Config::get('site.language');
     $urlGleft = '';
     $condition = BFW_Request::server('QUERY_STRING') ? '&' . BFW_Request::server('QUERY_STRING') : '';
     $condition = preg_replace('/&?pageId=[0-9]*/', '', $condition);
     $condition = preg_replace('/&?groupId=[0-9]*/', '', $condition);
     $minpage = ($groupId - 1) * self::$group + 1;
     $maxpage = $minpage + self::$group - 1;
     $fileName = BFW_Request::server('PHP_SELF');
     if ($maxpage > $totalPage) {
         $maxpage = $totalPage;
     }
     if ($groupId == 1) {
         $urlPleft = '';
     } else {
         $group1 = $groupId - 1;
         if (self::$callJs) {
             $gLeftHref = 'href="#" onclick="' . self::$callJs . '(\'groupId=' . $group1 . $condition . '\')"';
         } else {
             $gLeftHref = 'href="' . $fileName . '?groupId=' . $group1 . $condition . '"';
         }
         $urlGleft = '<a ' . $gLeftHref . ' title="' . BFW_Config::get($language . '.page.up') . self::$group . BFW_Config::get($language . '.page.page') . '">&lt;&lt;</a>';
     }
     if ($pageId == 1) {
         $urlPleft = '';
     } else {
         $page1 = $pageId - 1;
         if (self::$callJs) {
             $pLeftHref = 'href="#" onclick="' . self::$callJs . '(\'pageId=' . $page1 . $condition . '\')"';
         } else {
             $pLeftHref = 'href="' . $fileName . '?pageId=' . $page1 . $condition . '"';
         }
         $urlPleft = '<a ' . $pLeftHref . ' title="' . BFW_Config::get($language . '.page.prev') . '">&lt;</a>';
     }
     if ($pageId >= $totalPage) {
         $urlPright = '';
     } else {
         $page2 = $pageId + 1;
         if (self::$callJs) {
             $pRightHref = 'href="#" onclick="' . self::$callJs . '(\'pageId=' . $page2 . $condition . '\')"';
         } else {
             $pRightHref = 'href="' . $fileName . '?pageId=' . $page2 . $condition . '"';
         }
         $urlPright = '<a ' . $pRightHref . ' title="' . BFW_Config::get($language . '.page.next') . '">&gt;</a>';
     }
     if ($groupId >= $totalGroup) {
         $urlGright = '';
     } else {
         $group2 = $groupId + 1;
         if (self::$callJs) {
             $gRightHref = 'href="#" onclick="' . self::$callJs . '(\'groupId=' . $group2 . $condition . '\')"';
         } else {
             $gRightHref = 'href="' . $fileName . '?groupId=' . $group2 . $condition . '"';
         }
         $urlGright = '<a ' . $gRightHref . ' title="' . BFW_Config::get($language . '.page.down') . self::$group . BFW_Config::get($language . '.page.page') . '">&gt;&gt;</a>';
     }
     $sumi = '<div class="page">';
     $sumi .= $urlGleft . $urlPleft;
     for ($i = $minpage; $i <= $maxpage; $i++) {
         if ($i == $pageId) {
             $sumi .= '<span class="currentPage">' . $i . '</span>';
         } else {
             if (self::$callJs) {
                 $pageHref = 'href="#" onclick="' . self::$callJs . '(\'pageId=' . $i . $condition . '\')"';
             } else {
                 $pageHref = 'href="' . $fileName . '?pageId=' . $i . $condition . '"';
             }
             $sumi .= '<a ' . $pageHref . '>' . $i . '</a>';
         }
     }
     $sumi .= $urlPright . $urlGright;
     $sumi .= '</div>';
     //if ($maxpage == 1) $sumi = '';
     return $sumi;
 }