public function actionMn()
 {
     $day = date("l", time());
     $data = Calendar::model()->find("thu = :thu", array(":thu" => $day));
     $nam = explode(",", $data->nam);
     $trung = explode(",", $data->trung);
     $bac = explode(",", $data->bac);
     $url = 'http://minhngoc.net.vn/xstt/MN/MN.php?visit=0';
     $content = file_get_contents($url);
     $arr = explode(";", $content);
     $ret = array();
     foreach ($arr as $item) {
         $tmp = explode('=', $item);
         $key = $tmp[0];
         $key = str_replace('kqxs["', '', $key);
         $key = str_replace('"]', '', $key);
         $key = str_replace("\r\n", '', $key);
         $value = end($tmp);
         $value = str_replace('"', '', $value);
         $value = preg_replace('/[^0-9]/', '', $value);
         $ret[$key] = $value;
     }
     if (date("d-m-Y", $ret["newtime"]) == date("d-m-Y", time())) {
         $tinh = explode(",", $ret["listtinhnew"]);
         $date = date("d-m-Y", time());
         foreach ($nam as $province) {
             $pro = CommonHelper::maprev($province);
             unset($ret["\r\nT" . $pro . "_LV"]);
             unset($ret["\r\n"]);
             $proexist = KqxsNam::model()->find("date=:date and provice=:provice", array(":date" => $date, ":provice" => $province));
             if (!$proexist) {
                 $model = new KqxsNam();
                 $model->date = $date;
                 $model->provice = $province;
                 $model->db = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_Gdb"]);
                 $model->nhat = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G1"]);
                 $model->nhi = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G2"]);
                 $model->ba1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G3_1"]);
                 $model->ba2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G3_2"]);
                 $model->tu1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_1"]);
                 $model->tu2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_2"]);
                 $model->tu3 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_3"]);
                 $model->tu4 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_4"]);
                 $model->tu5 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_5"]);
                 $model->tu6 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_6"]);
                 $model->tu7 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_7"]);
                 $model->nam = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G5"]);
                 $model->sau1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_1"]);
                 $model->sau2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_2"]);
                 $model->sau3 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_3"]);
                 $model->bay = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G7"]);
                 $model->tam = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G8"]);
                 $model->insert();
             } else {
                 $proexist->db = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_Gdb"]);
                 $proexist->nhat = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G1"]);
                 $proexist->nhi = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G2"]);
                 $proexist->ba1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G3_1"]);
                 $proexist->ba2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G3_2"]);
                 $proexist->tu1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_1"]);
                 $proexist->tu2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_2"]);
                 $proexist->tu3 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_3"]);
                 $proexist->tu4 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_4"]);
                 $proexist->tu5 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_5"]);
                 $proexist->tu6 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_6"]);
                 $proexist->tu7 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G4_7"]);
                 $proexist->nam = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G5"]);
                 $proexist->sau1 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_1"]);
                 $proexist->sau2 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_2"]);
                 $proexist->sau3 = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G6_3"]);
                 $proexist->bay = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G7"]);
                 $proexist->tam = preg_replace('/[^A-Za-z0-9]/', '', $ret["T" . $pro . "_G8"]);
                 $proexist->update();
             }
         }
     }
     $this->renderJSON($ret);
 }
예제 #2
0
                  Giải Đặc Biệt
                </a>
              </td>
            </tr>
          </tbody>
        </table>
      </td>
      <td valign="top" style="padding: 0;">
        
        <table class="table table-bordered" style="padding: 0;border-left: 0 !important; border-top: 0 !important;">
          <tbody>
            <tr>
                          
               <?php 
foreach ($nam as $itemnam) {
    $t = CommonHelper::maprev($itemnam->provice);
    ?>
              <td valign="top" style="padding: 0;" width="<?php 
    echo 100 / count($nam);
    ?>
%">
                <table class="table tony" cellpadding="0" cellspacing="0">
                  <tbody>
                    <tr>
                      <td class="tinh" align="center">
                        <?php 
    $tinh = Tinh::model()->findByPk($itemnam->provice);
    ?>
                        <a href="/xo-so-mien-nam/tay-ninh.html" title="<?php 
    echo $tinh->tinh;
    ?>