ok i need php functon names for the following.
questions lead to long posts, which take me away from working. So hello smart people, help me. I need function names for: (php)

file saving
file writes
filename generators

for the saving part i was thinking tmpfile , fwrite & fclose, or file_put_contents... any suggestions
It should all be on this page here:
http://us2.php.net/manual/en/ref.filesystem.php

The PHP Reference Guide is an excellent place to find functions and theis syntax. I use it all the time when I use PHP. File writes is the same as file saving, so you don't need to worry about that. I'm not quite sure what you mean by "filename generators" but md5() can help to make random ones if thats what you want.

Tip:
Thermoman wrote:
questions lead to long posts, which take me away from working.

Being vague takes even more time. We have to ask what it is you want exactly and then you have to post clarifying.
user comes to my site
now the funny kids will think its cool to give them funny file names like assface so! i assign one for them, a system where 5 numbers are generated and then used as the file name os everyone feels happy. If i say more now i would ruin the fun part where u guys guess what im thinking
just make sure you dont overwrite existing files. I recommend using the current system time when the upload happens as part of the filename, plus a hash of the original
ok the filename is generated by the users name inputso from that would this work. 1,2,3,4,5 being the users quotes.

Code:

<?php
$quotes = '' . $_GET['1'] . '\n' . $_GET['2']  . '\n' . $_GET['3']  . '\n' . $_GET['4']  . '\n' . $_GET['5']  . '';

$handle = $filename
fwrite($handle, $quotes);
fclose($handle);
?>
Yes, but. That's a horrible method because you're not filtering user input at all. The user can _directly_ write arbitrary code to your webserver that way. Also, you're not defining $handle correctly. You need to use the fopen() command.
i need some help fixing this

http://www.thermomods.com/files/quotes/custom-quote.php

if u think u can help IM me plz
It looks like you're still trying to write to a nonexistant file handle to me...
KermMartian wrote:
It looks like you're still trying to write to a nonexistant file handle to me...


that was just to see what hte whole code does. as i was going to explain later because this is a custom thing for anyone i need someway of created filenames for the user, so i have them enter any name and it does an md5 on it making it into numbers. from that the filename it given to the rest of the post. if anyone thinks they can help i'll just post the full code here but im afriad some of the people i dislike may come here and follow what i have done *cough*bjway bandit*cough* (i think only Kerm knows him)
Thermoman wrote:
KermMartian wrote:
It looks like you're still trying to write to a nonexistant file handle to me...


that was just to see what hte whole code does. as i was going to explain later because this is a custom thing for anyone i need someway of created filenames for the user, so i have them enter any name and it does an md5 on it making it into numbers. from that the filename it given to the rest of the post. if anyone thinks they can help i'll just post the full code here but im afriad some of the people i dislike may come here and follow what i have done *cough*bjway bandit*cough* (i think only Kerm knows him)
Just post it. I somehow doubt he reads this at all. :/ Plus, I'm sure whatever I tell you is stuff that can be found anywhere on the internet if you know what you're searching for.
rofl well im not sure what im looking for so im here Smile

This is the page you guys see

Code:

<?php
switch ($_GET['p'])
{
default:
echo <<<TYPE
<form method="post" action="custom-quote.php?p=2">
<p>Name: <input name="user" type="text"></p>
<p>Comments:<br />
<p><input name="1" type="text"></p>
<p><input name="2" type="text"></p>
<p><input name="3" type="text"></p>
<p><input name="4" type="text"></p>
<p><input name="5" type="text"></p>
<p><input type=submit value=Submit></p>
TYPE;
break;

case '2':
$name = md5($_GET['user']);
$filename = array(0,0,0,0,0,0);
for($i=0;$i<32;$i+=8)
{
   for($j=0;$j<8;$j++) {
   $filename[$j] += substr($name,$i+$j,1);
   }
}
$filename = '' . $filename[0] . $filename[1] . $filename[2] . $filename[3] . $filename[4] . $filename[5] . ''.txt;
if (file_exists($filename)) {
  $filename = '' . $filename[0] . $filename[1] . $filename[2] . $filename[3] . $filename[4] . ''.txt;
} else {
}
$quotes = '' . $_GET['1'] . '\n' . $_GET['2']  . '\n' . $_GET['3'] . '\n' . $_GET['4']  . '\n' . $_GET['5']  . '';
$handle = ($filename);
fwrite($handle, $quotes);
fclose($handle);
echo <<<TEST
<img src="quote.php?id=' . $filename . '" />
TEST;
break;
}
?>

the page to generate the quote isn't worth seeing yet
Here's one I made. Modify it to your liking.

Code:
<?php
function sfopen($file,$mode="r"){
   global $ofile;
   for($x=0; $x < 5; $x++){
      if(!$ofile = fopen($file, $mode)) sleep(1);
      else{return true; break;}
   }
   $dstate=<<< DSTATE
   There was a problem while trying to access a file on the server.<br>
   <a href="#" onclick="document.location.reload()">Click here to retry.</a></body></html>
DSTATE;
   die($dstate);
   return false;
}

function censor($input) {
   if (file_exists("filterlist.txt"))
      $flist="filterlist.txt";
   @$fh=fopen($flist,"r");
   while($word=@fgets($fh,filesize($flist))) {
      if(!empty($word)){$input=preg_replace("/".trim($word)."/i","[***]",$input); }
   }
   return $input;
}

function truncate($string, $max = 50, $rep = '') {
   $leave = $max - strlen ($rep);
   return substr_replace($string, $rep, $leave);
}

$fnamePrefix="quotes_";
$fnameSuffix=".txt";

$file=$fnamePrefix.time().$fnameSuffix;
$quotes=array("");
for($x=1;$x<5;$x++){
   $quotes[]=truncate(htmlentities(censor($_POST[$x])),500);
}

sfopen($file,"w");
fputs($ofile,implode("\n",$quotes));
?>
thank you but this was a bit confusing lol
all i need was it to write the stuff they wrote in the 5 text boexes to a file w/ a generated name. the code you posted has censors and stuff. personally im not responsible for user content and i will clearly display this when i make the final version
It's not a matter of responsibility for content, it's a matter of getting hacked.
true true, i will work on this later, i kinda just stopped working on this, i guess i will do some edits later
Explination of functions (that I probably should of commented):

function sfopen() - "Safely" opens a file for writing or reading so if it is already open, or something bad happens, it will wait and try again a few times and if still no luck, will give up and give the visitor an nice little error message.

function censor() - If you make a file called "filterlist.txt" it will remove whatever words you put in the list. Otherwise, it leaves the input alone.

function truncate() - If input is longer then however many characters you define, it will get cut off. I'm sure you don't want people making 10k posts...
thank you i didn't know that
i will try to use your stuff later tonight
do you have aim? or any way i can reach you incase i have a problem?
By webste: http://pyros.blogsite.org - You can post it in the Bug Reports room (don't post in Main or Dragonrage will bug you).
Or by email: pyro_xp2k[at]yahoo.com (Edited by jpez to be safe from spambots)
im just stuck doing work for the video game im making now. I made 43 bricks just now from hand, so if someone wants to make the php code for me i would love that
I saw those bricks, they're ok... (don't worry, I won't share them.) And pyro, that's a good piece of code you've got there; I didn't know you knew PHP.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement