Please see the below code.
As of now we have written codes in such a way that for example;
For the image named logo.jpg it is showing on the page titled "a" (please refer to attached screen shot) logo.jpg is the image which says IMAGE 1
If i change the image NAME from the admin it self then it is not showing on the path for the page titled "a"
I need to write the code in such a way that if i change the name of the image to lets say test.jpg, it should still be showing on the page.
Please advise,
thanx in advance,
phpquery
Code: Select all
<?php
if(isset($_POST['create']))
{
$value=$_POST['value'];
$style=$_POST['style'];
//echo $value;
$filetype=$_POST['filetype'];
$sitename=$_POST['sitename'];
if($sitename==''| $value=='')
{
header("location: home.php?ref=1");
}
else
{
mkdir('D:\work\apache2triad\htdocs\\'.$sitename,0777);
$sitepath='D:\work\apache2triad\htdocs\\'.$sitename;
}
////////////////////////////////////////////
$i=1;
while($i<=$value)
{
$file[$i]=$_POST['filename'.$i];
$key[$i]=$_POST['keyword'.$i];
if($key[$i]!='')
{
$keyw[$i]=$key[$i];
}
else
$keyw[$i]=$file[$i];
$i++;
}
////////////////////////////////////////////
$i=1;
while($i<=$value)
{
if($file[$i]!='' && $key[$i]!='')
{
$ourFileName[$i] = $sitepath.'/'.$file[$i].'_'.$key[$i].'.'.$filetype;
$ourFileHandle = fopen($ourFileName[$i], 'w') or die("can't open file");
fclose($ourFileHandle);
$filename[$i]=$file[$i].'_'.$key[$i].'.'.$filetype;
//echo $filename[$i];
}
else
{
if($file[$i]!='')
{
$ourFileName[$i] = $sitepath.'/'.$file[$i].'.'.$filetype;
$ourFileHandle = fopen($ourFileName[$i], 'w') or die("can't open file");
fclose($ourFileHandle);
$filename[$i]=$file[$i].'.'.$filetype;
}
}
$i++;
}
////////////////////////////////////////////HORIZONTAL
if($style=='horizontal')
{
$l=800/$value;
$start='<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
<title>Untitled Document</title>
</head><style type="text/css">
<!--
body {
margin-top: 0px;
margin-bottom: 0px;
}
-->
</style>
<body>
<table align=center bgcolor=#CC99FF cellspace=0 cellpadding=0 height=100 width=800 background=image/logo.jpg><tr><td valign=top>top</td></tr></table><table width=800 align=center bgcolor=#CC99FF cellspace=0 cellpadding=0 border=1><tr align=center width=800 height=25>';
$end='</tr><tr><td valign=top><tr><td border=0 background=image/image.jpg height='.$l.' width='.$l.' valign=top>image1</td></tr><tr><td border=0 background=image/image.jpg height='.$l.' width='.$l.' valign=top>image2</td></tr><tr><td border=0 background=image/image.jpg height='.$l.' width='.$l.' valign=top>image3</td></tr><tr><td border=0 background=image/image.jpg height='.$l.' width='.$l.' valign=top>image4</td></tr></td></tr><table valign=bottom align=center bgcolor=#CC99FF cellspace=0 cellpadding=0 height=100 width=800 background=image/logo.jpg><tr valign=bottom><td valign=bottom>bottom</td></tr></table></table></body></html>';
$i=$value;
while($i>0)
{
$content='<td bgcolor=#CC9900 hieght=40 width='.$l.' align=center border=1><a href=http://localhost/'.$sitename.'/'.$filename[$i].'><b>'.$file[$i].'</b></a></td>'.$content;
//$content1='<td width=400>aaaaa</td>'.$content;
$i--;
}
$cont=$start.$content.$end;
//echo $content;
}
//////////////////////////////////////////VERTICAL
if($style=='vertical')
{
$l=800/$value;
$start='<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml><head><meta http-equiv=Content-Type content=text/html; charset=utf-8 /><title>Untitled Document</title><style type="text/css">
<!--
body {
margin-top: 0px;
margin-bottom: 0px;
}
-->
</style></head><body>
<table align=center bgcolor=#CC99FF cellspace=0 cellpadding=0><tr><td>
<table align=center bgcolor=#CC99FF cellspace=0 cellpadding=0 height=100 width=800 background=image/logo.jpg><tr><td valign=top>top</td></tr></table><table border=1 width='.$l.' height='.$l.' bgcolor=#CC99FF cellspace=0 cellpadding=0>';
$end='</table><tr cellspace=0 cellpadding=0><td><tr cellspace=0 cellpadding=0><td><img src=image/image.jpg height='.$l.' width='.$l.'></tr></td><tr><td><img src=image/image.jpg height='.$l.' width='.$l.'></tr></td><tr><td><img src=image/image.jpg height='.$l.' width='.$l.'></tr></td><tr><td><img src=image/image.jpg height='.$l.' width='.$l.'></tr></td></td></tr><table valign=bottom align=center bgcolor=#CC99FF cellspace=0 cellpadding=0 height=100 width=800 background=image/logo.jpg><tr valign=bottom><td valign=bottom>bottom</td></tr></table></table></td></tr></table></body></html>';
$i=$value;
while($i>0)
{
$content='<tr width='.$l.'><td width='.$l.' bgcolor=#CC9900 height=20 width='.$l.' align=left border=1><a href=http://localhost/'.$sitename.'/'.$filename[$i].'><b>'.$file[$i].'</b></a></td></tr>'.$content;
//$content1='<td width=400>aaaaa</td>'.$content;
$i--;
}
$cont=$start.$content.$end;
//echo $content;
}
////////////////////////////////////////
$i=1;
while($i<=$value)
{
//$ourFileName1 = $sitepath.'/'.$file[$i].'_'.$key[$i].'.'.$filetype;
$ourFileHandle = fopen($ourFileName[$i], 'w') or die("can't open file");
fwrite($ourFileHandle,$cont);
fclose($ourFileHandle);
$i++;
}
}
if($_GET['ref']==1)
{
?>
<script type="text/javascript">
alert('* field should not be left blank');
</script>
<?php
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="home.php">
<table width="646" border="1" align="center">
<tr>
<td width="122">Enter No Of links</td>
<td colspan="2">
<input type="text" name="value" id="value" />
*
<input type="submit" name="enter" id="enter" value="enter" />
</td>
</tr>
<?php
if(isset($_POST['enter']))
{
$a=$_POST['value'];
$i=1;
while($i<=$a)
{
?>
<tr>
<td>enter name of files</td>
<td width="167">
<input type="text" name="filename<? echo $i;?>" id="filename" />
*
</td>
<td width="293">keyword
<input type="text" name="keyword<? echo $i;?>" id="keyword" /></td>
</tr>
<?php
$i++;
}
?>
<input name="value" type="hidden" value="<? echo $a; ?>" />
<tr>
<td>filetype
<select name="filetype" id="filetype">
<option>html</option>
<option>php</option>
</select></td>
<td>style
<select name="style" id="style">
<option selected="selected">horizontal</option>
<option>vertical</option>
</select></td>
<td>site name
<input type="text" name="sitename" id="sitename" />
*</td>
</tr>
<tr>
<td colspan="3" align="right">
<input type="reset" name="reset" id="reset" value="reset" />
<input type="submit" name="create" id="create" value="create" />
</td>
</tr>
<?php
}
?>
</table>
</form>
</body>
</html>