예제 #1
0
 /**
  * 修正取得資料,僅修正最後一筆。
  */
 private function FixSEOState()
 {
     //取得最後一筆Task
     $lastId = Yii::app()->db->createCommand('SELECT TaskID FROM task ORDER BY TaskID DESC LIMIT 1')->queryScalar();
     //取得網址
     $dataProvider = new CActiveDataProvider(SiteUrl::model(), array('pagination' => false));
     //echo '資料庫共'.$dataProvider->totalItemCount.'筆資料'."\r\n";
     $i = 0;
     foreach ($dataProvider->getData() as $record) {
         //逐一將DataID取出
         //print_r($record);
         $DataId = Yii::app()->db->createCommand("SELECT DataId FROM data WHERE `SiteID`= {$record->SiteID} AND `TaskID` = {$lastId} LIMIT 1")->queryScalar();
         //讀取資料
         $model = Data::model()->findByPk($DataId);
         if ($model === null) {
             continue;
         }
         //print_r($model);
         //$model->getAttributes(array('name', 'distance'));
         //僅檢查Google API部分
         if ($model->GoogleData == '0' or $model->GoogleData == '' or is_null($model->GoogleData) or empty($model->GoogleData)) {
             usleep(rand(500, 1000));
             $model->GoogleData = $this->GetGoogleSearch("site:{$record->site}");
             echo "[{$record->site} 修正索引部分],";
         }
         usleep(rand(1000, 3000));
         if ($model->google_backlink == '0' or $model->google_backlink == '' or is_null($model->google_backlink) or empty($model->google_backlink)) {
             usleep(rand(500, 1000));
             $model->google_backlink = $this->GetGoogleSearch("link:{$record->site}");
             echo "[{$record->site} 修正連結部分],";
         }
         //逐一檢查檔案是否取得資料。
         $fileTypeList = array('pdf', 'doc', 'docx', 'ppt', 'pptx', 'ps', 'eps');
         $fileCount = array();
         $error_statues = 0;
         foreach ($fileTypeList as $key => $value) {
             usleep(rand(5000, 10000));
             if ($model->{$value} == 0) {
                 $model->{$value} = $this->GetGoogleSearch("site:{$record->site}" . ' filetype:' . $value);
                 echo "[{$record->site} 修正檔案 {$value} 部分],";
                 if (is_null($model->{$value})) {
                     $model->{$value} = \SEOstats\Services\Google::getSiteFileTypeTotal($record->site, $value);
                     //表示系統被Google封鎖了。
                     if (is_null($model->{$value})) {
                         $model->{$value} = 0;
                         $error_statues++;
                     }
                 }
             }
         }
         if ($model->save()) {
             $i++;
         } else {
             print "網址: {$site} 出現錯誤";
             print_r($model->getErrors());
         }
         usleep(rand(100, 400));
     }
     Yii::app()->end();
 }
예제 #2
0
 public function actionData($id = null, $metric = null)
 {
     if (isset($_POST['data'])) {
         foreach ($_POST['data'] as $id => $value) {
             $model = Data::model()->findByPk($id);
             $model->value = is_numeric($value) ? (int) $value : null;
             $model->save();
         }
         echo Sector::getJson();
     } else {
         $metricModel = Metric::model()->findByAttributes(array('name' => $metric));
         $metric_ids = CHtml::listData($metricModel->getMetricWithDescendants(), 'id', 'id');
         if ($metricModel->type == '1') {
             echo $this->renderPartial('dataForm', array('sector' => Sector::model()->findByPk($id), 'metric_ids' => $metric_ids));
         } elseif ($metricModel->type = '2') {
             foreach (Sector::model()->findByPk($id)->square->sectors as $sector) {
                 echo CHtml::tag('h3', array(), $sector->title);
                 echo $this->renderPartial('dataForm', array('sector' => $sector, 'metric_ids' => $metric_ids));
                 echo Chtml::hiddenField('sector_id', $id);
             }
         }
     }
 }
예제 #3
0
<?php

$data = Data::model()->metrics($metric_ids)->sectors($sector->id)->findAll();
foreach ($data as $item) {
    echo CHtml::label($item->metric->title, 'data[' . $item->id . ']');
    echo '<br />';
    echo CHtml::textField('data[' . $item->id . ']', $item->value);
    echo '<br />';
}
예제 #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Data the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Data::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #5
0
<header class="header-image">
    <div class="headline">
        <div class="container">
            <h1><?php 
echo CHtml::encode(Yii::app()->name);
?>
<br><small>各單位系所網站資訊統計系統</small></h1>

			<br>
			<!-- Contextual button for informational alert messages -->

            <div class="row">
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter">
                    <?php 
echo Data::model()->count() * 8;
?>
                    </span>
                    <h4>登錄資料筆數</h4>
                </div>
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter"> <?php 
echo Group::model()->count();
?>
</span>
                    <h4>網站數</h4>
                </div>
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter"> <?php 
echo SiteUrl::model()->count();
?>