Ejemplo n.º 1
0
 function command_app()
 {
     if (!($app_id = array_shift(func_get_args()))) {
         echo "用法是: dev:new app 应用名";
         return false;
     }
     $app_dir = APP_DIR . "/" . $app_id;
     echo "生成目录结构\n";
     @mkdir($app_dir);
     $src = APP_DIR . "/dev/demo";
     echo "拷贝文件\n";
     core_file::cp($src, $app_dir);
     echo "更新配置文件\n";
     $replace_map = array('APP_ID' => $app_id, 'APP_NAME' => $app_id, 'APP_DESC' => "app简短的介绍,请在{$app_dir}/app.xml中修改这段信息", 'APP_AUTHOR' => "app作者的信息", 'DEFAULT_CTL' => 'default');
     core_file::replace_in_file("{$app_dir}/app.xml", $replace_map);
     core_file::replace_in_file("{$app_dir}/admin/controller/default.php", $replace_map);
     echo "安装app\n";
     kernel::single('core_application_manage')->install($app_id);
 }
Ejemplo n.º 2
0
 /**
  * 将当天之前的数据归档到logs文件夹
  * @since 2
  * @param string $log_dir 日志保存目录路径
  * @return boolean
  */
 public function files($log_dir)
 {
     $re = false;
     $sql = 'SELECT `id`,`log_date`,`log_ip`,`log_message` FROM `' . $this->table_name . '` ORDER BY `log_date` ASC LIMIT ?,30';
     $sth = $this->db->prepare($sql);
     $limit_page = 0;
     //遍历数据表,将记录按照时间顺序保存到文件
     do {
         $sth->bindParam(1, $limit_page, PDO::PARAM_INT);
         $sth->execute();
         $res = $sth->fetchAll(PDO::FETCH_ASSOC);
         if (is_array($res) && count($res) > 0) {
             foreach ($res as $k => $v) {
                 $date_ym = substr($v['log_date'], 0, 4) . substr($v['log_date'], 5, 2);
                 $date_d = substr($v['log_date'], 8, 2);
                 $log_file_dir = $log_dir . DS . $date_ym;
                 if (core_file::new_dir($log_file_dir) == false) {
                     return $re;
                 }
                 $log_file = $log_file_dir . DS . $date_d . '.log';
                 $log_message = $v['log_date'] . "\t" . $v['log_ip'] . "\t" . $v['log_message'] . "\r\n";
                 if (core_file::edit_file($log_file, $log_message, true) == false) {
                     return $re;
                 }
             }
         }
         $limit_page++;
     } while (is_array($res) && count($res) > 0);
     //清空日志数据表
     $sql_trash = 'TRUNCATE TABLE `' . $this->table_name . '`';
     if ($this->db->exec($sql_trash) == true) {
         $re = true;
     }
     return $re;
 }