TestController.class.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class TestController extends Controller {
  5. var $arrt='1,';
  6. public function index(){
  7. // $this->show('aaaaaaaaaaaaaaaaaaaaa');
  8. /* import("Org.Util_it.PHPExcel");
  9. //import("Org.excel.PHPExcel/Classes/PHPExcel/Writer/Excel5.php"); // 用于其他低版本xls
  10. //import("Org.excel.PHPExcel.Classes.PHPExcel.Writer.Excel2007.php"); // 用于 excel-2007 格式
  11. $objPHPExcel = new \PHPExcel(); */
  12. //echo '<div class="bjui-pageContent">';
  13. //echo '<div class="panel panel-default">
  14. //test控制器
  15. //</div>
  16. //';
  17. ////dump( ini_get('upload_max_filesize'));//上传最大限制
  18. //dump(ini_get_all());
  19. //echo '内存:'.memory_get_usage();
  20. //echo '</div>';
  21. $Auth = new \Think\Auth();
  22. $ruleName =MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME; //规则唯一标识
  23. $userId = 1; //用户ID
  24. $type = 1; //分类-具体是什么没搞懂,默认为1
  25. $mode='url'; //执行check的模式
  26. $relation = 'or'; //'or' 表示满足任一条规则即通过验证; 'and'则表示需满足所有规则才能通过验证
  27. $ccc=$Auth->check($ruleName,$userId,$type,$mode,$relation);
  28. if (is_string($ruleName)) {
  29. $name = strtolower($ruleName);
  30. $REQUEST = unserialize( strtolower(serialize($_REQUEST)) );
  31. if (strpos($name, ',') !== false) {
  32. $name = explode(',', $name);
  33. } else {
  34. $name = array($name);
  35. }
  36. }
  37. if($ccc){
  38. $dietxt = '认证:通过';
  39. }else{
  40. $dietxt = '认证:失败';
  41. }
  42. $user_groups=M('auth_group_access');
  43. $condition['uid'] =$userId;
  44. $condition['`status`']=1;
  45. $listxx = $user_groups->join('sp_auth_group on group_id=id')->where($condition)->field("uid,group_id,title,rules")->select();
  46. $ids = array();//保存用户所属用户组设置的所有权限规则id
  47. foreach ($listxx as $g) {
  48. $ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
  49. }
  50. $ids = array_unique($ids);
  51. $map=array(
  52. 'id'=>array('in',$ids),
  53. 'type'=>$type,
  54. 'status'=>1,
  55. );
  56. $rules = M('auth_rule')->where($map)->select();
  57. // $this->assign('dietxt',$dietxt);
  58. $authList = array(); //
  59. foreach ($rules as $rule) {
  60. if (!empty($rule['condition'])) { //根据condition进行验证
  61. $user = $this->getUserInfo($uid);//获取用户信息,一维数组
  62. $command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']);
  63. //dump($command);//debug
  64. @(eval('$condition=(' . $command . ');'));
  65. if ($condition) {
  66. $authList[] = strtolower($rule['name']);
  67. }
  68. } else {
  69. //只要存在就记录
  70. $authList[] = strtolower($rule['name']);
  71. }
  72. }
  73. $t = implode(',',(array)$type);
  74. foreach ( $authList as $auth ) {
  75. $query = preg_replace('/^.+\?/U','',$auth);
  76. if ($mode=='url' && $query!=$auth ) {
  77. parse_str($query,$param); //解析规则中的param
  78. $intersect = array_intersect_assoc($REQUEST,$param);
  79. $auth = preg_replace('/\?.*$/U','',$auth);
  80. if ( in_array($auth,$name) && $intersect==$param ) { //如果节点相符且url参数满足
  81. $list[] = $auth ;
  82. }
  83. }else if (in_array($auth , $name)){
  84. $list[] = $auth ;
  85. }
  86. }
  87. //if ($relation == 'or' and !empty($list)) {
  88. // return true;
  89. // }
  90. // $diff = array_diff($name, $list);
  91. // if ($relation == 'and' and empty($diff)) {
  92. // return true;
  93. // }
  94. $menu = M('menu');
  95. $menulv1 = $menu->query("SELECT
  96. sp_menu.ID,sp_menu.menuname,sp_menu.pageurl,sp_menu.pid,sp_menu.Lv,
  97. (SELECT COUNT(ID) FROM sp_menu b WHERE b.pid= sp_menu.ID ) as clicn
  98. FROM
  99. sp_menu WHERE Lv=1");
  100. $phone='012345068';
  101. $frist = substr( $phone,0,1 );
  102. // $delete_last = substr(base_url(),0,-1);
  103. $rest1=preg_match('/^0.*/',$phone);
  104. // $rest1=preg_replace('/^0.*/', '', $phone);
  105. $work=M('v_customer');
  106. //$Map['_string']='agent=1002';
  107. // $Map['agent']=array('in','2000');
  108. $InfoData=array(
  109. 'U',
  110. $Data['start_date'],
  111. $Data['end_date'],
  112. '5454',
  113. date('Y-m-d H:i:s',time()),
  114. $Data['title'],
  115. '12345646546546546',
  116. '',
  117. '',
  118. 0,
  119. 1,
  120. );
  121. $QcscoreVIew=M('v_tasklist');
  122. $Count= $QcscoreVIew->where($Map)->count();// 查询满足要求的总记录数
  123. $List = $QcscoreVIew->field("id,taskname,taskdescr,taskstatus,tasktable,createtime,createman")->where($Map)
  124. ->limit(1,20)->order('createtime desc')->select();
  125. $ListData = array();
  126. foreach($List as $key => $Value){
  127. $tables=$List[$key]['tasktable'];
  128. $ListValue=M('')->query("select IFNULL((round((SELECT COUNT(*) FROM asteriskcdrdb.%s where data1!='')/COUNT(*)*100,0)),0) as num FROM asteriskcdrdb.%s",$tables,$tables);
  129. $ListData[$key]=array_merge($List[$key],$ListValue[0]);
  130. }
  131. //$DataList=M()->query("SELECT * FROM sp_gonggao WHERE title ='%s' AND ID=56",$InfoData2);
  132. // $DataList2=M()->query("select @countss");
  133. $model = M("");
  134. $sql = "call PROC_AGENT_REPOR('C','','','3000','','','')";
  135. //echo $sql;
  136. $ref = $model -> procedure($sql);
  137. //var_dump($ref);
  138. $this->show('vvvvv'.$_SERVER['SERVER_ADDR'].' vvvv'.print_r($DataList2).' ss'.dump($ref));
  139. //$this->display();
  140. }
  141. public function test($p,$cc){
  142. return '1='.$aa.' 2='.$p.' 3='.$cc;
  143. }
  144. protected function permdata() {
  145. $ModelUser=M('v_user');
  146. $Uid=21;
  147. $PermData=3;
  148. if($Uid!=1)
  149. {
  150. $ListData=$ModelUser->where(array('id' => $Uid))->Field("dataperm,agentid,depnameid")->select();
  151. $PermData =$ListData[0]['dataperm'];
  152. }
  153. if($PermData==1)
  154. {
  155. $Data =$ListData[0]['agentid'];
  156. }
  157. else if($PermData==2)
  158. {
  159. $ListId=$this->groupdata($ListData[0]['depnameid']).$ListData[0]['depnameid'];
  160. $DepData=explode(',',$ListId);
  161. $Map['depname']=array('in',$DepData);
  162. $List = M('user')->where($Map)->field("agentid")->select();
  163. $Ids=array();
  164. foreach ($List as $g) {
  165. $Ids = array_merge($Ids, explode(',', trim($g['agentid'], ',')));
  166. }
  167. $Data =array('in',array_unique($Ids));
  168. }
  169. else{
  170. $Data='';
  171. }
  172. return $Data;
  173. }
  174. protected function groupdata($DepPid){
  175. $ModelGroup=M('auth_group');
  176. $ListPid=$ModelGroup->where(array('pid' => $DepPid,'type'=> 0))->Field('id')->select();
  177. if(!empty($ListPid)){//如果有子类
  178. $i=0;
  179. foreach($ListPid as $g){
  180. $Arrt.=$g['id'].',';
  181. $Arrt.=$this->groupdata($g['id']);
  182. }
  183. return $Arrt;
  184. }
  185. }
  186. public function ini(){
  187. echo '<div class="bjui-pageContent">';
  188. echo '<div class="panel panel-default">
  189. test控制器
  190. </div>
  191. ';
  192. dump( ini_get('upload_max_filesize'));//上传最大限制
  193. dump( ini_get('mssql.textsize'));
  194. dump(ini_get_all());
  195. //echo '内存:'.memory_get_usage();
  196. echo '</div>';
  197. }
  198. //事务
  199. public function shiwu(){
  200. $Model = M(); // 实例化一个空对象
  201. $Model->startTrans(); // 开启事务
  202. $res=$Model->execute("update b set userid='9' where id='9'");
  203. $res2=$Model->execute("update b set userid='9' where id='8'");
  204. if ($res && $res2) {
  205. $Model->commit(); // 成功则提交事务
  206. echo '成功';
  207. } else {
  208. $Model->rollback(); // 否则将事务回滚
  209. echo '失败';
  210. }
  211. }
  212. //返回多值
  213. public function calls(){
  214. $res=M()->procedure('select * from a;select * from b');
  215. dump($res);
  216. }
  217. public function getip(){
  218. $iipp=$_SERVER["REMOTE_ADDR"];
  219. $port = $_SERVER['REMOTE_PORT'];
  220. echo $iipp.':'.$port;
  221. }
  222. public function gettianqi(){
  223. $ch = curl_init();
  224. // curl_setopt($ch, CURLOPT_URL, "https://www.sojson.com/open/api/weather/json.shtml?city=上海");
  225. curl_setopt($ch, CURLOPT_URL, "http://tj.nineton.cn/Heart/index/all?city=CHSH000000");
  226. curl_setopt($ch, CURLOPT_HEADER, false);
  227. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果把这行注释掉的话,就会直接输出
  228. $result=curl_exec($ch);
  229. $res=json_decode($result,true);
  230. dump($res['weather'][0]['city_name']);
  231. dump($res['weather'][0]['now']['text']);
  232. dump($res['weather'][0]['now']['temperature']);
  233. dump($res['weather'][0]['now']['wind_direction']);
  234. dump($res['weather'][0]['now']['wind_scale']);
  235. dump($res['weather'][0]['now']['air_quality']['city']['quality']);
  236. dump($res['weather'][0]['now']);
  237. curl_close($ch);
  238. }
  239. }