예제 #1
0
 public function actionCreate()
 {
     $post = Yii::$app->request->post();
     //判断名称
     if (empty($post['name'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Missing required parameters: {params}', ['params' => '公众号名称']));
     }
     //判断类型
     if (empty($post['type'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Missing required parameters: {params}', ['params' => '公众号类型']));
     }
     //判断appid
     if (empty($post['appid'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Missing required parameters: {params}', ['params' => 'AppID(应用ID)']));
     }
     //判断appsecret
     if (empty($post['appsecret'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Missing required parameters: {params}', ['params' => 'AppSecret(应用密钥)']));
     }
     //加解密模式
     $post['encript_mode'] = !empty($post['encript_mode']) ? intval($post['encript_mode']) : 1;
     //默认明文模式
     $post['create_time'] = time();
     $post['update_time'] = time();
     $post['unique_id'] = md5(Yii::$app->security->generateRandomString() . time());
     //随机生成
     $post['token'] = Common::getGenerateSalt(8);
     //随机生成英文或者数字组合的随机字符串
     $model = new PublicNumber();
     if ($model->load(['PublicNumber' => $post]) && $model->save()) {
         $model->order_id = $model->id;
         $model->save();
         return $this->redirect(['public-number/form', 'id' => $model->id]);
     } else {
         throw new NotFoundHttpException(Yii::t('yii', 'An internal server error occurred.'));
     }
 }
예제 #2
0
파일: index.php 프로젝트: RoyZeng/weimp
        ?>
					<tr id="tr_<?php 
        echo $v['id'];
        ?>
">
						<td><input type="checkbox" /></td>
						<td><?php 
        echo Html::encode($v['name']);
        ?>
</td>
						<td><?php 
        echo $v['type'];
        ?>
</td>
						<td><?php 
        echo Common::fileSizeConv($v['filesize']);
        ?>
</td>
						<td><?php 
        echo $v['create_time'];
        ?>
</td>
						<td>
						   <a href="<?php 
        echo Url::to(['material/form', 'id' => $v['id'], 'pid' => Yii::$app->controller->pid]);
        ?>
" class="btn btn-primary"><i class="icon-pencil icon-white"></i> 查看详情</a>
						   <a href="javascript:void(0);" _id=<?php 
        echo $v['id'];
        ?>
 class="btn btn-danger remove-row"><i class="icon-remove icon-white"></i> 删除</a>
예제 #3
0
파일: Uploader.php 프로젝트: RoyZeng/weimp
 /**
  * 文件命名 规则
  */
 private function getSaveName($file)
 {
     $saveName = md5(uniqid() . Common::getGenerateSalt()) . '.' . $file['extension'];
     return $saveName;
 }