Jump to content

Just to show you my intelligence directory app i build up


aliento

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.