Example #1
0
 private function copycatalog($folderGuid, $space, $source, $target)
 {
     $source = "http://files.hukumonline.com/uploads/files";
     $catalogDb = new App_Model_Db_Table_Catalog();
     $catalogs = $catalogDb->fetchCatalogInFolder($folderGuid);
     $count = 1;
     foreach ($catalogs as $data) {
         $catalogs0 = $catalogDb->getCatalogByGuid($data->guid);
         $rowsetCatalogAttribute0 = $catalogs0->findDependentRowsetCatalogAttribute();
         $fixedTitle0 = $rowsetCatalogAttribute0->findByAttributeGuid('fixedTitle');
         $message = $space . $count . " > " . $data->guid . " ( " . $fixedTitle0['value'] . " )<br>";
         $this->printMessage($message, "", "");
         $count++;
         $relatedItemDb = new App_Model_Db_Table_RelatedItem();
         $filesCatalog = $relatedItemDb->fetchDocumentById($data->guid, "RELATED_FILE");
         $count1 = 1;
         foreach ($filesCatalog as $data1) {
             $catalogs1 = $catalogDb->getCatalogByGuid($data1->itemGuid);
             $rowsetCatalogAttribute = $catalogs1->findDependentRowsetCatalogAttribute();
             $docSystemName = $rowsetCatalogAttribute->findByAttributeGuid('docSystemName');
             $docSystemName = $docSystemName['value'];
             $docOriginalName = $rowsetCatalogAttribute->findByAttributeGuid('docOriginalName');
             $docOriginalName = $docOriginalName['value'];
             $success = false;
             $sDir1 = $source . "/" . $docSystemName;
             $sDir2 = $source . "/" . $data->guid . "/" . $docSystemName;
             $sDir3 = $source . "/" . $docOriginalName;
             $sDir4 = $source . "/" . $data->guid . "/" . $docOriginalName;
             if ($this->url_exists($sDir1)) {
                 $url = $sDir1;
                 $outputfile = $target . '/' . $docOriginalName;
                 $success = true;
                 echo $space . "&nbsp;&nbsp;&nbsp;96 -> sDir1 : " . $sDir1 . "<br>";
                 echo $space . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\$docOriginalName : " . $docOriginalName . "<br>";
                 //exec('wget -O '.$docOriginalName.' -P '.$sDir1);
                 $cmd = "/usr/bin/wget -O \"{$outputfile}\" \"{$url}\"";
                 exec($cmd);
             } else {
                 if ($this->url_exists($sDir2)) {
                     $url = $sDir2;
                     $outputfile = $target . '/' . $docOriginalName;
                     //$cmd = "wget -O - -P \"$url\" > $outputfile";
                     $cmd = "/usr/bin/wget -O \"{$outputfile}\" \"{$url}\"";
                     /*set_time_limit(0);
                     		 $file = file_get_contents($url);
                     		file_put_contents($outputfile, $file);*/
                     //exec('wget -O '.$docOriginalName.' -P '.$sDir2);
                     //exec('wget -O - -P '.$sDir2.' > '.$docOriginalName);
                     exec($cmd);
                     $success = true;
                     echo $space . "&nbsp;&nbsp;&nbsp;96 -> sDir2 : " . $sDir2 . "<br>";
                     echo $space . "\$docOriginalName : " . $docOriginalName . "<br>";
                 } else {
                     if ($this->url_exists($sDir3)) {
                         $url = $sDir3;
                         $outputfile = $target . '/' . $docOriginalName;
                         $cmd = "/usr/bin/wget -O \"{$outputfile}\" \"{$url}\"";
                         $success = true;
                         echo $space . "&nbsp;&nbsp;&nbsp;96 -> sDir3 : " . $sDir3 . "<br>";
                         //exec('wget -O '.$docOriginalName.' -P '.$sDir3);
                         exec($cmd);
                         echo $space . "\$docOriginalName : " . $docOriginalName . "<br>";
                     } else {
                         if ($this->url_exists($sDir4)) {
                             $url = $sDir4;
                             $outputfile = $target . '/' . $docOriginalName;
                             $cmd = "/usr/bin/wget -O \"{$outputfile}\" \"{$url}\"";
                             $success = true;
                             echo $space . "&nbsp;&nbsp;&nbsp;96 -> sDir4 : " . $sDir4 . "<br>";
                             //exec('wget -O '.$docOriginalName.' -P '.$sDir4);
                             exec($cmd);
                         } else {
                             $this->failCatalog[] = $data->guid . " ( " . $fixedTitle0['value'] . " )";
                         }
                     }
                 }
             }
             $count1++;
         }
     }
 }