Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-03-03 Thread haliphax
 On Fri, Feb 26, 2010 at 11:01 PM, clanc...@cybec.com.au wrote:
  while ($i  $j) { $b[$i] = $a[$i++]; }  B.
 
  You get $b[0] = $a[1], and so on (as you would expect).


Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the
statement was finished executing? You used a post-decrement operator on $i
at the end of your statement, so I don't think that $i would be increased
before being used to index into the $a array.


// Todd


Re: [PHP] Linux ERD software

2010-02-24 Thread haliphax
Dia is also a superb diagramming software, though I don't think it generates
any SQL for you when it's said and done. There are versions for several
operating systems (including Linux AND Windows).


// Todd


Re: [PHP] Appalling Dreamweaver performance

2010-02-05 Thread haliphax
On Fri, Feb 5, 2010 at 3:59 PM, Lenin doctortomor...@gmail.com wrote:

 Try the NetBeans then


Personally, I've found that Programmer's Notepad 2 is a pretty capable
editor, and has some nice features such as auto-closing elements when
working with markup languages (HTML, XML, XSL, XHTML, etc.).

http://www.pnotepad.org


// Todd


Re: [PHP] OpenID

2010-02-05 Thread haliphax
On Mon, Feb 1, 2010 at 9:54 PM, Michael A. Peters mpet...@mac.com wrote:

 Daevid Vincent wrote:



 -Original Message-
 From: Al [mailto:n...@ridersite.org] Sent: Monday, February 01, 2010
 12:09 PM
 To: php-general@lists.php.net
 Subject: [PHP] OpenID

 This is a bit off subject, but

 What is your opinion on OpenID?


 Failed gimick. Tried to resurface again about a year ago. Still seems like
 failure.


 ++

 Session ID hijacking is bad enough, it gives the malicious user access to
 one resource.

 OpenID hijacking gives the malicious user access to a ton of resources.
 And what does a user do when their OpenID provider disappears?


I think Michael hit the nail on the head as far as my concerns are.. well..
concerned. :) Google's OpenID provider seems like it would be around forever
and whatnot, but if you're going to rely on one of the big OpenID
providers, then it would appear that OpenID itself is useless. Facebook's
OpenID, etc., are on shaky ground at best.

I use a few sites that leverage OpenID as their login process, and I've got
to say--it's very convenient. However, I only use my Google account for
OpenID logins, so to me, it's really just a Google connector.

I commend everyone involved for their effort, but I think the underlying
principles need to be re-examined. It feels like they rushed the whole
concept into production before too many of the fundamental issues had been
discussed and dealt with.

My 2c.


// Todd


Re: [PHP] header(Location:...) fails

2010-01-14 Thread haliphax
On Wed, Jan 13, 2010 at 7:02 PM, Shawn McKenzie nos...@mckenzies.netwrote:

 Robert Cummings wrote:
  Just make your life easy and create a redirect() function that generates
  the header instruction, makes a relative URL into an absolute URL and
  does the exit call. Then you just need to do:
 
  redirect( 'target.php' );
 
  So much simpler :)
 
  Cheers,
  Rob.

 Definitely!  Technically, header() with Location: should have an
 absolute URL, though it works without one most of the time.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Also, when in doubt, I find it's usually a good idea to check the output
being sent with a more low-level tool, such as Fiddler, so that you can view
the raw values rather than leaving it up to your browser to interpret them.


// Todd


Re: [PHP] Need Idea to make Backup

2010-01-14 Thread haliphax
On Thu, Jan 14, 2010 at 5:45 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Thu, 2010-01-14 at 12:32 +0100, Jens Geier wrote:

  Ashley Sheridan a...@ashleysheridan.co.uk schrieb im Newsbeitrag
  news:1263463572.5952.71.ca...@localhost...
   On Thu, 2010-01-14 at 10:12 +0100, Jens Geier wrote:
  
   Ashley Sheridan a...@ashleysheridan.co.uk schrieb im Newsbeitrag
   news:1263391167.5952.62.ca...@localhost...
On Wed, 2010-01-13 at 14:57 +0100, Jens Geier wrote:
   
Hello Ashley,
   
yes rsync is a good idea, but does this also work if there is only
 a
internet conection to may SERVER ?
   
Kind Regards
Jens Geier
   
Ashley Sheridan a...@ashleysheridan.co.uk schrieb im
 Newsbeitrag
news:1263377397.5952.60.ca...@localhost...
 On Wed, 2010-01-13 at 10:53 +0100, Jens Geier wrote:

 Hello,

 my idea is to make a backup of some paths of my laptop via PHP.

 I like to use a MySQL Datebase to trace which file was uploaded
 from
 which
 path and so on.

 Also it should be uses to look up it is nessasery to backup this
 file
 because it was changed since last time or not.

 All this files should be uploaded to the SERVER in a special
 folder
 where
 this files run to a tape backup machine.

 I hope some one can give me some ideas for this.

 Kind Regards
 Jens Geier

 There's a few ways to go about doing this, but I reckon you
 should
 do
 something similar to the following:

  * schedule a cron job to run as often as you want the backup
 to
 be
done, and have the cron call a script
  * the script can either be php and use your own code to
 create
copies of files and check file dates for backup purposes,
 or
 use
the rsync tool which pretty much does all of this for you
automatically
  * update a database as you need. this can be done either
 from a
php script or directly via mysql on the console

 If you do use PHP for this, you'll want to code it as a CLI
 script
 rather than a web page script. On the whole it won't make much of
 a
 difference, but obviously some global variables will change a
 bit.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

   
I don't understand what you mean?
   
Ps, please try not to top-post.
   
Thanks,
Ash
http://www.ashleysheridan.co.uk
   
   Hello Ashley,
  
   i try to make a backup from some paths of my local laptop harddrive to
 a
   folder on my server. Even if i'm not in the company.
  
   If i'm outside (this time i'm in China) i have to copy it through the
   Internet that is using http or ftp transport protocol.
  
   The start of the copy is when the user clicks to a buttom and start
 the
   backup process.
  
   Kind Regards
   Jens Geier
  
   The script needs to be set up on your local machine. I don't think HTTP
   will help you much here, as that isn't great for transferring files
   upstream I've found. Googling 'rsync ftp example' brings about over
   230,000 results, have you actually tried looking?
  
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  No, i have not.
 
  Because i also think that there will not a finish software.
 
  So i think i have to write something by my own.
  That is the reason i ask for ideas to do so.
 
  I just read here the following thread:
 
  [PHP] Read directory; store filenames found in mySQL table?
 
  That is something that is running in that direction in try to go.
 
  Kind Regards
  Jens Geier
 
 
 


 But I've told you that the best tool to do it is rsync. This is a tool,
 not a whole large peice of software with a GUI, etc. You use it in
 conjunction with other software to achieve what you need. Have you even
 looked up at what rsync is?

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


I recently used rsync (for the first time, even) in order to transfer an
entire directory structure of several thousand files and folders from one
VPS host to another. It worked like a dream, and the standard output could
be captured to build a report such as the OP was asking for.

Srsly, man -- take Ashley's suggestion and at least check it out. :)


Re: [PHP] strtotime

2010-01-14 Thread haliphax
On Thu, Jan 14, 2010 at 2:53 PM, Adam Richardson simples...@gmail.comwrote:

 I've not read this, but if the first valid date is Jan. 1st, 1970, then
 passing that date back in the case of errors would lead to ambiguity.  Is
 it
 a valid date or is it an error.  Passing back the date of the day just
 before (in terms of time, I think it's the second before) the first valid
 date lets you easily identify an error.

 Again, I didn't read this anywhere, though, and I could be wrong.

 Adam

 On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen php@emax.dk wrote:

  Hi guys
 
  I have a question:
 
  snip
  Ashley Sheridan wrote on 14/01/2010 19:20:
 
  MySQL uses a default -00-00 value for date fields generally, but
  when converted into a timestamp, the string equates to a false value. In
  PHP, timestamps are numerical values indicating the seconds since
  Midnight of the 1st January 1969. As PHP uses loose data typing, false
  /snip
 
  Adam Richardson wrote on 14/01/2010 19:25:
  snip
  2. date returns 1969, because it's not passed a valid timestamp and it
  works from December 31, 1969 for any invalid date.
  /snip
 
  Why is this? Unixtime starts at January 1st 1970 GMT (see for instance
  http://php.net/microtime), I've never heard of the other dates you
  mentioned.
 
  My guess is the time, date or GMT is wrong for Johns setup and that's why
  he get 1969 and not 1970, cause something is seting time in the past


Time zones. If I have PHP spit out a date for 0 as a string on my system,
it comes back as 18:00 on December 31st, 1969, because I am in the Central
time zone.

// Todd


Re: [PHP] SVG and PHP

2010-01-11 Thread haliphax
On Wed, Jan 6, 2010 at 5:04 PM, Bob Strasser bstras...@noccorp.com wrote:


 Hi,

  Just went online and saw an SVG generated from Python, and wanted to
 do the similar thing by loading the SVG into an PHP script. Here is the
 script that I have:

 ?php

 #Load the Map
 $ourFileName= USA_Counties_with_FIPS_and_names.svg;
 $fh = fopen($ourFileName, r) or die(Can't open file);
 fclose($fh);

 ?

 The problem is that my screen appears as blank even though I could open
 up USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does
 anyone know what I might have done wrong here?

 Thanks in advance.

 Alice


Bob/Alice/Whatever,

You don't do anything with the SVG file except open it and close it. Opening
and closing a door doesn't walk you through the doorway. Maybe you should
echo the contents of said file after sending a Content-Type header through
to the browser?


// Todd


Re: [PHP] Not a regular file?

2009-06-04 Thread haliphax
On Thu, Jun 4, 2009 at 9:07 AM, Miller, Terion
tmil...@springfi.gannett.com wrote:
 I've never encountered this error:

 Warning: ftp_put() [function.ftp-put]: 
 /httpdocs/Announcements/photos/obitsTest/: Not a regular file in 
 /Applications/MAMP/htdocs/HarrisAutomate/ObitsTester.php on line 149
 There was a problem while uploading 659428.jpg 658626

 Can't find much info on how to correct it, anyone seen this?

http://www.lmgtfy.com/?q=php+%22not+a+regular+file%22

Apparently, it's not actually a file in the first place. Just a
guess--but most all incidents of ftp_put throwing this error that I've
found in web searches point to someone using it on a directory/etc.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Best Encryption Algorithm

2009-06-03 Thread haliphax
On Wed, Jun 3, 2009 at 8:28 AM, Bruno Fajardo bsfaja...@gmail.com wrote:
 Hi there!

 Try out AES.
 http://en.wikipedia.org/wiki/Advanced_Encryption_Standard

 Bruno.

 2009/6/3 Hemant Patel hemant.develo...@gmail.com

 Hello Everyone,
                      Hope you all are doing great.
                      Now we are creating a application which has high level
 of security so its obvious that we will require a algorithm for
 encryption/decrytpion.So Can anybody suggest me the best algorithm for
 encryption(irrespective of any languageJust a Algorithm).

This link [1] should explain the algorithm to a point, as well as work
as a good place to jump off from and investigate other algorithm
choices. Below the main article, there is also a list of PHP
implementations (as well as additional languages).

As for Blowfish--if you're going down that road, I would recommend its
successor, Twofish [2].

1. http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
2. http://en.wikipedia.org/wiki/Twofish

HTH,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query Regarding a Player

2009-06-03 Thread haliphax
On Wed, Jun 3, 2009 at 8:14 AM, Hemant Patel hemant.develo...@gmail.com wrote:
 Hi All,
            I hope you all are doing great.We are developing a application
 on our end and we got a problem with a Audio/Vedio player.As flash player is
 working  well with client side but it has limitation of file formats like it
 can run .flv file format only.If we go for media player then it  won't run
 on Linux Server.

            Now i want to develop a player which can run any file format at
 client side.Can anybody suggest any algorithm or protocol to build a Player?

As many have already done, you might consider just transcoding the
bad formats into FLV and stick with your current Flash player setup.
There are many ffmpeg tutorials out there that should help you out
[1].

1. 
http://vexxhost.com/blog/2007/05/20/how-to-convertencode-files-to-flv-using-ffmpeg-php/

-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP vs ASP.NET

2009-06-01 Thread haliphax
On Mon, Jun 1, 2009 at 2:18 PM, Lists li...@euca.us wrote:
 ASP (Classic) and ASP.NET = two different things.

 en.wikipedia.org/wiki/Active_Server_Pages

 Personally, I don't see a reason for putting anyone, or any
 company through the torture of building web apps with
 .NET. ...VBSCRIPT for the web just doesn't make sense to
 me with the other solutions that are available... but
 I suppose decisions are made for many reasons that can
 force, perhaps less than optimal methods.

Funny, since ASP.NET does not use VBScript (Classic ASP can, with
JScript being the alternative). ASP.NET is basically a web framework
for the .NET language platform. It's a bit more complicated than that,
but I hardly see the reason(s) for it not making any sense as a
development tool for web sites.

As a VB.NET programmer, I can move seamlessly between developing
command-line, GUI, and web applications... much like I can as a PHP
programmer (minus the GUI part, I suppose, but Gtk+ can probably help
with that).

For that matter, I don't see why VBScript as a web development
language is frowned upon so vehemently. So you're sending your output
to an object rather than a pseudo-function (echo)... big deal. Class
instantiation can be a pain with the Server.CreateObject() method, but
I hardly see how one solution is automatically less than optimal.

Most of the same tips and development methods are prevalent in BOTH
languages (talking about VB/ASP.NET and PHP)... but one uses % and
one uses ? (which, coincidentally, is less than optimal when dealing
with XML).

I'm not trying to get on a high horse here, but I felt
VB.NET/ASP/ASP.NET deserve a voice if they are being mindlessly
smashed on flimsy evidence, suspicion, and anti-MS bandwagoning. I
love OSS too, guys! That doesn't, however, make all closed-source
software into The Devil.

-- 
// Todd

I was just ninja'd during this post by Andrew, who brought up a good
point about file uploading ... although I have to say--ASP.NET handles
it with an incredibly simple control. Put the tag on your page,
reference that tag's internal ID in your code. Done and done.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Directing form to different handlers?

2009-06-01 Thread haliphax
On Mon, Jun 1, 2009 at 2:59 PM, Matthew McKay m...@mattmckay.org wrote:
 On Mon, Jun 1, 2009 at 2:43 PM, James Ausmus
 james.ausmus.li...@gmail.comwrote:

 On Mon, Jun 1, 2009 at 12:32 PM, Matthew McKay m...@mattmckay.org wrote:
  It would be much simpler and cleaner to use Javascript to modify the
 form's
  action attribute onClick.
 

 Not really. What about clients who don't have Javascript installed?
 What about users who want to either do something nefarious or just to
 see what happens,  - exposing your Delete my record-specific PHP
 code could potentially cause security holes. The less of your internal
 interface/structure you expose to the end user, the less easy it is
 for the casual script kiddies to find the security holes that you have
 (and yes, everyone has them... ;)  )

 -James


 How is passing parameters to a 'delete' action different than passing
 'delete' as a parameter to a general purpose action?
 You do have a point with not all clients having Javascript. It would be a
 business decision on the part of Shawn if he wants to support the fraction
 of users running browsers without support for the most basic of extensions.

Often times, it has absolutely nothing to do with the browser's
capability, and more to do with the user's purposeful deactivation of
the feature.

http://noscript.net


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Azure SDK for PHP

2009-05-21 Thread haliphax
Microsoft's Azure cloud computing framework has now been exposed to
PHP. I haven't tested any of the features myself, but it seems like a
pretty interesting (and leverage-able) concept to work with... figured
I'd pass the word along.

http://phpazure.codeplex.com/


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ImageMagick

2009-05-04 Thread haliphax
On Fri, May 1, 2009 at 7:11 AM, Kevin Waterson ke...@phpro.org wrote:
 This one time, at band camp, Michael A. Peters wrote:
 Here's the scenario -

 Website has some demonstrative images.

 I create these images with the gimp - starting with a jpeg, adding a few
 text layers and straight lines.

 I then save as xcf in case I ever need to edit.

 Then I export to jpeg, resize for thumb and export to jpeg again.

It seems that Imagick supports XCF internally:
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1t=10431

I would imagine you can perform your Imagick export as you would with
any other image type.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Static and/or Dynamic site scraping using PHP

2009-05-04 Thread haliphax
On Thu, Apr 30, 2009 at 8:03 AM, 9el le...@phpxperts.net wrote:
 On Thu, Apr 30, 2009 at 3:33 AM, 9el le...@phpxperts.net wrote:
 I just got a project to do on PHP of scraping the body items from
 static sites or just html sites.
 Could you experts please suggest me some quick resources?

 I have to make an WP plugin with the data as well.

 Any expert there yet? Was looking for urgent advices on accomplishing the 
 task.

http://www.regular-expressions.info and preg_match are your best friend(s).


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Suggestions of some good, simple file upload 'in progress' code?

2009-04-22 Thread haliphax
On Tue, Apr 21, 2009 at 11:35 PM, Michael Shadle mike...@gmail.com wrote:
 On Tue, Apr 21, 2009 at 9:02 PM, scubak1w1 sk...@spamcop.net wrote:

 scubak1w1 sk...@spamcop.net wrote in message
 news:cf.13.21597.2ee8e...@pb1.pair.com...
 Hello,

 Can someone pass on some suggestions of some good, simple file upload 'in
 progress' code?

 Maybe as simple as changing the cursor icon for the duration?

 [self snip!]

 http://www.johnboy.com/about-us/news/a-useful-php-file-upload-progress-meter
 seems to be the cleanest example I can find - would this be fair to say?

 Google Gears makes it very easy and can make it very simple (no
 webserver configuration required) to basically slice the file up and
 send chunks via POST - I need to publish all the code and a howto, and
 Valery has written some code for nginx that might make it alleviate
 the need for PHP to be involved at all - I have still not tested that
 though, but the PHP code required is only like 10 lines or so, the
 Gears stuff is pretty basic Javascript and since it's Javascript you
 can make it match your UI perfectly by filling in div tags or whatever
 else you want (works great with jQuery)

 Actually I have a demo, not the cleanest code if you view the source
 but you get the idea. It also works over NFS with multiple webservers
 writing to the same file (I have 3 webservers behind LVS so
 technically your request could be going to any of them)

 http://mikehost.com/~mike/tmp/u/ - frontend and view source to see gears + js
 http://mikehost.com/~mike/tmp/u/temp.php.txt - server side piece

 I can't find the latest/cleanest code, but it gives you an idea.

Michael,

Given the fact that Gears requires a client-side installation, has an
awful penetration percentage, and his original solution is all
server-side (though it does require APC and YUI-JS), I wouldn't say
this is a very good suggestion. Compared to what he has already found,
the Gears solution is not clean by any stretch of the imagination.


Greg,

I believe the link you posted is a very elegant solution that does not
(at first glance) involve Flash objects or Java applets. I'm a little
disappointed that a particular JS framework is necessary, but that's
just the nature of the beast with this sort of thing. If I were you,
I'd run with the native PHP solution you've already found. Maybe you
can even crack open the JS and find a way to do it with your favorite
framework as opposed to YUI...


My 2c,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Suggestions of some good, simple file upload 'in progress' code?

2009-04-22 Thread haliphax
On Wed, Apr 22, 2009 at 11:25 AM, Michael Shadle mike...@gmail.com wrote:
 On Wed, Apr 22, 2009 at 6:20 AM, haliphax halip...@gmail.com wrote:

 Michael,

 Given the fact that Gears requires a client-side installation, has an
 awful penetration percentage, and his original solution is all
 server-side (though it does require APC and YUI-JS), I wouldn't say
 this is a very good suggestion. Compared to what he has already found,
 the Gears solution is not clean by any stretch of the imagination.

 a) the native solution that requires APC is not multi-webserver capable
 b) i was just sharing a different approach to an idea. who knows. it
 might be something to explore. gears is pretty lightweight, and for
 the ease of this and the functionality it brings (not to mention
 cross-browser+platform) i see a compelling reason to give it a shot.
 c) the APC method -still- requires webserver tweaks and post max size
 etc. this is sending small chunks of data, is proxy-safe, and requires
 nothing on the server; all that is required is gears, which is a
 library to extend your browser's capabilities and i have not heard any
 issues with it or security holes thus far. penetration is an issue but
 when more sites push it and say hey, you should install it the
 penetration will grow. not to mention youtube for example is using
 roughly the same method and picking up a lot of browser installs off
 that.

 i completely disagree it is not clean - it is literally one browser
 addon that a lot of people do have, comes from a reputable company,
 and creates basically limitless upload capabilities - i can do 300 meg
 files without blinking - it's not one long single POST that can fail
 anytime, it's lots of small POST requests; it takes basic PHP on the
 server and then some javascript for the UI (all the pieces to get a
 basic functional install i sent links to)

