Ejemplo n.º 1
0
 public function avatarUpload()
 {
     try {
         $file = $this->request->file('image');
         $fileName = $file->getClientOriginalName();
         \Image::make($file)->save('uploads/avatars/' . $fileName);
         //上传图片至七牛
         $this->disk->put($fileName, fopen('uploads/avatars/' . $fileName, 'r'));
         //
         $imgUrl = $this->disk->downloadUrl($fileName);
         return return_message(true, $imgUrl);
     } catch (\Exception $e) {
         //图片上传失败
         return return_message(false, $e->getMessage());
     }
 }
Ejemplo n.º 2
0
function return_error($reason, $shard, $info, $query_id = null, $job_type = "store_resultset")
{
    return return_message($reason . ':' . $info, $shard, 'error', 0, 0, $query_id);
}
Ejemplo n.º 3
0
 private function broadcast($arg)
 {
     if (!$arg) {
         return;
     }
     $arg = (object) $arg;
     $conn = SimpleDAL::factory($arg->shard);
     if ($conn->my_error()) {
         return return_message($conn->my_error(), $arg->shard, $arg->query_id);
     }
     if (!$conn->my_select_db($arg->shard['db'])) {
         return return_message($conn->my_error(), $arg->shard, $arg->query_id);
     }
     $stmt = $conn->my_query($arg->sql);
     if (!$stmt) {
         return return_message($conn->my_error(), $arg->shard, $arg->query_id);
     }
     $last_insert_id = 0;
     if ($affected_row_count = $conn->my_affected_rows() == 0) {
         $affected_row_count = "0";
     }
     if (preg_match('/insert |last_insert_id/', $arg->sql)) {
         $last_insert_id = $conn->my_insert_id();
     }
     unset($conn);
     return return_message('success', $arg->shard, 'info', $affected_row_count, $last_insert_id, $arg->query_id);
 }
Ejemplo n.º 4
0
    }
}
if (isset($_POST['action'])) {
    $conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
    if (!$conn) {
        return_message(false, mysql_error());
    }
    if (!isset($_POST['username']) || !isset($_POST['password'])) {
        return_message(false, 'Username or password is empty.');
    }
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    if (strlen($password) != 32) {
        return_message(false, 'Invalid password encoding format.');
    }
    mysql_query('SET NAMES utf8');
    $query = mysql_db_query($mysql_db, "SELECT * FROM sqli1_users WHERE username='******' AND password='******'");
    if (!$query) {
        return_message(false, 'Username or password error.');
    } else {
        $rows = mysql_fetch_assoc($query);
        if (intval($rows['is_admin']) == 0) {
            return_message(false, 'Access Denied.');
        }
        $r = rand();
        $sess = md5("{$username}#" . $r);
        $f = fopen($sess, 'w');
        fclose($f);
        return_message(true, $sess);
    }
}