SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Plain text added into a .txt doc

    I looked it up a while ago, but how exactly can you add plain text into a .txt document, and NOT allow users to be able to read it.

    Ex: Cutenews for example has it's /data/ folder, and you are not able to go into it etc. - Is that the chmod permission, 755 or something??

    But, i want to be able to ADD plain text, into a text document, and give it a title:

    ///
    $Title = 'Orange';
    -- plain text here --
    //


    or something, I have no clue what i am talking about lmao, but yeah. Can you give me a easy to understand tutorial or something please, thanks

  2. #2
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i give my files 600(RW- - ) and they work fine. i am able to read from and write to those files.
    this code will write plain text to a file. try this
    PHP Code:
    $testToWrite =' Something';
    $strToWrite "///\r\nOrange\r\n$textToWrite\r\n///";
    $fh fopen('file.txt','w') or die('cannot open file.');
    fwrite($fh,$strToWrite);
    fclose($fh); 

  3. #3
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. Then how can I post data/info from it?

    Also - You have orange inside the 2nd line, whats that surpose to mean - since i used random words in my explanation lol

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    One neat trick, especially for ini files. Just give them a php extension, then add the following code at the beginning of the file:
    PHP Code:
    ;<?php exit('HACKER'); ?>
    Keeps prying eyes out so long as PHP keeps working on the server. And if PHP dies, the whole webserver has probably gone down as well.

  5. #5
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by medicjoe95
    ///
    $Title = 'Orange';
    -- plain text here --
    //
    This is where i got orange. i just put it there you can use $title or whatever you want.

  6. #6
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $testToWrite =' Something';
    $strToWrite = "///\r\nOrange\r\n$textToWrite\r\n///";
    $fh = fopen('file.txt','w') or die('cannot open file.');
    fwrite($fh,$strToWrite);
    fclose($fh);
    So, i can do like:
    $strToWrite = "///\r\nUsername\r\n$User\r\nPassword\r\n$Pass///";
    $fh = fopen('users.txt','w') or die('cannot open file.');
    fwrite($fh,$strToWrite);
    fclose($fh);

    But, once again, how do I pull? and How would I pull for the user/pass

    EX: With mysql, i can dy WHERE user = '$Username' AND pass = '$Password'");
    Etc.

    Understand? I would want to pull for their username. But this is only one example, I would use other documents for other stuff.

    To be exactly honest, I want to be able to use this for hostultra.com accounts I have, or for friends accounts etc.

  7. #7
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ??

  8. #8
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might wanna put usernames and passwords in a specifice formats and then retrive them later easily.
    now, are you gonna store one username/password per file or many usernames/passwords per file.

    you can store them say like

    username1@@password1
    username2@@password2
    username3@@password3
    then read it and get an array for them
    PHP Code:
    $fh fopen('filename.txt','r');
    if(
    $fh)
    {
      
    $arr = array();
      while(!
    feof($fh))
      {
        
    $line fgets($fh,4096);
        
    $tempArr explode('@@',$line);
         
    $arr[$tempArr[0]] = $tempArr[1];
      }

    now $arr has all the usernames as its keys and all the passwords as its values.

    is this what you meant??

  9. #9
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No Clue what i want =P

  10. #10
    SitePoint Evangelist
    Join Date
    Sep 2004
    Location
    Oregon
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to be able to store data, like i do with my mysql databases, in text documents. Since it is more complex, i will probably just skip it =P


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •