public function pakAction()
 {
     $redis = Leb_Dao_Redis::getInstance();
     $redisGet = $redis->lRange("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_IOS", 0, 0);
     if (empty($redisGet)) {
         die("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_IOS not find");
     }
     foreach ($redisGet as $key => $val) {
         $redis->lRem("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_IOS", $val, 0);
         $vals = json_decode($val, true);
         if (!empty($vals['uid']) || !empty($vals['channel'])) {
             $pakRe = $this->pakIos($vals['channel'], $vals['uid'], $vals['c']);
             $dateNow = date("Y-m-d H:i:s", time());
             if (!empty($pakRe['status']) && 1 == $pakRe['status']) {
                 $pushValue = array("uid" => $vals['uid'], "channel" => $vals['channel'], "rtn" => 1, "error" => "", "ctime" => $dateNow);
             } else {
                 if (!empty($pakRe['status']) && 11 == $pakRe['status']) {
                     $pushValue = array("uid" => $vals['uid'], "channel" => $vals['channel'], "rtn" => 11, "error" => $pakRe['error'], "ctime" => $dateNow);
                 } else {
                     $pushValue = array("uid" => $vals['uid'], "channel" => $vals['channel'], "rtn" => 0, "error" => $pakRe['error'], "ctime" => $dateNow);
                 }
             }
             $redis->lPush("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_RESULT_IOS", json_encode($pushValue));
         }
         sleep(10);
     }
     die;
 }
 private function clearSendSet()
 {
     $redis = Leb_Dao_Redis::getInstance();
     for ($i = 1; $i <= $this->sendNum; $i++) {
         $redis->del($this->NotifSendStartNid[$i]);
         //
         $redis->del($this->NotifEndNid[$i]);
         //
         $redis->del($this->NotifSendIndicator[$i]);
         //
     }
 }
 private function endCount($errorCode, $endTime, $yesterdayNum)
 {
     if (empty($errorCode) || empty($endTime)) {
         return '';
     }
     //通过redis缓存获取错误码记录
     $redis = Leb_Dao_Redis::getInstance($this->configSet);
     $errorCodeKey = '_zhuanerrcode' . date("Y-m-d", strtotime('-1 day')) . '_' . $errorCode;
     $codeTypeSet['errorcode'] = $errorCode;
     $codeTypeList = $this->errorcodeTypeModel->getErrorCodeTypeList($codeTypeSet);
     if ($codeTypeList) {
         $totalNum = 0;
         foreach ($codeTypeList as $key => $val) {
             $isType = $redis->exists($errorCodeKey . '_' . $val['type_name'] . '_');
             if (empty($isType)) {
                 continue;
             }
             $errorCodeNum = $redis->get($errorCodeKey . '_' . $val['type_name'] . '_');
             $addErrorCodeLog['errorcode'] = $errorCode;
             $addErrorCodeLog['type_name'] = $val['type_name'];
             $addErrorCodeLog['num'] = (int) $errorCodeNum;
             $addErrorCodeLog['is_end'] = 1;
             $addErrorCodeLog['end_time'] = date("Y-m-d H:i:s", time());
             $addErrorCodeLog['ctime'] = $endTime;
             $this->errorcodeLogModel->addErrorCodeLog($addErrorCodeLog);
             $totalNum = $totalNum + $addErrorCodeLog['num'];
         }
         //更新昨天、前天总数
         $errorCodeSave['yesterday_num'] = $totalNum;
         $errorCodeSave['before_yesterday_num'] = (int) $yesterdayNum;
         $errorCodeSave['updatetime'] = date("Y-m-d H:i:s", time());
         $this->errorcodeCountModel->saveErrorcode($errorCode, $errorCodeSave);
     }
     return true;
 }
 public function batch_ios_zaibeiAction()
 {
     $abnormal = daddslashes($this->reqVar('abnormal', ''));
     $dosubmit = daddslashes($this->reqVar('dosubmit', ''));
     if (!in_array(UID, array(1, 2, 3, 4, 5, 8, 29, 30))) {
         $this->redirect('打包提交成功', '/admin/package', 3);
     } elseif ($dosubmit) {
         $redis = Leb_Dao_Redis::getInstance();
         $redisLen = $redis->llen("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_IOS_ZAIBEI");
         if (empty($redisLen)) {
             $redis->delete("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_RESULT_IOS_ZAIBEI");
             if (empty($abnormal)) {
                 $packageList = $this->packageModel->query("SELECT * FROM a_package_log WHERE pk_os =2 order by id asc");
             } else {
                 $packageList = $this->packageModel->query("SELECT * FROM a_package_log WHERE pk_os =2 AND STATUS < 0 order by id asc");
             }
             if ($packageList) {
                 foreach ($packageList as $key => $val) {
                     if (1 == $val['is_hidden_invite']) {
                         $val['c'] = 'c';
                     } else {
                         $val['c'] = '';
                     }
                     //循环加入队列
                     $pushValue = json_encode(array("uid" => $val['uid'], "channel" => $val['channel'], "c" => $val['c']));
                     $redis->lPush("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_IOS_ZAIBEI", $pushValue);
                 }
             }
             $this->oplog(array("batch_ios_zaibei" => "submit"));
             $this->redirect('打包提交成功', '/admin/package/batch_ios_zaibei', 3);
         }
         $this->redirect('正在执行打包操作,请稍等..', '/admin/package/batch_ios_zaibei', 3);
     } else {
         $redisGetList = array();
         $succeeCount = $failCount = 0;
         $redis = Leb_Dao_Redis::getInstance();
         $redisGet = $redis->lRange("ZHUAN_ADMIN_TASK_PACKAGE_BATCH_RESULT_IOS_ZAIBEI", 0, -1);
         if ($redisGet) {
             foreach ($redisGet as $key => $val) {
                 $vRe = json_decode($val, true);
                 if (!empty($vRe['rtn']) && 1 == $vRe['rtn']) {
                     $succeeCount = $succeeCount + 1;
                     $redisGetList[$key]['status'] = "成功";
                 } else {
                     if (!empty($vRe['rtn']) && 11 == $vRe['rtn']) {
                         $succeeCount = $succeeCount + 1;
                         $redisGetList[$key]['status'] = "文件正常, 不用打包";
                     } elseif (!empty($vRe['error'])) {
                         $failCount = $failCount + 1;
                         $redisGetList[$key]['status'] = '<span class="red">失败:' . $vRe['error'] . '</span>';
                     } else {
                         $failCount = $failCount + 1;
                         $redisGetList[$key]['status'] = '<span class="red">失败</span>';
                     }
                 }
                 $redisGetList[$key]['uid'] = $vRe['uid'];
                 $redisGetList[$key]['channel'] = $vRe['channel'];
                 $redisGetList[$key]['ctime'] = $vRe['ctime'];
             }
         }
         $sumCount = count($redisGet);
         $this->assign('redisGetList', $redisGetList);
         $this->assign('sumCount', $sumCount);
         $this->assign('succeeCount', $succeeCount);
         $this->assign('failCount', $failCount);
         $this->getViewer()->needLayout(false);
         $this->render('package_batch_zaibei');
     }
 }
  public function get_side_bar_menu()
  {
      $model = $this->loadAppModel('admin');
      $redis = Leb_Dao_Redis::getInstance();
      //获取用户权限配置
      $user_permission_key = "ADMIN_PERMISSION_SET_KEY" . UID;
      $uid_permission_str = $redis->get($user_permission_key);
      if (empty($uid_permission_str)) {
          $permission_key = "ADMIN_PERMISSION_SET_KEY";
          $permission_str = $redis->get($permission_key);
          if (empty($permission_str)) {
              $permission = $model->query("SELECT permission FROM a_user ORDER BY id ASC ");
              $permission_list = [];
              foreach ($permission as $var) {
                  if (!empty($var['permission'])) {
                      $permission_list[] = $var['permission'];
                  }
              }
              $permission_str = '{' . join(',', $permission_list) . '}';
              $redis->setex($permission_key, 60 * 60 * 10, $permission_str);
          }
          $limitConfig = json_decode($permission_str, true);
          define(UID, 1);
          $loginLimit = $limitConfig[UID];
          $menu_id_list = $loginLimit['limit'];
          ksort($menu_id_list);
          $menu_id_str = '';
          $temp = [];
          foreach ($menu_id_list as $key => $var) {
              $menu_id_str .= "{$key}, ";
              $menu_id_str .= "" . join(',', $var);
              $menu_id_str .= ",";
              asort($var);
              $temp[$key] = $var;
          }
          $menu_id_str .= "0";
          $menu_id_list = $temp;
          $menuListRe = $model->query("SELECT * FROM a_menus where id in ({$menu_id_str})");
          $temp = [];
          foreach ($menuListRe as $var) {
              $var['url'] = "/{$var['app']}/{$var['controller']}/{$var['action']}";
              $temp[intval($var['id'])] = $var;
          }
          $menuListRe = $temp;
          $side_bar_menu = '<aside class="main-sidebar">
 <!-- sidebar: style can be found in sidebar.less -->
 <section class="sidebar" style="height: auto;">
  <!-- Sidebar user panel -->
  <div class="user-panel">
   <div class="pull-left image">
   </div>
   <div class="pull-left info">
    <p>' . UNAME . '</p>
    <a href="#"><i class="fa fa-circle text-success active"></i>Online</a>
   </div>
  </div>
  <div>
   <ul class="sidebar-menu" id="main_menu">
    <!-- content in sidebar menu will be set in js code -->
    <li class="header">MAIN NAVIGATION</li>';
          //            var_dump($menuListRe['1']);
          foreach ($menu_id_list as $key => $val) {
              $side_bar_menu .= '<li class="treeview"> <a href="#"><i class="fa fa-files-o"></i>  <span>' . $menuListRe[$key]['name'] . '</span> </a>   <ul class="treeview-menu">';
              foreach ($val as $k => $v) {
                  $side_bar_menu .= ' <li><a href="' . $menuListRe[$v]['url'] . '"><i class="fa fa-circle-o"></i>' . $menuListRe[$v]['name'] . '</a></li>';
              }
              $side_bar_menu .= '</ul> </li> ';
          }
          $side_bar_menu .= ' </div>
                             </section>
                             <!-- /.sidebar -->
                            </aside>';
          $redis->setex($user_permission_key, 60 * 60 * 10, $side_bar_menu);
          return $side_bar_menu;
      } else {
          return $uid_permission_str;
      }
  }
 private function clearRedis($user = '')
 {
     if (empty($user)) {
         $key = "ZHUBO_INVITE_CODE_RATE_SET_KEY";
         $redis = Leb_Dao_Redis::getInstance();
         $res = $redis->get($key);
         if ($res) {
             $redis->del($key);
         }
     } else {
         $key = "ZHUBO_INVITE_CODE_KEY_FIRST{$user}";
         $redis = Leb_Dao_Redis::getInstance();
         $res = $redis->get($key);
         if ($res) {
             $redis->del($key);
         }
         //            var_dump($redis->get($key));die();
     }
 }
 private function clearRedis()
 {
     //清理redis缓存
     $redis = Leb_Dao_Redis::getInstance();
     $bannerAndroidKey = '_ZHUAN_AD_BANNER_android';
     $bannerAndroid = $redis->get($bannerAndroidKey);
     if ($bannerAndroid) {
         $redis->del($bannerAndroidKey);
     }
     $bannerIosKey = '_ZHUAN_AD_BANNER_ios';
     $bannerIos = $redis->get($bannerIosKey);
     if ($bannerIos) {
         $redis->del($bannerIosKey);
     }
     $bannerAndroidDatKey = '_ZHUAN_AD_BANNER_android_dat';
     $bannerAndroidDat = $redis->get($bannerAndroidDatKey);
     if ($bannerAndroidDat) {
         $redis->del($bannerAndroidDatKey);
     }
     $bannerIosDatKey = '_ZHUAN_AD_BANNER_ios_dat';
     $bannerIosDat = $redis->get($bannerIosDatKey);
     if ($bannerIosDat) {
         $redis->del($bannerIosDatKey);
     }
 }
 public function indexAction()
 {
     $menuId = (int) $this->reqVar('menu_id', 1);
     $getMenu = $this->menuModel->getMenu(array("id" => $menuId));
     //获取用户权限配置
     $limitConfig = C('register_user.php');
     //////////////////////////////////////////////////////////////////////////////// 后台权限更新代码
     //用户权限配置
     //            $registerUser = C('register_user.php');
     //            $str = json_encode($registerUser);
     //            $str = substr($str, 1, strlen($str) - 2);
     //
     //            $pieces = explode('"},"', $str);
     //            $pieces_c = [];
     //            for($ii = 0; $ii < count($pieces); $ii++)
     //            {
     //                if ($ii == 0)
     //                    $pieces_c[$ii + 1] = $pieces[0] . '"}';
     //                else if ($ii == count($pieces) - 1)
     //                    $pieces_c[$ii + 1] = '"' . $pieces[$ii];
     //                else
     //                    $pieces_c[$ii + 1] = '"' . $pieces[$ii] . '"}';
     //            }
     //
     //            for($ii = 1; $ii <= count($pieces_c); $ii++)
     //            {
     //                $model->query("UPDATE a_user SET permission = '{$pieces_c[$ii]}' WHERE id = $ii");
     //            }
     //            $permission_str = '{' . join(',', $pieces_c) . '}';
     //            $registerUser = json_decode($permission_str, true);
     //////////////////////var_dump($registerUser);die();
     ////////////////////////////////////////////////////////////////////////////// 后台权限更新代码
     $permission_key = "ADMIN_PERMISSION_SET_KEY";
     $redis = Leb_Dao_Redis::getInstance();
     $permission_str = $redis->get($permission_key);
     if (empty($permission_str)) {
         $permission = $this->menuModel->query("SELECT permission FROM a_user ORDER BY id ASC ");
         $permission_list = [];
         foreach ($permission as $var) {
             if (!empty($var['permission'])) {
                 $permission_list[] = $var['permission'];
             }
         }
         $permission_str = '{' . join(',', $permission_list) . '}';
         $redis->setex($permission_key, 60 * 60 * 10, $permission_str);
     }
     $limitConfig = json_decode($permission_str, true);
     $loginLimit = $limitConfig[UID];
     //显示运营菜单
     $menuList = array();
     $menuSet['status'] = 1;
     $menuSet['parent_id'] = $menuId;
     $menuSet['orderby'] = "id asc";
     $menuListRe = $this->menuModel->getMenuList($menuSet, 1, 50);
     if ($menuListRe && !empty($loginLimit)) {
         foreach ($menuListRe as $key => $val) {
             if (in_array($val['id'], $loginLimit['limit'][$menuId])) {
                 $menuList[$key] = $val;
             }
         }
     }
     $this->assign('getMenu', $getMenu);
     $this->assign('menuList', $menuList);
     $this->getViewer()->needLayout(false);
     $this->render('menu_public');
 }
