[PHP] php exe from cli, but no web
Hi, I won't be redundant by saying I'm new to PHP, so I won't :) The following code works by doing; php file.php contents of file.php; * I config'd this ssh user to not need a password, copied its key. I place this file off of web root and point my browser to web root and type the file name; http://mywebroot/file.php but it doesn't exe. I'm not expecting to see a screen full, but I check to see if the perl script runs on the remote host, and it doesn't. All is well from a CLI. Any suggestions are greatly appreciated, - aurfalien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php exe from cli, but no web
wow, that was ez! thanks a lot. i also enabled php logging and checked my apache logs and it was as you said. very cool. my httpd process runs as apache, but I also did a whoami php script to very this. thanks again stu, you helped out hugely! - aurf On Mar 31, 2009, at 3:38 PM, Stuart wrote: 2009/3/31 : Hi, I won't be redundant by saying I'm new to PHP, so I won't :) The following code works by doing; php file.php contents of file.php; * I config'd this ssh user to not need a password, copied its key. I place this file off of web root and point my browser to web root and type the file name; http://mywebroot/file.php but it doesn't exe. I'm not expecting to see a screen full, but I check to see if the perl script runs on the remote host, and it doesn't. All is well from a CLI. Any suggestions are greatly appreciated, PHP runs as a different user in a web server, usually nobody but it depends on how your system has been set up. Given that it should be obvious that the keys you've set up for the user you run it as from the command line will not be used from the web server. Hope that gives you enough info to solve the problem. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] syntax woes
Hi all, I'm unsure how to describe this but I'll try. The following code works fine in its own PHP script; $mkdircmd = '/bin/mkdir /homes/'.$uid; exec($mkdircmd); But when placed in a larger PHP script being part of the ldap_provisioning module in Drupal, the Drupal GUI is blank until I do; $mkdircmd = "'/bin/mkdir /homes/'.$uid"; ... were I surrounded the variable with "", which causes it to not work. I'm totally unsure how to approach this and am hoping syntax adjustments will fix it. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax woes
aurfal...@gmail.com wrote: Hi all, I'm unsure how to describe this but I'll try. The following code works fine in its own PHP script; $mkdircmd = '/bin/mkdir /homes/'.$uid; exec($mkdircmd); But when placed in a larger PHP script being part of the ldap_provisioning module in Drupal, the Drupal GUI is blank until I do; $mkdircmd = "'/bin/mkdir /homes/'.$uid"; ... were I surrounded the variable with "", which causes it to not work. $mkdircmd = "/bin/mkdir /homes/$uid"; or $mkdircmd = "/bin/mkdir /homes/${uid}"; Should fix the syntax. I guess you've already solved the permissions problem on the /homes/ folder (normally the web server would not be able to create such a path because of permission issues). Blank GUI - no idea. Anything in the error logs (php or apache) ? Maybe asking on a drupal specific list would be a better idea for that one. -- Postgresql & php tutorials http://www.designmagick.com/ Thanks Chris. I appreciate the response. I was hoping my description wasn't too vague because I don't really understand what I'm doing. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax woes
On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote: aurfal...@gmail.com wrote: Hi all, I'm unsure how to describe this but I'll try. The following code works fine in its own PHP script; $mkdircmd = '/bin/mkdir /homes/'.$uid; exec($mkdircmd); But when placed in a larger PHP script being part of the ldap_provisioning module in Drupal, the Drupal GUI is blank until I do; $mkdircmd = "'/bin/mkdir /homes/'.$uid"; ... were I surrounded the variable with "", which causes it to not work. $mkdircmd = "/bin/mkdir /homes/$uid"; or $mkdircmd = "/bin/mkdir /homes/${uid}"; Should fix the syntax. I guess you've already solved the permissions problem on the /homes/ folder (normally the web server would not be able to create such a path because of permission issues). Blank GUI - no idea. Anything in the error logs (php or apache) ? Maybe asking on a drupal specific list would be a better idea for that one. -- Postgresql & php tutorials http://www.designmagick.com/ Thanks Chris. I appreciate the response. I was hoping my description wasn't too vague because I don't really understand what I'm doing. - aurf This might sound stupid because I've not played with Drupal, but what's wrong with using the mkdir command in PHP instead of the exec call? Ash www.ashleysheridan.co.uk Hi Ash, I didn't know there was one. Lemme study it up, thanks for the suggestion. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax woes
On Thu, 2009-04-02 at 15:58 -0700, aurfal...@gmail.com wrote: On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote: aurfal...@gmail.com wrote: Hi all, I'm unsure how to describe this but I'll try. The following code works fine in its own PHP script; $mkdircmd = '/bin/mkdir /homes/'.$uid; exec($mkdircmd); But when placed in a larger PHP script being part of the ldap_provisioning module in Drupal, the Drupal GUI is blank until I do; $mkdircmd = "'/bin/mkdir /homes/'.$uid"; ... were I surrounded the variable with "", which causes it to not work. $mkdircmd = "/bin/mkdir /homes/$uid"; or $mkdircmd = "/bin/mkdir /homes/${uid}"; Should fix the syntax. I guess you've already solved the permissions problem on the / homes/ folder (normally the web server would not be able to create such a path because of permission issues). Blank GUI - no idea. Anything in the error logs (php or apache) ? Maybe asking on a drupal specific list would be a better idea for that one. -- Postgresql & php tutorials http://www.designmagick.com/ Thanks Chris. I appreciate the response. I was hoping my description wasn't too vague because I don't really understand what I'm doing. - aurf This might sound stupid because I've not played with Drupal, but what's wrong with using the mkdir command in PHP instead of the exec call? Ash www.ashleysheridan.co.uk Hi Ash, I didn't know there was one. Lemme study it up, thanks for the suggestion. - aurf PHP can do everything ;) Ash www.ashleysheridan.co.uk Wow, it does chown and chmod as well, thats friggen cool. Ok, then, I'm sold, PHP can do everything... ... but save us from ourselves. Sorry, I had to kik that in. Tech will be the death of us all, wahahahahaha :) - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax woes
Hi all, For any one following this thread, here is how I worked around the apache/php/chown limitation. script snippet (and if any one has a more elegant style, please share as I am an amateur script kiddie). $path = "/homes".$username; $chowncmd = "/usr/bin/sudo /bin/chown "; mkdir($path); chmod($path, 0775); exec($chowncmd.$username. " ".$path); I modified /etc/sudoers; #Defaults requiretty - I added the comment. apache ALL = NOPASSWD: /bin/chown - added this line. - aurf On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote: Chris wrote: Shawn McKenzie wrote: Chris wrote: Wow, it does chown and chmod as well, thats friggen cool. chown will only work if the script is running as root which I doubt your drupal site will be. Or if the script is running as a user/group that has write permissions to the dir/file that your trying to chown. chmod may allow that, but not chown. I believe it depends upon the operating system and version of the operating system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] string concatenation with fgets
Hi all, I'm trying to append some text to what I read from a file. My code; $file = fopen("foo.txt", "r"); while (!feof($file)) { $line = fgets($file); print $line."sometext"; } fclose($file); foo,txt; a b c d e f g And when I run the script, it looks like; a sometextb sometextc sometextd ... Any ideas? Thanks in advance, - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation with fgets
On Nov 24, 2009, at 5:55 PM, Nirmalya Lahiri wrote: --- On Wed, 11/25/09, aurfal...@gmail.com wrote: From: aurfal...@gmail.com Subject: [PHP] string concatenation with fgets To: php-general@lists.php.net Date: Wednesday, November 25, 2009, 7:00 AM Hi all, I'm trying to append some text to what I read from a file. My code; $file = fopen("foo.txt", "r"); while (!feof($file)) { $line = fgets($file); print $line."sometext"; } fclose($file); foo,txt; a b c d e f g And when I run the script, it looks like; a sometextb sometextc sometextd ... Any ideas? So, what output you actually wants from your program? Is it like this asometextbsometextcsometext.. or, like this asometext bsometext csometext Hi, Sorry, I was incomplete :) I would like; asometext bsometext csometext Basically, I would like to add whatever text to the end of what I find in the file. So if the file contains a b c I would like; asometext bsometext csometext... - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation with fgets
On Nov 24, 2009, at 5:52 PM, ryan wrote: Is this what you want $file = fopen("test.txt", "r"); while (!feof($file)) { $line = trim(fgets($file)); print $line."sometext\n"; } fclose($file); outputs asometext bsometext csometext Ref to http://us3.php.net/manual/en/function.fgets.php. "Reading ends when /length/ - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line. " aurfal...@gmail.com wrote: Hi all, I'm trying to append some text to what I read from a file. My code; $file = fopen("foo.txt", "r"); while (!feof($file)) { $line = fgets($file); print $line."sometext"; } fclose($file); foo,txt; a b c d e f g And when I run the script, it looks like; a sometextb sometextc sometextd ... Any ideas? Thanks in advance, - aurf OMG, very very cool, thanks Ryan. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wiki recommendation?
On Nov 25, 2009, at 2:42 PM, Skip Evans wrote: Hey all, I'm looking for a good Wiki to maintain documentation on a large commercial web site that is always growing. DokuWiki is the only one I've installed and used at any length, so before I just use that one again I'd like to hear from the peanut gallery what other suggestions you'd have. Remember, this will be for end user documentation for a large commercial CMS type system, something site admins will go to for information on site features, updates, etc. Let the shouting begin! Thanks, all, and a very happy eating-charred-dead-bird-flesh day to you all!!! Skip Well, I've used DocuWiki and bit new to MediaWiki which I think WikiPedia uses. MediaWiki uses a MySQL DB were as DocuWiki is a tree dir structure kind of thing. I actually prefer DocuWiki but maybe thats because I didn't setup MediaWiki correctly. Cacti uses DocuWiki by the way and I personally avoid DB usage if possible. I think its easier to corrupt a DB then it is to corrupt a filesystem. However I'm unsure of how scalable a pure file system based Wiki is, I think if you put it on a mirrored disk with a decent cache on the Raid controller, you'll be fine performance and DR wise. If its Linux, then MD based (software raids) works pretty well. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation with fgets
So here is my final test code, notice the check for ' ' in the if. Since I'm on Linux, this has to do with whats between the last LF and EOF which is nothing but this nothing will get printed out. $file = fopen("somefile.txt", "r"); while (! feof($file)) { $names = trim(fgets($file)); if ($names == '') { break; } print $names."sometext\n"; } fclose($file); - aurf On Nov 24, 2009, at 5:52 PM, ryan wrote: Is this what you want $file = fopen("test.txt", "r"); while (!feof($file)) { $line = trim(fgets($file)); print $line."sometext\n"; } fclose($file); outputs asometext bsometext csometext Ref to http://us3.php.net/manual/en/function.fgets.php. "Reading ends when /length/ - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line. " aurfal...@gmail.com wrote: Hi all, I'm trying to append some text to what I read from a file. My code; $file = fopen("foo.txt", "r"); while (!feof($file)) { $line = fgets($file); print $line."sometext"; } fclose($file); foo,txt; a b c d e f g And when I run the script, it looks like; a sometextb sometextc sometextd ... Any ideas? Thanks in advance, - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to prevent a mild DOSS attack?
On Nov 28, 2009, at 9:24 AM, LAMP wrote: LinuxManMikeC wrote: On Wed, Nov 25, 2009 at 3:57 PM, Ashley Sheridan wrote: On Wed, 2009-11-25 at 16:38 -0600, LAMP wrote: hi guys, this morning I got complains from website owner and tons of visitors - nobody was able to access the website. it will just timeout. I contacted hosting company for more info but they said the virtual privet server, where the website is, has a lot of traffic and 512MB of RAM is not enough and I have to make an upgrade to at least 1GB etc. it does a make a sense. though, at 4pm I, nor 10 other people I asked for help, was able to access to the website. it was a little bit fishy about BIG traffic whole day long (the website is far from it) and, since I don't have a problem accessing WHM/ cPanel of the server, I downloaded apache access file (stupid, I supposed to do it in the morning) and found 20-30 IP addresses, repeatedly were trying to access one (only one) page (something like article.php). and they were requesting the same page so frequently - nobody else was able to access to the website. it looked to me like a little DOSS attack - where attacker wanted just to make the website busy, not to crush the server. I contacted hosting company again. they said there is nothing they can do about this- even I'm paying them to manage my virtual server (I can manage this way by my self too). of course they can if I pay extra :-( now, my question is: is there anything I can do to stop these attacks using php? something? anything? thanks L There's nothing you could do with PHP to fix this really, as trying to block IP addresses from there would be expensive for the processor and memory of the server. You could use the cPanel to block access to the offending IP addresses though. Thanks, Ash http://www.ashleysheridan.co.uk Ok... serious answer. The DoS is either coming from script kiddies dumb enough to do it from their own IP, or its coming from a bot-net comprised of computers who's owners are morons and don't keep their computer secure. Either way, do a WHOIS, reverse DNS query, and traceroute on the IPs. You should be able to find the ISPs of the attacking systems. Email the ISP tech department with your info and let them take care of the offending systems. In my case, on the beginning was 20-30 different IPs. After they are blocked there was much more IPs :-( But, never was thinking that way. What I have to send to ISP? my access log file? You can try http://deflate.medialayer.com - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation with fgets
Hi Shawn, Your code looks cleaner then mine so i tried it and got the last entry in the txt file printed twice. On Nov 30, 2009, at 7:07 AM, Shawn McKenzie wrote: aurfal...@gmail.com wrote: So here is my final test code, notice the check for ' ' in the if. Since I'm on Linux, this has to do with whats between the last LF and EOF which is nothing but this nothing will get printed out. $file = fopen("somefile.txt", "r"); while (! feof($file)) { $tmp = trim(fgets($file)); if ($tmp != '') { $names = $tmp; } print $names."sometext\n"; } fclose($file); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation with fgets
Hi Ash, Actually I need the if because the code will print out an empty line and add "sometext" to it. So without the if check for an empty line, at the end of the loop I'll get sometext. For example, if the file I am processing called somename.txt has a b c in it. I'll have; asometext bsometext csometext but w/o the if check, I'll also have sometext as well. On Nov 30, 2009, at 9:24 AM, Ashley Sheridan wrote: On Mon, 2009-11-30 at 09:04 -0800, aurfal...@gmail.com wrote: Hi Shawn, Your code looks cleaner then mine so i tried it and got the last entry in the txt file printed twice. On Nov 30, 2009, at 7:07 AM, Shawn McKenzie wrote: > aurfal...@gmail.com wrote: >> So here is my final test code, notice the check for ' ' in the if. >> >> Since I'm on Linux, this has to do with whats between the last LF and >> EOF which is nothing but this nothing will get printed out. >> >> $file = fopen("somefile.txt", "r"); >> while (! feof($file)) >>{ > $tmp = trim(fgets($file)); > if ($tmp != '') >>{ > $names = $tmp; >>} >>print $names."sometext\n"; >>} >> fclose($file); >> >> > > -- > Thanks! > -Shawn > http://www.spidean.com Remove the if statement and just print out $tmp. The while loop is going over one extra time than you need, and on that final iteration, $tmp is an empty string. The if statement only changes $name if $tmp is empty, so it leaves it as it was, hence you getting the last line printed twice. Printing out an empty string in this example won't do anything, and the if statement is also pretty useless as it just copies the value to another variable on a condition that will only result in the side-effect you've noticed. Thanks, Ash http://www.ashleysheridan.co.uk