aliento Posted September 3, 2009 Share Posted September 3, 2009 I always ask now is time to give. THE ONE FILE BELLOW : From 2 arrays it creates the directories and a subcategory at the filesystem . It stores into every directory the infos into an nfo file it adds the categories to the db with there ids At every folder i include a index.php which inside takes the data i need from the data.nfo and includes the main and one index.php will be used <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="el, en" /> </head> <body> <?php include "nomoi.php"; // it includes 2 arrays , the names of the categories it should create function dwrite($i,$nomoi_el,$nomoi_en) { $id = $i ; $mysql_id = mysql_connect('localhost', 'root', ''); mysql_select_db("lefta"); mysql_query("SET NAMES 'utf8'"); $sql = "INSERT INTO `nomoi` (id, nomoi_el, nomoi_en ) VALUES ('".$id."' , '".$nomoi_el."' , '".$nomoi_en."' ) ;"; mysql_query($sql) or die(mysql_error()); } function index_nomoi($nomoi_en,$nomoi_el,$nomoi_id) { $text = $nomoi_en.";"; $text .= $nomoi_el.";"; $text .= $nomoi_id; return $text; } function index_mere($nomoi_en,$nomoi_el,$nomoi_id) { $text = $nomoi_en.";"; $text .= $nomoi_el.";"; $text .= $nomoi_id.";"; $text .= "subdirectory"; return $text; } function write($path, $content) { $path=$path."/info.dir"; if (file_exists($path) && !is_writeable($path)) { return false; } if ($fp = fopen($path, "w")) { fwrite($fp, $content); fclose($fp); chmod($path,0777);} else { return false; } return true; } function copyindexnomoi($path) { $old = './build/nomos.php'; $new = $path.'/index.php'; copy($old, $new) or die("Unable to copy $old to $new."); chmod($new,0777); } function copyindexsubdirectory($path) { $old = './build/nomos.php'; $new = $path.'/index.php'; copy($old, $new) or die("Unable to copy $old to $new."); chmod($new,0777); } for ($i=0;$i<count($nomoi_en);$i++) { mkdir("./dir/".$nomoi_en[$i]); // directory creation for directory chmod("./dir/".$nomoi_en[$i],0777); write("./dir/".$nomoi_en[$i], index_nomoi($nomoi_en[$i],$nomoi_el[$i],$i+1)); // write info for the directory copyindexnomoi("./dir/".$nomoi_en[$i]); // copy index.php for the directory of directory dwrite($i+1,$nomoi_el[$i],$nomoi_en[$i]); // copy to mysql the dyrectory mkdir("./dir/".$nomoi_en[$i]."/subdirectory"); // make subdirectory directory chmod("./dir/".$nomoi_en[$i]."/subdirectory",0777); write("./dir/".$nomoi_en[$i]."/subdirectory", index_mere($nomoi_en[$i],$nomoi_el[$i],$i+1)); // write info for the subdirectory copyindexsubdirectory("./dir/".$nomoi_en[$i]."/subdirectory"); // copy index for subdirectory } echo 'Done! Check it out'; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/172950-just-to-show-you-my-intelligence-directory-app-i-build-up/ Share on other sites More sharing options...
trq Posted September 3, 2009 Share Posted September 3, 2009 The point of this is what? No offense, but every heard of indentation? Link to comment https://forums.phpfreaks.com/topic/172950-just-to-show-you-my-intelligence-directory-app-i-build-up/#findComment-911551 Share on other sites More sharing options...
aliento Posted September 3, 2009 Author Share Posted September 3, 2009 i didn't know this 'indentation' It came from a hard thought through years to me. I am not disappointed i feel rather more excited to go on ... Link to comment https://forums.phpfreaks.com/topic/172950-just-to-show-you-my-intelligence-directory-app-i-build-up/#findComment-911561 Share on other sites More sharing options...
gevans Posted September 3, 2009 Share Posted September 3, 2009 i didn't know this 'indentation' <?php function this_is_my_function() { $this = 'has been indented'; return $this_var; } ?> Link to comment https://forums.phpfreaks.com/topic/172950-just-to-show-you-my-intelligence-directory-app-i-build-up/#findComment-911577 Share on other sites More sharing options...
aliento Posted September 3, 2009 Author Share Posted September 3, 2009 a ok i didnt study php on school to know everything. I post it here to show you the logic i use to create a all directory application easy just with one file, i know the code is pure. Link to comment https://forums.phpfreaks.com/topic/172950-just-to-show-you-my-intelligence-directory-app-i-build-up/#findComment-911587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.