| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | <?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;    }}
 |