Beispiel #9
0
 /**
  * 输出60*20验证码图片
  */
 public function codeAction()
 {
     $this->getViewer()->needLayout(false);
     $width = 84;
     //验证码图片的宽度
     $height = 24;
     //验证码图片的高度
     $code = $this->randstring(4);
     //redis缓存code
     $redis = Leb_Dao_Redis::getInstance();
     $redis->setex(self::VALIDATE_CODE, 300, $code);
     //
     //        var_dump($code);die();
     //        setcookie(self::VALIDATE_CODE, $code, time()+300, '/', $_SERVER['SERVER_NAME']);
     @header("Content-Type:image/png");
     $img = @imagecreate($width, $height);
     imagecolorallocate($img, 255, 255, 255);
     imagerectangle($img, 0, 0, $width - 1, $height - 1, imagecolorallocate($img, 41, 163, 238));
     $len = strlen($code);
     for ($i = 0; $i < $len; $i++) {
         $font = mt_rand(5, 100);
         $x = mt_rand(1, 8) + $width * $i / 4;
         $y = mt_rand(1, $height / 4);
         $color = imagecolorallocate($img, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200));
         imagestring($img, $font, $x, $y, $code[$i], $color);
     }
     for ($i = 0; $i < 100 / $len; $i++) {
         imagesetpixel($img, rand(1, $width), rand(1, $height), mt_rand(50, 200));
     }
     imagepng($img);
     imagedestroy($img);
 }