Unless you are in a corporate environment where you control what is
installed on your visitors' machines, then just about any server-side
hell you have to put yourself through is cleaner to the client than
them needing to install ANYTHING.

I'm sorry if my opinion seems a little too black and white, but
those are the breaks. I can definitely say that, coming from a higher
education institution standpoint, the site I work on would ALWAYS do
something server-side and exhaust all of those possibilities before
forcing prospective students, applicants, etc. to download additional
software for their web browser.

It depends on the clientele, really.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Let me google that for you.

2009-04-21 Thread haliphax
On Fri, Apr 17, 2009 at 1:01 PM, 9el le...@phpxperts.net wrote:
 If you play with jQuery its easy.

 And if you talk about JavaScript's urlencode functionality you wont ask
 about 'how to remove the + sign'

 I'm not very good yet on jQuery or else I would have shown you the codes.

jQuery doesn't make this much easier than vanilla Javascript in this
case. I don't see why JS is necessary at all, in fact.

search.html
===
html
headtitleSearch/title/head
body
form action=http://lmgtfy.com; method=get
  input type=text name=q /
  input type=submit value=Search /
/form
/body
/html


No URLEncoding necessary, no JS, no PHP... just HTML. Were you to pass
pre-conceived search strings to it, it's as easy as this:

index.php
===
?php
$s = 'search for this';
header('Location: http://lmgtfy.com?q=' . urlencode($s));
?


And you're done!

HTH,

-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Check whether a page is Google Cached

2009-04-21 Thread haliphax
On Tue, Apr 21, 2009 at 8:29 AM, Alan Chen c...@datanumen.com wrote:
 Hi, everyone,

 I want to write a small PHP script test.php that can determine whether a
 webpage is Google Cached.

 Assuming it is uploaded to www.mysite.com, and I want to use it to check
 whether www.yoursite.com is google cached.

 It works as follows:

 The user input the query:

 http://www.mysite.com/test.php?site=www.yoursite.com

 The php script will send the following request to the browser

 http://www.google.com/search?q=cache:www.yoursite.com

 in the background.

 And if the returned result contains a string This is Google's cache of,
 then the page is cached, so the php script can display

 Your site is cached by Google

 otherwise, it will say

 Your site is not cached by Google

 Just wonder how to implement such a feature, can anyone write a simple
 sample so that I can use as a startpoint as I am a totally new guy in PHP
 coding

You've already laid out most of what needs to be done. I think the
file_get_contents() function will be your best friend here, provided
allow_url_fopen has been set to TRUE in your PHP configuration. Take
the result you get back from that function and parse the 2nd line for
This is Google#39;s cache of  (I have made this assumption by
looking at the source of
http://www.google.com/search?q=cache:www.php.net).

example.php
===
?php
$url = $_GET['url'];
$res = file_get_contents('http://www.google.com/search?q=cache:' . $url);
if($res  strstr('This is Google#39;s cache of ', $res))
  echo 'Your page is cached.';
else
  echo 'Your page is not cached.';
?

UNTESTED. Hope this helps.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encrypting email

2009-04-21 Thread haliphax
On Tue, Apr 21, 2009 at 9:43 AM, Bob McConnell r...@cbord.com wrote:
 From: tedd [mailto:tedd.sperl...@gmail.com]
 At 9:49 AM -0400 4/21/09, Bob McConnell wrote:
 From: tedd
   At 8:39 AM -0400 4/21/09, Bob McConnell wrote:
 I have been asked by a product manager what our options are for
 encrypting email messages with sensitive information. We are
 currently
 using PHPMailer to send email. What can be done to encrypt those
 messages? Can it be done without OOP?
 
    From within a php script, it's not a problem to encrypt a text
 string
 
   and send it as email. The sending of the email and the encrypting
 the
   contents are two different issues. You may want to look at it that
   way.
 
 But can it be done so the recipient's email client will automatically
 open and decrypt the message? How do you make it as seamless as
 possible
 for them, preferably so they don't even realize the message was
 encrypted?

 At some point both parties (sender/receiver) must know (agree) what
 the encrypting mechanism is.

 If I was writing a script to do this for a client, I must have
 control over both the send and receive scripts and then I could
 deliver the email to the client seamlessly. They would never know
 what happened in the background.

 However, if your client wants to send stuff to anyone and have it
 encrypted without knowing who the receiver is going to be, then there
 is no way to do this. Both the sender and receiver must agree on the
 encrypting mechanism either by providing passwords OR by you having
 access to both the sending and receiving scripts. As I see it, there
 is no other way.

 These will be targeted emails for selected recipients, primarily in the
 Security and Public Safety offices. But they will be sent via public
 mail servers, so the content must be protected.

 Knowing the first site where this would go for field trials, I suspect
 most recipients are using some version of Microsoft Outlook. But other
 sites down the road are likely to have different clients. That end is
 completely outside of my control or influence. All I can do is recommend
 packages for them to download and install. I already know I need to get
 a public key from each recipient before I can encrypt their messages,
 but that's as far as I have gotten. I did glance at the GPG site
 earlier, and it appears they only support the version of Outlook in
 Office 2003.

 I have a feeling this is going to get messy, at least on the deployment
 end.

This may alleviate some of the mess:
http://blog.cumps.be/gpg-in-outlook-2007-outlookgnupg/


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL - Error 400

2009-04-20 Thread haliphax
On Fri, Apr 17, 2009 at 7:58 AM, David quick.webmas...@gmail.com wrote:
 On Fri, Apr 17, 2009 at 8:55 PM, Andrew Ballard aball...@gmail.com wrote:

 On Fri, Apr 17, 2009 at 12:41 AM, David quick.webmas...@gmail.com wrote:
  On Thu, Apr 16, 2009 at 11:48 PM, haliphax halip...@gmail.com wrote:
 
  On Wed, Apr 15, 2009 at 9:17 PM, David quick.webmas...@gmail.com
  wrote:
   Except I also need to POST data to the server to login. After I've
   logged
   in, I then need to use cookies to maintain a session.
  
   Doing that via file_get_contents() just isn't possible.
  
  
   Thanks
  
   On Thu, Apr 16, 2009 at 2:30 AM, haliphax halip...@gmail.com wrote:
  
   On Wed, Apr 15, 2009 at 10:36 AM, David quick.webmas...@gmail.com
  wrote:
I was wondering if anyone could please help me with this cURL
script
since I
keep getting error 400 from the web server:
   
http://pastebin.ca/1392840
   
It worked until around a month ago which is when they presumably
made
changes to the site. Except I can't figure out what configuration
  option
in
the cURL PHP script needs to be changed. I can visit the site
  perfectly
in
Lynx, Firefox and IE.
  
   Are you just trying to get the contents of the page, or is there
   something special you're doing? If it's just the contents you're
   after, try file_get_contents() if allow_url_fopen is set to TRUE for
   your PHP installation.
  
   http://php.net/file_get_contents
   http://php.net/allow_url_fopen
 
  David, please refrain from top-posting.
 
  As for cURL login/session handling... I have an automated script that
  connects to a phpBB bulletin board, and here are the settings that
  have worked for me:
 
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_COOKIEFILE, {$homedir}cookiefile);
  curl_setopt($ch, CURLOPT_COOKIEJAR, {$homedir}cookiefile);
  curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
 
  I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
  are most important for resolving your issue.
 
  HTH,
 
 
  --
  // Todd
 
 

  Hi,
 
  Sorry, that didn't work. The website is still returning error 400 with
  CURLOPT_COOKIESESSION and CURLOPT_COOKIE enabled.
 
  I did some experimentation in Firefox by blocking and deleting all
  cookies
  from the site. When I then visited the site, I was able to reach the
  logon
  page without returning error 400 so I doubt it's cookies that is the
  problem.
 
  I also tried changing the HTTP headers to:
 
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Connection: Keep-Alive
  Content-Type: text/html; charset=UTF-8
 
  Which didn't work either.
 
 
 
 
  Thanks
 

 Does the site require a valid HTTP_REFERER? I haven't seen
 CURLOPT_REFERER in any of your examples. (If I missed it somewhere,
 just ignore the noise.)

Have you set your CURLOPT_COOKIEFILE properly? Also--you may need to
unlink() it before you log-in using your cURL script to make sure that
any invalid cookie values (i.e., expired session ID) are cleared out.

unlink({$homedir}cookiefile);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, {$homedir}cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, {$homedir}cookiefile);
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
...

(where $homedir is /home/haliphax/ or some such value.)

HTH,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL - Error 400

2009-04-17 Thread haliphax
On Thu, Apr 16, 2009 at 11:41 PM, David quick.webmas...@gmail.com wrote:
 Hi,

 Sorry, that didn't work. The website is still returning error 400 with
 CURLOPT_COOKIESESSION and CURLOPT_COOKIE enabled.

 I did some experimentation in Firefox by blocking and deleting all cookies
 from the site. When I then visited the site, I was able to reach the logon
 page without returning error 400 so I doubt it's cookies that is the
 problem.

 I also tried changing the HTTP headers to:

 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Connection: Keep-Alive
 Content-Type: text/html; charset=UTF-8

 Which didn't work either.




 Thanks

 On Thu, Apr 16, 2009 at 11:48 PM, haliphax halip...@gmail.com wrote:

 On Wed, Apr 15, 2009 at 9:17 PM, David quick.webmas...@gmail.com wrote:
  Except I also need to POST data to the server to login. After I've
  logged
  in, I then need to use cookies to maintain a session.
 
  Doing that via file_get_contents() just isn't possible.
 
 
  Thanks
 
  On Thu, Apr 16, 2009 at 2:30 AM, haliphax halip...@gmail.com wrote:
 
  On Wed, Apr 15, 2009 at 10:36 AM, David quick.webmas...@gmail.com
  wrote:
   I was wondering if anyone could please help me with this cURL script
   since I
   keep getting error 400 from the web server:
  
   http://pastebin.ca/1392840
  
   It worked until around a month ago which is when they presumably made
   changes to the site. Except I can't figure out what configuration
   option
   in
   the cURL PHP script needs to be changed. I can visit the site
   perfectly
   in
   Lynx, Firefox and IE.
 
  Are you just trying to get the contents of the page, or is there
  something special you're doing? If it's just the contents you're
  after, try file_get_contents() if allow_url_fopen is set to TRUE for
  your PHP installation.
 
  http://php.net/file_get_contents
  http://php.net/allow_url_fopen

 David, please refrain from top-posting.

 As for cURL login/session handling... I have an automated script that
 connects to a phpBB bulletin board, and here are the settings that
 have worked for me:

 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_COOKIESESSION, true);
 curl_setopt($ch, CURLOPT_HEADER, false);
 curl_setopt($ch, CURLOPT_COOKIEFILE, {$homedir}cookiefile);
 curl_setopt($ch, CURLOPT_COOKIEJAR, {$homedir}cookiefile);
 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());

 I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
 are most important for resolving your issue.

PLEASE.
STOP.
TOP.
POSTING.

Did you try CURLOPT_FOLLOWLOCATION? If your page uses any sort of
redirect, cURL will probably fail without this option.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL - Error 400

2009-04-16 Thread haliphax
On Wed, Apr 15, 2009 at 9:17 PM, David quick.webmas...@gmail.com wrote:
 Except I also need to POST data to the server to login. After I've logged
 in, I then need to use cookies to maintain a session.

 Doing that via file_get_contents() just isn't possible.


 Thanks

 On Thu, Apr 16, 2009 at 2:30 AM, haliphax halip...@gmail.com wrote:

 On Wed, Apr 15, 2009 at 10:36 AM, David quick.webmas...@gmail.com wrote:
  I was wondering if anyone could please help me with this cURL script
  since I
  keep getting error 400 from the web server:
 
  http://pastebin.ca/1392840
 
  It worked until around a month ago which is when they presumably made
  changes to the site. Except I can't figure out what configuration option
  in
  the cURL PHP script needs to be changed. I can visit the site perfectly
  in
  Lynx, Firefox and IE.

 Are you just trying to get the contents of the page, or is there
 something special you're doing? If it's just the contents you're
 after, try file_get_contents() if allow_url_fopen is set to TRUE for
 your PHP installation.

 http://php.net/file_get_contents
 http://php.net/allow_url_fopen

David, please refrain from top-posting.

As for cURL login/session handling... I have an automated script that
connects to a phpBB bulletin board, and here are the settings that
have worked for me:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_COOKIEFILE, {$homedir}cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, {$homedir}cookiefile);
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());

I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
are most important for resolving your issue.

HTH,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread haliphax
On Thu, Apr 16, 2009 at 1:29 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 Hi List,

 I have been thinking for a while about setting up my own rapidshare.comclone,
 Few days back I went really serious with this and came up with some ideas.

 This is where I need your help, my partner and I have been thinking about
 the
 system that the website should run on.
 We came to conclusion that we are going to write it in PHP.

 There are several issues that came up during the mind-storm:
 First, how we can keep the files out of being published as direct links?

 My first idea was to host them one directory up from the http directory.
 It seems good but how I would deliver the files to the users?
 We are talking about unlimited file-size hosting so that means that we
 will have to stream the files somehow... and they will be BIG (it's
 defendant,
 about 700MB~ each)

 We thought of letting users pay by SMS'es, whats your ideas about it?

 I'm generally looking after a do and NOT do list of creating a file
 hoster ;)
 If you have any general ideas / precautions that would definitely make my
 partner and I happy :)

