Re: [PHP] Can PHP do this? -- w/o using event handler
Thanks everyone. I think, I will go with the sockets. Louie On Tue, Mar 4, 2008 at 12:36 AM, Richard Lynch <[EMAIL PROTECTED]> wrote: > On Mon, March 3, 2008 1:57 am, Louie Miranda wrote: > > Could PHP do.. > > > > 1. Connect and send a parameter to a remote host > > 2. Wait for the host to reply -- not using event handler > > 3. Send XML data to the host > > $xml = file_get_contents("/path/to/file.xml"); > $s = fsockopen("remote host here"); > $reply = fgets($s, 100); > $bytes = fputs($s, $xml); > if ($bytes != ($len = strlen($xml))){ > error_log("Only sent $bytes of $len bytes!"); > } > ?> > > You'll need about 3X as much code for proper error checking, but > that's about it, really... > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some indie artist. > http://cdbaby.com/from/lynch > Yeah, I get a buck. So? > > -- Louie Miranda ([EMAIL PROTECTED]) http://www.axishift.com Security Is A Series Of Well-Defined Steps chmod -R 0 / ; and smile :)
Re: [PHP] Can PHP do this? -- w/o using event handler
On Mon, March 3, 2008 1:57 am, Louie Miranda wrote: > Could PHP do.. > > 1. Connect and send a parameter to a remote host > 2. Wait for the host to reply -- not using event handler > 3. Send XML data to the host You'll need about 3X as much code for proper error checking, but that's about it, really... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can PHP do this? -- w/o using event handler
sure, user curl (www.php.net/curl) bastien > Date: Mon, 3 Mar 2008 15:57:19 +0800> From: [EMAIL PROTECTED]> To: > php-general@lists.php.net> Subject: [PHP] Can PHP do this? -- w/o using event > handler> > Could PHP do..> > 1. Connect and send a parameter to a remote > host> 2. Wait for the host to reply -- not using event handler> 3. Send XML > data to the host> > -- > Louie Miranda ([EMAIL PROTECTED])> > http://www.axishift.com> > Security Is A Series Of Well-Defined Steps> chmod > -R 0 / ; and smile :) _
Re: [PHP] Can PHP do this? -- w/o using event handler
On Mon, Mar 3, 2008 at 8:57 AM, Louie Miranda <[EMAIL PROTECTED]> wrote: > Could PHP do.. > > 1. Connect and send a parameter to a remote host > 2. Wait for the host to reply -- not using event handler > 3. Send XML data to the host Probably with a socket : http://php.net/manual/en/ref.sockets.php > -- > Louie Miranda ([EMAIL PROTECTED]) > http://www.axishift.com > > Security Is A Series Of Well-Defined Steps > chmod -R 0 / ; and smile :) > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can PHP do this...?
Hello, "1LT John W. Holmes" <[EMAIL PROTECTED]> wrote: > > OK. I think I understand this, but let me ask just to be sure. > > > > So if I setup in my page something to this effect: > > if ($_SERVER['!HTTPS']) { > > echo "Switching over to SSL..."; > > echo ""; > > } else { > > echo "**Rest of Page**"; > > } > > > > Would this work? I am about to add a secind site to my site using an alias > > in Apache. Example is http://www.mysite.com for first site and > > http://www.mysite.com/2ndsite. Except I want everything for the second > site > > to be https. Make sense? > > if(!isset($_SERVER['HTTPS'])) > { header("Location: https://www.mysite.com/2ndsite";); } > > That should work. Or you could echo the META redirect if you wanted to > display a page, but this should do it transparently. There is probably a way > to do it with just Apache, too, that wouldn't involve PHP. I think there's some useful info here (about doing it with "just Apache"): http://httpd.apache.org/docs-2.0/ssl/ssl_howto.html Just in case... - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can PHP do this...?
>John, PHP-general, > >OK. I think I understand this, but let me ask just to be sure. > >So if I setup in my page something to this effect: >if ($_SERVER['!HTTPS']) { > echo "Switching over to SSL..."; > echo ""; yuck recommend insuring this is at the top of your page and using header() instead appears seamless to the client > } else { > echo "**Rest of Page**"; > } and would eliminate that as well -Start of file-- https://www.example.com/page.ext";); exit; } # rest of page here since if it isn't secure the page stops at the exit after the header has been sent to the browser to redirect. ?> -end of file-- Check your particular server response for the match, you may be able to just do; if (!$_SERVER['HTTPS']) { Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can PHP do this...?
On Wednesday 11 December 2002 19:19, Ronald Clark wrote: Hi Ronald, hi List, it isn't > if ($_SERVER['!HTTPS']) { but if (!isset($_SERVER['HTTPS']) { // unsecure } else { //secure } You want to check wether the server variable HTTPS is set or not. johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can PHP do this...?
> OK. I think I understand this, but let me ask just to be sure. > > So if I setup in my page something to this effect: > if ($_SERVER['!HTTPS']) { > echo "Switching over to SSL..."; > echo ""; > } else { > echo "**Rest of Page**"; > } > > Would this work? I am about to add a secind site to my site using an alias > in Apache. Example is http://www.mysite.com for first site and > http://www.mysite.com/2ndsite. Except I want everything for the second site > to be https. Make sense? if(!isset($_SERVER['HTTPS'])) { header("Location: https://www.mysite.com/2ndsite";); } That should work. Or you could echo the META redirect if you wanted to display a page, but this should do it transparently. There is probably a way to do it with just Apache, too, that wouldn't involve PHP. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can PHP do this...?
John, PHP-general, OK. I think I understand this, but let me ask just to be sure. So if I setup in my page something to this effect: if ($_SERVER['!HTTPS']) { echo "Switching over to SSL..."; echo ""; } else { echo "**Rest of Page**"; } Would this work? I am about to add a secind site to my site using an alias in Apache. Example is http://www.mysite.com for first site and http://www.mysite.com/2ndsite. Except I want everything for the second site to be https. Make sense? Thanks again, Ron Clark -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:45 AM To: Ronald Clark; [EMAIL PROTECTED] Subject: RE: [PHP] Can PHP do this...? > Hello all. I have a question that I hope someone can answer. Is it > possible to determine is someone is hitting your site over SSL or > plain http using > PHP? If so, is it part of getenv()? I think it's $_SERVER['HTTPS']. If that is set, then the connection is over SSL. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited.
RE: [PHP] Can PHP do this...?
> Hello all. I have a question that I hope someone can answer. Is it > possible > to determine is someone is hitting your site over SSL or plain http using > PHP? If so, is it part of getenv()? I think it's $_SERVER['HTTPS']. If that is set, then the connection is over SSL. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can php do this?
At 09:22 AM 11/25/2001 -0400, Miles Thompson wrote: >I've followed this with interest, but unless you specifically need some >properties of PHP to do this, use an easier tool. > >Python has modules for both MySQL and PHP. They are easily invoked and >don't involve calling Lynx & feeding it the script. >Here's some code, you might want to think about it as an alternative. I >hope the indents preserve, as Python reliese on indentation and a >ends it's line. Thanks for the code! The easiest way for me personally to learn a new language is to think of a task that needs to be done then look at some sample code. I'm not quite ready to learn Python (yet) but I'm saving this into the archive for when I'm ready. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can php do this?
I've followed this with interest, but unless you specifically need some properties of PHP to do this, use an easier tool. Python has modules for both MySQL and PHP. They are easily invoked and don't involve calling Lynx & feeding it the script. Here's some code, you might want to think about it as an alternative. I hope the indents preserve, as Python reliese on indentation and a ends it's line. Miles Thompson #! /usr/bin/python "Mails Passwords from sub_list, a MySQL database " import sys, MySQLdb, traceback import rfc822, string, sys import smtplib # MySQLdb allows connection to the MySQL database # This connects to the database, all parameters must be explicitly named try: db = MySQLdb.connect( db='sub_list' ) except: traceback.print_exc() sys.exit() # create connection to the database object try: pcursor = db.cursor() except: traceback.print_exc() sys.exit() #let's display some information print db.get_host_info() print db.stat() #let's fetch our data, mailing to everyone who has not been emailed a password try: pcursor.execute("select * from subscriber where lpasswd_mailed = 0 and email !='';") resultset = pcursor.fetchall() except: traceback.print_exc() sys.exit() #let's build the message fromaddr = '[EMAIL PROTECTED]' toaddr = '[EMAIL PROTECTED]' username = "" password = "" msgFirstPart = "Thanks for subscribing. Passwords have been\n\ updated as part of our security schedule to protect your subscription. \n\ Your name and new password are: \n\n" msgEndPart = "Please contact us at (555) 555- or 555-5556 for help with your subscription, \n\ or email us at [EMAIL PROTECTED]\n\ \n\ Best regards, \n\ John Doe" # we've gotten this far, so let's open the SMTP connection server = smtplib.SMTP('smtp.domain.com',25) server.set_debuglevel(2) # for each record in the cursor # set toaddr, username and password # then send the message # here in the for loop we send the mail message #server.sendmail( fromaddr, toaddr, msg, "Subject: Your new password" )[D for cursorRecord in resultset: toaddr = cursorRecord[ 3 ] first_name = " First name: " + cursorRecord[ 2 ] + "\n" last_name = " Last name: " + cursorRecord[ 1 ] + "\n" password = " Password : " + cursorRecord[ 4 ] + "\n\n" msgMail = msgFirstPart + first_name + last_name + password + msgEndPart print msgMail server.sendmail( fromaddr, toaddr, msgMail, "Subject: Password for ALLnovascotia.com" ) # build the update query upd_query = "update subscriber set lpasswd_mailed = 1 where email ='" + cursorRecord[ 3 ] + "';" try: #pcursor.execute( "update subscriber set lpasswd_mailed = 1 where email = c_email;") pcursor.execute( upd_query ) except: traceback.print_exc() sys.exit() print "\n\n" print "All records printed" #close the smpt connection #server.quit() # close the database try: db.close() except: traceback.print_exc() sys.exit() # All done print "*"*30 print "" print "mailpass.py completed" print "" print "*"*30 At 02:58 AM 11/25/2001 -0500, you wrote: >Thanks guys > >I just want to confirm one last thing, as it's been a while since I needed >cron > >After I create this file (cron.file) for ex >and use >crontab cronfile (I do this as root, if it matters) >do permissions need to be set? I really can't recall >I would think that would do it as I am not uploading it >and do it as root > >Thanks for the help, GREAT help and it's appreciated > >Now I just need to get freetype 2 installed right on my raq 3 >and I can live like a king > >Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can php do this?
Thanks guys I just want to confirm one last thing, as it's been a while since I needed cron After I create this file (cron.file) for ex and use crontab cronfile (I do this as root, if it matters) do permissions need to be set? I really can't recall I would think that would do it as I am not uploading it and do it as root Thanks for the help, GREAT help and it's appreciated Now I just need to get freetype 2 installed right on my raq 3 and I can live like a king Joel
Re: [PHP] Can php do this?
On 24 November 2001 23:45, Michael Sims spaketh unto ye recipient: > It sure can. There's a couple of ways to accomplish this. I personally > think the easiest way is to code your page like normal, then call it in a > cron job via lynx. Let's say you have a page called "page.php" that > connects to your database, retrieves the email addresses, and sends the > emails. To call it from a cron job add the following to your crontab: > > 0 8 * * * /usr/bin/lynx -dump http://localhost/page.php > > /path/to/logfile/or/dev/null Nice tip! Another alternative is using wget on the URL, or links -dump if you have that instead. Or if your script has #!/usr/bin/php or whatever path at the top and is made executable, you can just call that script without relying on the webserver. I think, even if it's just a normal php file you could cron it as /usr/bin/php . -- Casey Allen Shobe [EMAIL PROTECTED] GCS/CM d+ s+:->+: a-- C++() ULU$ P- L+++> E- W++ N++ !o K- w-- !O M V- PS++ PE Y+ PGP>++ t+ 5+ X R>+ tv-- b++ DI+ D G++ e h-(*) r--- z-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can php do this?
If you have built the php standalone binary then its easy- #!/usr/local/bin/php What I do when I build php is build it twice. First I build it with all my options EXCEPT for with-apxs=/blah That builds the standalone binary, and I install that in /usr/local/bin Then, I build the apache module and install that where my apache modules go. This allows me to use php as a regular unix scripting language, so I can do stuff from the crontab. btw- I'm actually doing a very similar thing- I have some customer support software that pops my support e-mail address and puts the message in a MySQL database. I have a cron job that calls a php shell script that pops the e-mail for me every 15 minutes. That way I don't have to log on to the support application as often, and the customers get an automated response fairly quickly, giving them a unique case ID etc. On Sat, 24 Nov 2001 22:04:21 EST [EMAIL PROTECTED] mentioned: > Thanks for your time . *This* = create follow up autoresponders > Or at least have php run with cron, so I can daily hit a mysql > db and use php to email those people at a specified time, like > every 3 days. Just so when I have users to the site who register > and their name/email is in a table "users" in db "data", > php/cron can be used to pull the name/email from mysql > and (with unsubscribe message at bottom) email them when I > say to do so in cron. Getting cron by itself to work is fine > but with php script that connects to mysql and emails users? > Can that be done? > > Sort of like cron doing what you would do if you visited > page.php and once it's hit, it emails specified users in a database > Would I need path to php in the cron script to do this? > Or am I just living a dream? > > The idea of emailing users in a mysql db with php script > every day is very appealing to me. (Yes, with unsubscribe feature) > ;) > > Thanks, I hope to goodness this made sense and you > enjoyed your holiday > > Joel > -- -=-=-=-=-=-=-=-=-=-=-=-=- Michael A. Peters http://24.5.29.77:10080/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can php do this?
At 10:04 PM 11/24/2001 -0500, [EMAIL PROTECTED] wrote: [snip] >Sort of like cron doing what you would do if you visited >page.php and once it's hit, it emails specified users in a database >Would I need path to php in the cron script to do this? >Or am I just living a dream? It sure can. There's a couple of ways to accomplish this. I personally think the easiest way is to code your page like normal, then call it in a cron job via lynx. Let's say you have a page called "page.php" that connects to your database, retrieves the email addresses, and sends the emails. To call it from a cron job add the following to your crontab: 0 8 * * * /usr/bin/lynx -dump http://localhost/page.php > /path/to/logfile/or/dev/null Of course this means your script is in your public web space, so theoretically could be called by anyone who knew the name of the page. You could put the page in a subdirectory and add an .htaccess file that restricts access to only 127.0.0.1 to take care of that if it concerns you. If you have PHP installed as a CGI then you could also write your page as a shell script. As the first line of your script put the line: #! -q I haven't personally used this method because I have PHP installed as an apache module and I was too lazy to compile the CGI version. Using lynx in the above configuration works fine for me... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]