Beispiel #10
0
 private function clearRedis()
 {
     $key = "ADMIN_PERMISSION_SET_KEY";
     $redis = Leb_Dao_Redis::getInstance();
     $res = $redis->get($key);
     if ($res) {
         $redis->del($key);
     }
 }
 public function flushShardInfoCache()
 {
     if (empty($this->_vsconfig)) {
         $this->_vsconfig = $vsconfig = (require _CONFIG_ . DIRECTORY_SEPARATOR . 'shard.php');
     } else {
         $vsconfig = $this->_vsconfig;
     }
     $infokey = $vsconfig['infokey'];
     $redis = Leb_Dao_Redis::getInstance($vsconfig['redis']);
     $bret = $redis->delete($infokey);
     if (!$bret) {
         return false;
     }
     $oldVirtShards = self::$_virtShards;
     self::$_virtShards = array();
     self::$_virtShards = $this->getShardInfo();
     if (empty(self::$_virtShards)) {
         self::$_virtShards = $oldVirtShards;
         return false;
     }
     return true;
 }
Beispiel #12
0
 /**
  * 实例化本程序
  * @param $args = func_get_args();
  * @return object of this class
  */
 public static function getInstance($config = array(), $options = array())
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self($config, $options);
     }
     return self::$_instance;
 }
 private function clearRedis($uid, $pnum, $deviceId)
 {
     //清理redis缓存
     $redis = Leb_Dao_Redis::getInstance();
     if (!empty($uid)) {
         $uKey = '_ZHUAN_U_L' . $uid;
         $uInfo = $redis->get($uKey);
         if ($uInfo) {
             $redis->del($uKey);
         }
         $uGKey = '_ZHUAN_U_S_L_G_' . $uid;
         $uGInfo = $redis->get($uGKey);
         if ($uGInfo) {
             $redis->del($uGInfo);
         }
         $uPKey = '_ZHUAN_P_U' . $uid;
         $uPInfo = $redis->get($uPKey);
         if ($uPInfo) {
             $redis->del($uPInfo);
         }
     }
     if (!empty($pnum)) {
         $pKey = '_ZHUAN_U_P' . $pnum;
         $pInfo = $redis->get($pKey);
         if ($pInfo) {
             $redis->del($pInfo);
         }
     }
     if (!empty($deviceId)) {
         $dKey = '_ZHUAN_U_I_B_D_I' . $deviceId;
         $dInfo = $redis->get($dKey);
         if ($dInfo) {
             $redis->del($dInfo);
         }
     }
 }
