/** * Copy all files to folder , it will ignore when file is existed * @param string $src * @param string $dest */ function copyfolder($src, $dst) { $dir = opendir($src); @mkdir($dst, 0777, true); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { copyfolder($src . '/' . $file, $dst . '/' . $file); } else { if (false === file_exists($dst . '/' . $file)) { copy($src . '/' . $file, $dst . '/' . $file); } } } } closedir($dir); }
{ //Open the specified directory $directory = opendir($source); //Create the copy folder location mkdir($destination); //Scan through the folder one file at a time while (($file = readdir($directory)) != false) { //Copy each individual file if ($file != NULL && $file != '.' && $file != '..') { copy($source . '/' . $file, $destination . '/' . $file); } } } $path_chk = public_path() . "/assets/itsp_assets/data/" . $by; if (!file_exists($path_chk . '/')) { copyfolder(public_path() . "/assets/itsp_assets/data/template", $path_chk); } if (!file_exists($path_chk . '/projectdetailstext.txt')) { copy(public_path() . "/assets/itsp_assets/data/template/projectdetailstext.txt", $path_chk . '/projectdetailstext.txt'); } function fetch_data($path_to_file, $text = 1) { $str = ""; if (file_exists($path_to_file)) { $file = fopen($path_to_file, "r"); while (!feof($file)) { $str .= fgets($file); } fclose($file); $str = trim($str); }
foreach ($ini_file as $k => $v) { preg_replace_file($k, '/zend_extension.*=.*/i', "zend_extension = " . realpath($v) . PHP_EOL); } echo "OK" . PHP_EOL; // copy phpMyAdmin config.sample.php to config.php echo "Configuring phpMyAdmin ... "; $conf_file = "{$PHPDEVSERVER_HOME}/phpmyadmin/config.inc.php"; $sample_file = "{$PHPDEVSERVER_HOME}/phpmyadmin/config.sample.inc.php"; if (!file_exists($conf_file)) { copy($sample_file, $conf_file); preg_replace_file($conf_file, "/\\\$cfg\\[\\'blowfish_secret\\'\\].*=.*/i", "\$cfg['blowfish_secret'] = '" . md5(time()) . "';"); } echo "OK" . PHP_EOL; echo "Configuring Apache24 ... "; // copy Apache24 config file copyfolder("{$PHPDEVSERVER_HOME}/bin/scripts/templates/Apache24", "{$PHPDEVSERVER_HOME}/Apache24"); $conf_file = "{$PHPDEVSERVER_HOME}/Apache24/conf/httpd.conf"; /* if(file_exists($conf_file)) { preg_replace_file( $conf_file , "/%__PHPDEVSERVER__%/i", cpath($PHPDEVSERVER_HOME) ); }*/ if (file_exists($conf_file)) { preg_replace_file($conf_file, '/Define SRVROOT \\"\\/Apache24\\"/i', 'Define SRVROOT "' . cpath($PHPDEVSERVER_HOME) . '/Apache24"'); } echo "OK" . PHP_EOL; // Replace all php fcgid setting echo "Configuring PHP as Apache fcgid module ... ";