With files of that size and the transfer speed of most broadband
users, you will almost absolutely have to use a Flash/Java uploader
app in order to ensure the files finish before server/browser timeout.

As far as hiding them from being accessed directly, I think you're
right--the file itself will have to be outside of your web root. I
would probably use a middle system to grab a request from your page,
verify that it did in fact come from your page (maybe with a
time-sensitive hash value) and then retrieve the file's contents based
on the validity of that hash value.

Just a thought.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cURL - Error 400

2009-04-15 Thread haliphax
On Wed, Apr 15, 2009 at 10:36 AM, David quick.webmas...@gmail.com wrote:
 I was wondering if anyone could please help me with this cURL script since I
 keep getting error 400 from the web server:

 http://pastebin.ca/1392840

 It worked until around a month ago which is when they presumably made
 changes to the site. Except I can't figure out what configuration option in
 the cURL PHP script needs to be changed. I can visit the site perfectly in
 Lynx, Firefox and IE.

Are you just trying to get the contents of the page, or is there
something special you're doing? If it's just the contents you're
after, try file_get_contents() if allow_url_fopen is set to TRUE for
your PHP installation.

http://php.net/file_get_contents
http://php.net/allow_url_fopen

Hope this helps,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] files creation/access dates

2009-04-14 Thread haliphax
On Tue, Apr 14, 2009 at 4:12 AM, Per Jessen p...@computer.org wrote:
 Tom Sparks wrote:


 how do I get the creation dates on a file?
 how do I get the last access date on a file?


 http://php.net/manual/en/function.stat.php

Or, perhaps a bit easier:

http://php.net/filemtime
http://php.net/fileatime
http://php.net/filectime


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] $_GET verses $_POST

2009-04-14 Thread haliphax
On Tue, Apr 14, 2009 at 8:40 AM, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 14, 2009 at 07:58:24AM +0100, Ashley Sheridan wrote:

 snip

 I've done a bit of research into that, and can't find any evidence to
 suggest that the so-called friendly URL's are actually of any benefit
 to search engines. Just put a question into Google, and more often than
 not, the top few results are from forums, which tend not to use these
 friendly URL's. The only reason one might help with SEO is the case
 where a site is being redeveloped or re-versioned, and you need to
 preserve old page names to retain any ranking the site once had.

 This is a really good point. I've *always* heard/read that ugly URLs
 aren't indexed by search engines. But somehow it never occurred to me
 that what you're saying about search engine results is true.

The URL of a website is just one more field to cram with
search-engine-friendly keywords. If your URL isn't
http://myserver/blog/regex-with-javascript; it's not going to count
against you NEARLY as much as people seem to believe nowadays. In
fact, you could probably just put the sentence regex with javascript
at the top of your HTML source and it would have the same impact.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Logical next step in learning?

2009-04-14 Thread haliphax
On Tue, Apr 14, 2009 at 2:20 PM, Luke l...@blog-thing.com wrote:
 2009/4/14 phphelp -- kbk phph...@comcast.net


 On Apr 14, 2009, at 10:58 AM, Gary wrote:

  I think most books have you writing code, and Head First did as well, so I
 think that is covered..


 No, it isn't. There is a big difference between writing it the way a book
 tells you to do it, hand-holding all the way and doing it. When you actually
 have to do it, you take what you have read and apply it, using the book as a
 reference.


  I actually have a real project to do that is a little beyond my abilities
 at
 this point (its my own), so I want to keep the learning process flowing.


 Bastien's suggestion is spot on. Catalog your family members  friends,
 shoes, girlfriends, any information that is important to you. Really the
 only way.

 Ken

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 That or create a website that has already been created, but on a smaller
 scale.
 That way you will run into the common issues that you will have to deal with
 in most of the projects you do.

There's also no reason you couldn't try to break your project down
into its component pieces, and starting to think about how you would
build them on an individual basis. It's not always the best thing to
completely separate the development process like this... but if you
start taking a look at each tree, the forest will become a little
clearer after a few of them. :)

Also, designing processes and such are language-independent, but will
help you to develop pseudocode (whether written or just in your head)
that will eventually become your PHP code.

My first project was a basic membership portal. I split it originally
into how I would organize accounts, the login/logout/check session
stuff, and the memberlist on the front page. It was a digital art
group, and later down the road, I added an art request form and tied
it to a member of the user's selection. Doing it one piece at a time
meant that I got some pretty ugly spaghetti code towards the end, but
knowing how all of the individual pieces worked allowed me to re-vamp
it into an efficient, functional system when everything was said and
done.

YMMV,

-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Workflow app for software

2009-04-01 Thread haliphax
On Tue, Mar 31, 2009 at 4:37 PM, bruce bedoug...@earthlink.net wrote:
 hey todd...

 just toook a look at the polarion svn-web app i thought that was closed 
 source... i see that it's open!!!

 -Original Message-
 From: haliphax [mailto:halip...@gmail.com]
 Sent: Tuesday, March 31, 2009 2:18 PM
 To: bruce; php-general@lists.php.net
 Subject: Re: [PHP] Workflow app for software


 On Tue, Mar 31, 2009 at 1:47 PM, bruce bedoug...@earthlink.net wrote:
 Ladies/Gents...

 Hi. Trying to get some input to a web based app for dealing with managing
 software apps/scripts.

 Basically, i'm envisioning a system where people register/signup, and then
 check in/out apps for development/testing/production... I need a way of
 dealing with users, assigning/accepting roles for the users, and to manage
 the flow of the file as it moves through the basic
 development/testing/production process. i'd like to have a database
 backend, combines with some kind of source/file reqpository...

 I've seen things like knowledgetree, owl, etc... but figured I'd get input
 from here. So, any thoughts to open source apps that you guys have actual
 experience using??

 This sounds like something Subversion (SVN) is suited for. Three
 repositories in the same realm: dev, test, prod. Slap a web front-end
 on it like Polarion's svn-web (for JSP/Tomcat) and you're in
 business.

Well, whether it's open source or not, the software is free to use...
that's all I ever really cared about. :)
(Please stop top-posting.)


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Workflow app for software

2009-04-01 Thread haliphax
On Wed, Apr 1, 2009 at 8:33 AM, bruce bedoug...@earthlink.net wrote:
 not another top/side/bottom post thread again!!!



 -Original Message-
 From: haliphax [mailto:halip...@gmail.com]
 Sent: Wednesday, April 01, 2009 5:38 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Workflow app for software


 On Tue, Mar 31, 2009 at 4:37 PM, bruce bedoug...@earthlink.net wrote:
 hey todd...

 just toook a look at the polarion svn-web app i thought that was closed 
 source... i see that it's open!!!

 -Original Message-
 From: haliphax [mailto:halip...@gmail.com]
 Sent: Tuesday, March 31, 2009 2:18 PM
 To: bruce; php-general@lists.php.net
 Subject: Re: [PHP] Workflow app for software


 On Tue, Mar 31, 2009 at 1:47 PM, bruce bedoug...@earthlink.net wrote:
 Ladies/Gents...

 Hi. Trying to get some input to a web based app for dealing with managing
 software apps/scripts.

 Basically, i'm envisioning a system where people register/signup, and then
 check in/out apps for development/testing/production... I need a way of
 dealing with users, assigning/accepting roles for the users, and to manage
 the flow of the file as it moves through the basic
 development/testing/production process. i'd like to have a database
 backend, combines with some kind of source/file reqpository...

 I've seen things like knowledgetree, owl, etc... but figured I'd get input
 from here. So, any thoughts to open source apps that you guys have actual
 experience using??

 This sounds like something Subversion (SVN) is suited for. Three
 repositories in the same realm: dev, test, prod. Slap a web front-end
 on it like Polarion's svn-web (for JSP/Tomcat) and you're in
 business.

 Well, whether it's open source or not, the software is free to use...
 that's all I ever really cared about. :)
 (Please stop top-posting.)

Again, please do not top-post. It is the agreed-upon procedure in this
list to bottom-post when replying to threads. (I am not just going
renegade thread-Nazi on you.)


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Workflow app for software

2009-04-01 Thread haliphax
On Wed, Apr 1, 2009 at 11:53 AM, bruce bedoug...@earthlink.net wrote:
 and haliphax...

 i specifically sent the reply to only you.. you then felt the need to reply
 to the list as a whole

 hmm.. ok.. this thread is officially dead!!

 unless of course it gets back to the initial question...

 peace!!


  -Original Message-
  From: haliphax [mailto:halip...@gmail.com]
  Sent: Wednesday, April 01, 2009 5:38 AM
  To: php-general@lists.php.net
  Subject: Re: [PHP] Workflow app for software

--8--

 Again, please do not top-post. It is the agreed-upon procedure in this
 list to bottom-post when replying to threads. (I am not just going
 renegade thread-Nazi on you.)

 Could you show me the signed agreement list. While it's convention on
 this list, it's certainly not something everyone agreed upon.

To Rob,
I meant agreed-upon as in: it's been written... so somebody had to
agree to it up to the point that it was posted here -
http://us3.php.net/reST/php-src/README.MAILINGLIST_RULES

To Bruce,
I replied to the mailing list because this is a PHP-General thread,
and it is a general practice (though not a rule listed at the above
address) to keep replies on-list. I did not do it out of spite... I
did it out of habit; out of reflex. Perhaps this time I'm doing it out
of spite. :P

Regardless, I agree--this has nothing to do with the original topic.
Bearing that in mind, here's another link for an open source ticket
system written in PHP: http://www.zentrack.net/ (however, their demo
seems to be offline).


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Workflow app for software

2009-04-01 Thread haliphax
On Wed, Apr 1, 2009 at 1:38 PM, Robert Cummings rob...@interjinn.com wrote:
 On Wed, 2009-04-01 at 13:30 -0500, haliphax wrote:
 On Wed, Apr 1, 2009 at 11:53 AM, bruce bedoug...@earthlink.net wrote:
  and haliphax...
 
  i specifically sent the reply to only you.. you then felt the need to reply
  to the list as a whole
 
  hmm.. ok.. this thread is officially dead!!
 
  unless of course it gets back to the initial question...
 
  peace!!
 
 
   -Original Message-
   From: haliphax [mailto:halip...@gmail.com]
   Sent: Wednesday, April 01, 2009 5:38 AM
   To: php-general@lists.php.net
   Subject: Re: [PHP] Workflow app for software

 --8--

  Again, please do not top-post. It is the agreed-upon procedure in this
  list to bottom-post when replying to threads. (I am not just going
  renegade thread-Nazi on you.)
 
  Could you show me the signed agreement list. While it's convention on
  this list, it's certainly not something everyone agreed upon.

 To Rob,
 I meant agreed-upon as in: it's been written... so somebody had to
 agree to it up to the point that it was posted here -
 http://us3.php.net/reST/php-src/README.MAILINGLIST_RULES

 It has been written and it has been agreed upon are two completely
 different things. Many things have been written, few things are agreed
 upon.

Unless the PHP development process has become a dictatorship, I'm
pretty sure more than one person decided it was a good idea before
putting it in the mailing list rules.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Workflow app for software

2009-03-31 Thread haliphax
On Tue, Mar 31, 2009 at 1:47 PM, bruce bedoug...@earthlink.net wrote:
 Ladies/Gents...

 Hi. Trying to get some input to a web based app for dealing with managing
 software apps/scripts.

 Basically, i'm envisioning a system where people register/signup, and then
 check in/out apps for development/testing/production... I need a way of
 dealing with users, assigning/accepting roles for the users, and to manage
 the flow of the file as it moves through the basic
 development/testing/production process. i'd like to have a database
 backend, combines with some kind of source/file reqpository...

 I've seen things like knowledgetree, owl, etc... but figured I'd get input
 from here. So, any thoughts to open source apps that you guys have actual
 experience using??

This sounds like something Subversion (SVN) is suited for. Three
repositories in the same realm: dev, test, prod. Slap a web front-end
on it like Polarion's svn-web (for JSP/Tomcat) and you're in
business.

-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP task manager

2009-03-31 Thread haliphax
On Tue, Mar 31, 2009 at 2:31 PM, George Larson
george.g.lar...@gmail.com wrote:
 We've got a homebrew ToDo list (task  project) manager / mailer that we're
 thinking about replacing with something a little more robust.

 Any suggestions?  I saw TaskFreak! on Google but I am curious if there are
 any personal recommendations out there.

There are plenty of open source ticket systems out there... just take
the time to look.

http://www.lmgtfy.com/?q=open+source+ticket+system

Here's the top of that list:

http://otrs.org/
http://osticket.com/
http://www.simpleticket.net/
http://www.opensourcehelpdesklist.com/
http://www.eticketsupport.com/


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formulate nested select

2009-03-31 Thread haliphax
On Tue, Mar 31, 2009 at 5:15 PM, PJ af.gour...@videotron.ca wrote:
 kyle.smith wrote:
 What about using IN, something like:

 SELECT * FROM book WHERE id IN (SELECT bookID FROM book_authors WHERE
 authID IN (SELECT author.id FROM authors WHERE last_name LIKE
 $Auth%));

 You could use LEFT instead of LIKE, too.
 Well, I learned something here... but that also revealed another,
 hidden, problem which I had not considered - the order by clause which I
 had stupidly not included in my example:

 $SQL = SELECT * FROM book
        WHERE id IN (SELECT bookID
        FROM book_author WHERE authID IN (SELECT author.id
        FROM author WHERE LEFT(last_name, 1 ) = '$Auth'))
        ORDER BY $sort $dir
        LIMIT $offset, $records_per_page ;

 I now realize that to keep things as simple as possible in the rest of
 the code, I must join 1 column to the query result and that is last_name
 from the author table.
 the spelling, column and table names are spelled correctly. Without the
 ORDER BY I get the right results. I'll try to JOIN the author table ???
 But I see that I may be trying to do too much - I thought of showing how
 many books were listed under each letter of the alphabet but I don't see
 how it can be done in any simiple way as it would mean that I would have
 to do the select once with the ORDER BY and a second time without it
 just to get the number of listing. If there are a lot of books, like
 thousands, it might slow down things.
 I suppose I could live with ORDER BY title as that does not require
 another effort.
 Any thoughts or suggestions?





 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: Tuesday, March 31, 2009 2:06 PM
 To: Jim Lucas
 Cc: Chris; php-general@lists.php.net
 Subject: Re: [PHP] formulate nested select

 Gentlemen  all others,
 The problem was partly fixed with ' ' around $Auth... but...
 somehow, I see that the results do not work with the rest of the script.
 The results give a an array within an array - so this mucks up all the
 rest which is set up to deal with only the book table. The count() is
 off as it shows the results_per_page setting and the pagination is off -
 it shows 10 books but only displays 5 entries (from 5 arrays which, I
 suppose is the reason for the coun() showing 10. The first page shows 5,
 but the second indicates 7 books but displays only 6...
 Now, I suppose that there are 2 ways to fix things:
 1. Redo the rest of the script (a royal pain, I suspect) or 2. SELECT
 only the books that are attributed to the targeted authors - which is
 what I wanted to do in the first place. Something like:

 $SQL = SELECT * FROM book b
 WHERE b.id = (SELECT book_author.bookID WHERE book_author.authID
 = (SELECT author.id WHERE LEFT(author.last_name, 1 ) = '$Auth');

 I want to avoid joins as that seems to screw up the rest of the code
 which is in an include page that needs to be repeated as long as there
 are letters in the alphabet.
 I'll try to figure something out, but as somebody not too optimistic
 once said: it sure don't look too good (American, I believe...) :-)
 Jim Lucas wrote:
 Chris wrote:
 PJ wrote:
 I cannot find anything on google or the manuals/tutorials that
 gives some kin of clear explanation of how to so nested selects
 with where or whatever.
 I have three tables: books, authors and book-authors.
 I need to retrieve only those books whose author's names begin with
 A.
 I have tried several maniipulations of where and select with select

 subqueries and I cannot get results from the queries.
 For example
 SELECT * FROM book b, book_authors c (SELECT id FROM author WHERE
 LEFT(author.last_name = $Auth )) as a WHERE a.id = c.authID  b.id

 = c.bookID snip
 Not really a php question :P

 You don't need a subquery for this. You can join all of the tables
 together and just use the where clause to cut down your results, but

 I'll give an example of both.

 select *
 from
 books b inner join book_authors c on (b.id=c.bookId) inner join
 authors a on (a.id=c.authorId) where left(a.last_name = 'A');
 correct me if I'm wrong, but did you use the left() function
 in-correctly?

 The documentation shows a different way to use it then you describe.

 Something more like the following:

 WHERE
 LEFT(a.last_name, 1) = 'A';

 But that would be case-sensitive...

 So, something like this would work better IMHO

 WHERE
 UPPER(LEFT(a.last_name, 1)) = 'A';

 or

 WHERE
 a.last_name ILIKE 'A%';

 would do the trick
 or

 select *
 from
 books b inner join book_authors c on (b.id=c.bookId) where
 c.authorId in ( select id from authors where left(last_name='A')
 Again...

 SELECT id FROM authors WHERE LEFT(last_name, 1) = 'A')

 but yet again, case-sensitive...

 SELECT id FROM authors WHERE UPPER(LEFT(last_name, 1)) = 'A') or
 SELECT id FROM authors WHERE last_name ILIKE 'A%'

 would do the trick

 );


 Thank you for the suggestions, gentlemen.
 As to the case sensitivity, since the authors' names must be written
 with the 