Beispiel #14
0
 private function publicIosFirstSetSave($nid)
 {
     if (empty($nid)) {
         return false;
     }
     //判断是否是第一次发放分配配置
     $redis = Leb_Dao_Redis::getInstance();
     $sendSet = $redis->get($this->NotifEndNid[1]);
     if (!empty($sendSet)) {
         return false;
     }
     $pushTokenRe = $this->pushModel->query("SELECT id FROM z_push_ios ORDER BY id DESC LIMIT 1");
     $pushTokenMaxId = !empty($pushTokenRe[0]['id']) ? $pushTokenRe[0]['id'] : 0;
     if (empty($pushTokenMaxId) || !is_numeric($pushTokenMaxId)) {
         return false;
     }
     $pushTokenAverage = ceil($pushTokenMaxId / $this->sendNum);
     $endNum = 0;
     for ($i = 1; $i <= $this->sendNum; $i++) {
         $sendSetSaveSet['nid'] = $nid;
         if ($endNum >= $pushTokenMaxId) {
             continue;
         }
         $sendSetSaveSet['star_num'] = $sendSetSaveSet['send_star'] = $endNum + 1;
         if ($i == $this->sendNum || $sendSetSaveSet['star_num'] == $pushTokenMaxId) {
             $sendSetSaveSet['end_num'] = $pushTokenMaxId;
         } else {
             $sendSetSaveSet['end_num'] = $endNum + $pushTokenAverage;
             if ($sendSetSaveSet['end_num'] > $pushTokenMaxId) {
                 $sendSetSaveSet['end_num'] = $pushTokenMaxId;
             }
         }
         $endNum = $sendSetSaveSet['end_num'];
         $sendSetSaveSet['futime'] = date("Y-m-d H:i:s", time());
         //redis缓存code
         $redis = Leb_Dao_Redis::getInstance();
         $redis->setex($this->NotifSendStartNid[$i], 60 * 60 * 24, $sendSetSaveSet['send_star']);
         //
         $redis->setex($this->NotifEndNid[$i], 60 * 60 * 24, $sendSetSaveSet['end_num']);
         //
         $redis->setex($this->NotifSendIndicator[$i], 60 * 60 * 24, 0);
         //
         $redis->setex($this->databaseReadLock[$i], 60 * 60, 0);
     }
 }