Jump to content

majocmatt

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by majocmatt

  1. I have a simple form here (code that I actually got from someone else), and what I'm doing is retrieving this file from another remote server and showing it in a textarea field. That works lovely. It shows up just fine in the textarea. The problem is when I submit the form, and it tries to connect to the other remote server again, it fails on fopen, fwrite, fclose and ftp_put. What I want to happen is that when you submit, it alters that file on the other server. Here is the code I'm using, followed by the errors I've received. Any ideas why it works when connecting and reading the first time, but then it can't open or write the second pass. I've chmodded the file and every directory in its path to 777. I have gotten this to work, only by moving the file to the root directory, which is pointless for the reasons I need to use it. So, it sounds like a permissions issue, but I've chmodded everything, and even before I did, the directories were set to 755, which should have allowed the file to read. Anyhow.. any ideas? Thank you. <?php $config = array ( 'ftp_user' => '*******', 'ftp_pass' => '*******', 'domain' => 'mydomain.com', 'file' => 'path/to/my/file.txt', ); if(isset($_POST['submit'])) { $fp = fopen($config['file'],'w'); fwrite($fp,stripslashes($_POST['newd'])); fclose($fp); $ftp = ftp_connect($config['domain']); ftp_login($ftp,$config['ftp_user'],$config['ftp_pass']); ftp_put($ftp,$config['file'],$config['file'],FTP_ASCII); ftp_close($ftp); } ?> <form method="post" action="<?=( $_SERVER['PHP_SELF'] )?>"> <textarea name="newd" cols="40" rows="15"><?=( file_get_contents('ftp://'.$config['ftp_user'].':'.$config['ftp_pass'].'@'.$config['domain'].'/'.$config['file']) )?></textarea> <input type="submit" name="submit" value="Save"> </form> Errors received: Warning: fopen(css/8.6.193.84:27015/cstrike/maplist.txt) [function.fopen]: failed to open stream: No such file or directory in /home/thepwned/public_html/test.php on line 13 Warning: fwrite(): supplied argument is not a valid stream resource in /home/thepwned/public_html/test.php on line 14 Warning: fclose(): supplied argument is not a valid stream resource in /home/thepwned/public_html/test.php on line 15 Warning: ftp_put(css/8.6.193.84:27015/cstrike/maplist.txt) [function.ftp-put]: failed to open stream: No such file or directory in /home/thepwned/public_html/test.php on line 19
  2. I have a database full of user input, some users enter in URLs.. when I display this information, I would like to go through the text, look for URLs and turn those into real hyperlinks... so I need to take http://www.whatever.com and make it a real hyperlink. Am I in the right place? If so, how would I go about doing this? I am using php/mysql and I would like to simply wrap a function around, for instance, my $output variable which holds the data retrieved from a user input.
  3. Sorry for the late reply, but thank you both. The Options -Indexes works like a charm, exactly how i needed it
  4. I'm not sure if this is appropriate here, but here goes. I have a website that users can sign up, when they do, it create a photos subdirectory for them according to their unique user id (i.e. photos_271), and then it creates them a thumbnail folder too. All of these user photos folders are in a main 'photos' folder. I would like to block people from seeing all of the photo_userids folders within the photos folder, and all of the sub folders. I don't just want a index.php file because I would need one in every folder thats dynamically generated. Instead, is there a way to not let people directly typing a URL get past anything with a URL prefix of http://www.mydomain.com/photos/ ???
  5. I have a table with date of births and I'm trying to select the next 3 upcoming birthdays and display them. I'm trying to use this ORDER BY clause but it seems not to want to listen to me. Can anyone help me figure out why? ORDER BY DATE_FORMAT('profile_dob', '%m-%d') > DATE_FORMAT(NOW(), '%m-%d') DESC, DATE_FORMAT('profile_dob', '%m-%d') LIMIT 3 Currently, it returns them in no particular order at all.. haha. Here is what I'm getting as the result: Sep 25, May 25, Sep 5, July 1, Sep 21, Mar 18 Any suggestions would be great.. thanks!
  6. I'll assume your just using YYYY-MM-DD, the DATE format in a database. If not, you can adapt your timestamp to the following: Create a variable for $now where $now = date("Y-m-d"); And query the database SELECT * FROM myTable WHERE date >= $now
  7. There's a few things you could do. Firstly, you need to run $_POST['password'], and username if you have one, through $password = mysql_real_escape_string($_POST['password']) Since someone can spoof the session $_SESSION['active'], I would also add the password session upon login: $_SESSION['password'] = $password; and on each page put in the if statement add: if ($_SESSION['active'] != 'TRUE' && !isset($password)) { Also, instead of isset($_POST['submit']), you could add a unique token. On the form you could start a session like $token = mt_rand() and on the processor page, make sure that session is there and the value is the same and it was on the previous page. That's a few ideas
  8. I have a site where I let users input text into my mysql database. I run their inputs through mysql_real_escape_string before I enter it into the DB and on the output I run it through htmlspecialchars. My question is: How can I add the ability for users to add things such as hyperlinks or images when all the <> brackets and such are converted to their entity counterpart? I don't want them to actually be able to input HTML, or scripts, but I would like to give them the freedom to insert hyperlinks and images, that will parse correctly on the viewing page. What's the best way around this?
  9. I have a list of country names in a database that is constantly being updated - countries are being added and deleted. It's for a client, and this is the way it has to be. My problem is getting USA to always be on top of the select dropdown list I populate on the admin page. Is this possible in a query? Can I ORDER BY countries in aplha order then force USA to be on top? I cannot order them by ID because, like I said, countries are coming and going, and it would screw up the order. I just need to know if it's possible in the query to do this? Thanks, Matt
  10. I store as a SQL DATE format (YYYY-MM-DD) ... so if I call something like this: $month_now = date("m"); SELECT * FROM myTable WHERE date > DATEADD(m, -3, $month_now) How do I get it to recognize each entires Month, and display as I listed above?
  11. It doesn't have to be a blog, but how would I go about making a script that grabs entries out of my mysql database by month, like current blogs do? January 2007 December 2006 November 2006 etc,etc I've searched on mysql's website, but i don't really understand how it works, still. I don't even care if there's nothing in one of those months, I would just like to display the last 3 months or so. Any help?
  12. Ok, i will do seperate cookies for each string, however, i dont think sessions alone will work since i want them to be persistent even if they leave and come back later. i realize this wont work if they use a diff computer but im simply trying to minimize the problems
  13. Users are able to vote via text input on my site, but they only are allowed to vote for a certain string once per day, but as many different strings per day as they like. I want to force this by setting cookies, what though, is the best way to do this since there will be multiple strings? One string per cookie or can you set an array of strings in a single cookie? Thanks.
  14. I'm curious to learn how sites, such as this one, track users so precisely. I have a web site that has a large amount of registered users, and most of these users set their login information to be 'remembered' at initial login time. I would like to show users what is new since their last visit, and also, when they surf through the different pages and come back to the 'Whats New' module on the front page, everything isn't gone, just what they have viewed during that session. Now, I think I have a solution to part of this problem I'm facing. Since user's are theoritcally always logged in (remember-me cookie), I think I would just have atop every page a: if -> is not set -> session -> send a query to the database and update the last_viewed field for the user with this instanced timestamp. Then I would compare that time to all the different entities my web site displays (blog, photos, etc) and show what is new. Is this sufficient? The second part of the problem, I do not understand well. How do I then track, only during the current session, what has been viewed from the 'whats new' list? Is this best accomplished via sessions paired with cookies?
  15. cool thanks, i got it thank you all for the valuable input, its much appreciated.
  16. Thats the thing, its a public voting system, and I dont want a constrained list of vote possibilities, users will be able to choose any name they like.
  17. but I dont neccessarily know what I will be searching for. distinct would eliminate duplicates, no?
  18. Yea I've had that problem before displaying alt's, I'm just trying to think how I fixed it because I can't find the files. did you try stripslashes too?
  19. It seems like your problem is apostraphes in your captions (alts), are you sure its printing just the first word? Or is it printing all the letters up until an apostraphe or slash?
  20. alt=".[color=red]addslahes([/color]$code['alternate'][color=red])[/color]."
  21. This might not belong here but most of you all work with mysql too... I have a voting system where people type their vote in a textbox, not from a radio group. This is because there can be so many answers. I'm currently creating a spellcheck script that will eliminate wrongly typed names, or at least try. My problem is however, tallying up the votes. DB Schema (id,vote,ip,date) - the vote field will be a name of a person. Let's say there are three entries of the name Naked Cowboy in the database, and lets say he has the most votes. How would my query find that he is indeed the most voted on. In other words, how does one construct a query to tally up duplicates of the name field? Thanks.
  22. I'm not having much luck finding what I need. Most of the info I find on the web if for making links to print the current page. I need a batch printing system. I feel I have all my ducks in a row up until the point of actually printing the reports. How do others make batch printing of selected items? Where you check all the checkboxes next to what you want printed and hit Print.
  23. Ok, I'll give it a search. But just to respond to your reply, the server is Linux  :( Also, I think that I would generate the report layout during each iteration just by storing all the html in a variable such as: $report_to_print = "<table>"; $report_to_print .= "<tr>"; $report_to_print .= "<td>Yadda yadda</td>"; etc etc... Then hopefully just use a print function (that I'm about to search for) to print($report_to_print) I'm hoping it works, also thanks for your help.
  24. Hi there, I was wondering if someone could help me out here. What I have is a page where users will choose reports via checkboxes that are next to each report name. Then when they submit the form, the processor gathers all of the selected up in an array. Next, I have a for loop that goes through each of the previously selected reports and prints them literally through the printer. The part that I cannot figure out is how to actually print them. I checked the manual and found the PECL printer_write() function, but I do not understand how to use PECL, furthermore, some of my users will be Mac and linux users, and from the description, those PECL functions dont support that. Then I thought to use javascript, but I don't know any javascript, and am having much trouble finding anything on the internet because the word 'print' has multiple definitions in the coding world. Does anyone have a suggestion that could help in achieving the ability to print to a users printer for each iteration of the loop? Thanks, Matt
  25. Alright, that code 'almost' works, except its acting a little erratic. It finds the first bad value but then prints it like 10 times then it finds some that have 'good' values, but mostly works except the multiple prints of the same one. any ideas? i've been playing with it a while.
×
×
  • 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.