Re: AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 3:16 AM, Michael A. Peters mpet...@mac.com wrote:
 Andrei Bintintan wrote:

 Any other ideas?



 Also - I believe the commercial (full) version of PDFlib can - in fact, I
 believe you can do it with the pecl-pdflib library if you have the full
 version of pdflib installed.

 I seem to remember there work on a clibpdf php wrapper back when php 4 was
 new, I don't know if it ever amounted to anything.

It may be worth your time to look into Adobe's IFilters. I know
they've got class libraries for C# and other .NET languages--those COM
DLLs could either be leveraged for PHP or there may be a native PHP
implementation.

Not in the mood to Google,

-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP + MySQL - Load last inserts

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 7:55 AM, Sebastian Muszytowski
s.muszytow...@googlemail.com wrote:
 Thijs Lensselink schrieb:

 Sebastian Muszytowski wrote:


 Hello :)

 I have some troubles with php and mysql.  I have a normal MySQL Query
 and this returns X  3 rows.
 Now i want to get the last 3 inserted values. For Example i've inserted

 A, B, C, D, E

 I want to get the last inserted values, e.g. E D C (in reversed order)

 So how to do this? I already searched the web and the whole php.net site
 but i don't see any workaround.

 Thanks in advance

 Sebastian




 It's not really a PHP question. But here goes :

 SELECT column FROM `table` ORDER BY column DESC LIMIT 3


 Oh okay thank you very much :)

 I thought I must do this with php and some sort of mysql_fetch_asssoc or
 something like this

Except when your primary key value rolls over, or fills a gap between
two other rows that was left when a row was deleted/moved/etc... there
has got to be a better way than grabbing rows in descending order
based on the auto_increment value.

Are you doing the inserts one at a time? If so, why not just use code
to remember what you put in the DB?


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP + MySQL - Load last inserts

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 9:13 AM, Sebastian Muszytowski
s.muszytow...@googlemail.com wrote:
 haliphax schrieb:

 [..cut...]

 Except when your primary key value rolls over, or fills a gap between
 two other rows that was left when a row was deleted/moved/etc... there
 has got to be a better way than grabbing rows in descending order
 based on the auto_increment value.

 Are you doing the inserts one at a time? If so, why not just use code
 to remember what you put in the DB?


 I do the inserts one at a time, i could use code to remember but i think it
 would be very slow when i have too much users.

 The second thing that aware me from doing this is, why use/build ressources
 when you could use others? i think why should i use and add another system?
 I work with mysql already and when php+mysql have the function i need it's
 better and i don't waste ressources :)

Insert 100 records. Delete 50 of them at random. Now do your grab the
last few records and sort them in descending order trick and see
where it gets you. Not trying to be rude, it just doesn't seem like
you read any of what I wrote in my last message.

Also--if you're already doing the inserts one at a time, you're not
going to lose any noticeable speed by tracking the last 5 inserted
rows or so. You are not working with an embedded system--this is a
high-level programming language. Why is everybody always so concerned
about adding two or three lines of code like it's going to slow their
system to a crawl?

Unless you're messing with file IO, chewing up gigantic amounts of
RAM, or performing cryptography/compression, you don't need to be
quite so frugal with your methods. I'm not saying you should be
sloppy--just that you shouldn't completely disregard an option because
it adds 1 term (NOT magnitude) to your project's Big-O Notation
measure.

My 2c. Go with ORDER BY asdf_id DESC if it suits your fancy.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time() TIMER in seconds or just numbers

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote:
 When someone does that, it means the execution time between $t1 and $t2...

 Is that for my benefit? Believe it or not, I do know the arcane art of
 subtraction...

I would subtract more often, but sacrificial farm animals and black
candles are so hard to come by these days...


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time() TIMER in seconds or just numbers

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 11:37 AM, Igor Escobar titiolin...@gmail.com wrote:
 The people use that to measure performance.

 If you're intersted about that read
 http://www.igorescobar.com/blog/2009/03/05/benchmarking-de-desempenho-no-php/
 (in portuguese, sorry)

 Regards,
 Igor Escobar

 On Mon, Mar 30, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote:

 On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote:
  When someone does that, it means the execution time between $t1 and
  $t2...
 
  Is that for my benefit? Believe it or not, I do know the arcane art of
  subtraction...

 I would subtract more often, but sacrificial farm animals and black
 candles are so hard to come by these days...

Oh, I'm fully aware of what it's for. FYI, microtime() is probably
more appropriate, since 1 full second in computer terms is a loong
time.

...and I don't speak a lick of Portuguese.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] UTF 8 support - enable-zend-multibyte ( was Re: [PHP] php bug from 2003 still alive?! - )

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 12:34 PM, Merlin Morgenstern
merli...@fastmail.fm wrote:
 HI there,

 I now compiled php with zend multibyte. The trouble with the extra
 characters is now gone, but all special characters are now replaced with a
 questionmark! The document type shows utf-8, but somehow php seems not to
 pars the content OK.

 Does nobody have the same problem?

 Regards, Merlin

Please stop top-posting.

Anyway, are you using a META tag codepage to tell the web browser what
to do with those special characters? I'm not certain a DOCTYPE is
going to handle everything.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time() TIMER in seconds or just numbers

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 1:51 PM, Igor Escobar titiolin...@gmail.com wrote:
 Okey, but you understand the purpouse of it?

 On Mon, Mar 30, 2009 at 3:42 PM, haliphax halip...@gmail.com wrote:

 On Mon, Mar 30, 2009 at 11:37 AM, Igor Escobar titiolin...@gmail.com
 wrote:
  The people use that to measure performance.
 
  If you're intersted about that read
 
  http://www.igorescobar.com/blog/2009/03/05/benchmarking-de-desempenho-no-php/
  (in portuguese, sorry)
 
  Regards,
  Igor Escobar
 
  On Mon, Mar 30, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote:
 
  On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net
  wrote:
   When someone does that, it means the execution time between $t1 and
   $t2...
  
   Is that for my benefit? Believe it or not, I do know the arcane art
   of
   subtraction...
 
  I would subtract more often, but sacrificial farm animals and black
  candles are so hard to come by these days...

 Oh, I'm fully aware of what it's for. FYI, microtime() is probably
 more appropriate, since 1 full second in computer terms is a loong
 time.

 ...and I don't speak a lick of Portuguese.

Please stop top-posting.

I'm fully aware of what it's for == I am aware of its purpose.

My point was that time() gives you seconds since the UNIX epoch,
whereas microtime(true) will give you more accurate results if you are
looking to benchmark a script. If your script takes a few minutes and
you don't really care about measuring those milli/micro seconds, then
time() should suit your needs just fine. However, if your script can
perform an iteration in less than one second, you have already
eliminated the usefulness of time() for benchmarks.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time() TIMER in seconds or just numbers

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 3:35 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 Andrew Williams wrote:
 what does time();

 $t1 = time();

 {

 do something
 }
 $t2 = time();

 $end_time = $t2 - $t1;
 echo $end_time;

 what does $end_time represent?

 how do you determine the next 5 mins?

 So if you haven't deduced the answer from other replies, this would
 probably be more readable:

 $start_time = time();  //or microtime()
 //do something
 $end_time = time();  //or microtime()

 $duration = $end_time - $start_time;
 echo $duration;

Don't forget--microtime() without the boolean true as an argument
will split the result into two parts. Using true as the argument
(minus quotes, of course) gives you a floating-point representation of
seconds/milliseconds/etc.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP + MySQL - Load last inserts

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 5:10 PM, Chris dmag...@gmail.com wrote:
 haliphax wrote:

 On Mon, Mar 30, 2009 at 9:13 AM, Sebastian Muszytowski
 s.muszytow...@googlemail.com wrote:

 haliphax schrieb:

 [..cut...]

 Except when your primary key value rolls over, or fills a gap between
 two other rows that was left when a row was deleted/moved/etc... there
 has got to be a better way than grabbing rows in descending order
 based on the auto_increment value.

 Are you doing the inserts one at a time? If so, why not just use code
 to remember what you put in the DB?

 I do the inserts one at a time, i could use code to remember but i think
 it
 would be very slow when i have too much users.

 The second thing that aware me from doing this is, why use/build
 ressources
 when you could use others? i think why should i use and add another
 system?
 I work with mysql already and when php+mysql have the function i need
 it's
 better and i don't waste ressources :)

 Insert 100 records. Delete 50 of them at random. Now do your grab the
 last few records and sort them in descending order trick and see
 where it gets you.

 Mysql does not re-use id's (nor does any other db as far as I'm aware, and
 nor should it). I don't know where you got that idea from.

 mysql create table test (id int auto_increment not null primary key, name
 text);
 Query OK, 0 rows affected (0.12 sec)

 mysql insert into test(name) values
 ('one'),('two'),('three'),('four'),('five'),('six'),('seven'),('eight'),('nine'),('ten');
 Query OK, 10 rows affected (0.00 sec)
 Records: 10  Duplicates: 0  Warnings: 0

 mysql select * from test;
 ++---+
 | id | name  |
 ++---+
 |  1 | one   |
 |  2 | two   |
 |  3 | three |
 |  4 | four  |
 |  5 | five  |
 |  6 | six   |
 |  7 | seven |
 |  8 | eight |
 |  9 | nine  |
 | 10 | ten   |
 ++---+
 10 rows in set (0.00 sec)

 mysql delete from test where id in (1,3,7);
 Query OK, 3 rows affected (0.00 sec)

 mysql insert into test(name) values('eleven');
 Query OK, 1 row affected (0.00 sec)

 mysql select * from test;
 +++
 | id | name   |
 +++
 |  2 | two    |
 |  4 | four   |
 |  5 | five   |
 |  6 | six    |
 | 11 | eleven |
 |  8 | eight  |
 |  9 | nine   |
 | 10 | ten    |
 +++
 8 rows in set (0.00 sec)

 The physical order of the rows changed (as you can see) but it does not
 re-use the id's that were deleted.

 Ordering by the id will get you the last bunch inserted.

 If you're using innodb you'll have to be aware it's transaction specific, if
 you're using myisam it will be system wide.

I'll have to check my DBs then, because the exact situation I
described happened to me a few years back when I was first getting
into the DB scene. Regardless, I'm fairly certain the MSSQL box we
have at work behaves this way.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex help please

2009-03-27 Thread haliphax
On Fri, Mar 27, 2009 at 9:40 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 I'm normally OK with regex, especially if I fiddle with it long enough,
 however I have fiddled with this one so long that I'm either totally
 missing it or it's something simple.  Does it have anything to do with
 the backref, or the fact that the value of the backref has a $?  I have:

 $out = '
 {$sites}
 tr
        td
        {Site.id}
        /td
 /tr
 {/$sites}';

 And I want to capture the first {$tag}, everything in between and the
 last {$/tag}.  I have tried several things and here is my current regex
 that looks like it should work, but doesn't:

 preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);

Shawn,

First thing I see--your first capture group doesn't include the $, and
so your final capture group will always fail given your current $out
(because it's looking for {/sites} instead of {/$sites}). Also, your
{} are outside of your capture group in \1, but inside in \3. Here's
what I came up with:

$out = '
{$sites}
tr
   td
   {Site.id}
   /td
/tr
{/$sites}';
$matches = array();
preg_match_all('#{(\$[^}]+)}(.*?){(/\1)}#s', $out, $matches);
print_r($matches);

Produces this:

Array
(
[0] = Array
(
[0] = {$sites}
tr
   td
   {Site.id}
   /td
/tr
{/$sites}
)

[1] = Array
(
[0] = $sites
)

[2] = Array
(
[0] =
tr
   td
   {Site.id}
   /td
/tr

)

[3] = Array
(
[0] = /$sites
)

)

Keep in mind, I had to view the page source in order to see the HTML
tags, but it showed me everything I expected to see.

HTH,

-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Frameworks / obstinate?

2009-03-23 Thread haliphax
On Mon, Mar 23, 2009 at 11:11 AM, tedd tedd.sperl...@gmail.com wrote:
 At 10:50 AM -0400 3/23/09, Bastien Koert wrote:

 Tedd,

 JS has been running on MS servers for a long time. It was always viewes as
 an acceptable replacement for vbscript.

 Well -- that's been my fear. I think that M$ is trying to get it's foot into
 this so they can charge for it -- similar to them creating C# as a alternate
 for Java. Has anyone taken M$ certification lately?


If anything, guys, it's not going to be Javascript... it will be some
other child of the ECMA standard, like ActionScript (which interfaces
natively with XML, MXML, and Flash). As for Microsoft and JS, I think
they're finally warming up (a bit) to the Open Source initiative:
jQuery will be included (AS-IS, WITHOUT MODIFICATION) in the new
versions of not only the .NET framework, but in code completion and
documentation for the next Visual Studio developer package.

I'm not so sure that C# was a replacement for Java, either--more a way
to bring C++ (OOP) into the .NET framework while maintaining their new
dynamic of safe vs. unsafe code, etc...

Related to server-side Javascript... there are MANY languages that
offer JS connectors so that JS can be embedded as a scripting language
in your application.  I'm sure this has been applied to a web
application as well as console apps (in lieu of Lua, VBScript, etc.).

My 2c.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] So called PHP Expert

2009-03-23 Thread haliphax
On Fri, Mar 20, 2009 at 5:27 PM, דניאל דנון danondan...@gmail.com wrote:

---8---

 ###
 function h3x($envar){
    $hax3d = bin2hex($envar);
    $hax3d  = chunk_split($hax3d , 2, %);
    $hax3d  = % . substr($hax3d , 0, strlen($hax3d ) - 1);
    return $hax3d;
 }
 ?*

Programmers who use 13375p34k (leet speak) in their code should be
dragged out into the street and shot.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Problems with exec() on windows

2009-03-20 Thread haliphax
On Fri, Mar 20, 2009 at 1:47 AM, Kyohere Luke pr0...@gmail.com wrote:
 You might have something there - never really thought about how windows
 forms the 8.3 names...  not many resources online about it ...

 The actual path is c:\Program File\Gammu 1.23.91\bin\gammu.exe
 I'd used c:\Progra~1\Gammu~1\bin\gammu.exe

You should be able to view these truncated path names via the dir
command in a CMD.EXE command line. I say this because Program Files
and Programs would collide with each other (just as an example); one
would be Progra~1 and one would be Progra~2.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems with exec() on windows

2009-03-19 Thread haliphax
On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote:
 Hi,
 I'm trying to use exec to call gammu.exe and send sms on windows XP.

 This works from commandline:

 C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2

 But if I run it through php like this:

 $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1
 test2\.;
 @exec($command, $response, $retval);

 This always fails, returns 1 and the response is empty.

 If the last argument is a string with no spaces, and the double quotes were
 omitted, it works perfectly.

 If the double quotes are added around the string with no spaces, it fails
 again, which makes me believe that the problem is with the double quotes.

 I've used procmon and it shows that when the double quotes are added around
 the last argument, gammu.exe is not even called at all.

 Problem is that the double quotes are required by gammu to send an sms with
 spaces in it.

I'm not sure if it will help, but the escapeshellarg() function looks
like it might handle all that tricky slash-and-quote-adding for you:

http://php.net/escapeshellarg

Other than that, perhaps proc_open() would do what you need it to by
completely separating the command's arguments from itself.

http://php.net/proc_open

HTH,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems with exec() on windows

2009-03-19 Thread haliphax
On Thu, Mar 19, 2009 at 9:25 AM, haliphax halip...@gmail.com wrote:
 On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote:
 Hi,
 I'm trying to use exec to call gammu.exe and send sms on windows XP.

 This works from commandline:

 C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2

 But if I run it through php like this:

 $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1
 test2\.;
 @exec($command, $response, $retval);

 This always fails, returns 1 and the response is empty.

 If the last argument is a string with no spaces, and the double quotes were
 omitted, it works perfectly.

 If the double quotes are added around the string with no spaces, it fails
 again, which makes me believe that the problem is with the double quotes.

 I've used procmon and it shows that when the double quotes are added around
 the last argument, gammu.exe is not even called at all.

 Problem is that the double quotes are required by gammu to send an sms with
 spaces in it.

 I'm not sure if it will help, but the escapeshellarg() function looks
 like it might handle all that tricky slash-and-quote-adding for you:

 http://php.net/escapeshellarg

 Other than that, perhaps proc_open() would do what you need it to by
 completely separating the command's arguments from itself.

 http://php.net/proc_open

Also--if you're only concerned with a one-way process tunnel (read or
write, but not both) then maybe popen() instead of proc_open() would
be preferable for overhead/speed. Of course, that's if either of them
do what you're looking for.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Knowledge Base software - looking for opinions

