Ejemplo n.º 1
0
 public static function go($fileName, $content, $fileLocation, $force)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "func" => "createFile");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array('fileName' => $fileName, 'content' => $content));
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $defaultLocation = $_SERVER["DOCUMENT_ROOT"];
     //----------------------------------------------------------
     if (substr($defaultLocation, -1) != "/") {
         $defaultLocation .= "/";
     }
     //----------------------------------------------------------
     $fileLocation = is_null($fileLocation) ? $defaultLocation : $defaultLocation . $fileLocation;
     //----------------------------------------------------------
     if (!is_dir($fileLocation)) {
         if ($force) {
             $fileLocation = GenFun::getPathFromFileLocation($fileLocation);
         }
         //------------------------------------------
         if (!is_dir($fileLocation)) {
             $chk['bool'] = false;
             $chk['message'] = $fileLocation . " directory does not exist";
             return $chk;
         }
     }
     //----------------------------------------------------------
     $file = $fileLocation . $fileName;
     //----------------------------------------------------------
     DupIncluded::createFolderStructure($file);
     //----------------------------------------------------------
     if (file_put_contents($file, $content)) {
         $chk['message'] = $file . " has been successfully created!!!!!";
     } else {
         $chk['bool'] = false;
         $chk['message'] = $file . " was not saved or did not save properly.";
     }
     //----------------------------------------------------------
     return $chk;
 }
Ejemplo n.º 2
0
 public static function createDependantFiles($content)
 {
     $arr = array();
     $phpArr = array();
     preg_match_all('~(["\'])([^"\']+)\\1~', $content, $arr);
     //----------------------------------------------------------
     for ($i = 0; $i < sizeof($arr[0]); $i++) {
         $pos = strpos($arr[0][$i], ".php?");
         //------------------------------------------------------
         if (strpos($arr[0][$i], ".php") !== false) {
             if ($pos !== false) {
                 $arr[0][$i] = substr($arr[0][$i], 0, $pos + 4);
             }
             //--------------------------------------------------
             if (strpos($arr[0][$i], "{SERVICES_PATH}") !== false) {
                 $arr[0][$i] = str_replace("{SERVICES_PATH}", Import::$uber_src_path . Constants::SERVICES_PATH, $arr[0][$i]);
                 //$arr[0][$i] = $_SERVER["DOCUMENT_ROOT"].$arr[0][$i];
             } else {
                 //$arr[0][$i] = GenFun::get_local_url($arr[0][$i]);
                 $arr[0][$i] = GenFun::get_local_url($_SERVER['HTTP_REFERER']) . $arr[0][$i];
                 $arr[0][$i] = StringUtil::removeQuotes($arr[0][$i]);
             }
             //--------------------------------------------------
             array_push($phpArr, $arr[0][$i]);
         }
     }
     //----------------------------------------------------------
     $phpArr = array_unique($phpArr);
     //----------------------------------------------------------
     for ($i = 0; $i < sizeof($phpArr); $i++) {
         include_once $phpArr[$i];
     }
     //print_r($phpArr);
     //krumo($included_files = get_included_files());
     DupIncluded::go("Modules/", "min/");
 }