rabin 1 일 전
부모
커밋
b2a1bd6dc2
6개의 변경된 파일78개의 추가작업 그리고 1개의 파일을 삭제
  1. 77 0
      app/Api/Manage.php
  2. 0 0
      app/Lib/Tool.php
  3. 0 0
      app/Lib/Tool/Core.php
  4. 0 0
      app/Lib/Tool/Gd.php
  5. 0 0
      app/Lib/Tool/Mg.php
  6. 1 1
      index.php

+ 77 - 0
app/Api/Manage.php

@@ -0,0 +1,77 @@
+<?php namespace Image\Api;
+use Dever;
+use Manage\Lib\Auth;
+use Upload\Lib\Util;
+use Upload\Lib\Save;
+class Manage
+{
+    public function set()
+    {
+        $data = array();
+        $data['authorization'] = Dever::input('authorization');
+        $data['id'] = Dever::input('id');
+        $data['state'] = Dever::input('state');
+        $data['name'] = Dever::input('name');
+        $data['pic'] = Dever::input('pic');
+        $data['type'] = Dever::input('type');
+        $data['wh'] = Dever::input('wh');
+        $data['group_id'] = Dever::load(Util::class)->getGroup();
+        $data['user_id'] = Dever::load(Util::class)->getUser();
+        $data['ratio'] = 16 / 9;
+        if ($data['wh']) {
+            if (strstr($data['wh'], '*')) {
+                $data['ratio'] = $this->ratio('*', $data['wh']);
+            } elseif (strstr($data['wh'], 'x')) {
+                $data['ratio'] = $this->ratio('x', $data['wh']);
+            } elseif (strstr($data['wh'], 'X')) {
+                $data['ratio'] = $this->ratio('X', $data['wh']);
+            } else {
+                $data['ratio'] = 1;
+            }
+        }
+        $data['search_cate'] = 1;
+        $data['param'] = '';
+        if (strstr($data['pic'], '?')) {
+            $temp = explode('?', $data['pic']);
+            $data['pic'] = $temp[0];
+        }
+        if (strstr($data['pic'], '_cr_')) {
+            $ext = '.' . pathinfo($data['pic'], PATHINFO_EXTENSION);
+            $temp = explode('_cr_', $data['pic']);
+            $param = $data['pic'];
+            $data['pic'] = $temp[0];
+            $data['param'] = str_replace($ext, '', $temp[1]);
+        }
+        $data['submit'] = Dever::url('image/manage.cropper');
+        Dever::view('set', $data);
+    }
+
+    public function cropper()
+    {
+        $send['param'] = array();
+        $input = Dever::input();
+        foreach ($input as $k => $v) {
+            if (strpos($k, 'param_') === 0) {
+                $send['param'][$k] = $v;
+            }
+        }
+        $cate = 3;
+        $group_id = Dever::input('group_id');
+        $user_id = Dever::input('user_id');
+        $id = Dever::input('id');
+        $source = Dever::input('img');
+        $dest = Dever::input('pic');
+        $dest = explode('/upload/', $dest);
+        $dest = end($dest);
+        $dest .= '_cr_' . implode('_', $send['param']) . '.png';
+        $result = Dever::load(Save::class)->init($id, $cate, $group_id, $user_id)->act($source, false, false, $dest);
+        return $result;
+    }
+
+    private function ratio($str, $wh)
+    {
+        $temp = explode($str, $wh);
+        $ratio = $temp[0] / $temp[1];
+        return $ratio;
+    }
+}

+ 0 - 0
lib/Tool.php → app/Lib/Tool.php


+ 0 - 0
lib/Tool/Core.php → app/Lib/Tool/Core.php


+ 0 - 0
lib/Tool/Gd.php → app/Lib/Tool/Gd.php


+ 0 - 0
lib/Tool/Mg.php → app/Lib/Tool/Mg.php


+ 1 - 1
index.php

@@ -1,5 +1,5 @@
 <?php
-define('DEVER_APP_NAME', 'image');
+define('DEVER_APP_NAME', 'Image');
 define('DEVER_APP_LANG', '图片处理');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 include(DEVER_APP_PATH . '../../boot.php');