2009-03-14 Thread haliphax
On Sat, Mar 14, 2009 at 4:34 AM, mike mike...@gmail.com wrote:
 Or, a very simple CMS so I don't have to code it that has the concept
 of basic ACLs (user-based or group-based is fine)

 Hierarchial directory of documents

 Allow anyone with the right privileges to edit it

 Keep an audit of who edited it, when, and the previous content

 I really don't want to have to code one myself but at the moment I
 might have to put a couple hours into it tomorrow.


Seriously, man... give TWiki a shot. It's hierarchal, it has an ACL,
and it's simple. Save yourself a LOT of time. :)


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP to create an ERD (sic) on the fly on a web page based on current DB records?

2009-03-13 Thread haliphax
On Thu, Mar 12, 2009 at 7:47 PM, scubak1w1 sk...@spamcop.net wrote:
 Hello,

 Seeking some advice on how to create an ERD (sic) graphically on the page on
 the fly when the page is 'called'...

 That is, I have a backend PostgreSQL database that I am getting data from
 and putting data into via web page/s and PHP...

 I would like to be able to show graphically to the web site admins the
 relationships between the pimary key contents of one table to all its
 foreign keys in the daughter table in a form of a simple entity relationship
 diagram.

 That is, a graphic showing (say) all of the PKs listed in the mother table,
 all of the more voluminous (sic) FKs listed in another table - and
 connecting lines.

 This is to aid the admin users that are used to conceptualiazing this sort
 of thing...

PHPMyAdmin does exactly this sort of thing, as do a lot of SQL
workbench programs. I'm sure there is one out there that will handle
PostgreSQL. My advice to you is not to reinvent the wheel. If they're
admin users, do you really need to wrap it up in a self-contained
webpage for them, or could you just show them using an administrative
tool that can handle ERD?


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: 2 forms, same page, 1st is file upload - works in IE, 'dies' in non-IE browsers

2009-03-13 Thread haliphax
On Fri, Mar 13, 2009 at 3:18 AM, 9el le...@phpxperts.net wrote:
 It sounds like a script error rather than a PHP error. Use Firebug which
 will show you the HTML as it is updated by Javascript, so you can see
 where the problem is. I'm willing to bet that the Javascript code you
 are using is IE only.

 Yeah, php is never browser specific. It is rendered to HTML before browser
 can see it. So all browsers will react the same with PHP. But will differ on
 the client sides like JavaScript.

Also--INCLUDE YOUR CODE. Listing everything you do in pseudocode will
do you absolutely no good for a problem like this, as it is no doubt a
syntax error or a browser-javascript-compatibility issue. If we can't
see the code, we can't point out the problem.

Anyway, yeah--if it works in IE and not in FF, then it has nothing to
do with PHP (directly). Change your JS.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sanitizing Numbers

2009-03-13 Thread haliphax
On Fri, Mar 13, 2009 at 12:34 PM, Matt Neimeyer m...@neimeyer.org wrote:
 I'm trying to sanitize some numeric data that's coming to us from
 another system which I have no control over where all fields are
 character fields with no formatting from the end user so data is a
 mishmash of clean and mixed types of dirty.

 I know I can use intval and floatval to sanitize if the numeric data
 is at the front of the string but what about when it's not?

 For example, Jersey Number = #45 or Dues = $1,234.56

 I see in the comments at php.net for floatval a lot of very complex
 solutions... am I missing something about the following that wouldn't
 cover me?

 ?php $output = floatval(ereg_replace([^-0-9\.],,$input)); ?

 I'm willing to assuming only US formatted numbers... and knowing that
 if they put in 45/46 for jersey it would come out 4546 (but I might
 put in additional code for that specific case on that specific
 field...). I'm also looking for something that I can generically apply
 to any numeric field.

Man... I went completely apeshit on this with regex and made this
long, complicated string to match numeric values and strip out
possible false positives like IP addresses, etc... if you really want
it, I'll post it. Anyway, the point I'm going to make instead is that
you need to do more than just strip out everything but numbers and
periods unless all of your values are going to be in the format Some
name = [possible junk]some value[possible junk]. If all of your
values are guaranteed to be in this format, and there will be no
values that would act as false positives (like IP addresses), then
stripping everything but numbers and periods should be fine.

However, values like 1 and 5 will turn into 15, 3 sizes. 30 day
trial. will return 3.30, etc... just something to keep in mind (if
cases like these can arise in your data).


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RE: non-auto increment question

2009-03-13 Thread haliphax
On Fri, Mar 13, 2009 at 1:24 PM, PJ af.gour...@videotron.ca wrote:
 Jim Lucas wrote:
 PJ wrote:
 am resending as this was erroneously ccd to mysql. sorry!

 Ashley Sheridan wrote:
 On Thu, 2009-02-26 at 11:27 -0500, PJ wrote:
 Jerry Schwartz wrote:

 Being rather new to all this, I understood from the MySql manual
 that
 the auto_increment is to b e used immediately after an insertion not
 intermittently. My application is for administrators (the site
 owner 
 designates) to update the database from and administration
 directory,
 accessed by user/password login... so there's really very little
 possibility of 2 people accessing at the same time.
 By using MAX + 1 I keep the id number in the $idIn and can reuse
 it in
 other INSERTS

 [JS] Are you looking for something like LAST_INSERT_ID()? If you
 INSERT a
 record that has an auto-increment field, you can retrieve the value
 that got
 inserted with SELECT LAST_INSERT_ID(). It is
 connection-specific, so
 you'll always have your own value. You can then save it to reuse,
 either
 as a session variable or (more easily) as a hidden field on your
 form.

 Thanks, Jerry,


 You hit the nail on the head.:)

 To refine my problem (and reduce my ignorance),here's what is
 happening
 on the form page:

 There is a series of INSERTs. The first inserts all the columns of
 book table except for the id, which I do not specify as it if
 auto-insert.

 In subsequent tables I have to reference the book.id (for transitional
 tables like book_author(refers authors to book) etc.

 If I understand it correctly, I must retrieve (SELECT
 LAST_INSERT_ID()) after the first INSERT and before the following
 insert; and save the id as a string ($id)...e.g. $sql = SELECT
 LAST_INSERT_ID() AS $id
 I need clarification on the AS $id - should this be simply id(does
 this have to be turned into a value into $id or does $id contain the
 value? And how do I retrieve it to use the returned value for the next
 $sql = INSERT ... - in other words, is the id or $id available for
 the
 next directive or do I have to do something like $id = id?
 I'm trying to figure this out with some trials but my insert does not
 work from a php file - but it works from command-line... that's
 another
 post.

 Here's how I mostly do it (albeit simplified):

 $query = INSERT INTO `sometable`(`title`,`content`)
 VALUES('$title','$content');
 $result = mysql_query($query);
 $autoId = mysql_insert_id($result);

 $query = INSERT INTO `another_table`(`link_id`,`value`)
 VALUES($autoId,'$value');
 $result = mysql_query($query);

 No need to call another query to retrieve the last inserted id, as
 it is
 tied to the last query executed within this session.


 Ash
 www.ashleysheridan.co.uk
 For some reason or other $autoId = mysql_insert_id($result); just does
 not work for me... Yet some of the data is inserted correctly...
 I did find that it does not work on tables that are empty... so you
 can't start with an empty table. I entered data  it still did not work.
 I tried on another duplicate database... doesn't work.
 I have checked  double checked the database, I have added checks to see
 what is returned and the returns are 0 or null - as I get different
 responses for slightly different functions.
 sessions is on
 mysql is 5.1.28
 php5

 here's what is parsed:
 else { $sql1 = INSERT INTO book
                     ( title, sub_title, descr, comment, bk_cover,
 copyright, ISBN, language, sellers )
                 VALUES
                     ('$titleIN', '$sub_titleIN', '$descrIN',
                     '$commentIN', '$bk_coverIN', '$copyrightIN',
 '$ISBNIN', '$languageIN', '$sellersIN');
         $result1 = mysql_query($sql1, $db);
     $autoid = mysql_insert_id($result1);
         $sql2 = INSERT INTO author (first_name, last_name) VALUES
 ('$first_nameIN', '$last_nameIN');
             $result2 = mysql_query($sql2, $db);
     $authorID = mysql_insert_id($result2);
         $sql2a = INSERT INTO book_author (authID, bookID, ordinal)
 VALUES ( '$authorID', '$autoid', '1');
             $result2a = mysql_query($sql2a, $db);
         $sql2b = INSERT INTO author (first_name, last_name) VALUES
 ('$first_name2IN', '$last_name2IN');
             $result2b = mysql_query($sql2b, $db);
     $author2ID = mysql_insert_id($result2b);
         $sql2c = INSERT INTO book_author (authID, bookID, ordinal)
 VALUES ( '$author2ID', '$autoid', '2');
             $result2c = mysql_query($sql2c, $db);
         $sql3 = INSERT INTO publishers (publisher) VALUES
 ('$publisherIN');
             $result3 = mysql_query($sql3, $db);
     $publisherID = mysql_insert_id($result3);
         $sql3a = INSERT INTO book_publisher (bookID, publishers_id)
 VALUES ( '$autoid', '$publisherID' );
             $result3a = mysql_query($sql3a, $db);
         foreach($_POST['categoriesIN'] as $category){
             $sql4 = INSERT INTO book_categories (book_id,
 categories_id)
                 VALUES ($autoid, $category);
             $result4 = 

Re: [PHP] Sanitizing Numbers

2009-03-13 Thread haliphax
On Fri, Mar 13, 2009 at 2:09 PM, Richard Heyes rich...@php.net wrote:
 ereg

 [Gasps and runs off shouting PCRE] ...

 --
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.net (Updated February 28th)


You can bet your shirt my tests were using preg_replace... :)


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Working directory of PHP pages?

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 12:47 AM, Clancy clanc...@cybec.com.au wrote:
 On Wed, 11 Mar 2009 13:03:19 -0500, halip...@gmail.com (haliphax) wrote:

On Wed, Mar 11, 2009 at 12:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 Clancy wrote:
 It is my understanding that when you open a page the PHP server looks for 
 index.php in the
 site root directory, and loads it. As a result the working directory of 
 the page will be
 the root directory of the site.  I have always worked on this assumption, 
 and it has
 always been correct.  On the other hand Stewart thinks that I cannot rely 
 this, and am
 likely to get into trouble as a result.

 Are there any systems in which my assumption will not be correct?


 In many frameworks this assumption is not correct.  I am using the
 default CakePHP layout as an example.

 Depending on your terminology, your DocumentRoot is /var/www/ and in
 this case is also the filesystem path of your site's root dir, however
 the sites root dir in a URL is /.

 Consider the CakePHP structure:

 /var/www/
  .htaccess
  index.php
 /var/www/webroot
  index.php

 If you browse to http://example.com/ (in most cases), one of 2 things
 happens:

 1. The webserver opens the /var/www/.htaccess and according to the
 rewrite rules there it rewrites to /var/www/webroot/.  So any getcwd()
 would be /var/www/webroot/

 2. If not using modrewrite, the web server looks for index.html and then
 index.php in /var/www/ which has a require for webroot/index.php.  So
 any getcwd() would be /var/www/.

 Consequently, CakePHP and the other frameworks that I've seen use
 basename() and dirname() in conjunction with __FILE__ to define the
 paths/relative dirs within the app.

Come to think of it, this may very well be true for all MVC frameworks
(unless the models, views, and controllers are all in the same
directory as the launch script). I can at least vouch for the fact
that CodeIgniter, like CakePHP, will fudge your directory estimation
if you're expecting getcwd() to be right.

 Something Stewart said the other day made me realise that there was a 
 fundamental error in
 the way I was thinking about this question. I had been thinking that opendir 
 (.) opened
 the root directory, and that paths such as Joe/Nurg.com were relative to the 
 root
 directory, but I now realise that they are relative to the current directory, 
 whatever
 that might be. (Yes; I should have known better, but there is an awful swamp 
 of burnt out
 brain cells at the bottom of my brain.)

 So the question I should have asked was When a web page is loaded, can I 
 rely on the CWD
 being the directory containing index.php (or whichever file is actually 
 loaded)?

I believe the answer was No, not really, from several different people.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] password field validation

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 2:39 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com wrote:

 if (empty($_POST[PASSSWORD]))
 { $GERROR=TRUE;}


 If that's a direct copy/paste from your actual code, there is an extra
 S in PASSWORD. Also, you should enclose the array key in quotes:

 if (empty($_POST['PASSWORD']))
 { $GERROR='TRUE'; }

 It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour
 of looking!

 Why enclose in quotes? I have never done this!

Because if it's not in quotes, you run the risk of colliding with one
of PHP's reserved words/constants/etc.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Knowledge Base software - looking for opinions

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote:
 http://puresw.com/products/lore/ - paid
 http://www.knowledgebase-script.com/ - paid
 http://68kb.com/ - free

 Free is good.

 Just needs to be basic, nothing crazy.

 A Wiki -almost- meets the needs but a) I hate wikis and b) they don't
 match up 100%

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Have you considered TRAC? I know it wasn't built specifically for
Knowledge Base articles, but it can be leveraged as such--and has been
by many organizations.

-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Knowledge Base software - looking for opinions

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 3:32 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Thu, 2009-03-12 at 13:24 -0700, mike wrote:
 Yeah, I have.. but it's just another wiki. Does integrate with its own
 style of bug tracking + svn, but I think an actual KB system would be
 neat.

 Especially if it had the capability to have page level security. So I
 can make KB articles just for admins...

 On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote:
  On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote:
  http://puresw.com/products/lore/ - paid
  http://www.knowledgebase-script.com/ - paid
  http://68kb.com/ - free
 
  Free is good.
 
  Just needs to be basic, nothing crazy.
 
  A Wiki -almost- meets the needs but a) I hate wikis and b) they don't
  match up 100%
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  Have you considered TRAC? I know it wasn't built specifically for
  Knowledge Base articles, but it can be leveraged as such--and has been
  by many organizations.
 
  --
  // Todd
 

 I'm looking for something similar myself to implement at work as a way
 of documenting things we need. I've lost count of the number of times
 someone has gone on holiday only for us to then find out that they were
 the only one with access details to this server or that system! I've
 already set up Mantis at work, and had considered using the docs section
 of that, but I think the documentation we're likely to need will go
 beyond the project scope, and we might need some way of linking
 documents together in a mesh-type way. Does anyone use anything like
 this already?

 Sorry if it seems I've hijacked this thread, but I felt I wasn't
 deviating from the topic really... :p

http://wkb.sourceforge.net/
http://kbpublisher.sourceforge.net/
http://twiki.org/ (wiki with granular security)
http://www.smartertools.com/SmarterTrack/Free-Customer-Service-Software.aspx
(single-user)
http://freemind.sourceforge.net/
http://freshmeat.net/projects/phpkb/


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Knowledge Base software - looking for opinions

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 3:44 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Thu, Mar 12, 2009 at 12:55:54PM -0700, mike wrote:

 http://puresw.com/products/lore/ - paid
 http://www.knowledgebase-script.com/ - paid
 http://68kb.com/ - free

 Free is good.

 Just needs to be basic, nothing crazy.

 A Wiki -almost- meets the needs but a) I hate wikis and b) they don't
 match up 100%

 Out of curiosity, why do you dislike wikis?

It may be the lack of access permissions in a lot of the wiki systems
out there right now... though some of them have an access control
layer (such as TWiki).

-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] This code using _GET exploitable

