/** * Lists all FriendLink models. * @return mixed */ public function actionIndex() { if (!$this->is_access('links/index')) { Yii::$app->session->setFlash('error', $this->errorInfo); return $this->redirect($this->redirectUrl); } $dataProvider = new ActiveDataProvider(['query' => FriendLink::find()]); Yii::$app->view->params['meta_title'] = '友情链接列表'; return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionDeleteLink() { $id = (int) \Yii::$app->request->get('id', 0); if (!$id) { exit(UtilD::handleResult(false, '非法提交')); } $model = FriendLink::find()->where('id=' . $id)->one(); if (strpos($model['link_logo'], 'http://') === false && strpos($model['link_logo'], 'https://') === false) { $img_name = basename($model['link_logo']); @unlink(\Yii::getAlias('static') . '/images/afficheimg/' . $img_name); } $model->delete(); AdminLog::admin_log('', 'remove', 'friendlink'); exit(UtilD::handleResult(true, '删除成功')); }