예제 #1
0
파일: fecth.php 프로젝트: TiMoChao/xingfu
                 $isQuan = 1;
                 if (stripos($v1, 'http') === false) {
                     $isQuan = 0;
                 }
                 $FileExt = strtolower(strrchr($v1, '.'));
                 $strFileName = time() . '_' . $k1 . $FileExt;
                 $strSaveFileName = $strSaveDir . $strFileName;
                 $strCallFileName = $strDir . $strFileName;
                 if ($isQuan) {
                     $objSnoopy->fetch($v1);
                 } else {
                     $objSnoopy->fetch($arrGFetch[$_GET['id']]['list_host'] . $v1);
                 }
                 $strImg = $objSnoopy->results;
                 if (!empty($strImg)) {
                     $isOK = check::write_file($strSaveFileName, $strImg);
                 }
                 if ($isOK) {
                     $strTemp = str_replace($v1, $strCallFileName, $strTemp);
                 }
             }
         }
         break;
 }
 $arrSave[$v[0]] .= $strTemp;
 if (empty($arrSave[$v[0]])) {
     check::AlertExit('标题采集为空,请检查!', -1);
 }
 if ($v[0] == 'title') {
     $arrInfoWhere = check::getAPI($arrGFetch[$_GET['id']]['module_id'], 'getInfoWhere', "WHERE `title` = '{$strTemp}'^id");
     if (!empty($arrInfoWhere)) {
예제 #2
0
 /**
  * 生成INSERT 语句
  *
  * @access  public
  * @param
  *
  * @return void
  */
 function get_table_content($table, $sql, $mark = false)
 {
     $trans = array("'" => "\\'", "\n" => '\\n', "\r" => '\\r');
     /* 获取数据表数据 */
     $strContentTotal = "SELECT count(*) as num FROM {$table}";
     try {
         $rs = $this->db->prepare($strContentTotal);
         $rs->execute();
         $intTotal = current($rs->fetch(PDO::FETCH_ASSOC));
     } catch (PDOException $e) {
         die("Failed: " . $e->__toString());
     }
     $sql = "\n-- \n-- Dumping data for table `{$table}` \n-- \n\n";
     for ($a = 0; $a <= $intTotal; $a += 100) {
         $content_query = "SELECT * FROM {$table} limit {$a},100";
         try {
             $rs = $this->db->prepare($content_query);
             $rs->execute();
             $arrData = $rs->fetchall(PDO::FETCH_ASSOC);
         } catch (PDOException $e) {
             die("Failed: " . $e->__toString());
         }
         /* 创建数据插入语句 */
         $tag = true;
         $is_first = 1;
         foreach ($arrData as $k => $v) {
             $sql_insert = '';
             if ($tag) {
                 $keys = array();
                 $keys = array_keys($v);
                 $field_names = array();
                 for ($i = 0; $i < count($keys); $i++) {
                     $field_names[] = $keys[$i];
                 }
                 $table_list = array();
                 $table_list = implode('`,`', $field_names);
                 $table_list = '( `' . $table_list . '`)';
                 $tag = false;
             }
             reset($keys);
             $values = array();
             for ($i = 0; $i < count($v); $i++) {
                 $values[] = str_replace("\\\\'", "\\\\''", strtr($v[$keys[$i]], $trans));
                 //$values[] = $v[$keys[$i]];
             }
             $field_values = implode('\', \'', $values);
             $field_values = '( \'' . $field_values . '\' )';
             $field_values = str_replace("\\'", "''", $field_values);
             if ($mark) {
                 if ($is_first == 1) {
                     $sql_insert = "INSERT INTO `{$table}` VALUES {$field_values} ,\n";
                     $is_first++;
                 } else {
                     $sql_insert = $field_values . ",\n";
                 }
             } else {
                 $sql_insert = "INSERT INTO `{$table}` {$table_list} VALUES {$field_values} ;\n";
             }
             $sql .= $sql_insert;
             //echo $sql;exit;
         }
         if ($mark) {
             $sql[strlen($sql) - 2] = ';';
         }
         if (check::write_file($this->cache, $sql, 'a')) {
             $sql = '';
         }
     }
     return true;
 }