2009-03-11 Thread haliphax
On Wed, Mar 11, 2009 at 7:56 AM, Michael A. Peters mpet...@mac.com wrote:
 filtered wrote:

 On Wed, Mar 11, 2009 at 13:44, Jochem Maas joc...@iamjochem.com wrote:

 filtered schreef:

 Hi,

 we have script containing

  ? echo $_GET['studio'] ?

 let say I do:

 example.com/yourscript.php?studio=script type=text/javascriptalert('I
 am an evil haxor');/script

 excusing the fact that the query is not urlencoded, what happens on your
 site
 (replace domain and script name to match your site/script)



 Ok, but I don't see how this code could be used to attack the local
 php/web-server

 reflected attack.
 Someone puts that as the image source on some website they trick a
 legitimate user in going to (IE - click here to see latest brittany spears
 scandal !!!) - their browser tries to load the image, instead calling your
 page with the XSS attack thus allowing the cracker to read any cookies the
 user has from your domain which can then allow the cracker to impersonate
 the user via session ID.

...this and many other bad things can happen to YOU!
/public-service-announcement

http://www.cgisecurity.com/xss-faq.html


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP/Apache: script unexpectedly invoked multiple times in parallel every 30 secs.

2009-03-11 Thread haliphax
On Wed, Mar 11, 2009 at 10:30 AM, Martin Zvarík mzva...@gmail.com wrote:
 Marc Venturini napsal(a):

 Hi all,

 I wrote a PHP script running in Apache which takes more than 30 seconds to
 complete. It uses set_time_limit() to extend the time it is allowed to
 run.
 The script generates thumbnails from a list of images. Upon completion,
 the
 script redirects the browser to another page using HTTP headers.

 If you die() at the end of the script and don't redirect does it continue
 this auto-30-seconds execution?


 On my local machine (Windows + EasyPHP), the script runs as expected and
 completes after a few minutes.

 I observe an unexpected behavior on my production web server:
 - The script runs as expected for the first 30 seconds.
 - After 30 seconds, the same script with the same parameters starts again
 in
 a new thread/process. The initial thread/process is *not* interrupted, so
 2
 threads/processes run in parallel, executing the same sequence of
 operations
 with a 30 time shift.
 - The same scenario happens every 30 seconds (i.e.: at 030, 100, 130,
 and
 so on), multiplying the parallel threads/processes.

 - The browser keeps on loading while the above happens.

 - After some time, the browser displays a blank page and all the
 threads/processes stop. I assume this is due to resources exhaustion, but
 I
 have no means to check this assumption.

 I deduced the above reading a text file in which I log the sequence of
 called functions.

 It all seems as a redirection / unclosed loop problem.


 Unfortunately I have no access *at all* to my production web server
 configuration (shared hosting, no documentation). I cannot even read the
 configuration settings. While I'm considering moving to another host, I'd
 be
 extremely pleased to have an explanation of the observed behavior.

 I have browsed the mailing list archives and looked for an explanation in
 other forums to no avail. This thread may deal with the same issue but
 does
 not include any explanation or solution:
 http://www.networkedmediatank.com/showthread.php?tid=17140

 Thanks for reading, and please do not hesitate to ask for further
 explanations if what I'm trying to achieve was not clear!

 Why it works on your local server is probably caused by different
 versions/settings, but I bet there's an error somewhere in your script.

 Consider sending it here, I'll take a look.

A blank URL does not redirect to the directory index, IIRC... it
refreshes the current page (such as a FORM tag with ACTION=). This
may very well still be your problem.

My 2c,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Working directory of PHP pages?

2009-03-11 Thread haliphax
On Wed, Mar 11, 2009 at 12:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 Clancy wrote:
 It is my understanding that when you open a page the PHP server looks for 
 index.php in the
 site root directory, and loads it. As a result the working directory of the 
 page will be
 the root directory of the site.  I have always worked on this assumption, 
 and it has
 always been correct.  On the other hand Stewart thinks that I cannot rely 
 this, and am
 likely to get into trouble as a result.

 Are there any systems in which my assumption will not be correct?


 In many frameworks this assumption is not correct.  I am using the
 default CakePHP layout as an example.

 Depending on your terminology, your DocumentRoot is /var/www/ and in
 this case is also the filesystem path of your site's root dir, however
 the sites root dir in a URL is /.

 Consider the CakePHP structure:

 /var/www/
  .htaccess
  index.php
 /var/www/webroot
  index.php

 If you browse to http://example.com/ (in most cases), one of 2 things
 happens:

 1. The webserver opens the /var/www/.htaccess and according to the
 rewrite rules there it rewrites to /var/www/webroot/.  So any getcwd()
 would be /var/www/webroot/

 2. If not using modrewrite, the web server looks for index.html and then
 index.php in /var/www/ which has a require for webroot/index.php.  So
 any getcwd() would be /var/www/.

 Consequently, CakePHP and the other frameworks that I've seen use
 basename() and dirname() in conjunction with __FILE__ to define the
 paths/relative dirs within the app.

Come to think of it, this may very well be true for all MVC frameworks
(unless the models, views, and controllers are all in the same
directory as the launch script). I can at least vouch for the fact
that CodeIgniter, like CakePHP, will fudge your directory estimation
if you're expecting getcwd() to be right.


--
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validation inserts not working

2009-03-11 Thread haliphax
On Wed, Mar 11, 2009 at 4:29 PM, PJ af.gour...@videotron.ca wrote:
 Lex Braun wrote:
 PJ,


     snip

     $sql1 = INSERT INTO book ( title, sub_title, descr,
                comment, bk_cover, copyright, ISBN, language, sellers )
             VALUES ('$titleIN', '$sub_titleIN', '$descrIN', '$commentIN',
                '$bk_coverIN', '$copyrightIN', '$ISBNIN', '$languageIN',
                '$sellersIN');
        $result1 = mysql_query($sql1, $db);
        $autoid = mysql_insert_id($result1);


 You're actually sending mysql_insert_id() the wrong parameter. It should be:
 $autoid = mysql_insert_id($db); // you send the resource of your MySQL
 connection (http://ca3.php.net/manual/en/function.mysql-insert-id.php)
 This should be corrected in everywhere you call mysql_insert_id()

 -Lex


 I tried this (from the link above)
 $result1 = mysql_query($sql1, $db);
    $autoid = mysql_insert_id();
    echo $autoid;
 works...

 but now, I have another problem... I am trying to debug this thing by
 going 1 query at a time ( I comment out the rest): every time I do an
 INSERT INTO book... the insert works fine but the ID is increased not
 from the highest id value but from the last id inserted. So my highest
 at the moment is 11; I insert test data and it goes in as id = 15; I
 delete this field and redo an insert and it goes in as id = 16. How can
 I change this so the auto_increment continues from the 11 ?

In MySQL,

ALTER TABLE [tablename] AUTO_INCREMENT = [value];

HTH,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-10 Thread haliphax
On Mon, Mar 9, 2009 at 8:43 PM, Sashikanth Gurram sashi...@vt.edu wrote:
 Is there any way in which I can assign a variable to a query string?
 Like for example, Let us say that there are two php files a.php and
 b.php. I am currently using a image tag like img
 src=imgtest.php?id=Williams Hall / in a.php and am passing the value
 to another variable using $build=$_GET['id']; in b.php. Now for this
 purpose, I am using the img tag in the html part of my first file which
 makes it kind of static. Now if I want to assign a variable (say
 $building) to 'id' in my first file, and retrieve it using the  variable
 $build in the second file what is the best way to do it?
 Will the command (written  inside the PHP tags) echo ' img
 src=imgtest.php?id=$building /'; be of any help in performing the
 task. I have actually tried this out, but it did not work for me (May be
 my syntax is wrong although I have tried various combinations). So, is
 there a better way or correct way of doing this (If what I have done is
 wrong). I have tried to use $_session() command, but it is kind of
 yielding me a header error.

I'm not sure if this has been addressed in any of the other replies,
but I felt it was worth mentioning: Be careful and pay attention to
whether you are using single quotes ( ' ) or double quotes (  ) in
your echo statements!

$var = 'asdf';
echo 'hey, $var'; // hey, $var
echo hey, $var; // hey, asdf

...and if you're using single or double quotes elsewhere (i.e.,
assignment operations)...

$var = 'asdf';
$othervar = 'blah$var'; // blah$var
$anothervar = blah$var; // blahasdf
$yetanothervar = blah{$var}blah; // blahasdfblah

Double quotes, when not using echo, can still parse variables for you.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] soft Phone

2009-03-10 Thread haliphax
On Tue, Mar 10, 2009 at 8:25 AM, Michael A. Peters mpet...@mac.com wrote:
 shahrzad khorrami wrote:

 Hi all :-)

 I want to use of *soft phone* application in my php codes..First is it
 possible? has php a module for this purpose?
 if it hasn't... By the way I think I must use of something else such as a
 java application in my php codes...
 now how can I embed this application to my program? and do you know where
 I
 can find this application source code?


 Thanks in advance,
 shahrzad khorrami


 http://www.voip-info.org/wiki-Open+Source+VOIP+Software

 You should be able to obtain the source code to anything listed there and
 legally use it (so long as abide by the terms of the open source license for
 the project you use)

 I don't know of any existing php modules for software phones, I suspect
 that's really beyond the scope of php (unless you are writing client side
 scripting, ala php-gtk).

 I can't speak to integrating php with java. You can embed java applet in a
 web page, but I personally haven't a clue about how to make them talk to
 each other.

http://php-java-bridge.sourceforge.net/

Still a bit shaky, but maybe worth looking at.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] verify data in fields

2009-03-09 Thread haliphax
On Sun, Mar 8, 2009 at 4:52 PM, PJ af.gour...@videotron.ca wrote:
 Ashley Sheridan wrote:
 On Sun, 2009-03-08 at 10:25 -0500, PJ wrote:

 My mysql table contains data. But I don't know how to verify what
 exactly is the data... is it an array, an integer, an alphanumeric
 character or what?
 vardump($whatever) returns null; the structure of the table is no null
 for the column fields and has been filled like this:
 $autoid = 1;
 $test = $_POST['categoriesIN']; // this can be several selections from form
 $tstring = implode(',' , $test);
 echo $tstring.'br /';
 $insert_category = INSERT INTO book_categories (book_id, categories_id)
 VALUES ($autoid, $tstring.);
 mysql_query($insert_category,$db);

 retrieval of data is:

 from SELECT ...snip...
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id
 LEFT JOIN book_categories AS d ON b.id = d.book_id
 LEFT JOIN categories AS e ON d.categories_id = e.id

 I have included the publisher stuff - it works, whereas the category
 stuff does not...

 Surely if it is your table, you already know what types of data each
 field contains?

 I did and do.. I just was not getting the output I was expecting...so I
 panicked and looked for ways to verify all... bit, by bit I went over
 all my little lessons of the past weeks and ...  of course, taking my
 sweet time and lack of knowledge it took me a while to figure out that
 the problem was a missing SELECT table.column from the query. When I
 found the error, everything fell into place.
 But there remains the problem of how to select and display several
 categories from the query. If there isi only one category, there is no
 problem; with more than one I can't figure out how to retrieve it
 without the output showing as many entries for the same book as there
 are categories. Everything is output (echoed) correctly but the books
 are echoed in their entirety along with the category... what could I
 post to analyse the prolem.  I'm sure it's something simple, like
 imploding the array so it isn't repeated... ??

I think you'll probably have to use an ORDER BY clause in your query,
and only output a new book name when it changes during iteration. For
instance:

1. grab book categories (book id, book name, category id, category
name) with a JOIN
2. set last book name to  (empty string)
3. for each row in the result set
3a. if book name is different than last book name, output it
3b. output category
3c. next

HTH,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Sun, Mar 8, 2009 at 11:57 PM, Micah Gersten
news.php@micahscomputing.com wrote:
 Chetan Rane wrote:
 HI

 I also was looking for various frameworks and came across a very nice
 framework, which is feature rich as well as very fast

 You can see more details at http://www.yiiframework.com/


 -Original Message-
 From: Micah Gersten [mailto:news.php@micahscomputing.com]
 Sent: Monday, March 09, 2009 9:52 AM
 To: php-general@lists.php.net
 Subject: [PHP] Re: PHP Frameworks

 HallMarc Websites wrote:
 First time caller; long time listener..

 I have been looking at various PHP MVC frameworks; Limb3, Symphony,
 Mojavi,
 Navigator, WACT, etc.

 I'm looking for any input anyone might have regarding which framework
 seems
 to be the most promising?


 I'm currently using Zend PHP Framework + Doctrine ORM.  Symfony has a
 little better integration with Doctrine.  I chose the Zend PHP Framework
 because of the rapid release schedule and large feature set.

 You might want to check the archives as this discussion has come up before.


 Please keep on list by hitting reply-all.  Someone else already
 mentioned yii framework.

Yes, this discussion has been hashed and rehashed more times than most
of us care to think about. The only thing I have to add since the last
time this came up was that I have been using CodeIgniter lately on a
personal project of mine, and I find it quite pleasant. It's like
Cake, only slimmer--but not lacking in important core features. Pretty
quick little bugger, too, and very easy to learn.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 Hi Nathan,

 Thanks a lot for the suggestion. It is working fine for an example code I
 have used to test it. The code I have written after your suggestion is as
 follows.
 ?php
 $location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 The above code is yielding me a picture. Now, When I tried to use it in my
 original code it is not giving me the image. Instead it is giving me this
 warning *Warning*: Cannot modify header information - headers already sent
 by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
 on line *221*
 and a lot binary characters again instead of the image. I know something
 about this warning that we should not output anything to the browser before
 the header. But I cannot do that, since I need the user input using a html
 form and I use the input to fetch the data and dispaly it in a table along
 with the image. I am posting the whole code below. Please do let me know
 about any changes, corrections or modifications that are needed. The image
 display code is towards the last.

 Thanks,
 Sashi

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
     option value=Williams HallWilliams Hall/option
     option value=Women's Softball FieldWomen's Softball Field/option
     option value=Wright HouseWright House/option
 /select
 /div
                   input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=*;
 $user=*;
 $password=*;
 $dbname=*;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
   {
       $error=mysqli_error($cxn);
       echo $error;
       die();
   }
 else
   {
       echo Connection established successfully;
   }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
   {
       $minute=00;
   }
 elseif ($minute=15  $minute=29)
   {
       $minute=15;
   }
 elseif ($minute=30  $minute=44)
   {
       $minute=30;
   }
 else
   {
       $minute=45;
   }
 $times=10:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
  buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='Monday' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
   {
       $error=mysqli_error($cxn);
       echo $error;
       die();
   }
 else
   {
       echo br;
       echo Query sent successfully;
   }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
       thBuilding/th\n
       thParking Lot/th\n
       thEstimated Number of Empty Spaces/th\n
       thDistance (Feet)/th\n
       thEstimated walking time to the building/th\n
   /tr\n;
 while ($row=mysqli_fetch_array($data))
   {
       extract($row);
 $building = $row[0];
     $parking_lot = $row[1];
     $Number_of_Empty_Spaces = $row[2];
     $Distance = $row[3];
     $time_l = $row[4];
     $time_h=$row[5];
     $location=$row[6];   echo tr\n
             td$building/td\n
             td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
             td$Distance/td\n
             td$time_h - $time_l mins/td\n
 td$location/td\n
             /tr\n;
   }
   echo /table\n;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 /body
 /html
 Nathan Nobbe wrote:

 On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu wrote:



 The thing is, I do not have a website or a place where I am storing my
 images. I am storing the images on my local PC in folder as mentioned in
 my
 earlier post. I have tried using only the

 else {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 imagedestroy($img);
 }

 Which you have suggested. This is the piece of code which is returning
 all
 the binary character stuff. The code is definitely fetching the image.
 But
 it is not able to deliver to the browser in the form of an image. I am
 trying to read the image file as binary, evident from the FILE_BINARY
 command. So may be, that is causing the image to be displayed as binary.
 Is
 there any way we can convert the binary content to jpeg/jpg content
 again.
 This is my guess after having gone through the code again.




Re: [PHP] assign array values to variables

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:25 AM, Jim Lucas li...@cmsws.com wrote:
 haliphax wrote:

 On Mon, Mar 9, 2009 at 2:22 AM, Jim Lucas li...@cmsws.com wrote:

 PJ wrote:

 PJ, this looks like your third thread for this same question. It might
 be easier to get a straight answer if your request isn't scattered all
 over the mailing list discussions.



 Actually, I think this is only the second for this specific topic.

 But, for his current project, this is like the 6th or 7th thread.

