zoukankan      html  css  js  c++  java
  • 12 版本升级接口开发 错误日志

    error.php


    <?php require_once('./common.php'); class ErrorLog extends Common { public function index() { $this->check(); $errorLog = isset($_POST['error_log']) ? $_POST['error_log'] : ''; if(!$errorLog) { return Response::show(401, '日志为空'); } $sql = "insert into error_log( `app_id`, `did`, `version_id`, `version_mini`, `error_log`, `create_time`) values( ".$this->params['app_id'].", '".$this->params['did']."', ".$this->params['version_id'].", ".$this->params['version_mini'].", '".$errorLog."', ".time()." )"; $connect = Db::getInstance()->connect(); if(mysql_query($sql, $connect)) { return Response::show(200, '错误信息插入成功'); } else { return Response::show(400, '错误信息插入失败'); } } } $error = new ErrorLog(); $error->index();

    common.php

    <?php
    /**
     * 处理接口公共业务
     */
    require_once('./response.php');
    require_once('./db.php');
    class Common {
        public $params;
        public $app;
        public function check() {
            $this->params['app_id'] = $appId = isset($_POST['app_id']) ? $_POST['app_id'] : '';
            $this->params['version_id'] = $versionId = isset($_POST['version_id']) ? $_POST['version_id'] : '';
            $this->params['version_mini'] = $versionMini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
            $this->params['did'] = $did = isset($_POST['did']) ? $_POST['did'] : '';
            $this->params['encrypt_did'] = $encryptDid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
            
            if(!is_numeric($appId) || !is_numeric($versionId)) {
                return Response::show(401, '参数不合法');
            }
            // 判断APP是否需要加密
            $this->app = $this->getApp($appId);
            if(!$this->app) {
                return Response::show(402, 'app_id不存在');
            }
            if($this->app['is_encryption'] && $encryptDid != md5($did . $this->app['key'])) {
                return Response::show(403, '没有该权限');
            }
        }
        
        public function getApp($id) {
            $sql = "select *
                    from `app`
                    where id = " . $id ."
                    and status = 1 
                    limit 1";
            $connect = Db::getInstance()->connect();
            $result = mysql_query($sql, $connect);
            return mysql_fetch_assoc($result);
        }
        
        public function getversionUpgrade($appId) {
            $sql = "select *
                    from `version_upgrade`
                    where app_id = " . $appId ."
                    and status = 1 
                    limit 1";
            $connect = Db::getInstance()->connect();
            $result = mysql_query($sql, $connect);
            return mysql_fetch_assoc($result);
        }
        
        /**
         * 根据图片大小组装相应图片
         * @param string $imageUrl
         * @param string $size
         */
        public function setImage($imageUrl, $size) {
            if(!$imageUrl) {
                return '';
            }
            if(!$size) {
                return $imageUrl;
            }
            
            $type = substr($imageUrl, strrpos($imageUrl, '.'));
            if(!$type) {
                return '';
            }
            $path = substr($imageUrl, 0, strrpos($imageUrl, '.'));
            
            return $path . '_' . $size . $type;
        }
    }
  • 相关阅读:
    java.lang.UnsatisfiedLinkError: No implementation found for
    target release 1.5 conflicts with default source release 1.7
    (转)makefile里PHONY的相关介绍
    Hint: A potential Change-Id was found, but it was not in the footer (last paragraph) of the commit message
    linux jdk版本随时切换
    提高Service的优先级
    第一章、数字图像的描述
    gluas图形处理——导读
    图像处理学习过程——网站,视频,书籍(长期更新)
    基数排序
  • 原文地址:https://www.cnblogs.com/hgj123/p/4361957.html
Copyright © 2011-2022 走看看