GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Mar-2005, 10:24
Qua Qua is offline
New Member
 
Join Date: Mar 2005
Posts: 2
Qua is on a distinguished road

Problem with some cheat :P


Hi

I've written down all the answers to our math test and was going to put them online for my friends, so i created 3 text files and put them in a folder together with index.php.

Then i created the following script, that was supposed to look for all text files in the dir and then automatically make them to links. Then when some of the links was pressed then the page should load itself and the text file!

SCRIPT::
PHP Code:

<?

 $dir_name = "/var/www/virtual/holdumnet/holdum.net/public_html/blaek/";
 $dir = opendir($dir_name);


 while ($file_name = readdir($dir))
    {
    if (($file_name != ".") && ($file_name != "..") && ($file_name != "index.php") && ($file_name != "secret"))
        {
        $file_list = "<a href=\"http://www.holdum.net/blaek/index.php?id=\"$file_name\"\">file_name</a>";
        }
    }
 closedir($dir);
?>
<? echo "$file_list"; ?>


<!--The object loads the manager to the text-based-database -->
<object id="tdc" classid="CLSID:333c7bc4-460f-11d0-bc04-0080c7055a83">
<param name="DataURL" value="

<?php
if (isset($_get['id']) == 1)
{
    print "$_GET['id']" ;
}
?>
">

<param name="DataType" value="html">
</object>


<div align="center">
<table border="1" class="default" datasrc="#tdc" bgcolor="#DFEBEB"  cellspacing="0" cellpadding="0" height="15">
<THEAD><TR>
<TD class="header"><strong>Stykke</strong></TD>
<TD class="header"><strong>Svar</strong></TD>
<TD class="header"><strong>Andre Bemærkninger</strong></TD>
</thead>
<TBODY>
<TR>
<TD class="body" ><DIV datafld="Column2" dataformatas=html></DIV></TD>
<TD class="body"><DIV datafld="Column1" dataformatas=html></DIV></TD>
<TD class="body"><DIV datafld="Column3" dataformatas=html></DIV></TD>
</TR>
</TBODY>
</TABLE>


 </div>
Last edited by JdS : 02-Mar-2005 at 07:14. Reason: please insert your example PHP codes between [php] and [/php] bbcode tags
  #2  
Old 03-Mar-2005, 06:56
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Sorry I didn't reply yesterday. I had already written a lot of code myself and was feeling a bit tired.

First problem, the while() loop is faulty... you are always REPLACING $file_list with each loop when you should be appending to it. So a fix could be to add the concatenating assignment operator i.e. .= to the line.

$file_list .= "<a href=\"http://www.holdum.net/blaek/index.php?id=\"$file_name\">file_name</a><br />";

You SHOULD also look at the function urlencode() and use it in your code before you display the links.
  #3  
Old 03-Mar-2005, 16:34
Qua Qua is offline
New Member
 
Join Date: Mar 2005
Posts: 2
Qua is on a distinguished road
Thx, i solved the problem myself But the urlencode was surely usefull thx alot
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advice on a disturbing problem JUNK KED Open Discussion Forum 6 31-Mar-2005 14:51
Mother board problem mrkamran Computer Hardware Forum 2 07-Oct-2004 11:31
C I/O problem kelly80 C Programming Language 4 27-Apr-2004 21:15
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 08:53
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 10:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:54.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.