This particular JOIN and its surrounding circumstances are being
discussed in three threads. This is one of them. Anyway, I digress, as
I'm wasting just as much bandwidth with this reply. :P


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:25 AM, Marc Christopher Hall
m...@hallmarcwebsites.com wrote:
 @todd; Micah - Precisely why I presented the question anew. Not only do I not 
 have enough time to troll through the archives; I was looking for a fresher 
 set of responses based on today's smorgasbord. Thank you for your input; I 
 have looked at both YII and CI and they look promising. I love the statement 
 about PEAR! That gave me a chuckle. With PHP 5.3 around the corner and 
 looking forward to both PHP/MySQL 6; I am ISO a framework that is just as 
 forward looking. I have already worked with Sapphire/SilverStripe for a 
 client of mine and I find it comes with a lot of overhead. It does seem to be 
 a promising future contender.

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:32 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram sashi...@vt.edu wrote:


 Hi Nathan,

 Thanks a lot for the suggestion. It is working fine for an example code I
 have used to test it. The code I have written after your suggestion is as
 follows.
 ?php
 $location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 The above code is yielding me a picture. Now, When I tried to use it in
 my
 original code it is not giving me the image. Instead it is giving me this
 warning *Warning*: Cannot modify header information - headers already
 sent
 by (output started at C:\wamp\www\mysqli.php:65) in
 *C:\wamp\www\mysqli.php*
 on line *221*
 and a lot binary characters again instead of the image. I know something
 about this warning that we should not output anything to the browser
 before
 the header. But I cannot do that, since I need the user input using a
 html
 form and I use the input to fetch the data and dispaly it in a table
 along
 with the image. I am posting the whole code below. Please do let me know
 about any changes, corrections or modifications that are needed. The
 image
 display code is towards the last.

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
    option value=Williams HallWilliams Hall/option
    option value=Women's Softball FieldWomen's Softball Field/option
    option value=Wright HouseWright House/option
 /select
 /div
                  input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=*;
 $user=*;
 $password=*;
 $dbname=*;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
  {
      $error=mysqli_error($cxn);
      echo $error;
      die();
  }
 else
  {
      echo Connection established successfully;
  }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
  {
      $minute=00;
  }
 elseif ($minute=15  $minute=29)
  {
      $minute=15;
  }
 elseif ($minute=30  $minute=44)
  {
      $minute=30;
  }
 else
  {
      $minute=45;
  }
 $times=10:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
  buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='Monday' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
  {
      $error=mysqli_error($cxn);
      echo $error;
      die();
  }
 else
  {
      echo br;
      echo Query sent successfully;
  }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
      thBuilding/th\n
      thParking Lot/th\n
      thEstimated Number of Empty Spaces/th\n
      thDistance (Feet)/th\n
      thEstimated walking time to the building/th\n
  /tr\n;
 while ($row=mysqli_fetch_array($data))
  {
      extract($row);
 $building = $row[0];
    $parking_lot = $row[1];
    $Number_of_Empty_Spaces = $row[2];
    $Distance = $row[3];
    $time_l = $row[4];
    $time_h=$row[5];
    $location=$row[6];   echo tr\n
            td$building/td\n
            td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
            td$Distance/td\n
            td$time_h - $time_l mins/td\n
 td$location/td\n
            /tr\n;
  }
  echo /table\n;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 /body
 /html
 Nathan Nobbe wrote:


 On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu
 wrote:

 The thing is, I do not have a website or a place where I am storing my
 images. I am storing the images on my local PC in folder as mentioned
 in
 my
 earlier post. I have tried using only the

 else {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 imagedestroy($img);
 }

 Which you have suggested. This is the piece of code which is returning
 all
 the binary character stuff. The code is definitely fetching the image.
 But
 it is not able to deliver to the browser in the form of an image. I am
 trying to read the image file as binary, evident from the FILE_BINARY
 command. So may be, that is causing the image to be displayed as
 binary.
 Is
 there any way we can convert the binary content to jpeg/jpg content
 again.
 This is my guess after having gone through the 

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 Nathan Nobbe wrote:


 On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu
 mailto:sashi...@vt.edu wrote:

    Hi,

    Yes, the problem was solved, but It did not work fine when I used
    the same code in my larger file. Now it makes sense.


 right, just track down where you started sending the output, and remember
 if youre going to use header() calls in your scripts, that all of them must
 come before sending any of the standard content.

    Let me just repeat what you have said just to make sure that I did
    not misread you.
    So you say that the solution to this problem is to create another
    php file with the image fetching header and just write an img tag
     img src=myimagescript.php?id=1234 / in my original php file
    (with the html tags).


 what i explained in my first response is that youre mixing 2 different
 approaches, and it was unclear what you were going for exactly.  if you want
 to have an image included in a page of html, then theres no need for the
 header() call (refer to my first response for the remaining details).  there
 are however legitimate use cases for the use of header()  the
 aforementioned image methods, i think between mine and some of the other
 posts on this thread, its explained clearly.

    This is what I have understood.
    Regarding the point you have mentioned ( If you set the content
    type using header() to image/jpeg, do not use HTML tags to
    display your image!),


 correct

    I definitely need the HTML tags, because this application works
    based on the user input. So unless there is not input through a
    html form, it wont work.


 right, then just configure your webserver such that you can first access
 the image directly via an http url, then integrate these links into your
 dynamic pages as i explained in my first response.

 Thanks a lot for all the patient replies. All the suggestions led me in a
 positive direction. Finally, instead of using the header() in my main PHP
 file (with HTML tags), I have used it in a secondary file and called it
 using  a tagimg src=imgtest.php. It is working fine. But, the image I
 need to display is also dynamic and needs a user input. So, is there any way
 in which I can transfer a particular variable (the user input) from my main
 php file (say A.php) to my secondary file containing the header () (say
 B.php)

Yes. Use the Query String of your image-producing PHP script to pass
values. If you had an image tag like this:

img src=imagescript.php?id=1234 /

Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.

HTH,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 haliphax wrote:

 On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram sashi...@vt.edu
 wrote:


 Nathan Nobbe wrote:


 On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu
 mailto:sashi...@vt.edu wrote:

   Hi,

   Yes, the problem was solved, but It did not work fine when I used
   the same code in my larger file. Now it makes sense.


 right, just track down where you started sending the output, and
 remember
 if youre going to use header() calls in your scripts, that all of them
 must
 come before sending any of the standard content.

   Let me just repeat what you have said just to make sure that I did
   not misread you.
   So you say that the solution to this problem is to create another
   php file with the image fetching header and just write an img tag
    img src=myimagescript.php?id=1234 / in my original php file
   (with the html tags).


 what i explained in my first response is that youre mixing 2 different
 approaches, and it was unclear what you were going for exactly.  if you
 want
 to have an image included in a page of html, then theres no need for the
 header() call (refer to my first response for the remaining details).
  there
 are however legitimate use cases for the use of header()  the
 aforementioned image methods, i think between mine and some of the other
 posts on this thread, its explained clearly.

   This is what I have understood.
   Regarding the point you have mentioned ( If you set the content
   type using header() to image/jpeg, do not use HTML tags to
   display your image!),


 correct

   I definitely need the HTML tags, because this application works
   based on the user input. So unless there is not input through a
   html form, it wont work.


 right, then just configure your webserver such that you can first access
 the image directly via an http url, then integrate these links into your
 dynamic pages as i explained in my first response.


 Thanks a lot for all the patient replies. All the suggestions led me in a
 positive direction. Finally, instead of using the header() in my main PHP
 file (with HTML tags), I have used it in a secondary file and called it
 using  a tagimg src=imgtest.php. It is working fine. But, the image I
 need to display is also dynamic and needs a user input. So, is there any
 way
 in which I can transfer a particular variable (the user input) from my
 main
 php file (say A.php) to my secondary file containing the header () (say
 B.php)


 Yes. Use the Query String of your image-producing PHP script to pass
 values. If you had an image tag like this:

 img src=imagescript.php?id=1234 /

 Then you could grab the value of $_GET['id'] in your PHP script and
 react accordingly.

 Thanks a lot everyone, particularly Haliphax, Nathan, Virgilio and Bob.

 I will try it and will come back to you.

You're very welcome. This page [1] may help you get started. It's a
bit dated, but the information still holds true today.

1. http://whn.vdhri.net/2005/10/how_to_use_the_query_string_in_php.html


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Hi!! I Joined the PHP Mailing List

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 12:54 PM, Picu Priya iniad...@gmail.com wrote:
 Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
 good time here.. I am already a PHP programmer, and Love to learn a lot of
 new php tricks while helping others, as best of my knowledge. :)

Hello, and welcome! Just a little FYI--the mailing list archives are
at http://marc.info/?l=php-general ... lots of useful information in
there, and you may find the solution to your problem before you even
need to ask a question!

Happy programming, and again, welcome to the list.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 1:26 PM, Jason Norwood-Young
ja...@freespeechpub.co.za wrote:
 haliphax wrote:

 Perhaps I should have phrased it a bit more concise: This has been
 discussed many times--often, and RECENTLY. Anyway, since I'm already
 writing this, I'll say that overhead/bloat vs. productivity of the
 developer is a trade-off you're going to have to make for ANY of the
 frameworks out there.


 I disagree somewhat. A good framework should actually reduce bloat. It
 encourages you to implement proper MVC architecture, helps you avoid those
 rambling function.php files, and if it's well built, things like DB
 connectivity should already be optimised. I like CI because it does all of
 that fairly well, and tends to perform faster than something some coder
 (like myself) hacked together in the smallest time-frame possible. I use it
 on some pretty big sites - one with DB's with 10's of millions of records,
 and one site with over 1.5 million users a month. Personal thumbs up for CI,
 but use whatever suits your skill level, timeframe and requirements. Some
 frameworks will increase bloat, but sometimes that's worth it to get the
 project out the door in a given timeframe. If you're doing a blog on caring
 for chickens, throw it up in an hour with WordPress. If you're planning on
 being the next NY Times, WordPress will not be a kind mistress.

 There are down sides to CI too, but it suits my needs for the types of sites
 I produce.

Framework = Overhead (when compared to vanilla PHP). Period. I'm not
saying it's overhead that will cripple your application, or that
frameworks should be avoided... quite the contrary, in fact. I have
recently fallen in love with CodeIgniter myself--I'm just saying that
one should be at least respectfully aware of the overhead that comes
hand-in-hand with a(ny) framework, and weigh those against what you
feel is acceptable for your purpose.


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 2:50 PM, Nathan Rixham nrix...@gmail.com wrote:
 haliphax wrote:

 Framework = Overhead (when compared to vanilla PHP). Period. I'm not

 by vanilla do you mean vanilla from lussimo? [http://getvanilla.com/] ?

You know damn well I didn't. :)


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:04 PM, Daniel Brown danbr...@php.net wrote:
 On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote:

 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?

    You're not imagining things.  In general, unless set up with
 SuExec privileges, Apache (which is probably the HTTP server you're
 using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.'  If you
 can't configure it to SuExec (check Google for some ideas on this
 you'll need root access), you could use the less-secure (this, not
 recommended) options of changing the file mode permissions to 0777 or
 change the file ownership (if you have the right permissions yourself)
 to be owned by the same user and/or group as which Apache runs.

    It may sound a little confusing at first glance, but it's really
 not.  Just keep in mind that UNIX and Linux (Mac and similar OS'es
 fall in here, too) are simultaneous multi-user systems, meaning that
 many users (including virtual users that the system uses as aliases
 for individualized permissions) can be logged in and run processes
 concurrently.

OP is a Windows user. I am assuming that they are using Windows.

George, if you are using IIS as your web server, PHP will be executed
(by default, anyway) under the IUSR_your computer name user account
(pre-Vista). The directories and files your PHP script will need to
mess with should be given the appropriate permissions as related to
that user.

HTH,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:28 PM, Daniel Brown paras...@gmail.com wrote:
 On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote:

    Re-read the context of that first paragraph from the OP and you'll
 see why I presume (as opposed to *ass*ume) that, despite his
 experience with Windows, this is a *NIX-like setup.

    DISCLAIMER: This was supposed to be added to my seemingly-gruff
 response: ;-P  Todd's alright by me.

    George, a cron - if run as the same user that owns the files -
 should work with no problem.

No worries, Daniel... though I appreciate the gesture. :) What I meant
in my message was that I couldn't tell if he was talking POSIX or Win,
but I would offer my Windows information on the off-chance that he was
referring to Windows... so I suppose I'm guilty of being obscure.

Too many meetings today. Brain is turning to pudding.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:36 PM, George Larson george.g.lar...@gmail.com wrote:
 That's funny!

 I've been watching this and a few other lists (MySQL, local Linux Users'
 Group) for a few days - weeks and I had wondered why the PHP list seemed
 more hostile.  :)

In a word, I think familiarity sums it up.

That, or ***holes.

:-D


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:55 PM, Nathan Rixham nrix...@gmail.com wrote:
 Daniel Brown wrote:

 On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote:

 That, or ***holes.

    That's what my name tag says.

 you got shot in the nametag 3 times? i dunno if that's good or bad luck!

Yep. Now nobody can tell it used to say ear holes anymore! :(


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Website on a USB key?

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 3:24 AM, Robert Cummings rob...@interjinn.com wrote:
 On Fri, 2009-03-06 at 01:40 -0500, Paul M Foster wrote:
 On Fri, Mar 06, 2009 at 04:24:24PM +1100, Clancy wrote:

  I bought some appliance recently, and found that they had thrown in a 2G
  USB key for good
  luck.  I guess I ought to be able to put a PHP server plus a copy of my
  website on it for
  demonstration purposes, but has anyone actually tried it, and if so are
  there any traps to
  avoid?

 Maybe I'm dense or I don't understand your question. It sounds like you
 want to run lighttpd or apache on this USB device in order to serve up
 your website. If so, then the device would have to be assigned a
 separate IP address from the machine it's mounted on. Someone would have
 to be able to surf to that IP at least, much less have the IP address
 translated into a name. Otherwise, there's no way a web server can serve
 up a website; it has to have an IP address. I don't know how you'd
 possibly do that. Even then, you'd have to mount the device and then
 issue a separate call to the USB-hosted web server to start, and then
 serve your site up.

 127.0.0.1 and name localhost should suffice. You might want to use a
 non-standard port so that it doesn't conflict with anything else the
 machine is running.


I've been running XAMPP and even Eclipse from my USB key for well over
a year now. It works like a charm. Fantastic for demonstrations, or if
you've got a pet project that you need to test and carry with you.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: if elseif elseif elseif....

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 6, 2009 at 09:15, Robert Cummings rob...@interjinn.com wrote:

 I remember the internals debate about 2 or 3 years ago. I was on the pro
 goto side... it does have uses when used properly.

    I wholeheartedly concur.  The first programming language I taught
 myself was BASIC about 23 years ago.  We may never see the inclusion
 of GOSUB in PHP, but GOTO is certainly worthwhile.


    Side note: I wrote a BASIC interpreter in PHP about two weeks ago.
  Talk about fond memories.

QuickBasic (actually QBasic, and then later QuickBasic when my mom
shelled out the money for me to buy it) was my first language. I
remember being completely flabbergasted when I found out they packaged
an interpreter with DOS, and it had been under my nose the whole time.
I think my first finished program was a DD character generator.
Basically, just colored and formatted text with the output of 6 or so
random number generations.

Meemorees... :D


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: if elseif elseif elseif....

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings rob...@interjinn.com wrote:
 On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote:
 On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown danbr...@php.net wrote:
  On Fri, Mar 6, 2009 at 09:15, Robert Cummings rob...@interjinn.com wrote:
 
  I remember the internals debate about 2 or 3 years ago. I was on the pro
  goto side... it does have uses when used properly.
 
     I wholeheartedly concur.  The first programming language I taught
  myself was BASIC about 23 years ago.  We may never see the inclusion
  of GOSUB in PHP, but GOTO is certainly worthwhile.
 
 
     Side note: I wrote a BASIC interpreter in PHP about two weeks ago.
   Talk about fond memories.

 QuickBasic (actually QBasic, and then later QuickBasic when my mom
 shelled out the money for me to buy it) was my first language. I
 remember being completely flabbergasted when I found out they packaged
 an interpreter with DOS, and it had been under my nose the whole time.
 I think my first finished program was a DD character generator.
 Basically, just colored and formatted text with the output of 6 or so
 random number generations.

 Meemorees... :D

 I did Basic on the TRS-80 and saved my programs to a big clunky audio
 tape drive... 1... 2... 3... queue Tedd with rocks :)

Oh, I'm not even trying to pretend like I'm half as old as some on
this list. I still chew my own food, thank you very much. ;)

(All in jest, of course... But some of you are pretty old. Ha!)


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: if elseif elseif elseif....

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 8:56 AM, Robert Cummings rob...@interjinn.com wrote:
 On Fri, 2009-03-06 at 08:51 -0600, haliphax wrote:
 On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings rob...@interjinn.com wrote:
  On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote:
  On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown danbr...@php.net wrote:
   On Fri, Mar 6, 2009 at 09:15, Robert Cummings rob...@interjinn.com 
   wrote:
  
   I remember the internals debate about 2 or 3 years ago. I was on the 
   pro
   goto side... it does have uses when used properly.
  
      I wholeheartedly concur.  The first programming language I taught
   myself was BASIC about 23 years ago.  We may never see the inclusion
   of GOSUB in PHP, but GOTO is certainly worthwhile.
  
  
      Side note: I wrote a BASIC interpreter in PHP about two weeks ago.
    Talk about fond memories.
 
  QuickBasic (actually QBasic, and then later QuickBasic when my mom
  shelled out the money for me to buy it) was my first language. I
  remember being completely flabbergasted when I found out they packaged
  an interpreter with DOS, and it had been under my nose the whole time.
  I think my first finished program was a DD character generator.
  Basically, just colored and formatted text with the output of 6 or so
  random number generations.
 
  Meemorees... :D
 
  I did Basic on the TRS-80 and saved my programs to a big clunky audio
  tape drive... 1... 2... 3... queue Tedd with rocks :)

 Oh, I'm not even trying to pretend like I'm half as old as some on
 this list. I still chew my own food, thank you very much. ;)

 (All in jest, of course... But some of you are pretty old. Ha!)

 I just turned 35... today... that's young by the standards of a 70 year
 old :)

Well, I may not be decrepit just yet, but I am by no means a
whippersnapper anymore. Looking at turning 27 this April. I'm sure
some of the more geriatric people in the world still consider me a
kid, but I can look at teenagers now and think, What the hell are
they doing that for?


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: if elseif elseif elseif....

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 9:08 AM, Stuart stut...@gmail.com wrote:
 2009/3/6 Robert Cummings rob...@interjinn.com

 I just turned 35... today... that's young by the standards of a 70 year
 old :)

  Happy Birthday ya wise old git.
 I started with BBC Basic, moved on to gwbasic then to C, and the rest, as
 they say, is history.
 First program I ever wrote was a game called Spider. I created person and
 spider characters (as in patching over existing letters in the standard
 character set), put them on a playing surface and the spider tried to catch
 the person as they moved around to pick up asterisks. Really simple but huge
 fun. I was hooked. Still am.

