public function pic($act = NULL, $uid = NULL) { $Public = A('Index', 'Public'); //main import('ORG.Net.FileSystem'); $sys = new FileSystem(); import('ORG.Net.UploadFile'); $up = new UploadFile(); $up->allowTypes = array('image/pjpeg', 'image/jpeg', 'image/x-png', 'image/png', 'image/gif'); $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $up->savePath = ROOT . '/' . $upload . '/Face/'; $up->maxSize = C('UPLOAD_SIZE'); $up->charset = 'UTF-8'; $up->autoSub = true; if ($act != NULL) { $act = intval($act); } if ($act == 1) { $role = $Public->check('Upload', array('p')); if ($role < 0) { echo $role; exit; } $filename = I('hi'); if ($up->upload()) { $info = $up->getUploadFileInfo(); if ($filename) { $path = ROOT . '/' . $upload . '/Face/' . $filename; if (file_exists($path)) { $df = $sys->delFile($path); } } echo $info[0]['savename']; unset($info); } else { echo -1; } } else { $this->assign('uid', $uid); $this->assign('uniqid', uniqid()); $this->assign('upload', $upload); $this->display(); } unset($Public, $sys, $upload, $up); }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'Linkage'; $Loop->field = '_parentId,id,text,sort,layer,deep'; $Loop->order = 'sort,id'; $Loop->isparnet = true; $Loop->where = '`status`=1'; $Loop->mode = 'son'; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $linkage = M('Linkage'); $info = $Loop->rowLevel(NULL); //dump($info); array_unshift($info, array('_parentId' => 0, 'id' => 0, 'text' => '', 'code' => '', 'sort' => 0)); $json_data = json_encode($info); $path = RUNTIME_PATH . 'Data/Json'; $put_json = $Write->write($path, $json_data, 'Linkage_data'); $info[0]['text'] = ''; $json_data = json_encode($info); $put_json = $Write->write($path, $json_data, 'Linkage_notit_data'); $sele = $linkage->field('id,text,code,val')->where('`status`=1')->select(); $Loop->field = 'id,text,sort'; $Loop->order = 'sort,id'; $Loop->mode = 'noson'; $path = RUNTIME_PATH . 'Data/Json/Linkage'; $sinfo = array(); $json_datas = json_encode($sinfo); $Write->write($path, $json_datas, 'null_data'); foreach ($sele as $t) { $has_son = $linkage->where('_parentId=' . $t['id'])->count(); if ($has_son > 0) { $sinfo = $Loop->rowLevel($t['id']); //dump($sinfo);exit; $json_datas = json_encode($sinfo); $Write->write($path, $json_datas, $t['code'] . '_data'); $Write->write($path, $json_datas, $t['id'] . '_data'); array_unshift($sinfo, array('id' => 0, 'text' => '', 'sort' => 0)); $json_datas = json_encode($sinfo); $Write->write($path, $json_datas, $t['code'] . '_notit_data'); $Write->write($path, $json_datas, $t['id'] . '_notit_data'); } } if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } unset($info, $json_datas, $path, $linkage, $Loop, $Write, $sele, $sinfo, $sys); }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'User_group_table'; $Loop->field = 'id,name as text'; $Loop->order = 'access'; $Loop->where = '`status`=1'; $Loop->mode = 'noson'; $Loop->isparnet = false; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $group = M('User_group_table'); $info = $Loop->rowLevel(); $json_data = json_encode($info); $path = RUNTIME_PATH . 'Data/Json'; $put_json = $Write->write($path, $json_data, 'Group_data'); if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } unset($group, $info, $json_data, $path, $Loop, $Write, $sys); }
/** * 打包下载备份包 *@param $file 文件路劲 *@examlpe */ public function downzip($file) { import('ORG.Util.phpzip'); $addzip = new phpzip(); import('ORG.Net.FileSystem'); $path = new FileSystem(); $path->root = ITEM; $path->charset = C('CFG_CHARSET'); load("@.download"); //main $file = strval($file); $realpath = CONF_PATH . 'Backup/' . $file; $bakfile = RUNTIME_PATH . 'Temp/Zip/'; if (!file_exists($bakfile)) { $path->putDir($bakfile); } $zipname = 'Backup_' . $file . '.zip'; $zippath = $bakfile . $zipname; $addzip->zip($realpath, $zippath); if (file_exists($zippath)) { download($zippath); $path->delFile($zippath); } unset($addzip, $path); }
/** * 清空所以缓存数,并重新生成Json *@examlpe */ public function cache() { import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); R(GROUP_NAME . '/User/json', array(NULL)); R(GROUP_NAME . '/Comy/json', array(NULL)); R(GROUP_NAME . '/Part/json', array(NULL)); R(GROUP_NAME . '/Client/json', array(NULL)); R(GROUP_NAME . '/Linkage/json', array(NULL)); R(GROUP_NAME . '/Group/json', array(NULL)); R(GROUP_NAME . '/Menu/json', array(NULL)); } echo 1; unset($sys, $field_path, $temp_path); }
/** * 删除数据 *@examlpe */ public function del() { import('ORG.Net.FileSystem'); $sys = new FileSystem(); $Public = A('Index', 'Public'); $role = $Public->check('Bug', array('d')); if ($role < 0) { echo $role; exit; } //main $str_id = I('id'); $str_id = strval($str_id); $str_id = substr($str_id, 0, -1); $arr_id = explode(',', $str_id); $Bug = D('Bug_table'); $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $pass = 0; $fail = 0; $uid = $_SESSION['login']['se_id']; $arr_ids = $arr_id; if ($role != 'all' && !in_array('a', $role)) { foreach ($arr_ids as $k => $id) { $user_id = $Bug->where('id=' . $id)->getField('user_id'); if ($uid != $user_id) { echo 2; exit; } } } foreach ($arr_id as $id) { $files = $Bug->where('id=' . $id)->getField('files'); $del = $Bug->relation(true)->delete($id); if ($del) { $path = ROOT . '/' . $upload . '/' . $files; if ($files && file_exists($path)) { $sys->delFile($path); } $pass++; } else { $fail++; } } unset($str_id, $arr_id, $arr_ids, $arr_creator); if ($pass == 0) { echo 0; } else { echo 1; } $pass = 0; $fail = 0; unset($Bug, $Public); }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $result = M(); $user = M('User_table'); $group = M('User_group_table'); $user_table = C('DB_PREFIX') . 'user_table'; $main_table = C('DB_PREFIX') . 'user_main_table'; $path = RUNTIME_PATH . 'Data/Json'; $ginfo = $group->field('CONCAT(\'top_\',id) as id,name as text,\'open\' as state')->where('status=1 or id=1')->order('access desc')->select(); $infos = $result->table($user_table . ' as t1')->field('t1.id,t1.username as text,t2.group_id')->join(' join ' . $main_table . ' as t2 on t1.id=t2.user_id')->where('t1.status=1')->order('convert(text using gbk) asc')->select(); $nginfo = $ginfo; $new_info = array(); foreach ($ginfo as $k => $t) { $gid = str_replace('top_', '', $t['id']); $infos = $result->table($user_table . ' as t1')->field('t1.id,t1.username as text,t2.group_id')->join(' join ' . $main_table . ' as t2 on t1.id=t2.user_id')->where('t1.status=1 and t2.group_id=' . $gid)->order('convert(text using gbk) asc')->select(); $ginfo[$k]['children'] = $infos; $ninfos = $result->table($user_table . ' as t1')->field('t1.username as id,t1.username as text,t2.group_id')->join(' join ' . $main_table . ' as t2 on t1.id=t2.user_id')->where('t1.status=1 and t2.group_id=' . $gid)->order('convert(text using gbk) asc')->select(); $nginfo[$k]['children'] = $ninfos; } $head = array('id' => 0, 'text' => ''); array_unshift($ginfo, $head); $json_data = json_encode($ginfo); $put_json5 = $Write->write($path, $json_data, 'User_tree_data'); $json_data = json_encode($nginfo); $put_json6 = $Write->write($path, $json_data, 'User_nametree_data'); $info = $user->field('id,username as text')->where('status=1')->order('convert(text using gbk) asc')->select(); //array_unshift($info,$head); $json_data = json_encode($info); //dump($info); $path = RUNTIME_PATH . 'Data/Json'; $put_json = $Write->write($path, $json_data, 'User_data'); $info = $user->field('id as id,username as text')->where('status=1')->order('convert(text using gbk) asc')->select(); $head = array('id' => 0, 'text' => ' '); array_unshift($info, $head); $json_data = json_encode($info); $put_json2 = $Write->write($path, $json_data, 'User_notit_data'); $info = $user->field('id,username as text')->where('status=1 and id<>1')->order('convert(text using gbk) asc')->select(); //array_unshift($info,$head); $json_data = json_encode($info); $put_json3 = $Write->write($path, $json_data, 'User_noadmin_data'); if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } unset($info, $json_data, $path, $Loop, $Write, $sys); }
/** * 删除附件 *@examlpe */ public function delfile() { $Public = A('Index', 'Public'); $Log = A('Log', 'Public'); $role = $Public->check('Report', array('d')); if ($role < 0) { echo $role; exit; } import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $files_table = M('Report_files_table'); $report_table = M('Report_table'); $id = intval(I('id')); $uid = intval(I('uid')); $file = I('path'); $path = ROOT . $upload . '/' . $file; $userid = $_SESSION['login']['se_id']; $username = $_SESSION['login']['se_user']; if ($userid != $uid) { echo 2; exit; } $rid = $files_table->where('id=' . $id)->getField('rid'); $info = $report_table->where('id=' . $rid)->find(); $del = $files_table->delete($id); if ($del == 1) { if ($file && file_exists($path)) { $sys->delFile($path); } $descrtption = $username . '删除了关于BUG编号为:' . $info['bugno'] . '的附件'; $log_data = array('pro_id' => $info['pid'], 'descrtption' => $descrtption); $Log->actLog($log_data); echo 1; } else { echo 0; } }
/** * 新增与更新数据 *@param $act add为新增、edit为编辑 *@param $go 为1时,获取post *@param $id 传人数据id *@examlpe */ public function add($act = NULL, $go = false, $id = NULL) { $Write = A('Write', 'Public'); //main $config = M('Config'); if ($go == false) { $this->assign('uniqid', uniqid()); if ($act == 'add') { $this->assign('act', 'add'); $this->display(); } else { if (!is_int((int) $id)) { $id = NULL; $this->show('无法获取ID'); } else { $map['id'] = array('eq', $id); $info = $config->where($map)->find(); unset($map); if ($info['types'] == 'between') { $info['opts'] = unserialize($info['opts']); } elseif ($info['types'] == 'select') { $sopt = ''; $str_opt = htmlspecialchars_decode($info['opts']); $arr_opt = explode('|', $str_opt); foreach ($arr_opt as $ss) { if (strstr($ss, '=>')) { list($sk, $sv) = explode('=>', $ss); if ($info['vals'] == $sk) { $selected = 'selected="selected"'; } else { $selected = ''; } $sopt .= '<option value="' . $sk . '" ' . $selected . '>' . $sv . '</option>'; unset($sk, $sv); } else { if ($info['vals'] == $ss) { $selected = 'selected="selected"'; } else { $selected = ''; } $sopt .= '<option value="' . $ss . '" ' . $selected . '>' . $ss . '</option>'; } } $this->assign('sopt', $sopt); unset($str_opt, $arr_opt); $sopt = ''; } elseif ($info['types'] == 'more') { $mopt = ''; $smopt = array(); $selected = ''; $str_opt = htmlspecialchars_decode($info['opts']); $arr_opt = explode('|', $str_opt); $arr_val = explode(',', $info['vals']); foreach ($arr_opt as $ss) { if (strstr($ss, '=>')) { list($sk, $sv) = explode('=>', $ss); if (in_array($sk, $arr_val)) { //$smopt[] = $sk; $selected = 'selected="selected"'; } else { $selected = ''; } $mopt .= '<option value="' . $sk . '" ' . $selected . '>' . $sv . '</option>'; unset($sk, $sv); } else { if (in_array($ss, $arr_val)) { //$smopt[] = $ss; $selected = 'selected="selected"'; } else { $selected = ''; } $mopt .= '<option value="' . $ss . '" ' . $selected . '>' . $ss . '</option>'; } } $this->assign('mopt', $mopt); $this->assign('smopt', $smopt); unset($str_opt, $arr_opt, $arr_val); $mopt = ''; } $this->assign('id', $id); $this->assign('act', 'edit'); $this->assign('info', $info); $this->display(); unset($info); } } } else { $data = $config->create(); $data['keyword'] = preg_replace("/[\"\\']/", "", $data['keyword']); switch ($data['types']) { case 'char': $data['opts'] = strval($data['opts']); $data['vals'] = $data['opts']; break; case 'int': $data['opts'] = floatval($data['opts']); $data['vals'] = $data['opts']; break; case 'bool': $data['opts'] = intval($data['opts']); $data['vals'] = $data['opts']; break; case 'upload': import('ORG.Net.UploadFile'); $up = new UploadFile(); $up->allowTypes = array('image/pjpeg', 'image/jpeg', 'image/x-png', 'image/png', 'image/gif', 'image/bmp'); $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $up->savePath = ROOT . '/' . $upload . '/'; $up->charset = 'UTF-8'; $up->autoSub = true; if ($up->upload()) { $info = $up->getUploadFileInfo(); $data['opts'] = $info[0]['savename']; $data['vals'] = $data['opts']; unset($up); } else { $errormsg = $up->getErrorMsg(); $errorno = $up->getErrorNo(); if ($errorno == 0) { if (isset($delimg)) { $data['opts'] = ''; } } else { echo 0; exit; } } break; case 'between': $data['opts'][0] = floatval($data['opts'][0]); $data['opts'][1] = floatval($data['opts'][1]); $data['opts'] = serialize($data['opts']); $data['vals'] = implode(',', $data['opts']); break; case 'text': $data['opts'] = htmlspecialchars($data['opts']); $data['vals'] = $data['opts']; break; case 'select': if (isset($data['opts'])) { $data['opts'] = htmlspecialchars($data['opts']); } break; case 'more': if (isset($data['opts'])) { $data['opts'] = htmlspecialchars($data['opts']); } else { $data['vals'] = implode(',', $data['vals']); } break; } //dump($data);exit; if ($act == 'add') { $Public = A('Index', 'Public'); $role = $Public->check('Setting', array('c')); if ($role < 0) { echo $role; exit; } $keywork = $config->where('keywork=\'' . $data['keyword'] . '\'')->count(); if ($keywork) { echo -99; exit; } $add = $config->add($data); if ($add > 0) { $info = $config->field('types,keyword,vals')->select(); $path = ROOT . '/Conf/appcfg.php'; $Write->write($path, $info, 'conf'); echo 1; } else { echo 0; } unset($info, $path, $Public, $data); } elseif ($act == 'edit') { $Public = A('Index', 'Public'); $role = $Public->check('Setting', array('u')); if ($role < 0) { echo $role; exit; } if (!is_int((int) $id)) { echo 0; } else { $otypes = I('otypes'); $oopts = I('oopts'); $delimg = I('delimg'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $path = ROOT . '/' . $upload . '/' . $oopts; $map['id'] = array('eq', $id); if ($data['opts'] == $oopts || $data['opts'] === '') { unset($data['opts']); unset($data['vals']); } if ($data['types'] == 'upload') { if ($delimg == 1) { if ($oopts) { if (file_exists($path)) { $df = $sys->delFile($path); if ($df) { $data['opts'] = ''; $data['vals'] = ''; } } } } } $edit = $config->where($map)->save($data); unset($map); if ($edit !== false) { if ($otypes == 'upload' && $data['types'] != $otypes) { if ($oopts) { if (strstr($path, '.')) { $sys->delFile($path); } } } if ($oopts && $data['opts']) { if (strstr($path, '.')) { $sys->delFile($path); } } $info = $config->field('types,keyword,vals')->select(); $path = ROOT . '/Conf/appcfg.php'; $Write->write($path, $info, 'conf'); echo 1; } else { echo 0; } } unset($sys, $path, $Public, $data, $upload); } } unset($config, $Write); }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'User_part_table'; $Loop->field = 'id,name as text'; $Loop->mode = 'noson'; $Loop->isparnet = false; if (C('MORE_COMY')) { $Loop->where = '`status`=1 and `_parentId`>0'; } else { $Loop->where = '`status`=1'; } $Loop->order = 'id'; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $comy = M('User_company_table'); $part = M('User_part_table'); $path = RUNTIME_PATH . 'Data/Json'; $info = $Loop->rowLevel(); $json_data = json_encode($info); $put_json3 = $Write->write($path, $json_data, 'Part_data'); $sele = $comy->field('id as oid,concat_ws(\'\',\'100\',id) as id,CONCAT(name,\'(客户)\') as text')->where('`status`=1 and `type`=1')->select(); if ($sele) { foreach ($sele as $t) { array_push($info, $t); } } $json_data = json_encode($info); $put_json4 = $Write->write($path, $json_data, 'Client_Part_data'); $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $sele = $comy->field('id as oid,concat_ws(\'\',\'100\',id) as id,name')->where('`status`=1 and `type`=0')->select(); $path = RUNTIME_PATH . 'Data/Json/Part'; $num = 0; foreach ($sele as $t) { $sinfo = $Loop->rowLevel($t['id']); $json_datas = json_encode($sinfo); $ww = $Write->write($path, $json_datas, $t['id'] . '_data'); if ($ww) { $num++; } } $path = RUNTIME_PATH . 'Data/Json'; $info = $comy->field('concat_ws(\'\',\'100\',id) as id,name as text')->where('`status`=1 and `type`=0')->select(); foreach ($info as $k => $t) { $pinfo = $part->field('id,name as text')->where('`status`=1 and _parentId=' . $t['id'])->select(); $info[$k]['children'] = $pinfo; } $json_data = json_encode($info); $put_json2 = $Write->write($path, $json_data, 'Comy_Part_data'); $json_data = json_encode(array('id' => 0, 'text' => '')); $put_json = $Write->write($path, $json_data, 'Empty_data'); if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } $num = 0; }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'Menu'; $Loop->field = 'id,_parentId,text,state,iconCls,url,level,sort,deep'; $Loop->where = ''; $Loop->isparnet = false; $Loop->mode = 'son'; $Loop->order = 'deep,sort'; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $menu = M('Menu'); $info = $Loop->rowLevel(); array_unshift($info, array('id' => 0, 'text' => ' ')); //dump($info); $json_data = json_encode($info); $path = RUNTIME_PATH . 'Data/Json'; $put_json = $Write->write($path, $json_data, 'Menu_data'); if ($back == 1) { if ($put_json) { echo 1; } } unset($info, $json_data, $menu, $Loop, $Write, $sys); }
/** * 生成json文件 *@param $back 为1时,返回数据 *@examlpe */ public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'User_company_table'; $Loop->field = 'id,name as text'; $Loop->mode = 'noson'; $Loop->isparnet = false; $Loop->where = '`status`=1 and `type`=0'; $Loop->order = 'id'; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $path = RUNTIME_PATH . 'Data/Json'; $info = $Loop->rowLevel(); $json_data = json_encode($info); $put_json = $Write->write($path, $json_data, 'Comy_data'); $Loop->field = 'concat_ws(\'\',\'100\',id) as id,name as text'; $info = $Loop->rowLevel(); $json_data = json_encode($info); $put_json2 = $Write->write($path, $json_data, 'Comy_top_data'); $Loop->field = 'id,IF(type=1,CONCAT(name,\'(客户)\'),name) as text,type'; $Loop->where = '`status`=1'; $Loop->order = 'type desc'; $info = $Loop->rowLevel(); $json_data = json_encode($info); $put_json3 = $Write->write($path, $json_data, 'Comy_Client_data'); R(GROUP_NAME . '/Part/json', array(NULL)); if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } }
public function json($back = 1) { $Loop = A('Loop', 'Public'); $Loop->table = 'User_company_table'; $Loop->field = 'id,name as text'; $Loop->where = '`status`=1 and `type`=1'; $Loop->mode = 'noson'; $Loop->order = 'id'; $Write = A('Write', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); //main $temp_path = RUNTIME_PATH . '/Temp/'; if (file_exists($temp_path)) { $dt = $sys->delFile($temp_path); } $path = RUNTIME_PATH . 'Data/Json'; $info = $Loop->rowLevel(); array_unshift($info, array('id' => 0, 'text' => '无')); $json_data = json_encode($info); $put_json = $Write->write($path, $json_data, 'Client_data'); if ($back == 1) { if ($put_json) { echo 1; } else { echo 0; } } R(GROUP_NAME . '/Comy/json', array(NULL)); //R(GROUP_NAME.'/Part/json',array(NULL)); }