Is that sort of like Robots, where you try to rescue all the humans,
and the robots take a step towards you every time you move? That was
my first TI-BASIC program, though I wrote it admittedly just two years
ago when I should have been paying attention in Accounting II. :D


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] verify another flavor

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 10:36 AM, PJ af.gour...@videotron.ca wrote:
 I know I'm a pain the butt but I just can't help asking for help. You
 guys are so nice... ;-)
 I am trying to do some checks if there are entries in the db so I can
 then insert the right stuff. And I'm looking for ways to simplify things.
 I probably dont understand the flow of things here, but this almost
 works. :-\
 $Author = $first_nameIN . ' ' . $last_nameIN;
 echo $Author;
 $sql1 = SELECT CONCAT_WS( , first_name, last_name) as Author FROM
 author     WHERE Author LIKE '$Author';
          $result1 = mysql_query($sql1);
 this would be instead of
 $sql1 = SELECT first_name, last_name) FROM author WHERE (first_name
 LIKE 'first_nameIN'  last_nameIN LIKE 'last_nameIN')

Personally, I would avoid using the CONCAT_WS() MySQL function in your
query, since you're just checking for existence rather than inserting
records (for efficiency and scalability's sake). Also--why are you
using LIKE if you're checking for a particular first and last name?
Why not just use the equality operator (=)? And... be careful
alternating quote styles in your SQL statements. The double-quotes (
) following CONCAT_WS( will end your string.

Also... I may be wholly wrong on this one, but I'm not sure MySQL uses
C-style syntax for comparisons (, ||, !=) but rather BASIC-style
syntax (AND, OR, NOT/). Again, I'm not sure about this. Maybe that
part works just fine.

I would go about it like this:

$sql1 = select concat_ws(' ', first_name, last_name) as Author_Name
from author where first_name = '$first_nameIN' and last_name =
'$last_nameIN';

You still get your pretty output (concatenated first and last name),
but you're checking the indexed columns individually rather than
combining them first, like you did in your second statement. However,
in your second statement, you did not prefix your PHP variable names
with $, so you were literally checking against the strings
'first_nameIN' and 'last_nameIN'.

Hope this helps,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Syntax checker? Character replacing

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 2:05 PM, Terion Miller webdev.ter...@gmail.com wrote:
 I have this and think maybe something is off, because if there is an amp ()
 in the location then it only displays a comma , and nothing else:

 if (isset($_SERVER['QUERY_STRING'])) {$Page .= ($_SERVER['QUERY_STRING']?
 '?'. str_replace(,amp;,$_SERVER['QUERY_STRING']) : '');}


 is that wrong?

It looks alright to me, but I don't see the need for the in-line
conditional statement since you've already run isset() on
$_SERVER['QUERY_STRING']. Simplify your code:

if(isset($_SERVER['QUERY_STRING']))
$Page .= str_replace('', 'amp;', $_SERVER['QUERY_STRING']);

Does that do the trick?


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] insert array values

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 3:00 PM, PJ af.gour...@videotron.ca wrote:
 I've been racking my little peanut-brain as well as big Google with
 little hope...
 I can retrieve the array from the multiple select dropdown box but I
 can't quite manage to insert the data which is just id numbers for a table.
 I've tried some while stuff but doesn't work. I know I don't have the
 right syntax on anything at this point. Here's an effort that doesn' work.
 Dont know if I should be using $categoriesIN[] type of stuff...
 but my tries were from web illustrations...
 the outcommented line returns the values of the array... but how to pass
 them to the query?

 foreach ($categoriesIN as $category) {
    //$categorybr;
 $sql = INSERT INTO book_categories ( book_id, category )
    VALUES( book.id WHERE title = $titleIN, $category );
        $result = mysql_query($query, $db);;
    }

Phil, you don't want to use an INSERT if you're just updating an
existing row. You can't do an INSERT and use the current row's values
(book.id/book_id/whatever) in your insert, since there IS no current
row. I'm assuming what you're trying to do is add a record to an
associative table that links Categories to Books, but only if that
Book title matches your $title string.

Try this:

foreach($categoriesIN as $category)
$sql = update book_categories set category = '$category' where
book_id in (select id from book where title = '$titleIN');

If that's not what you're going for, and you just wanted to update
something's category, try this:

foreach($categoriesIN as $category)
$sql = update book_categories set category = '$category' where
book_id = '$somevalue';

Perhaps it would help us help you if you would explain what it is
you're trying to accomplish with this query?


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexplained Issue Using Regex

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 3:44 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 I'm not looking for other ideas, the main thing here is that I have about
 30-100 regex's in the database and the script fetches them and applies them
 to the string. I can't build again the engine and I'm not going to do that.
 I'm trying to solve my problem ;) If you have any ideas regarding my issue
 and not going in another way this would be very appreciated.

Nitsan,

I think it's because you're referencing the capture group with index
instead of index 2. Also, I don't understand why you have the pipe
(|) character in your regex string... is that part of your engine?

This code:

$orig = 'http://www.zshare.net/video/541070871c7a8d9c';
$matches = array();
preg_match('#http://(www\.)zshare\.net/video/([^/]+)#', $orig, $matches);
echo $matches[2];

Grabs the correct match:

541070871c7a8d9c

The regex pattern works with the pipe char, but it is unnecessary and
may lead to some strange behavior.

Hope this helps,


--
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexplained Issue Using Regex

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 3:53 PM, haliphax halip...@gmail.com wrote:
 On Fri, Mar 6, 2009 at 3:44 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 I'm not looking for other ideas, the main thing here is that I have about
 30-100 regex's in the database and the script fetches them and applies them
 to the string. I can't build again the engine and I'm not going to do that.
 I'm trying to solve my problem ;) If you have any ideas regarding my issue
 and not going in another way this would be very appreciated.

 Nitsan,

 I think it's because you're referencing the capture group with index
 instead of index 2. Also, I don't understand why you have the pipe
 (|) character in your regex string... is that part of your engine?

*cough*... I meant to say index 3 instead of index 2.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexplained Issue Using Regex

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 4:01 PM, Nitsan Bin-Nun nit...@binnun.co.il wrote:
 On Fri, Mar 6, 2009 at 11:53 PM, haliphax halip...@gmail.com wrote:

 On Fri, Mar 6, 2009 at 3:44 PM, Nitsan Bin-Nun nit...@binnun.co.il
 wrote:
  I'm not looking for other ideas, the main thing here is that I have
  about
  30-100 regex's in the database and the script fetches them and applies
  them
  to the string. I can't build again the engine and I'm not going to do
  that.
  I'm trying to solve my problem ;) If you have any ideas regarding my
  issue
  and not going in another way this would be very appreciated.

 Nitsan,

 I think it's because you're referencing the capture group with index
 instead of index 2. Also, I don't understand why you have the pipe
 (|) character in your regex string... is that part of your engine?

 This code:

 $orig = 'http://www.zshare.net/video/541070871c7a8d9c';
 $matches = array();
 preg_match('#http://(www\.)zshare\.net/video/([^/]+)#', $orig, $matches);
 echo $matches[2];

 Grabs the correct match:

 541070871c7a8d9c

 The regex pattern works with the pipe char, but it is unnecessary and
 may lead to some strange behavior.

 Thank you Todd, I also want to capture when I don't have the www in the
 beginning of the URL.
 For instance, try to execute your code with
 $orig = 'http://zshare.net/video/541070871c7a8d9c';

 That's why I used (www\.|), but I'm not a regex expert and I'm sure there a
 way better solutions to this problem.

http://www.regular-expressions.info is your best friend. Spend an
afternoon playing around on it... that's really the only advantage I
have over someone who hasn't.

Anyway, you can make that entire group optional with the ? character like so:

#http://(www\.)?zshare\.net/video/([^/]+)#

And if you don't want it to be captured, making the URL suffix index 1
instead of index 2, do this:

#http://(?:www\.)?zshare\.net/video/([^/]+)#

Any group that begins with ?: will not be captured in a match index. To recap:

$pattern = '#http://(?:www\.)?zshare\.net/video/([^/]+)#';
$orig = 'http://zshare.net/video/541070871c7a8d9c';
$matches = array();
preg_match($pattern, $orig, $matches);
echo $matches[1] . \n;
$orig = 'http://www.zshare.net/video/541070871c7a8d9c';
preg_match($pattern, $orig, $matches);
echo $matches[1] . \n;

Produces this output:

541070871c7a8d9c
541070871c7a8d9c

Hope this helps,


-- 
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] insert array values

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 4:07 PM, PJ af.gour...@videotron.ca wrote:
 haliphax wrote:
 On Fri, Mar 6, 2009 at 3:00 PM, PJ af.gour...@videotron.ca wrote:
 I've been racking my little peanut-brain as well as big Google with
 little hope...
 I can retrieve the array from the multiple select dropdown box but I
 can't quite manage to insert the data which is just id numbers for a
 table.
 I've tried some while stuff but doesn't work. I know I don't have the
 right syntax on anything at this point. Here's an effort that doesn'
 work.
 Dont know if I should be using $categoriesIN[] type of stuff...
 but my tries were from web illustrations...
 the outcommented line returns the values of the array... but how to pass
 them to the query?

 foreach ($categoriesIN as $category) {
 Â  Â //$categorybr;
 $sql = INSERT INTO book_categories ( book_id, category )
 Â  Â VALUES( book.id WHERE title = $titleIN, $category );
 Â  Â  Â  Â $result = mysql_query($query, $db);;
 Â  Â }

 Phil, you don't want to use an INSERT if you're just updating an
 existing row. You can't do an INSERT and use the current row's values
 (book.id/book_id/whatever) in your insert, since there IS no current
 row. I'm assuming what you're trying to do is add a record to an
 associative table that links Categories to Books, but only if that
 Book title matches your $title string.

 Try this:

 foreach($categoriesIN as $category)
 $sql = update book_categories set category = '$category' where
 book_id in (select id from book where title = '$titleIN');

 If that's not what you're going for, and you just wanted to update
 something's category, try this:

 foreach($categoriesIN as $category)
 $sql = update book_categories set category = '$category' where
 book_id = '$somevalue';

 Perhaps it would help us help you if you would explain what it is
 you're trying to accomplish with this query?
 Hmmm, maybe I'm chasing my own tail...
 following the trail of execution is tough... :'(
 I'm trying to enter a new book into the database and that means I have
 to enter the info for the relational tables as well.
 I think I stumbled here a bit as what I need is the id that is inserted
 in the db before inserting this category stuff.
 As I look at the code, it looks like i have to find the
 last-entered-id for the book that is being entered.

Well, there are two ways you can do that with PHP/MySQL. First, you
can do it on the DB server. Second, you can do it in PHP after your
insert query has been performed.

MySQL:
SELECT LAST_INSERT_ID();

PHP:
mysql_query(insert into tablename(foo, bar) values('foo', 'bar');, $db);
echo mysql_insert_id();

If you're just trying to tie a book to existing categories, I would
insert the book and then separately insert the records in the
associative table (book_categories).

Pseudocode:
insert book into book table
grab last inserted id with mysql_insert_id()
for each category book is a part of
{
  insert book (via last inserted id) and category IDs into book_categories
}

If you're trying to insert a book and a category and then link them
together, I would do this:

Pseudocode:
insert book into book table
grab last inserted book id with mysql_insert_id()
insert category into category table
grab last inserted category id with mysql_insert_id()
insert last book and last category IDs into book_categories

Hope this helps,


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Testing gmail submission

2009-03-05 Thread haliphax
Got tired of using Microsoft Outlook to sort the PHP list discussions...
apparently a lot of people use GMail for this, so I figured I would hook it
into my GMail account and see what happens.


// Todd


Re: [PHP] Testing gmail submission

2009-03-05 Thread haliphax
On Thu, Mar 5, 2009 at 8:56 AM, Daniel Brown danbr...@php.net wrote:

 On Thu, Mar 5, 2009 at 09:20, haliphax halip...@gmail.com wrote:
  Got tired of using Microsoft Outlook to sort the PHP list discussions...
  apparently a lot of people use GMail for this, so I figured I would hook it
  into my GMail account and see what happens.

    Boyd?

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

Indeed, it is I! Now, if I can only figure out how to keep GMail from
mangling quotes... ah, there's the Plain Text button! :)

--
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Testing gmail submission

2009-03-05 Thread haliphax
On Thu, Mar 5, 2009 at 9:22 AM, Daniel Brown danbr...@php.net wrote:
 On Thu, Mar 5, 2009 at 10:05, haliphax halip...@gmail.com wrote:

 Indeed, it is I! Now, if I can only figure out how to keep GMail from
 mangling quotes... ah, there's the Plain Text button! :)

Yeah, and if only we could get a GreaseMonkey script to stop
 top-posting by default.  Not to suggest that you did, of course,
 because you didn't but it's a pain in the ass to have to take the
 extra couple of seconds to set up the message at the bottom.

Like George Jetson always complained: Another hard day at the
 office pushing the button.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1


I've started playing with GreaseMonkey quite a bit lately (making mods
[1] for Urban Dead [2], a web-based zombie apocalypse MMORPG that
helps cure my boredom)... I'm sure GMail's interface is probably built
on-the-fly with some ridiculously obfuscated/minimized Javascript, but
it may be worth tinkering with if I get some spare time after finals;
because you're right--it bugs the hell out of me, too.

(It also seems to be adding two lines of blank space at the end of my
signature. Rrrgh.)

Links:
1. http://sites.google.com/sites/udscripts
2. http://www.urbandead.com


--
// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP script lag (5 secs) when declaring mime type.

2009-03-05 Thread haliphax
On Thu, Mar 5, 2009 at 10:27 AM, Jsbeginner jsbegin...@monarobase.net wrote:
 Hello, Just to say that I've got a bit further in my search :

 ?php
 header('Content-Type: application/x-javascript');
 //header('Content-Length: '.filesize('test.js'));
 readfile('test.js');
 ?

 (Content-Length line removed) Has no lag...

 My guess is there is a problem with gzip or something that corrupts the
 content-length.

 So I'm still not sure if this is a PHP problem or an apache problem but any
 help would be great :)

 Thankyou


 Jsbeginner a écrit :

 Hello,

 I don't know for sure is this problem is only related to PHP so I hope
 I've posted in the right list.

 My problem is that with certain headers my script takes about 5 seconds
 before sending the page, no matter how small the file I try to load...
 My server :
 Centos
 Apache 2.2
 PHP 5.2.9

 Here's my code :

 ?php
 header('Content-Type: application/x-javascript');
 header('Content-Length: '.filesize('test.js'));
 readfile('test.js');
 ?

 test.js is only a few lines long, and if I remove the header content type
 the file loads instantaniously do it's not a problem with readfile.
 I thought about zlib gzip taking maybe a long time to load but I've
 changed the compression level from 6 to 1 and the file still has a the same
 lag.

 My server responds very fast for eveything else except this script. Do you
 have an idea what might be causing this lag ?

 Thanks in advance :)

Well, have you tried using Content-Type: text/javascript as
suggested? Is application/x-javascript absolutely necessary for
whatever application is reading your script's output? As it has
already been mentioned, Apache may be looking for your content type in
some sort of lookup table, not finding it, and taking its sweet time
returning control back to PHP while it grabs at straws to match.


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem with mysql_real_escape_string

2009-03-05 Thread haliphax
On Thu, Mar 5, 2009 at 10:52 AM, Eric Butera eric.but...@gmail.com wrote:
 On Thu, Mar 5, 2009 at 11:16 AM, Nigel Green ni...@greenlemur.com wrote:
 Hi all,

 This is my first post to the list. Have been observing for a few weeks and
 have learnt a lot.

 I am having an issue in one of my scripts where using the
 mysql_real_escape_string function is stripping content out of my input data.
 All is working well on my local installation, but when the files are
 transferred over to the live site I am getting problems.

 The sample code I am using to test this is as follows:

 if(isset($this-mysql)) {
    $query = update pages set;
    $query .=  `title` = ' . mysql_real_escape_string ($title) . ',;
    $query .=  `text` = ' . mysql_real_escape_string ($text) . ',;
    $query .=  where id = \$id\;
 }
 echo $query;

 The $title, $text and $id values are passed in as parameters when I call the
 method that runs the update, and if I echo them out at the top of the method
 they are all present and correct.

 The $mysql class variable is populated with a connection handle when I
 instantiate an instance of the class, and the code is finding the connection
 as it is building the query. On my local machine the query is built using
 the escaped values from the $_POST array, but on the live site the escaped
 values for $title and $text are blank.

 Any ideas on where to look for config differences? The main thing I've found
 so far is that this may happen if no connection is present, but it is. Doing
 a var_dump of the connection handle shows that it is the correct handle as
 well.

 Any thoughts?

 Many thanks in advance for any help.

 Nigel


 Make sure to always pass your active database connection into the
 second parameter of mysql_real_escape_string.  There could be
 character set differences between your two servers too that might be
 causing issues for you.  If at all possible I would recommend
 upgrading to mysqli or pdo and use prepared statements.

mysqli may not be available to him (PHP4, etc.) and I don't see why he
should completely switch his procedure if his code will work with the
addition of the db handle in the function call... but that's my 2c. I
agree that at some level, it is more beneficial to change all of the
code you have to use a new method/construct/whatever, but it may not
be worth it in his case.


// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   >