Re: [PHP] If date is greater than

2013-10-20 Thread Ashley Sheridan
On Sun, 2013-10-20 at 00:00 -0400, Bastien wrote:

 
 Thanks,
 
 Bastien
 
  On Oct 19, 2013, at 10:44 PM, John Taylor-Johnston 
  jt.johns...@usherbrooke.ca wrote:
  
  I have date strings in my mysql db. -mm-dd.
  I want to parse to see if the date is greater than november 2011 and less 
  than december 2012.
  
  Is this the right approach? How bad is my syntax?
  
  |function dates_range($todaynow)
  { |
  |$date1=strtotime(2011-11-01);
  $date2=strtotime(2012-12-31);
if (|||($|todaynow |= $date1) and |($|||todaynow| = 
  $date2)||)
  ||   {
  ||   # do something
     }
  }
  |||
 
 Easiest to convert to integers and then compare


Yes, I was going to ask, why are you storing your dates as strings?
MySQL has a perfectly good DATE type. It's also generally faster
comparing dates within a MySQL query than PHP code.

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




Re: [PHP] date time problem

2013-10-06 Thread Ashley Sheridan
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:

 Jim,
 
 The date method takes in a timestamp (not seconds away).
 
 You have the seconds, you will need to manually convert those seconds to
 what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
 
 Aziz
 
 
 On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote:
 
  Its so freaky
 
  Best Regards
  Farzan Dalaee
 
   On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote:
  
   On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
   Try this please
  
gmdate(H:i:s, $diff%86400)
  
   Best Regards
   Farzan Dalaee
  
   On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com
  wrote:
  
   On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
   You should use  gmdate() if you want to how many hours left to expire
   $time_left = gmdate(H:i:s,$diff);
  
   Best Regards
   Farzan Dalaee
  
   On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com
  wrote:
  
   I always hate dealing with date/time stuff in php - never get it
  even close until an hour or two goes by
  
   anyway
  
   I have this:
  
   // get two timestamp values
   $exp_time = $_COOKIE[$applid.expire];
   $curr_time = time();
   // get the difference
   $diff = $exp_time - $curr_time;
   // produce a display time of the diff
   $time_left = date(h:i:s,$diff);
  
   Currently the results are:
   exp_time is 06:55:07
   curr_time is 06:12:03
   the diff is 2584
   All of these are correct.
  
   BUT time_left is 07:43:04 when it should be only 00:43:04.
  
   So - where is the hour value of '07' coming from?? And how do I get
  this right?
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
   Thanks for the quick response, but why do I want to show the time in
  GMT?  However, I did try it, changing the 'time_left' calc to use gmdate.
   Now instead of a 7 for hours I have a 12.
  
   exp 07:34:52
   curr 06:40:14
   diff 3158
   left is 12:52:38
  
   The 52:38 is the correct value, but not the 12.
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
   Doesn't work either.
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 


Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

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




Re: [PHP] Algorithm Help

2013-10-01 Thread Ashley Sheridan
On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote:

 DB or flatfile?
 
 I would create a matrix of all kids crossed with every kid. Everytime a kid
 is put in a home with another kid, ++ that index. When dispatching kids,
 sort by index ASC.
 
 Aziz
 
 
 On Tue, Oct 1, 2013 at 3:01 PM, John Meyer 
 johnme...@pueblocomputing.comwrote:
 
  On 10/1/2013 12:51 PM, Floyd Resler wrote:
 
  Here's my task: A group of kids is going to be staying with different
  host families throughout the next 8 months.  The number of kids staying
  with a host family can range from 2 to 10.  When deciding which kids should
  stay together at a host family, the idea is for the system to put together
  kids who have stayed with each other the least on past weekends.  So, if a
  host family can keep 5 kids, then the group of 5 kids who have stayed
  together the least will be chosen.
 
  I can't think of an easy, quick way to accomplish this.  I've tried
  various approaches that have resulted in a lot of coding and being very
  slow.  My idea was to give each group of kids a score and the lowest score
  is the group that is selected.  However, this approach wound of iterating
  through several arrays several times which was really slow.  Does anyone
  have any ideas on this puzzle?
 
  Thanks!
  Floyd
 
 
   Whatever solution you're going with will probably involve a relational
  database of some sort.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


This sounds remarkably like homework, which we can't help you with
unless you've got a specific problem that you're stuck with.

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




Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Ashley Sheridan
On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote:

 Hi All,
 
  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
 
  Here's how they describe the process in the docs:
 
 $result = $client-deleteBucket(array(
 // Bucket is required
 'Bucket' = 'string',
 ));
 
  You can find the full entry here:
 
 AWS PHP SDK Delete Bucket
 Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket
 
 Here's how I approached it in my code:
 
  $s3 = new AmazonS3();
 
   $result = $s3-deleteObject(array(
 'Bucket' = $bucket_name ));
 
 But when I run it, this is the error I get:
 
 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
 on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
 /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
 variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
 Warning: preg_match() expects parameter 2 to be string, array given in
 /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
 expects parameter 2 to be string, array given in
 /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
 exception 'S3_Exception' with message 'S3 does not support Array as a
 valid bucket name. Review Bucket Restrictions and Limitations in the S3
 Developer Guide for more information.' in
 /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array,
 Array) #1 [internal function]: AmazonS3-delete_object(Array) #2
 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject',
 Array) #4 /var/www/awssdk/delete_bucket.php(10):
 AmazonS3-deleteObject(Array) #5 {main} thrown in
 /var/www/awssdk/services/s3.class.php on line 548'
 
 
 This is line 548 in the above referenced file:
 
 // Validate the S3 bucket name
 if (!$this-validate_bucketname_support($bucket))
 {
 // @codeCoverageIgnoreStart
 throw new S3_Exception('S3 does not support ' .
 $bucket . ' as a valid bucket name. Review Bucket Restrictions and
 Limitations in the S3 Developer Guide for more information.');
 // @codeCoverageIgnoreEnd
 }
 
 
 
 
 Has anyone played around enough with the AWS SDK to know what I'm doing
 wrong here? Would anyone else be able to hazard a guess?
 
 Thanks
 Tim


Your code is failing because $bucket_name, I suspect, is null. Where do
you define this variable before you use it in this bit of code:

$result = $s3-deleteObject(array(
'Bucket' = $bucket_name ));

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




Re: [PHP] Apache

2013-09-24 Thread Ashley Sheridan


Domain nikha.org m...@nikha.org wrote:
Ashley Sheridan am Montag, 23. September 2013 - 21:35:

 No, no, no! That is not a good stand-in for fundamental security
 principles!
 
 This is a better method for ensuring an image is really an image:
 
 ?php
 if(isset($_FILES['file']))
 {
  list($width, $height) = getimagesize($_FILES['file']['tmp_name']);
  if($width  $height)
  {
  $source = imagecreatefromjpeg($_FILES['file']['tmp_name']);
  $dest = imagecreatetruecolor($width, $height);
  
  imagecopyresampled($dest, $source,
  0, 0, 0, 0,
  $width, $height, $width, $height);
  imagejpeg($dest, basename($_FILES['file']['tmp_name']));
  }
  else
  echo {$_FILES['file']['name']} is not a jpeg;
 }
 ?
 form enctype=multipart/form-data method=post
  input type=file name=file/
  input type=submit name=submit value=submit/
 /form
 
 Obviously it's only rough, and checks only for jpeg images, but
that's
 easy to alter. I've just tested this with a regular jpeg, the same
jpeg
 with PHP code concatenated onto the end (which still appears to be a
 valid image to viewing/editing software) and a pure PHP file with a
.jpg
 extension. In the case of the first 2, a new jpeg is generated with
the
 same image and without the code. The third example just echoes out an
 error.
 

Dear Ashley, nice, but useless for this problem!


The problem was to do with an image upload, so no, not useless. 

First, because users may upload other things than images! PDF's, audio
files, videos etc!

In an earlier email I detailed some methods for validating other types, such as 
DomDocument for HTML, XML, svg, etc, or fpdf for PDF. 

And on behalf images: GD you are using handles only
jpeg, gif and png. There are about hunderd other image types on the
way,

At the moment those are the 3 raster formats you can use on the web, so those 
are the ones that pose an issue. If you're using anything else, it's not for 
web and doesn't need to be in a publicly accessible location. 

users can upload! How to detect them, if the extension is missleading?

The extension comes from the user. Never trust the user, ever.


And even if we succeed: As your script demonstrates very well,
malicious
code does not affect the rendering of the image. 

My script does effectively strip out malicious code though, even if it can't 
easily be seen.

The hacker says: Hi,
this is a nice picture, play it, and then, please do this--follows his
code, that can be a desaster for the whole system.

Social engineering is a whole different issue.


Yes, your script seems to purge the image file, simply because GD does
not copy the malware code. But why are you sure about that? You cannot
see that code, OK, but may be it was executed in the plain GD
environement? 

GD isn't a PHP parser, and PHP doesn't execute the image before GD touches it. 
Infact, Apache isn't even involved between GD and the image at that point, so 
it won't suffer from this bad config.

What you are doing is dangerous, because you force the
execution of things that should be never executed!

Erm, no, the image isn't being executed.


no no no forget it. After all we cannot exclude that users come in
with malware. 

If you think it's fine that a user be able to upload malware, then you're going 
to have a very bad time.

But we MUST exclude, it is executed on the web server.

This is important too, but in this profession belt and braces is best I 
believe. 

That is the Apache chainsaw massacre as Steward whould say. And
probably
it can be avoided by purging the filenames (not the files!). 

Nevertheless, the standard configuration of the Apache servers is
basically unacceptable. It must execute user requests and never ever
user files! Period.

Have nice days,
Niklaus 

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

Thanks,
Ash

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



Re: [PHP] Apache

2013-09-24 Thread Ashley Sheridan


Domain nikha.org m...@nikha.org wrote:
Ashley Sheridan am Dienstag, 24. September 2013 - 18:22:

 In an earlier email I detailed some methods for validating other
types, such
as DomDocument for HTML, XML, svg, etc, or fpdf for PDF. 
 
Fine, gratulations!

 And on behalf images: GD you are using handles only
 jpeg, gif and png. There are about hunderd other image types on the
 way,
 
 At the moment those are the 3 raster formats you can use on the web,
so those
are the ones that pose an issue. If you're using anything else, it's
not for web
and doesn't need to be in a publicly accessible location. 
 
Why that???!!! Why should users only upload files, that are used for
web, and
what does this mean, for web? Users may store personal files on your
host,
because they use your website as a cloud, as it is said today. Not
for web,

Ok, imagine this scenario. A user uploads a .tif. this isn't a web format, so 
we treat it as a binary file, uploading to a non web accessible area of the 
site. Tell me again where the exploit is please.

but for personal use on everey computer connected to the internet! That
is
absolutly legitime and the ONLY reason to offer file uploading I can
imagine! I
allow it only for authenticated, subscribed users. 

Nevertheless those trusted users may upload (unintenionally!) infected
files.
And again: No virus was ever written for web,

Not exactly true, but beyond the scope of this discussion I think 

 but to harm
computersystems,
clients and servers. They are just distributed via web.
 
Whould be great we could block them, and I appreciate your efforts to
do this.
But sorry, your script shows me, that this cannot be done this way!

Tell me how you would get a jpg past that example and I'll look into it, as I 
explained that was an example not a full solution. We don't tend to just write 
full code for people here.

Perhaps, if
you are right and GD processing really is harmless (I'm in doubt),

Evidence? Either give some or stop saying GD isn't secure. The PHP community 
needs less hyperbole and more facts.

 we
have a
clean jpeg (or gif or png). And then? What's about the rest?

Keep in mind, that PHP is a scripting framework to create websites,
certainly
not a tool for virus detection! And we have a big problem with the
Apache web
server, not because Apache serves possibly infected files, but because
all kind
of files are NOT served, but passed to the script interpreter! 

that's a bad Apache setup, which I'm not saying isn't a problem, but your 
original solution doesn't even cover validation. 

That's
awfull
enough, and opens a new exploit!

 
 The hacker says: Hi,
 this is a nice picture, play it, and then, please do this--follows
his
 code, that can be a desaster for the whole system.
 
 Social engineering is a whole different issue.
 
yes, what I tried to describe is criminal.
Niklaus

Thanks,
Ash

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



Re: [PHP] Apache

2013-09-23 Thread Ashley Sheridan
On Mon, 2013-09-23 at 20:36 +0200, Domain nikha.org wrote:

 Stuart Dallas am Montag, 23. September 2013 - 12:58:
 
  And, honestly, who would have a PHP file per language? I think it's
 perfectly reasonable to not allow that, because duplicating PHP code
 across many files is an incredible stupid way to support multiple
 languages.
  
 I agree!! Didn't even know, that this kind of faked language support
 exists...
 
  Some people run all their files through PHP - true, but that doesn't
 mean they should, or that you, as a responsible web host, should be
 endorsing it.
  
  PHP developers should absolutely validate all content coming in from
 users in every possible way, but I would be highly dubious about
 trusting a host who gives the reason above for what I consider a lax and
 insecure Apache configuration. It's like saying they sliced your arm off
 with their chainsaw because it's made for cutting things, attempting to
 dodge all responsibility for having swung it in your direction!
  
 OK, in principle, I also agree. But this case is very easy to handle.
 I'm simply running str_replace() against dangerous parts of uploaded
 filenames, .php for instance. After that, Apache in every
 configuration will just serve, and never execute user uploaded files.
 Remains the risk on the clients side, I must concede. Better solutions?
 
 Nice days,
 Niklaus   
 


No, no, no! That is not a good stand-in for fundamental security
principles!

This is a better method for ensuring an image is really an image:

?php
if(isset($_FILES['file']))
{
list($width, $height) = getimagesize($_FILES['file']['tmp_name']);
if($width  $height)
{
$source = imagecreatefromjpeg($_FILES['file']['tmp_name']);
$dest = imagecreatetruecolor($width, $height);

imagecopyresampled($dest, $source,
0, 0, 0, 0,
$width, $height, $width, 
$height);
imagejpeg($dest, basename($_FILES['file']['tmp_name']));
}
else
echo {$_FILES['file']['name']} is not a jpeg;
}
?
form enctype=multipart/form-data method=post
input type=file name=file/
input type=submit name=submit value=submit/
/form

Obviously it's only rough, and checks only for jpeg images, but that's
easy to alter. I've just tested this with a regular jpeg, the same jpeg
with PHP code concatenated onto the end (which still appears to be a
valid image to viewing/editing software) and a pure PHP file with a .jpg
extension. In the case of the first 2, a new jpeg is generated with the
same image and without the code. The third example just echoes out an
error.


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




Re: [PHP] jquery fill select option value

2013-09-22 Thread Ashley Sheridan


iccsi inu...@gmail.com wrote:
select id=mark name=mark
  option value=--/option
  option value=bmwBMW/option
  option value=audiAudi/option
/select

I use above code to have my select drop down on the form and would like
to 
use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example
code at 
server site is appreciated,

Your help and information is great appreciated,

Regards,

Iccsi, 

Yes it is possible but a) not at server side because JavaScript is run on the 
browser, and b) this is a PHP list not a JavaScript list.

Saying that, why aren't you populating it on the server side with PHP? 

Thanks,
Ash

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



Re: [PHP] Friday's Question

2013-09-21 Thread Ashley Sheridan
On Sat, 2013-09-21 at 11:07 +1000, Daniel wrote:

 25 network admin and programmer and yes I use a mouse pad - my mouse
 hates me if I dont use it.
 
 -- 
 Regards,
 Daniel Fenn
 


29 and don't use a mouse pad right now, although I did before I moved
because the surface of my desk was too shiny. That's the only reason I
ever use one now.

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




RE: [PHP] Apache's PHP handlers

2013-09-19 Thread Ashley Sheridan
On Thu, 2013-09-19 at 16:14 +0200, Arno Kuhl wrote:

 Arno: If you can request that file using a web browser, and it gets executed
 as PHP on your server then there is an error in the Apache configuration.
 
 Easy test: create a file in a text editor containing some PHP (?php
 phpinfo(); ? would be enough) and upload it to the www root of your site
 and name it test.pgif. Then hit http://www.yourdomain.com/test.pgif in your
 browser. If you see the PHP code or an error then you're fine. If you see
 PHP's info page then you need to change web host as quickly as possible. I
 don't care if they fix it - the fact their server was configured to do this
 by default is enough for me to never trust them again.
 
 -Stuart
 --
 
 Thanks Stuart. I just tried it now, test.php.pgif displayed the info while
 test.xyz.pgif returned the content, confirming the problem. My service
 provider finally conceded the problem is on their side and are looking for
 an urgent fix, much too complicated to consider moving service providers in
 the short term.
 
 As a side note, the sp said the issue is new and coincided with an upgrade
 to fastcgi recently, I wonder if the hacker was exploiting a known issue
 with that scenario?
 
 Cheers
 Arno
 
 


I think most importantly, validate your input!

If you're expecting an image, check to make sure it's an image. Use the
imagecopyresampled() function that's part of GD to create a duplicate of
the exact same size to ensure that it's both an image and not containing
a hidden payload (which has happened to JPEG images before)

If it's a file of another type, use a different appropriate method to
validate that. DOMDocument will deal with XML and HTML documents, you
can use zip functions to inspect Office documents (the newer types at
least), FPDF to handle PDF files, etc.

By only checking the extension you're relying on user-supplied data,
which by definition is tainted.

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




Re: [PHP] char set ?

2013-09-07 Thread Ashley Sheridan
On Sat, 2013-09-07 at 18:21 +0200, georg chambert wrote:

 This Q is possibly rather HTML (is there a good list for that...)
 
 anyways;
  Im in Sweden, and have done som pages with Swedish text, however our special 
 (weird) characters åäö
 comes out wrong when displayd in browser, would be nice if I could tag the 
 text and keep the file as is rather
 than changing the file format of the text (and encode the characters with 
 some double/prefix notation, 
 which I guess would be the main stream
 anyone ?
 
 regards
 Georg


Save PHP script as UTF8, and make sure you output UTF8 headers

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




Re: [PHP] Re: Permissions

2013-08-27 Thread Ashley Sheridan
On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:

 Ethan Rosenberg wrote:
 
  Dear List -
  
  Tried to run the program, that we have been discussing, and received a
  403 error.
  
  rosenberg:/var/www# ls -la StoreInventory.php
  -rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php
  
  rosenberg:/var# ls -ld www
  drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www
  
  I had set the S bit [probably a nasty mistake] and I thought I was able
  to remove the bit. [it doesn't show above]
  
  How do I extricate myself from the hole into which I have planted myself?
  
  TIA
  
  Ethan
 
 This is in no way a php question, as the same result will happen no matter 
 what you ask apache to serve from that directory.
 
 You have the directory permissions set to 776 not 777.
 -- 
 Cheers
 David Robley
 
 Steal this tagline and I'll tie-dye your cat!
 
 


776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What 

It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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




Re: [PHP] PHP vs JAVA

2013-08-20 Thread Ashley Sheridan


Tedd Sperling t...@sperling.com wrote:
Hi guys:

A teacher at my college made the statement that JAVA for Web
Development is more popular than PHP.

Where can I go to prove this right or wrong -- and/or -- what
references do any of you have to support your answer? (sounds like a
teacher, huh?)

Here are my two references:

http://w3techs.com/technologies/details/pl-php/all/all

http://w3techs.com/technologies/history_overview/programming_language/ms/y


But I do not know how accurate they are.

What say you?

Cheers,


tedd

___
tedd sperling
t...@sperling.com






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

Is he possibly getting confused with Javascript?

Thanks,
Ash

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Ashley Sheridan
On Tue, 2013-08-20 at 21:44 +0100, Stuart Dallas wrote:

 On 20 Aug 2013, at 21:30, Dan Munro d...@danmunro.com wrote:
 
  in my opinion, that would be like asking how big is the internet?.
  
  http://www.washingtonpost.com/blogs/the-switch/wp/2013/08/18/heres-what-you-find-when-you-scan-the-entire-internet-in-an-hour/
 
 That's scanning IP addresses and doesn't come close to answering how big is 
 the internet, assuming that means how many sites are there rather than how 
 many publicly responsive edge servers exist.
 
 -Stuart
 
 -- 
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/


I'd argue that a large proportion of really secure servers out there
won't respond to a lot of what Zmap pings out. Nmap works by throwing
out requests on a bunch of different ports, not just ping, which is
slow, so I'd be surprised if Zmap could really rival that while giving
the same results. Bearing in mind there are over 4,000 million (I won't
say billion, because that's a million million, despite what the
Americans say!) IPv4 address out there, 40 minutes is a ridiculous
amount of time to even scan half of that, especially given the fact that
IPv6 is being majorly pushed because IPv4 is apparently running out of
free address space! Then not forgetting that lots of websites exist on
the same IP address/range, I would say the article is lacking on so many
details as to be untrue.

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




Re: [PHP] Mysqli Extension

2013-08-19 Thread Ashley Sheridan


Curtis Maurand cur...@maurand.com wrote:


Ethan Rosenberg wrote:
 Dear List -
 
 My
mysqli extension seems to have gone away.
 
 $host =
'localhost';
 $user = 'root';
 $password = 'SdR3908';
 echo hello2br /;

var_dump(function_exists('mysqli_connect'));// this returns boo(false)
 $db = 'Store';
 $cxn =
mysqli_connect($host,$user,$password,$db);
 
 I tried to
reinstall -
 
 rosenberg:/home/ethan#  apt-get install
php5-common libapache2-mod-php5
 php5-cli
 Reading
package lists... Done
 Building dependency tree
 Reading
state information... Done
 libapache2-mod-php5 is already the
newest version.
 libapache2-mod-php5 set to manually
installed.
 php5-cli is already the newest version.

php5-cli set to manually installed.
 php5-common is already the
newest version.
 php5-common set to manually installed.

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


 It did not help.
 
 TIA
 

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


Found
this in ubuntu forums.

http://ubuntuforums.org/showthread.php?t=1814736


sudo apt-get install
php5-mysql
This package contains the PHP module that interfaces with the MySQL
server.

Could it be that the mysql service on the server has stopped. Typically you'd 
do something like this on RedHat/Fedora servers:

service mysqld status

That would certainly stop the extension working from within PHP.

Thanks,
Ash

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



Re: [PHP] Mysqli Extension

2013-08-19 Thread Ashley Sheridan


Matijn Woudt tijn...@gmail.com wrote:
On Mon, Aug 19, 2013 at 8:55 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:



 Curtis Maurand cur...@maurand.com wrote:
 
 
 Ethan Rosenberg wrote:
  Dear List -
 
  My
 mysqli extension seems to have gone away.
 
  $host =
 'localhost';
  $user = 'root';
  $password = 'SdR3908';
  echo hello2br /;
 
 var_dump(function_exists('mysqli_connect'));// this returns
boo(false)
  $db = 'Store';
  $cxn =
 mysqli_connect($host,$user,$password,$db);
 
  I tried to
 reinstall -
 
  rosenberg:/home/ethan#  apt-get install
 php5-common libapache2-mod-php5
  php5-cli
  Reading
 package lists... Done
  Building dependency tree
  Reading
 state information... Done
  libapache2-mod-php5 is already the
 newest version.
  libapache2-mod-php5 set to manually
 installed.
  php5-cli is already the newest version.
 
 php5-cli set to manually installed.
  php5-common is already the
 newest version.
  php5-common set to manually installed.
 
 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
 
 
  It did not help.
 
  TIA
 
 
 Ethan
 
  --
  PHP General Mailing List
 (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 
 
 Found
 this in ubuntu forums.
 
 http://ubuntuforums.org/showthread.php?t=1814736
 
 
 sudo apt-get install
 php5-mysql
 This package contains the PHP module that interfaces with the MySQL
 server.

 Could it be that the mysql service on the server has stopped.
Typically
 you'd do something like this on RedHat/Fedora servers:

 service mysqld status

 That would certainly stop the extension working from within PHP.

 Thanks,
 Ash


I'm sorry, but this is just plain wrong.
The extension has nothing to do with the mysql service. In fact, a lot
of
the larger websites have their database service running at a different
server, and probably don't even have the mysql service installed.

- Matijn

Look at his connection settings, it says localhost...

Thanks,
Ash

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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Ashley Sheridan
On Wed, 2013-08-07 at 13:11 -0600, Brian Smither wrote:

 Second go around:
 
 I have a situation where, for some unknown reason, where each class that 
 finishes its __contruct{} function, that class gets automatically assigned to 
 a variable - other than the variable I specify.
 
 Conceptually (a little bit better on the conceptualizing):
 
 class Hello {
 private $_world = 'World';
 function __construct(){}
 }
 
 $clsHello = new Hello();
 
 echo 'The variable $hello is '.gettype($hello).\n.print_r($hello,true);
 
 Output:
 The variable $hello is object
 Hello Object
 (
 [_world:Hello:private] = World
 )
 
 There is no statement in my application that assigns an instance of the class 
 to another variable, the name being a lowercase variant of the class name.
 
 Would there be a PHP function that would do this as a side-effect?
 
 I am more interested in learning what is happening as opposed to rolling back 
 to a previous version. (A backup copy functions fine. A file compare does not 
 reveal any likely suspects.)
 
 PHP5.4.17-NTS-VC9 (Windows XP-SP3)
 
 
 
 


I cannot replicate this. That code you supplied correctly gives a notice
warning about an undefined variable '$hello'. Are you sure that that
simple code excerpt is giving you the problem you describe and there's
not more to the whole thing, more code, etc?

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




Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Ashley Sheridan
On Wed, 2013-08-07 at 21:02 +0100, Stuart Dallas wrote:

 On 7 Aug 2013, at 20:45, Brian Smither bhsmit...@gmail.com wrote:
 
  I cannot replicate this.
  
  I don't expect anyone to be able to replicate this behavior. The example 
  shows an extraordinarily stripped-down sequence of statements that informs 
  what should work, but do to some unknown agent, which, therefore, cannot be 
  included in the example, produces unexpected output.
  
  This conceptual example is not a 'sample' or 'excerpt' of the actual 
  application. There is much, much more code. None of it is an apparent 
  likely suspect in causing this behavior.
  
  I am hoping for a, Oh, yeah! I've seen that happen before. It's caused 
  by...
  
  Let us focus on the central question:
  
  Would there be a PHP function that would do [what the example describes] as 
  a side-effect?
 
 Yes:
 
 $hello = $clsHello;
 
 There are only a few variables that get assigned as side effects of 
 functions, but they have very specific names, and none of them are $hello 
 (but I'm guessing that's not the actual variable name) and none of them will 
 assign a userland object. Somewhere in your code there is something that is 
 assigning to $hello. Find everything that's doing that and look at each 
 instance in detail.
 
 -Stuart
 
 -- 
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/
 


As you've said that your excerpt doesn't replicate the problem, it's not
that useful really to accurately illustrate it. I would say for definite
that it's some of the surrounding code, probably something similar to
this:

class Hello
{
private $_world = 'World';
function __construct(){}

function test()
{
$GLOBALS[strtolower(get_class($this))] = $this;
}
}

$clsHello = new Hello();
$clsHello-test();

echo 'The variable $hello is
'.gettype($hello).\n.print_r($hello,true);


There are probably many ways to achieve this, I can't think of a sane
reason for any of them though!

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




Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Ashley Sheridan



I have two dozen classes in this application. In every case, there will
be a variable, the name of which is a lowercase variant of the class
name, to which is assigned an instance of the class, when the class's
construct() function completes. The example informs you of this.


Actually, as we've explained, your example does _not_ show this, it works as 
expected and throws a notice, from which can be inferred there is other code 
doing this


 I would say for definite that it's some of the surrounding code,

Exactly. No sooner and no later than precisely when the class's
construct() function ends, and control is given to the next statement
after the one that instantiated that class.


Is your class maybe inheriting from another one and that contains the code 
causing this issue?


 probably something similar to this:

Let's explore this statement:

 $GLOBALS[strtolower(get_class($this))] = $this;

May I infer that the declaration of $GLOBALS['hello'] will, at the same
time, also create $hello (without a statement declaring such)?

The $GLOBALS array is what's known as a super global. Elements within the array 
are reflected as global variables and vice-versa.


This:
http://php.net/manual/en/reserved.variables.globals.php
implies the opposite direction.


Not sure what you mean, but this super global works both ways. Don't 
necessarily get hung up on this being the exact code, it's just a proof of 
concept of how it /might/ be happening. Like I said, there are probably other 
ways too.


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

Thanks,
Ash

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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Ashley Sheridan
On Wed, 2013-08-07 at 19:02 -0600, Brian Smither wrote:

 Your example does _not_ show this, it works
 as expected and throws a notice, from which can be inferred there is other
 code doing this
 
 Or relevant code having a side-effect not currently realized.


No, you just didn't post relevant code.


 
 
 Is your class maybe inheriting from another one and that contains the code
 causing this issue?
 
 No.
 
 
 May I infer that the declaration of $GLOBALS['hello'] will, at the same
 time, also create $hello (without a statement declaring such)?
 
 The $GLOBALS array is what's known as a super global. Elements within the
 array are reflected as global variables and vice-versa.
 
 
 Let's refine the conceptual example:
  
 class Hello {
 private $_world = 'World';
 function __construct(){}
 }
 
 $GLOBALS['hello'] = new Hello();
 
 echo 'The variable $hello is '.gettype($hello).\n.print_r($hello,true);
 
 Can we then postulate that the value of $GLOBALS['hello'] will also be 
 revealed in $hello, even though $hello was never formally declared?
 
 I know that $GLOBALS['hello'] has a universal scope, and $hello (wherever it 
 comes from) needs to be global-ized inside functions.
 


$GLOBALS['hello'] is essentially a synonym for $hello in this context.
$GLOBALS is just an array of all variables that have global scope, so
adding to this causes variables to be added at the global scope level.
But, like I've said a few times, this might not be your specific
problem, and without seeing the actual code that causes this problem,
it's very difficult for anyone to help. Your code examples don't exhibit
the issue you describe, so they're not useful in the context of
pin-pointing the problem. If you can post code that *does* give that
problem, then someone on the list may be able to help.


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




Re: [PHP] how to see all sessions sets in server

2013-08-04 Thread Ashley Sheridan
On Sun, 2013-08-04 at 14:56 +0430, Farzan Dalaee wrote:

 You mean when user logged in i add new record to table and when logged out i 
 delete the row? So if user close the browser without logout how can i find 
 user is online or not?
 
 Sent from my iPhone
 
 On Aug 4, 2013, at 14:44, Matijn Woudt tijn...@gmail.com wrote:
 
  
  
  
  On Sun, Aug 4, 2013 at 11:02 AM, Farzan Dalaee farzan.dal...@gmail.com 
  wrote:
  hi
  i want to write online user module for my site and i want to check
  $_SESSION['userID'] to find all users id who loged in
  but when i echo this code its return only current user detail
  how i can see all sessions?
  
  foreach($_SESSION as $k = $v)
  {
  echo $k.--.$v;
  }
   or how i handle online users?
  
  You can only access sessions when you know the session id.
  Most sites handle online users in their database, store a timestamp each 
  time a user loads a page. When you want to display the online users, check 
  where the timestamp is between now and a few minutes ago. Note that without 
  javascript (or flash/java/etc) there is no way to truly know if the user 
  left or not. The session will stay active for a long time, depending on 
  your php.ini settings.
  
  - Matijn
  


Like Matijn said, unless you're using some kind of client-side method to
continually poll the server, you can't know if they've just closed their
browser. There are Javascript events for exiting a page, but they don't
work correctly on Safari and iOS Safari.

You don't have to actually save anything to the DB manually, just
instruct PHP to use the DB for its own sessions, rather than files.

Do you really need to inspect each visitors session in detail, or do you
just need a way to determine how many unique visitors are on the site at
any one time?

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




[PHP] What the hell is Begacom?

2013-08-04 Thread Ashley Sheridan
And why everytime I reply to the list am I getting an automated reply
from this email address

Belgacom Webteam [no-reply] supp...@skynet.be



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




Re: [PHP] What the hell is Begacom?

2013-08-04 Thread Ashley Sheridan
On Sun, 2013-08-04 at 12:27 +0100, Lester Caine wrote:

 Ashley Sheridan wrote:
  And why everytime I reply to the list am I getting an automated reply
  from this email address
 
  Belgacom Webteam [no-reply]supp...@skynet.be
 
 Because of the way the list is set up ...
 We all get every bounce message as a result of posting to PHP lists since WE 
 are 
 set as the reply-to address. This apparently is the right way of doing email 
 lists ;)
 
 -- 
 Lester Caine - G8HFL
 -
 Contact - http://lsces.co.uk/wiki/?page=contact
 L.S.Caine Electronic Services - http://lsces.co.uk
 EnquirySolve - http://enquirysolve.com/
 Model Engineers Digital Workshop - http://medw.co.uk
 Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
 


Maybe someone can take them off of the list? ;)

(hint, hint)

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




Re: [PHP] Re: how to see all sessions sets in server

2013-08-04 Thread Ashley Sheridan
On Sun, 2013-08-04 at 13:27 +0100, Tim Streater wrote:

 On 04 Aug 2013 at 11:28, Ashley Sheridan a...@ashleysheridan.co.uk wrote: 
 
  Like Matijn said, unless you're using some kind of client-side method to
  continually poll the server, you can't know if they've just closed their
  browser. There are Javascript events for exiting a page, but they don't
  work correctly on Safari and iOS Safari.
 
 onbeforeunload works fine in Safari; I use it all the time.
 
 --
 Cheers  --  Tim
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Apparently it has problems when browsing in porn mode, and mobile
safari has major problems with it. I'm basing this on previous posts on
forums I've been on, so it might have been fixed now, but I don't know
for sure either way.

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




Re: [PHP] how to see all sessions sets in server

2013-08-04 Thread Ashley Sheridan


Farzan Dalaee farzan.dal...@gmail.com wrote:


 On Sun, 2013-08-04 at 14:56 +0430, Farzan Dalaee wrote:
 
 You mean when user logged in i add new record to table and when
logged out i delete the row? So if user close the browser without
logout how can i find user is online or not?
 
 Sent from my iPhone
 
 On Aug 4, 2013, at 14:44, Matijn Woudt tijn...@gmail.com wrote:
 
  
  
  
  On Sun, Aug 4, 2013 at 11:02 AM, Farzan Dalaee
farzan.dal...@gmail.com wrote:
  hi
  i want to write online user module for my site and i want to
check
  $_SESSION['userID'] to find all users id who loged in
  but when i echo this code its return only current user detail
  how i can see all sessions?
  
  foreach($_SESSION as $k = $v)
  {
  echo $k.--.$v;
  }
   or how i handle online users?
  
  You can only access sessions when you know the session id.
  Most sites handle online users in their database, store a
timestamp each time a user loads a page. When you want to display the
online users, check where the timestamp is between now and a few
minutes ago. Note that without javascript (or flash/java/etc) there is
no way to truly know if the user left or not. The session will stay
active for a long time, depending on your php.ini settings.
  
  - Matijn
  
 
 Like Matijn said, unless you're using some kind of client-side method
to continually poll the server, you can't know if they've just closed
their browser. There are Javascript events for exiting a page, but they
don't work correctly on Safari and iOS Safari.
 
 You don't have to actually save anything to the DB manually, just
instruct PHP to use the DB for its own sessions, rather than files.
 
 Do you really need to inspect each visitors session in detail, or do
you just need a way to determine how many unique visitors are on the
site at any one time?
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 


I need to inspect each visitor to show how online or who offline for
chat
Like facebook chat
 

Ah, so you don't need to see the details of the sessions then. Facebook does 
this (badly) by using javascript on the client side which triggers an update of 
a timestamp on the server, which then allows you to determine who is online (or 
was within a given time limit)
Thanks,
Ash

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



Re: [PHP] how to see all sessions sets in server

2013-08-04 Thread Ashley Sheridan


Matijn Woudt tijn...@gmail.com wrote:
On Sun, Aug 4, 2013 at 4:00 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:



 Farzan Dalaee farzan.dal...@gmail.com wrote:
 
 
  On Sun, 2013-08-04 at 14:56 +0430, Farzan Dalaee wrote:
 
  You mean when user logged in i add new record to table and when
 logged out i delete the row? So if user close the browser without
 logout how can i find user is online or not?
 
  Sent from my iPhone
 
  On Aug 4, 2013, at 14:44, Matijn Woudt tijn...@gmail.com wrote:
 
  
  
  
   On Sun, Aug 4, 2013 at 11:02 AM, Farzan Dalaee
 farzan.dal...@gmail.com wrote:
   hi
   i want to write online user module for my site and i want to
 check
   $_SESSION['userID'] to find all users id who loged in
   but when i echo this code its return only current user detail
   how i can see all sessions?
  
   foreach($_SESSION as $k = $v)
   {
   echo $k.--.$v;
   }
or how i handle online users?
  
   You can only access sessions when you know the session id.
   Most sites handle online users in their database, store a
 timestamp each time a user loads a page. When you want to display
the
 online users, check where the timestamp is between now and a few
 minutes ago. Note that without javascript (or flash/java/etc) there
is
 no way to truly know if the user left or not. The session will stay
 active for a long time, depending on your php.ini settings.
  
   - Matijn
  
 
  Like Matijn said, unless you're using some kind of client-side
method
 to continually poll the server, you can't know if they've just
closed
 their browser. There are Javascript events for exiting a page, but
they
 don't work correctly on Safari and iOS Safari.
 
  You don't have to actually save anything to the DB manually, just
 instruct PHP to use the DB for its own sessions, rather than files.
 
  Do you really need to inspect each visitors session in detail, or
do
 you just need a way to determine how many unique visitors are on the
 site at any one time?
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 
 I need to inspect each visitor to show how online or who offline for
 chat
 Like facebook chat
 

 Ah, so you don't need to see the details of the sessions then.
Facebook
 does this (badly) by using javascript on the client side which
triggers an
 update of a timestamp on the server, which then allows you to
determine who
 is online (or was within a given time limit)
 Thanks,
 Ash


Maybe it's bad, but there's no good alternative, except sending ping
requests to your server every second or so, but any site as large as
Facebook will DDOS itself when using things like that ;)

- Matijn

I'm not saying the method is bad, but the way Facebook does it isn't great, I'm 
constantly seeing people online who sign out when I open up a message box. 
Now that might be genuine, but I'm not *that* unpopular! 

Thanks,
Ash

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



Re: [PHP] POST action

2013-07-28 Thread Ashley Sheridan
On Sun, 2013-07-28 at 13:37 -0400, Jim Giner wrote:

 On 7/28/2013 1:26 PM, Larry Garfield wrote:
  On 07/28/2013 12:14 PM, iccsi wrote:
  form action=action.php method=post
  pYour name: input type=text name=name //p
  pYour age: input type=text name=age //p
  pinput type=submit //p
  /formIn the PHP tutorial manual, it says that we can have post
  action to the form itself just like above coding.I would like to know
  in the real projects, can we have action to the same PHP file, since
  that we only need have one filebut not 2 files foe POST request,Your
  help and information is great appreciated,regards,Iccsi,
 
  Real projects to all kinds of things.  Which is best depends on who
  you ask. :-)
 
  I would argue that there's 3 good approaches, both of which are viable:
 
  1) Define your form abstractly via an API, and have the API detect the
  presence of POST request and then process the form after it's built.
  That means you do submit back to the same URL.  (Drupal 7 and earlier do
  this.)
 
  2) Put 2 separate request handlers / controllers at the same path, one
  for GET and one for POST.  So you submit back to the same URL but an
  entirely different piece of code responds to it.  (This requires a good
  routing system that can differentiate between GET and POST.)
 
  3) Every form is defined as its own object somewhere with a unique ID.
  All forms post to the same URL but include the form ID.  Code at that
  URL looks up the form object by ID and maps the submitted data to it to
  know what to do with it.
 
  Note that in all 3 cases you're defining a form via an API of some
  kind.  You are not writing form tags yourself.  Don't do that. Ever.  I
  promise you that you will have a security hole or six if you do.  Use a
  good form handling API for building forms.  That's what good Real
  projects do.  There are a lot out there.  Most fullstack frameworks or
  CMSes have one built in (I know Drupal and Code Ignighter do, although
  they're quite different), and there are reasonably stand-alone
  components available in both Symfony2 Components and Zend Framework.
  Please don't write your own.  There are too many good ones (and even
  more bad ones, of course) already out there that have been security
  hardened.
 
  --Larry Garfield
 Never write your own form?  I'm guilty - oh, so guilty.  What exactly is 
 a 'security hardened' form?
 
 IN answer to OP - yes you can use a single script to handle your from 
 return.  I do that too!  I start by recognizing my first time thru and 
 send out a form/page.  I process the submit back from that page, doing 
 something based on the label of the submit button that I detect.  I may 
 then do some more processing and produce a newer version of the same 
 form/page and repeat.  Or I may end it all at that point.  Depends on 
 what the overall appl is doing.
 
 And now I'll watch and see how much I'm doing wrong.
 


I don't think there's anything inherently wrong with writing your own
form processing code, as long as you understand what's going on. Many
frameworks do make this a lot easier though, but sometimes I find it
encourages you to ignore some of the details (like security) because you
know the framework handles that stuff.

I would say code forms on your own first, as a learning experience, then
use frameworks once you know what you're doing.

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




Re: [PHP] How to extract php source code from joomla

2013-07-22 Thread Ashley Sheridan
On Mon, 2013-07-22 at 12:18 -0700, elk dolk wrote:

 Hi all,
 I want to build a website using Joomla 2.5 . It should have 5 pages:
 
 index.php
 pageOne.php
 pageTwo.php
 ...
 
 How can I get the php source code for those pages?
 
 I installed joomla 2.5 on my windows box and use XAMPP's appache web server 
 thanks


Erm, Joomla is a CMS, which means that you don't have source code for
individual pages like that. If you want, you don't have to get involved
with the PHP at all in Joomla. What is it that you're actually trying to
achieve?

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




Re: [PHP] How to extract php source code from joomla

2013-07-22 Thread Ashley Sheridan
On Mon, 2013-07-22 at 12:49 -0700, elk dolk wrote:

 Thank you for the quick response ! What I am trying to do : I have to 
 complete two university projects for
 
  my professor !
 
 project One  : Make an online shop and must use the following components in 
 it 
 
 
 Shopping cart, Catalog of products, payment gateway , user login and user 
 activity log .
 
 
 project Two : Implementing of a B2B sell-side portal with negotiation 
 mechanism.
 
 As I am familiar with php and My.SQL and I have only 20 days to complete 
 those projects !  I thought it's 
 
 better to use Joomla I'll be grateful if you can give me an advice 
 
 
 thank you
 
 
 - Forwarded Message -
 From: Ashley Sheridan a...@ashleysheridan.co.uk
 To: elk dolk elkd...@yahoo.com 
 Cc: php-general@lists.php.net php-general@lists.php.net 
 Sent: Monday, July 22, 2013 11:45 PM
 Subject: Re: [PHP] How to extract php source code from joomla
  
 
 On Mon, 2013-07-22 at 12:18 -0700, elk dolk wrote:
 
  Hi all,
  I want to build a website using Joomla 2.5 . It should have 5 pages:
  
  index.php
  pageOne.php
  pageTwo.php
  ...
  
  How can I get the php source code for those pages?
  
  I installed joomla 2.5 on my windows box and use XAMPP's appache web server 
  thanks
 
 
 Erm, Joomla is a CMS, which means that you don't have source code for
 individual pages like that. If you want, you don't have to get involved
 with the PHP at all in Joomla. What is it that you're actually trying to
 achieve?
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


20 days seems awfully ambitious, does your professor expect you to code
these by hand or are you allowed to use an existing CMS, I ask because
your original question seemed a bit odd.

For e-commerce you're better off choosing a CMS which does that out of
the box. Joomla has plugins that allow you to do these things, but it
can be a hefty CMS, and it's not particularly suited for shops, plus it
has a bit of a learning curve and some large security holes (which I
know first hand having had to just get a Joomla site to pass a rigorous
security test)

Lastly, please try not to top post :)

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




Re: [PHP] How to extract php source code from joomla

2013-07-22 Thread Ashley Sheridan
On Mon, 2013-07-22 at 13:10 -0700, elk dolk wrote:

 I am allowed to use tools or code by hand , it does not matter ,the professor 
 wants to have the source code.
 
 
 
 


You say tools, but would he consider a full-blown complex CMS as merely
a tool, or not? At this point, I agree, your best option is probably a
CMS with plugins, because 20 days is not much time to build that sort of
thing, and that's coming from someone who develops in PHP for a living.

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




Re: [PHP] Can this work?

2013-07-05 Thread Ashley Sheridan
Can't you just use a number field, which is a hell of a lot easier (especially 
on an iPad) to use than a bunch of select lists.

Karl-Arne Gjersøyen karlar...@gmail.com wrote:

2013/7/5 Stuart Dallas stu...@3ft9.com

 On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen karlar...@gmail.com
wrote:

  2013/7/5 Stuart Dallas stu...@3ft9.com
 
  On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen karlar...@gmail.com
 wrote:
 
  Hello. I have a form in HTML/PHP with for loops that generate a
 selected
  list like this:
  for($i = 1; $i 25;$i++ ){
  option value=?php echo $i; ??php echo $i; ?/option
  }
 
  The lists look like this:
 
  form action=index.php
  view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php
  method=postselect name=valgt_dynamit_polse_1-25kgoption
  value=1-25 selected=selected1-25/optionoption
  value=11/optionoption value=22/optionoption
  value=33/optionoption value=44/optionoption
  value=55/optionoption value=66/optionoption
  value=77/optionoption value=88/optionoption
  value=99/optionoption value=1010/optionoption
  value=/optionoption value=1212/optionoption
  value=1313/optionoption value=1414/optionoption
  value=1515/optionoption value=1616/optionoption
  value=1717/optionoption value=1818/optionoption
  value=1919/optionoption value=2020/optionoption
  value=2121/optionoption value=/optionoption
  value=2323/optionoption value=2424/optionoption
  value=2525/option/select Kgnbsp;select
  name=valgt_dynamit_polse_26-50kgoption value=26-50
  selected=selected26-50/optionoption
  value=2626/optionoption value=2727/optionoption
  value=2828/optionoption value=2929/optionoption
  value=3030/optionoption value=3131/optionoption
  value=3232/optionoption value=/optionoption
  value=3434/optionoption value=3535/optionoption
  value=3636/optionoption value=3737/optionoption
  value=3838/optionoption value=3939/optionoption
  value=4040/optionoption value=4141/optionoption
  value=4242/optionoption value=4343/optionoption
  value=/optionoption value=4545/optionoption
  value=4646/optionoption value=4747/optionoption
  value=4848/optionoption value=4949/optionoption
  value=5050/option/select Kgnbsp;
 
  What I try to do with it is to register the selected value and do
  something
  with it. The lists is weight in KG. I hope to select only one
value
  between
  1-25kg OR 26-50kg. I don't know if this is possible? What do you
think?
 
  If the range of acceptable values is 1-50, why do you have two
select
  fields instead of one?
 
  The select list has values between 1 and 200. Therefore I split it
up for
  every 25th value.

 Ok, but why?


I will use my application on iPad and find it more easy to use multiple
select lists than one big list with all 200 values at once.

Karl

Can't you just use a number field, which is a hell of a lot easier (especially 
on an iPad) to use than a bunch of select lists.
Thanks,
Ash

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



Re: [PHP] strlen ?

2013-07-05 Thread Ashley Sheridan


Jim Giner jim.gi...@albanyhandball.com wrote:

On 7/5/2013 3:02 PM, Stephen wrote:
 On 13-07-05 02:50 PM, Jim Giner wrote:

 Now the question is - how the heck did I put that in there?
Certainly
 not intentionally.  The data is captured from a d/e screen I wrote
and
 it simply grabs the post value and inserts a new record with that
 value along with some other values.  And I don't see anything
 concatenating a LF to my string.

 Is this a browser being used for input? Never assume what a browser
will
 do.

 It is good practice to validate and condition data before inserting
into
 a database.

 Consider trimming the data before doing the INSERT.

I do validate my data by quoting it but I never expected to have to do
a 
trim to remove a LF.  Especially on an iphone for input, since it's not

easy to enter a LF.

Quoting the data is not the same thing as validating it.

Thanks,
Ash

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



Re: [PHP] newbie PDO query display question

2013-06-16 Thread Ashley Sheridan


dealTek deal...@gmail.com wrote:


On Jun 16, 2013, at 3:37 PM, Stephen stephe...@rogers.com wrote:

 Here is a sample from my code:
 
 $photo_category_list = ;
$SQL = SELECT category_id, category_name FROM gallery_category
ORDER by category_order;
try {
$stmt = $dbh-prepare($SQL);
$stmt-execute();
while ( list( $id, $name) = $stmt-fetch(PDO::FETCH_NUM)) {
$photo_category_list .= option
value=$id$name/option\n;
   }
}
catch (PDOException $e){
echo 'Error getting category name. ' . $e-getMessage();
}
return $photo_category_list;
 
 Try to avoid your code assuming that you will just get one record
back (unless you use Limit 1)
 


Thanks Stephen,

Nice code!

you mentioned ... - to avoid your code assuming that you will just get
one record back

But what about the case where you are deliberately just showing one
record as in  FIND ONE PERSON like where ID = 101 ?

do you still need to loop through when you just selected/displayed 1
ITEM? 

Q: How do I display the columns without a loop in this 1 record
case...?


these fail - so what will work?

echo $results[First];
echo $results[First][0]; ???
echo $results[First][1]; ???



 While works better than foreach for getting the result rows from PDO








--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]

Have you tried chaining the the fetch() method on as in:

$pdo_object-query()-fetch();
Thanks,
Ash

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



Re: [PHP] Using Table prefixes

2013-06-08 Thread Ashley Sheridan


dealTek deal...@gmail.com wrote:

Hi all,

I can see the basic need for a table prefix in a case where you may use
one mysql database for several projects at once so as to distinguish
tables per project like...


Project 1

mysales_contacts
mysales_invoices
etc

and

jobs_contacts
jobs_invoices

however I was told a long time ago to use a prefix tbl_ like
tbl_Mytable but I don't really see much need for this by itself ... Am
I missing something?



--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]

I think that's a pattern that people use to distinguish their tables from 
views, etc, but personally I find it a little pointless. It doesn't really help 
in any way, and just means more typing.

Using a prefix for a set of tables in one db where you might have several 
things using the db (i.e. some hosting limits the databases you can have) makes 
sense, and especially so if you name it sensibly as in your first example. 
Thanks,
Ash

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



Re: [PHP] browser rendering

2013-06-02 Thread Ashley Sheridan
Width and height parameters on an image aren't required in HTML, it's preferred 
to use CSS. If different browsers are displaying the image at different sizes 
I'd look at the browser zoom level maybe.

Daniel Pöllmann poellmann.dan...@gmail.com wrote:

Well I think it depends.
When the image is part of the website, like a chart or something like
that
you can use the height and width attribute inside the img tag (don't
forget
alt for correct validation).
When the image is part of the layout or you're having multiple images
like
in a gallery with the same height and width you should use the
corrosponding css.

It might be useful to resize the image on serverside so that the
browser
doesn't have to load a big image and then resize it to a tiny pic. This
will - in most cases - speed up your website. But you have to use the
tags
even with a perfectly sized picture, otherwise the browser will be
confused
when the image can't be loaded

Daniel
Am 02.06.2013 15:12 schrieb georg georg.chamb...@telia.com:

 Possibly this issue is for other fora, which you might direct me,
anyways;

 I have been dablling making my own little webpages, however having
gotten
 a nice
 result jon fireforx, I realize picture sizes gets treated very
differntly
 on different browsers !!!
 so the looks of the pages get very strange from smaller (Opera) and
much
 bigger (Explorer)
 brower !!!

 any hints for mitigation ?

 br georg

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



Thanks,
Ash

Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Ashley Sheridan


Matijn Woudt tijn...@gmail.com wrote:

On Wed, May 29, 2013 at 10:51 PM, Sebastian Krebs
krebs@gmail.comwrote:




 2013/5/29 Matijn Woudt tijn...@gmail.com

 On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade
zootboys...@gmail.com
 wrote:

  On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
   On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
   I'm adding some minification to our cache.class.php and am
running
 into
  an
   edge case that is causing me grief.
  
   I want to remove all comments of the // variety, HOWEVER I
don't
 want to
   remove URLs...
  
   KISS.
  
   To make it simple, straight-forward, and understandable next
year
 when I
   have to re-read what I've written:
  
   I'd change all :// to QqQ  -- or any unlikely text string.
  
   Then I'd do whatever needs to be done to the // occurances.
  
   Finally, I'd change all QqQ back to ://.
  
   Jonesy
 
  Wow. This is just a spectacularly bad suggestion.
 
  First off, this task is probably a bit beyond the capabilities of
a
  regex. Yes, you may be able to come up with something that works
99%
  of the time, but this is really a job for a parser of some sort.
I'm
  sorry I don't have any suggestions on exactly where to go with
that,
  however I'm sure Google can be of assistance. The main problem is
that
  regex doesn't understand context. It just blindly finds patterns.
A
  parser understands context, and can figure out which //'s are
comments
  and which are something else. As a bonus, it can probably
understand
  other forms of comments like /* */, which regex would completely
die
  on.
 
 
 It is possible to write a whole parser as a single regex, being it
 terribly
 long and complex.


 No, it isn't.



It's better if you throw some smart words on the screen if you want to
convince someone. Just thinking about it, it makes sense as a true
regular
expression can only describe a regular language, and I think all the
programming languages are not regular languages.
But, We have PHP PCRE with extensions like Recursive patterns[1] and
Back
references[2], which can describe much more than just a regular
language.
And I do believe it would be able to handle it.
Too bad it probably takes months to complete a regular expression like
this.

- Matijn

[1] http://php.net/manual/en/regexp.reference.recursive.php
[2] http://php.net/manual/en/regexp.reference.back-references.php

Sometimes when all you know is regex, everything looks like a nail...

Thanks,
Ash

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



Re: [PHP] Random

2013-05-24 Thread Ashley Sheridan


Last Hacker Always onpoint lasthack...@gmail.com wrote:

I needed something like this echo(rand(1,30))

On 5/24/13, Last Hacker Always onpoint lasthack...@gmail.com wrote:
 okay thanks tamouse and others you think am not on point hmmm? I'll
 show you i am.

 On 5/24/13, tamouse mailing lists tamouse.li...@gmail.com wrote:
 On Thu, May 23, 2013 at 3:51 PM, Last Hacker Always onpoint
 lasthack...@gmail.com wrote:
 Hey I need code for random number 1-30 for my site.

 function rand_from_1_to_30() {
 return 4;
 }



Did you actually try that?

Thanks,
Ash

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



Re: [PHP] ODBC

2013-05-19 Thread Ashley Sheridan
On Sun, 2013-05-19 at 17:06 +0200, georg wrote:

 Actually who the heck has put SELinux in my machine ? 
 
 anyone knows (is this a part of fedora ?)
 
 /g


SELinux is part of Fedora install. You can disable it (not recommended)
or just follow one of the options it gives you depending on what you
actually want to achieve.

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




Re: [PHP] undef func - any more clues ?

2013-05-11 Thread Ashley Sheridan
On Sat, 2013-05-11 at 11:36 +0200, georg wrote:

 Hi again,
 is there any more clues to how Apache/PHP would get hold of ODBC libraries ?
 
 
 (( summery; Im a bit new to linux (here Fedora 17) so Im not sure of how
 these entities get hold of each other; are they linked into same module or 
 are they dynamically loaded
 libraries, guess that the latter. Then Im not clear over the path or 
 linkage of these; that is where
 are the definitions made to link them together; there is a series of conf 
 and ini files (and keyword) which should
 link names, and point to file names in (defined ?) directories (given by 
 paths)))
 
 / Georg
 
 
 
 
 
 
 - Original Message - 
 From: georg georg.chamb...@telia.com
 To: James Yerge ja...@nixsecurity.org
 Cc: PHP General php-general@lists.php.net
 Sent: Saturday, May 11, 2013 12:47 AM
 Subject: Re: [PHP] undef func
 
 
  Ok, txn ! so
  yum install php-devel
 
  worked, and got me a hole lot of pearl, however, still PHP has 
  odbc_connect() call as undefined function. as per Apache error log.
 
  There was some mentioning of php.ini; could that be something here ?
 
  /georg
 
  - Original Message - 
  From: James Yerge ja...@nixsecurity.org
  To: Gabriel Ricci gabrielri...@gmail.com
  Cc: georg georg.chamb...@telia.com; Serge Fonville 
  serge.fonvi...@gmail.com; Daniel Brown danbr...@php.net; tamouse 
  mailing lists tamouse.li...@gmail.com; PHP General 
  php-general@lists.php.net
  Sent: Saturday, May 11, 2013 12:12 AM
  Subject: Re: [PHP] undef func
 
 
  On 05/10/2013 06:08 PM, Gabriel Ricci wrote:
  pear isntall php-dev
 
 
  Att.
 
  Gabriel Ricci
  
 
  Website http://gabrielricci.github.com
  Follow @gabrielricci http://www.twitter.com/gabrielricci
  Facebook profile http://www.facebook.com/gabrielricci2, GitHub
  profilehttp://www.github.com/gabrielricci/
  http://code.google.com/p/syslibjs/
 
 
  On Fri, May 10, 2013 at 7:07 PM, georg georg.chamb...@telia.com wrote:
 
  **
  So thanx again, closing in. It turned out that I had tried; yum install
  php_pear  // i.e. with an underscore, should be with hyphen !
  so crawling a mm forward; then stuck on; pecl install pdo_odbc// in
  this case the undrscore is ok (!)
  which fails as
 
  Cant find php headers in /usr/include/php  followed by Error phpize
  failed
 
  /georg
 
  - Original Message -
  *From:* Serge Fonville serge.fonvi...@gmail.com
  *To:* georg georg.chamb...@telia.com
  *Cc:* Gabriel Ricci gabrielri...@gmail.com ; Daniel 
  Browndanbr...@php.net; tamouse
  mailing lists tamouse.li...@gmail.com ; PHP 
  Generalphp-general@lists.php.net
  *Sent:* Friday, May 10, 2013 11:41 PM
  *Subject:* Re: [PHP] undef func
 
   Assuming OP is using a distro that uses yum for package management;
  A yum whatprovides pecl should provide the package name that needs to 
  be
  installed, in case of an apt based distro, this could be done through
  aptitude. Either way, it seems what might provide more information is
  details like the commands executed, the distro used and the errors 
  received
 
  HTH
 
   Kind regards/met vriendelijke groet,
 
  Serge Fonville
 
  http://www.sergefonville.nl
 
  Convince Microsoft!
  They need to add TRUNCATE PARTITION in SQL Server
 
  https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
 
 
  2013/5/10 georg georg.chamb...@telia.com
 
  noop, didnt take, no such package, was my reward
 
  /georg
- Original Message -
From: Gabriel Ricci
To: georg
Cc: Daniel Brown ; tamouse mailing lists ; PHP General
Sent: Friday, May 10, 2013 11:06 PM
Subject: Re: [PHP] undef func
 
 
To have pecl, you need to install PEAR first, yum install php-pear
  (or yum install php5-pear) should work.
 
 
Then you can try pecl install pdo_odbc.
 
 
 
Att.
 
Gabriel Ricci

 
Website
Follow @gabrielricci
Facebook profile, GitHub profile
 
 
 
 
 
On Fri, May 10, 2013 at 6:03 PM, georg georg.chamb...@telia.com
  wrote:
 
  unfortunately that didnt take, pecl is undefined command (my linux 
  is
  not so strong)
  trying yum renders no such package
 
 
 
  - Original Message - From: Daniel Brown 
  danbr...@php.net
  To: tamouse mailing lists tamouse.li...@gmail.com
  Cc: georg georg.chamb...@telia.com; PHP General 
  php-general@lists.php.net
  Sent: Friday, May 10, 2013 9:21 PM
  Subject: Re: [PHP] undef func
 
 
 
 
On Fri, May 10, 2013 at 3:18 PM, tamouse mailing lists
tamouse.li...@gmail.com wrote:
 
 
  Aren't DLLs a Windows thing?
 
 
   Yeah, I misread the bit about MS XP and thought he was 
  using XP
for this install.  I just realized the remainder of the 
  discussion
between us was off-list, so - for posterity - my response, when
finding out it is indeed a Linux box, is: pecl install pdo_odbc.
 
--

Re: [PHP] undef func

2013-05-10 Thread Ashley Sheridan


James Yerge ja...@nixsecurity.org wrote:

On 05/10/2013 06:08 PM, Gabriel Ricci wrote:
 pear isntall php-dev


 Att.

 Gabriel Ricci
 

 Website http://gabrielricci.github.com
 Follow @gabrielricci http://www.twitter.com/gabrielricci
 Facebook profile http://www.facebook.com/gabrielricci2, GitHub
 profilehttp://www.github.com/gabrielricci/
 http://code.google.com/p/syslibjs/


 On Fri, May 10, 2013 at 7:07 PM, georg georg.chamb...@telia.com
wrote:

 **
 So thanx again, closing in. It turned out that I had tried; yum
install
 php_pear  // i.e. with an underscore, should be with hyphen !
 so crawling a mm forward; then stuck on; pecl install pdo_odbc//
in
 this case the undrscore is ok (!)
 which fails as

 Cant find php headers in /usr/include/php  followed by Error
phpize
 failed

 /georg

 - Original Message -
 *From:* Serge Fonville serge.fonvi...@gmail.com
 *To:* georg georg.chamb...@telia.com
 *Cc:* Gabriel Ricci gabrielri...@gmail.com ; Daniel
Browndanbr...@php.net; tamouse
 mailing lists tamouse.li...@gmail.com ; PHP
Generalphp-general@lists.php.net
 *Sent:* Friday, May 10, 2013 11:41 PM
 *Subject:* Re: [PHP] undef func

  Assuming OP is using a distro that uses yum for package management;
 A yum whatprovides pecl should provide the package name that needs
to be
 installed, in case of an apt based distro, this could be done
through
 aptitude. Either way, it seems what might provide more information
is
 details like the commands executed, the distro used and the errors
received

 HTH

  Kind regards/met vriendelijke groet,

 Serge Fonville

 http://www.sergefonville.nl

 Convince Microsoft!
 They need to add TRUNCATE PARTITION in SQL Server


https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


 2013/5/10 georg georg.chamb...@telia.com

 noop, didnt take, no such package, was my reward

 /georg
   - Original Message -
   From: Gabriel Ricci
   To: georg
   Cc: Daniel Brown ; tamouse mailing lists ; PHP General
   Sent: Friday, May 10, 2013 11:06 PM
   Subject: Re: [PHP] undef func


   To have pecl, you need to install PEAR first, yum install
php-pear
 (or yum install php5-pear) should work.


   Then you can try pecl install pdo_odbc.



   Att.

   Gabriel Ricci
   

   Website
   Follow @gabrielricci
   Facebook profile, GitHub profile





   On Fri, May 10, 2013 at 6:03 PM, georg georg.chamb...@telia.com
 wrote:

 unfortunately that didnt take, pecl is undefined command (my
linux is
 not so strong)
 trying yum renders no such package



 - Original Message - From: Daniel Brown
danbr...@php.net
 To: tamouse mailing lists tamouse.li...@gmail.com
 Cc: georg georg.chamb...@telia.com; PHP General 
 php-general@lists.php.net
 Sent: Friday, May 10, 2013 9:21 PM
 Subject: Re: [PHP] undef func




   On Fri, May 10, 2013 at 3:18 PM, tamouse mailing lists
   tamouse.li...@gmail.com wrote:


 Aren't DLLs a Windows thing?


  Yeah, I misread the bit about MS XP and thought he was
using XP
   for this install.  I just realized the remainder of the
discussion
   between us was off-list, so - for posterity - my response,
when
   finding out it is indeed a Linux box, is: pecl install
pdo_odbc.

   --
   /Daniel P. Brown
   Network Infrastructure Manager
   http://www.php.net/

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




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





Should be yum install php-devel

If you're looking for a specific package, try

yum list php*

The * acts as a wildcard, it makes it easier to find packages whose names 
change slightly. Should avoid the ambiguity of the various lines of advice 

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



Re: [PHP] FW:

2013-05-08 Thread Ashley Sheridan


Dan Joseph dmjos...@gmail.com wrote:

Yo,

  (And, no, PHP doesn't stand
 for Produced by Horses  Ponies.)


This is completely devastating

Just noticed the original link has a nasty payload for android, I assume the 
same applies for other OSs (probably best not to check!)

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



RE: [PHP]

2013-05-08 Thread Ashley Sheridan


Steven Staples sstap...@mnsi.net wrote:

 So you're just lucky I didn't acronymize it as the Pretty House of
 Princesses or something.  And yes, I just made up the word 
 acronymize.  It may be Wednesday, but it feels more like a Friday.


Why does this feel like a new function/feature for PHP now?

Function acronymize($acronym)
{
   // do stuff here now... :S
}

Steve

Dont call it with the argument php, you'll get stuck in a recursive loop!

And its not even Friday! 
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



Re: [PHP] Re: generate onfly PDF

2013-05-05 Thread Ashley Sheridan


Tim Behrendsen t...@behrendsen.com wrote:

I have had outstanding success with wkhtmltopdf:

https://code.google.com/p/wkhtmltopdf/

It's a self-contained standalone program that you can call from PHP. It
uses a full-bodied HTML interpreter based on Webkit. Highly
recommended, I've been using it for years. It's open source and free.

I should say, I've used the Linux version. It looks like there's a
Windows version, but I have no experience with that, if that's what you
need.

Tim

Rafnewsraf.n...@gmail.com  wrote:

 Hi,

Is there a solution to generate onfly PDF from HTML page, and from
data

user typed in form (let's say like a template) without using PECL ?
i read that is hosting does not allow such extension, we can not
generate PDF, so i would rather get a solution without such library.

Moreover i'm searching a solution free and that i can supply with my
web
components.
I created a component that should be able to generate PDF files quite
often as service for user.

thx

Al.

I think that requires external libraries that are not part of a typical shared 
hosting installation, which is what it sounds like the OP has. 

I've used it before myself though , and aside from some oddities, works very 
well.

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

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



Re: [PHP] generate onfly PDF

2013-05-04 Thread Ashley Sheridan


Rafnews raf.n...@gmail.com wrote:

Hi,

Is there a solution to generate onfly PDF from HTML page, and from data

user typed in form (let's say like a template) without using PECL ?
i read that is hosting does not allow such extension, we can not 
generate PDF, so i would rather get a solution without such library.

Moreover i'm searching a solution free and that i can supply with my
web 
components.
I created a component that should be able to generate PDF files quite 
often as service for user.

thx

Al.

Have a look at fpdf, its a class that doesn't need any special server-side 
support. Its basic, but is pretty good.

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

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



Re: [PHP] Looking for complete entered URL

2013-04-21 Thread Ashley Sheridan


tamouse mailing lists tamouse.li...@gmail.com wrote:

On Sat, Apr 20, 2013 at 1:51 PM, Angela Barone
ang...@italian-getaways.com wrote:
 I've written a script that logs all visits to a web site,
complete with referrer and IP address.  It also logs all 4xx errors. 
What I'd like to add to this is, if someone adds extra code after the
page_name.php, to be able to capture any extra code and log that.

 I've tried:

 $_SERVER['QUERY_STRING']
 $_SERVER['REDIRECT_QUERY_STRING']
 $_SERVER['REDIRECT_URL']

So, since I wasn't exactly sure what got put into $_SERVER, and since
I'm lazy, I tapped out the following script:

?php
header(Content-type: text/plain);
echo '$_SERVER:'.PHP_EOL;
var_dump($_SERVER);
?

When I called it with the following URL:

http://localhost/~tamara/teststuffout/logger.php/one/two?a=true#fragment

It showed all the stuff in $_SERVER as a result of that, including:

 [REQUEST_URI]=
  string(47) /~tamara/teststuffout/logger.php/one/two?a=true

  [PATH_INFO]=
  string(8) /one/two

  [QUERY_STRING]=
  string(6) a=true

Interestingly, it appears nothing reports #fragment...

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

It wont, the fragment is always local. You'd need javascript to handle that

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

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



Re: [PHP] timezone

2013-04-15 Thread Ashley Sheridan
You don't know which timezone the server is in? That's what it wants.

Larry Martell larry.mart...@gmail.com wrote:

On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist
jsundqu...@gmail.com wrote:



 On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell
larry.mart...@gmail.com
 wrote:

 I have a client that has an app the runs with PHP 5.1.6. They want
to
 upgrade to 5.3.3. First issue I ran into, they have a line of code
 that is:

 $deftz = date(T);

 I'm getting this for that line:

 [Mon Apr 15 10:44:16 2013] [error] [client 10.7.14.21] PHP Warning:
 date(): It is not safe to rely on the system's timezone settings.
You
 are *required* to use the date.timezone setting or the
 date_default_timezone_set() function. In case you used any of those
 methods and you are still getting this warning, you most likely
 misspelled the timezone identifier. We selected 'America/Denver' for
 'MDT/-6.0/DST' instead in /home/www/itrade-dev/defs.inc on line 349

 So I changed it to

 $deftz = date.timezone;

 and now I get:

 [Mon Apr 15 10:49:35 2013] [error] [client 10.7.14.21] PHP Notice:
 Use of undefined constant date - assumed 'date' in
 /home/www/itrade-dev/defs.inc on line 349
 [Mon Apr 15 10:49:35 2013] [error] [client 10.7.14.21] PHP Notice:
 Use of undefined constant timezone - assumed 'timezone' in
 /home/www/itrade-dev/defs.inc on line 349

 Why is this undefined?

  You need to set the default time zone in this fashion,

 http://php.net/manual/en/function.date-default-timezone-set.php

But I don't know the timezone - I'm trying to get it so I can convert
times I get from the database to a user requested timezone.

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

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

Re: [PHP] webform spam prevention

2013-04-04 Thread Ashley Sheridan
On Wed, 2013-04-03 at 20:32 -0500, tamouse mailing lists wrote:

 I'd love to learn how to do that WITHOUT A MOUSE
 
 On Wed, Apr 3, 2013 at 8:10 PM, jomali jomali3...@gmail.com wrote:
  On Wed, Apr 3, 2013 at 7:33 PM, tamouse mailing lists
  tamouse.li...@gmail.com wrote:
 
  These folks might have direction for you: http://textcaptcha.com/really
 
  (And my apologies for top posting. It seems Google has forced their
  new mail compose widget upon me. I can no longer use my own editor to
  smoothly and easily edit message, and Google forces the top post.)
 
 
  Actually, it doesn't, as I show below.
 
 
  On Tue, Apr 2, 2013 at 2:13 PM, Jen Rasmussen j...@cetaceasound.com
  wrote:
   Can someone recommend a best practice for blocking spam on web forms
   (aside
   from captcha) ?
  
  
  
   I've been for the most part utilizing a honeypot method and then
   individually blocking IPs and am looking for a more efficient method
   that
   won't require daily maintenance.
  
  
  
   I've come across this module: http://spam-ip.com/phpnuke-spam-module.php
  
  
  
   Has anyone used this method or have any other better suggestions?
  
  
  
   Thanks in advance!
  
  
  
   Jen Rasmussen
  
   Web Development Manager | Cetacea Sound Corp.
  
   763-225-8465 | www.cetaceasound.com
  
  
   P Before printing this message, make sure that it's necessary. The
   environment is in your hands
  
  
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  Actually, it doesn't. All you have to do is scroll to the bottom and add
  your material.
 


Captchas are not very accessible. Not only do you often need a near
super-human ability to identify the scrawl that's displayed, but if you
can't actually see very well to start with (maybe your vision isn't
perfect or you can't see at all) then you have to fall back to the audio
replacement offered by the captcha. I've tried listening to some, and
they are awful.

One type I've seen (and use myself) which is gaining traction is that of
asking for a human type of response to a question, or have them perform
a simple mathematical problem, where the numbers are replaced with
something else.

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




Re: [PHP] Empty $_POST after submit.

2013-04-04 Thread Ashley Sheridan
On Thu, 2013-04-04 at 15:55 +0530, Ninad wrote:

 Hello,
 
 Thanks for such a fast response.
 
 Yes I tried bellow things but result is same --- no output..
 
 $postdata = file_get_contents('php://input');
 var_dump($postdata);
 var_dump($_POST);
 
 Regards,
 Ninad.
 
 On 04/04/2013 03:50 PM, Sorin Badea wrote:
  Hi,
  Did you tried a print_r($_POST) or a var_dump ?
 
 
  On Thu, Apr 4, 2013 at 1:10 PM, Ninad ninadsh...@iitb.ac.in 
  mailto:ninadsh...@iitb.ac.in wrote:
 
  Dear all,
 
  I am having 2 servers. One is running fedora 10 with php 5.2.6-5
  and second one is running
  fedora17 with php 5.4.13.
  Below given code is working absolutely fine on fedora10 with
  php5.2 But the same code is not working on fedora17 with php
  5.4.13. After submit I am getting $_POST variable empty.
 
  Please guide me in the same.
 
 
  ?php
  if (isset($_POST['lastname'], $_POST['lastname']))
  {
 echo(First name:  . $_POST['firstname'] . br /\n);
 echo(Last name:  . $_POST['lastname'] . br /\n);
  }
  ?
 
  html
  head
  /head
  body
  form action=index.php method=post
 pFirst name: input type=text name=firstname //p
 pLast name: input type=text name=lastname //p
 input type=submit name=submit value=Submit /
  /form
  /body
  /html
 
 
  Thanks  Regards,
  Ninad.
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  -- 
  Badea Sorin (unu.sorin)
  sorin.bade...@gmail.com mailto:sorin.bade...@gmail.com
  unu_so...@yahoo.com mailto:unu_so...@yahoo.com
  Pagina personala:
  http://badeasorin.com
 


Have you used the network inspector of your browser to see if what you
think is being sent is really being sent? Firefox and Chrome come with
these tools built in now.

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




Re: [PHP] Empty $_POST after submit.

2013-04-04 Thread Ashley Sheridan
On Thu, 2013-04-04 at 13:53 +0300, Sorin Badea wrote:

 So you have a single php file with the code from the first email and the
 $_POST var is empty. Am I right ?
 
 
 On Thu, Apr 4, 2013 at 1:49 PM, Ninad ninadsh...@iitb.ac.in wrote:
 
   Hi,
 
  I am using httpd as a web server with default configuration.
 
  Regards,
  Ninad.
 
 
  On 04/04/2013 04:11 PM, Sorin Badea wrote:
 
  What are you using on the server for http ? nginx or apache ? can you give
  us more details about your configuration (mods, configuration, htaccess ) ?
 
 
   On Thu, Apr 4, 2013 at 1:25 PM, Ninad ninadsh...@iitb.ac.in wrote:
 
   Hello,
 
  Thanks for such a fast response.
 
  Yes I tried bellow things but result is same --- no output..
 
  $postdata = file_get_contents('php://input');
  var_dump($postdata);
  var_dump($_POST);
 
  Regards,
  Ninad.
 
 
  On 04/04/2013 03:50 PM, Sorin Badea wrote:
 
  Hi,
  Did you tried a print_r($_POST) or a var_dump ?
 
 
  On Thu, Apr 4, 2013 at 1:10 PM, Ninad ninadsh...@iitb.ac.in wrote:
 
  Dear all,
 
  I am having 2 servers. One is running fedora 10 with php 5.2.6-5 and
  second one is running
  fedora17 with php 5.4.13.
  Below given code is working absolutely fine on fedora10 with php5.2 But
  the same code is not working on fedora17 with php 5.4.13. After submit I 
  am
  getting $_POST variable empty.
 
  Please guide me in the same.
 
 
  ?php
  if (isset($_POST['lastname'], $_POST['lastname']))
  {
 echo(First name:  . $_POST['firstname'] . br /\n);
 echo(Last name:  . $_POST['lastname'] . br /\n);
  }
  ?
 
  html
  head
  /head
  body
  form action=index.php method=post
 pFirst name: input type=text name=firstname //p
 pLast name: input type=text name=lastname //p
 input type=submit name=submit value=Submit /
  /form
  /body
  /html
 
 
  Thanks  Regards,
  Ninad.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
   --
  Badea Sorin (unu.sorin)
  sorin.bade...@gmail.com
  unu_so...@yahoo.com
  Pagina personala:
  http://badeasorin.com
 
 
 
 
 
   --
  Badea Sorin (unu.sorin)
  sorin.bade...@gmail.com
  unu_so...@yahoo.com
  Pagina personala:
  http://badeasorin.com
 
 
 
 
 


I've noticed the first line looks a little odd. It might be valid, just
probably not the way I've ever done it. For my own sanity, could you try
changing it to:

if (isset($_POST['lastname'])  isset($_POST['lastname']))

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




Re: [PHP] Empty $_POST after submit.

2013-04-04 Thread Ashley Sheridan
On Thu, 2013-04-04 at 16:33 +0530, Ninad wrote:

 I tried that already but same result ... no output...
 
 
 On 04/04/2013 04:32 PM, Ashley Sheridan wrote:
  On Thu, 2013-04-04 at 13:53 +0300, Sorin Badea wrote:
  So you have a single php file with the code from the first email and the
  $_POST var is empty. Am I right ?
 
 
  On Thu, Apr 4, 2013 at 1:49 PM, Ninad ninadsh...@iitb.ac.in  
  mailto:ninadsh...@iitb.ac.in wrote:
 
Hi,
  
   I am using httpd as a web server with default configuration.
  
   Regards,
   Ninad.
  
  
   On 04/04/2013 04:11 PM, Sorin Badea wrote:
  
   What are you using on the server for http ? nginx or apache ? can you 
   give
   us more details about your configuration (mods, configuration, htaccess 
   ) ?
  
  
On Thu, Apr 4, 2013 at 1:25 PM, Ninad ninadsh...@iitb.ac.in  
   mailto:ninadsh...@iitb.ac.in wrote:
  
Hello,
  
   Thanks for such a fast response.
  
   Yes I tried bellow things but result is same --- no output..
  
   $postdata = file_get_contents('php://input');
   var_dump($postdata);
   var_dump($_POST);
  
   Regards,
   Ninad.
  
  
   On 04/04/2013 03:50 PM, Sorin Badea wrote:
  
   Hi,
   Did you tried a print_r($_POST) or a var_dump ?
  
  
   On Thu, Apr 4, 2013 at 1:10 PM, Ninad ninadsh...@iitb.ac.in  
   mailto:ninadsh...@iitb.ac.in wrote:
  
   Dear all,
  
   I am having 2 servers. One is running fedora 10 with php 5.2.6-5 and
   second one is running
   fedora17 with php 5.4.13.
   Below given code is working absolutely fine on fedora10 with php5.2 But
   the same code is not working on fedora17 with php 5.4.13. After submit 
   I am
   getting $_POST variable empty.
  
   Please guide me in the same.
  
  
   ?php
   if (isset($_POST['lastname'], $_POST['lastname']))
   {
  echo(First name:  . $_POST['firstname'] . br /\n);
  echo(Last name:  . $_POST['lastname'] . br /\n);
   }
   ?
  
   html
   head
   /head
   body
   form action=index.php method=post
  pFirst name: input type=text name=firstname //p
  pLast name: input type=text name=lastname //p
  input type=submit name=submit value=Submit /
   /form
   /body
   /html
  
  
   Thanks  Regards,
   Ninad.
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit:http://www.php.net/unsub.php
  
  
  
  
--
   Badea Sorin (unu.sorin)
  sorin.bade...@gmail.com  mailto:sorin.bade...@gmail.com
  unu_so...@yahoo.com  mailto:unu_so...@yahoo.com
   Pagina personala:
  http://badeasorin.com
  
  
  
  
  
--
   Badea Sorin (unu.sorin)
  sorin.bade...@gmail.com  mailto:sorin.bade...@gmail.com
  unu_so...@yahoo.com  mailto:unu_so...@yahoo.com
   Pagina personala:
  http://badeasorin.com
  
  
  
 
 
 
  I've noticed the first line looks a little odd. It might be valid, 
  just probably not the way I've ever done it. For my own sanity, could 
  you try changing it to:
 
  if (isset($_POST['lastname'])  isset($_POST['lastname']))
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 


This is really starting to sound like some sort of weird bug somewhere.
I know this is the typical IT response, but have you tried restarting
Apache? Also, this shouldn't happen, but try restarting your browser
too. Maybe it's exhibiting some strange cache bug.

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




Re: [PHP] Empty $_POST after submit.

2013-04-04 Thread Ashley Sheridan
On Thu, 2013-04-04 at 16:41 +0530, Ninad wrote:

 yes yes I tried that also...
 
 I have restarted apache as well as my entire system also...
 again I have cleared all the cache of my browser  restarted it also.
 but I am getting same result
 
 Regards,
 Ninad.
 
 On 04/04/2013 04:41 PM, Ashley Sheridan wrote:
  On Thu, 2013-04-04 at 16:33 +0530, Ninad wrote:
  I tried that already but same result ... no output...
 
 
  On 04/04/2013 04:32 PM, Ashley Sheridan wrote:
   On Thu, 2013-04-04 at 13:53 +0300, Sorin Badea wrote:
   So you have a single php file with the code from the first email and the
   $_POST var is empty. Am I right ?
  
  
   On Thu, Apr 4, 2013 at 1:49 PM, Ninad ninadsh...@iitb.ac.in  
   mailto:ninadsh...@iitb.ac.in   mailto:ninadsh...@iitb.ac.in wrote:
  
 Hi,
   
I am using httpd as a web server with default configuration.
   
Regards,
Ninad.
   
   
On 04/04/2013 04:11 PM, Sorin Badea wrote:
   
What are you using on the server for http ? nginx or apache ? can you 
give
us more details about your configuration (mods, configuration, 
htaccess ) ?
   
   
 On Thu, Apr 4, 2013 at 1:25 PM, Ninad ninadsh...@iitb.ac.in  
mailto:ninadsh...@iitb.ac.in   mailto:ninadsh...@iitb.ac.in 
wrote:
   
 Hello,
   
Thanks for such a fast response.
   
Yes I tried bellow things but result is same --- no output..
   
$postdata = file_get_contents('php://input');
var_dump($postdata);
var_dump($_POST);
   
Regards,
Ninad.
   
   
On 04/04/2013 03:50 PM, Sorin Badea wrote:
   
Hi,
Did you tried a print_r($_POST) or a var_dump ?
   
   
On Thu, Apr 4, 2013 at 1:10 PM, Ninad ninadsh...@iitb.ac.in  
mailto:ninadsh...@iitb.ac.in   mailto:ninadsh...@iitb.ac.in 
wrote:
   
Dear all,
   
I am having 2 servers. One is running fedora 10 with php 5.2.6-5 and
second one is running
fedora17 with php 5.4.13.
Below given code is working absolutely fine on fedora10 with php5.2 
But
the same code is not working on fedora17 with php 5.4.13. After 
submit I am
getting $_POST variable empty.
   
Please guide me in the same.
   
   
?php
if (isset($_POST['lastname'], $_POST['lastname']))
{
   echo(First name:  . $_POST['firstname'] . br /\n);
   echo(Last name:  . $_POST['lastname'] . br /\n);
}
?
   
html
head
/head
body
form action=index.php method=post
   pFirst name: input type=text name=firstname //p
   pLast name: input type=text name=lastname //p
   input type=submit name=submit value=Submit /
/form
/body
/html
   
   
Thanks  Regards,
Ninad.
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:http://www.php.net/unsub.php
   
   
   
   
 --
Badea Sorin (unu.sorin)
   sorin.bade...@gmail.com  mailto:sorin.bade...@gmail.com   
   mailto:sorin.bade...@gmail.com
   unu_so...@yahoo.com  mailto:unu_so...@yahoo.com   
   mailto:unu_so...@yahoo.com
Pagina personala:
   http://badeasorin.com
   
   
   
   
   
 --
Badea Sorin (unu.sorin)
   sorin.bade...@gmail.com  mailto:sorin.bade...@gmail.com   
   mailto:sorin.bade...@gmail.com
   unu_so...@yahoo.com  mailto:unu_so...@yahoo.com   
   mailto:unu_so...@yahoo.com
Pagina personala:
   http://badeasorin.com
   
   
   
  
  
  
   I've noticed the first line looks a little odd. It might be valid,
   just probably not the way I've ever done it. For my own sanity, could
   you try changing it to:
  
   if (isset($_POST['lastname'])  isset($_POST['lastname']))
  
   Thanks,
   Ash
  http://www.ashleysheridan.co.uk
  
  
 
 
  This is really starting to sound like some sort of weird bug 
  somewhere. I know this is the typical IT response, but have you tried 
  restarting Apache? Also, this shouldn't happen, but try restarting 
  your browser too. Maybe it's exhibiting some strange cache bug.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 


Have you tried a different browser? Just thinking of anything which
might narrow down the location of the problem.

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




Re: [PHP] webform spam prevention

2013-04-04 Thread Ashley Sheridan
On Thu, 2013-04-04 at 19:29 +0100, Terry Ally (Gmail) wrote:

 I am running captcha but the problem that I am having is that fly-by-night
 SEO marketeers are using the form to send marketing messages anyway. We get
 so many spam messages that I put up in red letters on the form that we do
 not want cold-calling SEO marketing messages. Since that message there has
 been a significant reduction in emails from legitimate SEO companies.
 
 However there is an upsurge in fly-by-night individuals who are all using
 Gmail addresses and originating in the USA. It seems as though someone is
 selling them a database of websites to contact.
 
 I wish there was a way of dealing with these people who evidently cannot
 read. Is there a technological solution?
 
 
 
 
 On 4 April 2013 17:28, Maciek Sokolewicz tula...@php.net wrote:
 
  On 4-4-2013 14:27, tamouse mailing lists wrote:
 
  On Apr 4, 2013 3:57 AM, Ashley Sheridan a...@ashleysheridan.co.uk
  wrote:
 
 
  One type I've seen (and use myself) which is gaining traction is that of
 
  asking for a human type of response to a question, or have them perform a
  simple mathematical problem, where the numbers are replaced with something
  else.
 
 
 
  Those can be great. The sticky part seems to be i18n and common user
  experience to answer the question, but this seem much easier to work with
  then throwing something horrible at your users.
 
 
  Still, questions like Does the sun rise in the morning or evening? or
  Is the sky usually blue or red? should be answerable by pretty much any
  human capable of understanding at least very basic things. I'm pretty sure
  that even if you have a severely reduced mental capacity, you can still
  answer these types of questions. And if you can't, you usually are in the
  wrong place anyway.
 
  - Tul
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 


They probably aren't using a paid for list but getting a list of contact
forms from a web search. I still maintain that asking some sort of
question that only a human could answer is best, and that doesn't mean a
tradition captcha like ReCaptcha. That's proved easier for bots to fill
than humans now!

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




Re: [PHP] What is an easiest way to port a PHP Web App to Android?

2013-03-27 Thread Ashley Sheridan


Kevin Peterson qh.res...@gmail.com wrote:

I have a web application written in PHP. It have been running for
several years. Now I want to run it as a stand-alone application on an
Android smartphone or tablet. How can I do it?

There are simple web servers you can run on Android, and also standalone PHP 
parsers too (i'm using one myself - search the play store for php server). Is 
that the sort of thing you wanted?

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

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



Re: [PHP] Session variable not persisting

2013-03-18 Thread Ashley Sheridan


Éric Oliver Paquette eopaque...@gmail.com wrote:


Le 2013-03-18 à 15:41, Éric Oliver Paquette a écrit :

 
 Le 2013-03-18 à 15:37, Matijn Woudt a écrit :
 
 
 
 
 On Mon, Mar 18, 2013 at 8:35 PM, Éric Oliver Paquette
eopaque...@gmail.com wrote:
 
 Le 2013-03-18 à 15:24, Éric Oliver Paquette a écrit :
 
 
 Le 2013-03-18 à 15:20, Matijn Woudt a écrit :
 
 
 
 
 On Mon, Mar 18, 2013 at 8:13 PM, Éric Oliver Paquette
eopaque...@gmail.com wrote:
 
 
 On Mon, Mar 18, 2013 at 7:46 PM, Éric Oliver Paquette
eopaque...@gmail.com wrote:
 Hi all,
 
 I'll be swift in my explanation as I can't find in any way the
source of the problem; it seems to be installation-related.
 
 At execution, sometimes (randomly it seems at first), variable
session aren't properly stored.
 
 
 In fact, when I run this on my server I randomly have empty
entries in the $_SESSION array. Any thoughts on this? Is this a known
bug (haven't found it…)
 
 Thanks!
 
 What does phpinfo() show about session stuff? Especially things
like save_handler and cookie_lifetime settings. 
 
 Note that this seems to occur 3 times out of 1000 on average. 
 
 Now, about your request :
 
 session
 
 Session Support   enabled
 Registered save handlers  files user
 Registered serializer handlersphp php_binary wddx
 
 Directive Local Value Master Value
 session.auto_startOff Off
 session.bug_compat_42 Off Off
 session.bug_compat_warn   Off Off
 session.cache_expire  180 180
 session.cache_limiter nocache nocache
 session.cookie_domain no valueno value
 session.cookie_httponly   Off Off
 session.cookie_lifetime   0   0
 session.cookie_path   /   /
 session.cookie_secure Off Off
 session.entropy_file  no valueno value
 session.entropy_length0   0
 session.gc_divisor10001000
 session.gc_maxlifetime14401440
 session.gc_probability1   1
 session.hash_bits_per_character   5   5
 session.hash_function 0   0
 session.name  PHPSESSID   PHPSESSID
 session.referer_check no valueno value
 session.save_handler  files   files
 session.save_path /var/lib/php/session/var/lib/php/session
 session.serialize_handler php php
 session.use_cookies   On  On
 session.use_only_cookies  On  On
 session.use_trans_sid 0   0
 
 
 Your settings seem to be fine. My best guess would be hardware
failure, though it seems unlikely. Did you check apache (or whatever
webserver you're using) logs for any errors or warnings?
 
 Yes I did. Everyhting seems normal there too. 
 
 Hm… Just noticed something new in fact; was looking a last time
before considering reinstallation on a new server: it seems that the
$_GET['push'] is undefined. In the other scripts I use where I have
this problem, I'm using $_POST variables though but still don't get
stored in $_SESSION. If I'm correct, this may implies that it is apache
that is faulty right?
 
 
 
 $_GET['push'] will be undefined if you still have your session
stored, but accessing the script directly. It should have nothing to do
with faulty Apache. 
 
 Okay, let me paraphrase: when I run the ping pong scripts written up
there, I have a blank in var_dump($_SESSION) if and only if I have 
 
 [Mon Mar 18 13:25:37 2013] [error] [client 184.151.114.111] PHP
Notice:  Undefined index: push in
/home/www/www.ngenioconnect.com/Modules/MPOSurveyTest/pong.php on line
8
 
 on apache log. So my question really is, it is apache that handles
the posts and gets requests, as I use both and it seems that the
non-persistence of data occurs before the storage in $_SESSION, is it
possible that it is Apache that is faulty?
Er… I looked where it caused a problem, it seems that $_GET, $_POST and
$_SESSION are indeed all affected. Any clue of a faulty installation
that would cause problem for many surperglobals? 

It sounds like some kind of memory problem. Can you run a memory tester on that 
server to see if that's the cause? 

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

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



Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:

  Guess regex are the only useful solution here. When you consider to use
  built-in functions, just remember, that for example '0xAF' is an integer
  too, but '42.00' isn't.
 
 Shoot...I hadn't considered how PHP might handle hex or octal strings when
 casting to int. (Again, not in front of a computer where I can test it
 right now. )
 
 Regexes have problems with more than 9 digits for 32-bit ints. I guess to
 some degree it depends on how likely you are to experience values that
 large.
 
 Andrew


Do they? Regex's deal with strings, so I don't see why they should have
such issues. I've certainly never come across that problem, or heard of
it before.

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




Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote:

 On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 
  On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:
 
   Guess regex are the only useful solution here. When you consider to use
   built-in functions, just remember, that for example '0xAF' is an
 integer
   too, but '42.00' isn't.
 
  Shoot...I hadn't considered how PHP might handle hex or octal strings
 when
  casting to int. (Again, not in front of a computer where I can test it
  right now. )
 
  Regexes have problems with more than 9 digits for 32-bit ints. I guess to
  some degree it depends on how likely you are to experience values that
  large.
 
  Andrew
 
 
  Do they? Regex's deal with strings, so I don't see why they should have
 such issues. I've certainly never come across that problem, or heard of it
 before.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 Sure. If the string is nine or fewer digits, they can all be 0-9. If it is
 10 digits, the first digit can only be 1-2. If it's 1, the remaining nine
 digits can still be 0-9, but if the first digit is 2, the second digit can
 only be 0-1. If the second digit is 0, the remaining eight digits can still
 be 0-9, but if it is 1, the third digit can only be 0-4. If the third digit
 is 0-3, the remaining seven digits can still be 0-9, but if it is 4, the
 fourth digit can only be 0-7.
 
 This pattern would continue for each of the remaining digits. Hopefully you
 get the idea. When you get to the final digit, its range depends not only
 on the nine preceding digits, but also the sign. If this is 64-bit, that
 adds even more wrinkles (including being aware of whether your
 implementation supports 64-bit ints). It may be possible to do with regular
 expressions, but it would definitely be complex and probably a time sink.
 
 As I said, if you KNOW you won't be dealing with integers that are more
 than nine digits, the regex should work fine.
 
 Remember, the OP didn't ask if it was an integer in the realm of infinite
 pure integers; he asked how to tell if a string was a number that could be
 converted to an int (presumably without loss).
 
 Andrew


Ah, I see. I think that's not an issue as such with regular expressions
having problems, more that bit limitations has a problem with numbers!
Bearing that in mind, this does the trick:

$string1 = '9';
$string2 = '99';
$string3 = '99';

var_dump($string === (intval($string1).''));
var_dump($string === (intval($string2).''));
var_dump($string === (intval($string3).''));

I'm getting the expected results on my machine (32-bit) but a 64-bit
machine would get the correct results for larger numbers.

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




Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:

 On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote:
  On 15/03/13 06:21, Jim Lucas wrote:
 
  On 3/14/2013 4:05 PM, Matijn Woudt wrote:
 
  On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote:
 
  On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
 
  Something like if (is_numeric($var) $var == floor($var)) will do
  the
 
  trick. I don't know if there's a better (more elegant) way.
 
 
  On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote:
 
  On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com**
 
  wrote:
 
  Hi,
 
 
  I have tried to find a way to check if a character string is
  possible to
  test whether it is convertible to an intger !
 
  any suggestion ?
 
  BR georg
 
 
 
  You could use is_numeric for that, though it also accepts floats.
 
  - Matijn
 
 
 
  for that type of test I have always used this:
 
  if ( $val == (int)$val ) {
 
  http://www.php.net/manual/en/**language.types.integer.php#**
 
  language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting
 
 
 
  I hope you're not serious about this...
 
  When comparing a string and an int, PHP will translate the string to int
  too, and of course they will always be equal then.
  So:
  $a = abc;
  if($a == (int)$a) echo YES;
  else echo NO;
  Will always return YES.
 
  - Matijn
 
 
  H... Interesting. Looking back at my code base where I thought I was
  doing that, turns out the final results were not that, but this:
 
  $value = asdf1234;
 
  if ( $value === (string)intval($value) ) {
 
  Looking back at the OP's request and after a little further searching,
  it seems that there might be a better possible solution for what the OP
  is requesting.
 
  ?php
 
  $values = array(asdf1234, 123.123, 123);
 
  foreach ( $values AS $value ) {
 
  echo $value;
 
  if ( ctype_digit($value) ) {
  echo ' - is all digits';
  } else {
  echo ' - is NOT all digits';
  }
  echo 'br /'.PHP_EOL;
  }
 
  returns...
 
  asdf1234 - is NOT all digits
  123.123 - is NOT all digits
  123 - is all digits
 
  http://www.php.net/manual/en/function.ctype-digit.php
 
  An important note:
 
  This function expects a string to be useful, so for example passing in
  an integer may not return the expected result. However, also note that
  HTML forms will result in numeric strings and not integers. See also the
  types section of the manual.
 
  --
  Jim
 
 
  Integers can be negative too: I suspect your test would reject a leading
  '-'...
 
 
 For my money, `is_numeric()` does just what I want.
 


The thing is, is_numeric() will not check if a string is a valid int,
but any valid number, including a float.

For something like this, wouldn't a regex be better?

if(preg_match('/^\-?\d+$/', $string))
echo int

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




Re: [PHP] PHP context editor

2013-03-15 Thread Ashley Sheridan
On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote:

 2013/3/15 Karim Geiger gei...@b1-systems.de
 
  Hi Georg,
 
  On Thu, 2013-03-14 at 23:10 +0100, georg wrote:
   hello,
   annyone knows of some good PHP context editor freeware ?
   (tired of missing out on trivials like ; )
 
  I don't know exactly what you mean by a context editor but if you want
  an editor with syntax highlighting try eclipse for an complete IDE
  (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim on
  Linux
 
 
 Or PhpStorm on Linux (multiplatform)  :) Or Netbeans on Linux
 (multiplatform too). Or gedit on Gnome/Linux, or or or ...
 vim is not the end of what can a linux desktop can provide :D
 
 
 
  Regards
 
  --
  Karim Geiger
 
  B1 Systems GmbH
  Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
  GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
 
 
 
 


For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is
great as a full-blown IDE, or Geany is quite nice if you need something
in-between those two. The great thing is that they are all available on
Windows too.

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




Re: FW: [PHP] Accessing Files Outside the Web Root

2013-03-15 Thread Ashley Sheridan
On Fri, 2013-03-15 at 09:11 -0400, Dale H. Cook wrote:

 At 09:44 PM 3/14/2013, tamouse mailing lists wrote:
 
 If you are delivering files to a (human) user via their browser, by whatever 
 mechanism, that means someone can write a script to scrape them.
 
 That script, however, would have to be running on my host system in order to 
 access the script which actually delivers the file, as the latter script is 
 located outside of the web root.
 
 Dale H. Cook, Market Chief Engineer, Centennial Broadcasting, 
 Roanoke/Lynchburg, VA
 http://plymouthcolony.net/starcityeng/index.html  
 
 


Not really.

You script is web accessible right? It just opens a file and delivers it
to the browser of your visitor. It's easy to make a script that pretends
to be a browser and make the same request of your script to grab the
file.

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




Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan


tamouse mailing lists tamouse.li...@gmail.com wrote:

On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 **
 On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:

 On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com
wrote:
  On 15/03/13 06:21, Jim Lucas wrote:
 
  On 3/14/2013 4:05 PM, Matijn Woudt wrote:
 
  On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com
wrote:
 
  On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
 
  Something like if (is_numeric($var) $var == floor($var))
will do
  the
 
  trick. I don't know if there's a better (more elegant) way.
 
 
  On Thu, Mar 14, 2013 at 3:09 PM, Matijn
Woudttijn...@gmail.com wrote:
 
  On Thu, Mar 14, 2013 at 7:02 PM,
georggeorg.chamb...@telia.com**
 
  wrote:
 
  Hi,
 
 
  I have tried to find a way to check if a character string is
  possible to
  test whether it is convertible to an intger !
 
  any suggestion ?
 
  BR georg
 
 
 
  You could use is_numeric for that, though it also accepts
floats.
 
  - Matijn
 
 
 
  for that type of test I have always used this:
 
  if ( $val == (int)$val ) {
 
  http://www.php.net/manual/en/**language.types.integer.php#**
 
 
language.types.integer.castinghttp://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting
 
 
 
  I hope you're not serious about this...
 
  When comparing a string and an int, PHP will translate the string
to int
  too, and of course they will always be equal then.
  So:
  $a = abc;
  if($a == (int)$a) echo YES;
  else echo NO;
  Will always return YES.
 
  - Matijn
 
 
  H... Interesting. Looking back at my code base where I thought
I was
  doing that, turns out the final results were not that, but this:
 
  $value = asdf1234;
 
  if ( $value === (string)intval($value) ) {
 
  Looking back at the OP's request and after a little further
searching,
  it seems that there might be a better possible solution for what
the OP
  is requesting.
 
  ?php
 
  $values = array(asdf1234, 123.123, 123);
 
  foreach ( $values AS $value ) {
 
  echo $value;
 
  if ( ctype_digit($value) ) {
  echo ' - is all digits';
  } else {
  echo ' - is NOT all digits';
  }
  echo 'br /'.PHP_EOL;
  }
 
  returns...
 
  asdf1234 - is NOT all digits
  123.123 - is NOT all digits
  123 - is all digits
 
  http://www.php.net/manual/en/function.ctype-digit.php
 
  An important note:
 
  This function expects a string to be useful, so for example
passing in
  an integer may not return the expected result. However, also note
that
  HTML forms will result in numeric strings and not integers. See
also the
  types section of the manual.
 
  --
  Jim
 
 
  Integers can be negative too: I suspect your test would reject a
leading
  '-'...


 For my money, `is_numeric()` does just what I want.



 The thing is, is_numeric() will not check if a string is a valid int,
but
 any valid number, including a float.

 For something like this, wouldn't a regex be better?

 if(preg_match('/^\-?\d+$/', $string))
 echo int

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



That is so about is_numeric(), but once I know it's a numeric, coercing
it
to just an int is easy. *Validating*, rather than just assuring, that a
string is an integer is another matter; if you need to give feedback to
the
user, etc., in which case a Regex is better.

(One small nit, + is possible on integers, too.)

The op wasn't about casting a string to an int but detecting if a string was 
just a string representation of an int. Hence using a regex to determine that. 
Regular expressions are not just about giving feedback to the user.

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

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



Re: [PHP] Re: Generating CRUD code for normalized db

2013-03-13 Thread Ashley Sheridan
On Wed, 2013-03-13 at 19:24 +0100, Marco Behnke wrote:

 Am 13.03.13 12:57, schrieb Gary:
  ma...@behnke.biz wrote:
 
  Do us all a favor abnd stay away from open source if you do not honor
  the work
  us wannabes put into it.
  As I said before I wasn't aware you would feel that the cap fitted.
  If you do feel that, then perhaps instead of complaining at me for
  pointing it out, you would be better off employing that time increasing
  the quality of what you produce.
 
 So you said you tried Yii. But have you wasted some of your precious
 time trying out the extension that extends Yii in a way, that creating
 models and views with Gii get proper SELECT Boxes and stuff for
 relations? If I understood you correct, this is what you were looking for?
 


At this point I don't think he's looking for an actual solution, but
merely wants to moan about open source. OSS has flaws, of course, but
even someone so narrow minded would have a hard time arguing in earnest
that it suffered from too little choice and a lack of solutions to a
problem.

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




Re: [PHP] Re: Generating CRUD code for normalized db

2013-03-11 Thread Ashley Sheridan


Gary listgj-phpgene...@yahoo.co.uk wrote:

Ashley Sheridan wrote:

 In any case, you could probably take something you like from another
 framework if you have the time/inclination/capability.

I honestly think I am simply going to write the shit myself. The CRUD
pages, I mean. I see no reason to keep searching for what, for me, is
very very basic functionaility. The inadequacies of so much Free Open
Source Shit never ceases to amaze me. Too many wannabes doing it who
overestimate their own capabilities and have no clue what is really
required in the real world.

Well, you don't really help yourself with a reply like that to the very people 
helping you.

I and others have pointed you towards open source solutions, the fact you don't 
want to put any effort in to make them work for you is not because of the state 
of open source software.

Your behaviour though makes me less-inclined to offer help in the future.
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] UNLESS Statement Equivalent

2013-03-11 Thread Ashley Sheridan
On Mon, 2013-03-11 at 16:38 -0500, Jonathan Sundquist wrote:

 Since you already have the return statement with the if statement the else
 isn't required. If those three statements are true you would exit the call
 any ways
 On Mar 11, 2013 4:33 PM, Angela Barone ang...@italian-getaways.com
 wrote:
 
  I'm looking for an 'unless' statement, but as far as I can tell,
  PHP doesn't have one.  Hopefully someone can help me rewrite my statement.
 
  In English, I want to say: always do something UNLESS these 3
  conditions are met.
 
  The best I've been able to come up with in PHP is this:
 
  if ( ($current_page == $saved_page) and ($current_ip == $saved_ip) and
  ($current_dt  ($saved_dt + 3600)) ) {
  return;
  } else {
  $query  = UPDATE `table` SET `hits` = '$count', `agent` =
  '$agent', `ts` = '$date_time'  WHERE `page` = '$page';
  $result = mysql_query($query) or die ('Error! -- ' .
  mysql_error());
  }
 
  However, I've read where this is not really acceptable.  Can
  someone help me eliminate the 'else' portion of this if statement?
 
  Thank you,
  Angela
 
  P.S.  I realize the above isn't complete code but it should still be
  clear.  If not, let me know.
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


What about this:

if ( !( ($current_page == $saved_page) and ($current_ip == $saved_ip)
and ($current_dt  ($saved_dt + 3600)) ) )

The 3 sub-expressions are grouped with an extra set of brackets and
the ! inverts the whole thing, so no need for an else clause.

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




Re: [PHP] Generating CRUD code for normalized db

2013-03-08 Thread Ashley Sheridan
On Fri, 2013-03-08 at 15:02 +0100, Ali Reza Sajedi wrote:

 Try Symfony 2
 
  Does anyone know of any framework that can generate CRUD code for
  normalized database tables? Preferably FOSS.
 

I believe Cake has this, although you need to have your fields named in
a certain way so that it understands the relationships, not sure if it
automatically recognises foreign keys as it was developed back when
MyISAM was the typical storage engine for MySQL, and that didn't have
foreign keys.

I think there are also CMS-like plugins for other slimmer frameworks
like CodeIgniter which have this functionality, but again, I would
assume previous rules apply with regards to your field naming
convention.

In any case, you could probably take something you like from another
framework if you have the time/inclination/capability.

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




Re: [PHP] Not counting my own page visits

2013-03-04 Thread Ashley Sheridan


Angela Barone ang...@italian-getaways.com wrote:

Hello,

   I have a script that counts hits to all the pages in my site and
emails me a report nightly.  However, it also counts my visits to my
site, and when I'm coding, I'm hitting a lot of my pages, repeatedly. 
I'd like to find a way to not count my page visits.

   At first, I thought about adding a parameter to each URL and parsing
that in the script, but that would get old real fast, and also, I may
forget to add it each time.  Is there a way to tell the script to
ignore my visits?

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

You could do it by checking for your ip address if you have a fixed one, or set 
a cookie with a long life and check for that, discounting visits when either 
are true 
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] Not counting my own page visits

2013-03-04 Thread Ashley Sheridan
On Mon, 2013-03-04 at 10:15 -0800, Angela Barone wrote:

 On Mar 4, 2013, at 9:56 AM, Ashley Sheridan wrote:
  set a cookie with a long life and check for that, discounting visits when 
  either are true
 
 Hi Ash,
 
   I don't know anything about cookies.  It sounds complicated to me.  Is 
 there a simple way to set one?
 
 Thanks,
 Angela


You can manually write a cookie on your machine, or use a special script
that only you visit that contains a setcookie() call (it only need be
set once). From there on, you can check the $_COOKIES super global for
the presence of your cookie. To test, visit the site with a different
browser (browsers won't share the cookies) and you'll see the visit
logged.

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




Re: [PHP] Re: Open form in new window

2013-03-04 Thread Ashley Sheridan
On Mon, 2013-03-04 at 15:22 -0500, Paul M Foster wrote:

 On Mon, Mar 04, 2013 at 06:58:41PM +0100, Matijn Woudt wrote:
 
  On Mon, Mar 4, 2013 at 6:10 PM, John Taylor-Johnston 
  john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
  
You could echo HTML code e.g.
  
   Which is still purely HTML and has nothing whatsoever to do with PHP.
  
   
form action=result.php method=post
Number: input id=quantity type=text /
button type=button onclick=OpenWindow()Submit**/button
/form
   
or include it as one of your form attributes:
   
form action=demo_form.asp method=get target=_blank
  First name: input type=text name=fnamebr
  Last name: input type=text name=lnamebr
  input type=submit value=Submit
/form
   Again, pure HTML, and no PHP involved. Specifically, the (asp??) page
   called in the form action handler will never even be aware of the 
   fact
   that the page was opened in a new window, or at least was supposed 
   to.
  
  
   I was using an example and NOT intended to show ASP.
  
   target=_blank will open a new window every time. That will defeat the
   purpose.
  
   I have many different submit buttons, for different purposes. Depending on
   the $_POST value of each submit button, I tell PHP to do different things,
  
  
  I don't wanna interrupt this thread, but are you sure you want multiple
  submit buttons, especially more than two?
  There are probably better solutions for what you want, for example, radio
  button to select which action to take?
  
  - Matijn
 
 I have to agree with Matijn for this reason: If the user hits the
 [Enter] button at the end of their form data entry, it will trigger the
 *first* submit button on the page, which may or may not be what you
 want. Perhaps better to have the user indicate the action they wish via
 radio button (as Matijn suggested) and then a single submit button.
 
 Paul
 
 -- 
 Paul M. Foster
 http://noferblatz.com
 http://quillandmouse.com
 


I don't know if that would hold true for forms that contain multiple
submit buttons.

There are plenty of good reasons though for multiple submit buttons in a
form, such as a shopping cart where each button is tied to a product and
allows it to be removed.

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




Re: [PHP] Not counting my own page visits

2013-03-04 Thread Ashley Sheridan
On Tue, 2013-03-05 at 10:19 +1030, David Robley wrote:

 Angela Barone wrote:
 
  On Mar 4, 2013, at 11:33 AM, Ashley Sheridan wrote:
  You can manually write a cookie on your machine, or use a special script
  that only you visit that contains a setcookie() call (it only need be set
  once). From there on, you can check the $_COOKIES super global for the
  presence of your cookie.
  
  I don't know why, but I can't get cookies to work.  Here's a script I'm
  calling from my browser:
  
  ?php
  $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ?
  $_SERVER['HTTP_HOST'] : false;
  $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain);
  ?
  
  !DOCTYPE html
  html lang=en
  head
  meta charset=utf-8 /
  titleTest Page/title
  /head
  body
  ?php echo 'Cookie is: '.$_COOKIE[$cookie].br; ?
  ?php echo 'Domain is: '.$domain.br; ?
  /body
  /html
  
  The domain is being displayed but the cookie is not.  There's no cookie in
  the browser prefs, either.  What am I doing wrong?
  
  Angela
 
 Misunderstanding what $cookie contains? It is a boolean, i.e. it will be 
 true or false depending on whether the cookie was set or not. To echo the 
 contents of a cookie, you need to use the cookie name, viz
 
 ?php echo 'Cookie is: '.$_COOKIE['test2'].br; ?
 
 -- 
 Cheers
 David Robley
 
 Oxymoron: Sisterly Love.
 
 


Not just that, but if you set a cookie, you won't be able to retrieve it
in the same script I believe. It's only available in the $_COOKIES array
once you refresh the page, as that's when the super global is populated
from the cookie data that the browser sends.

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




Re: [PHP] Stupid question

2013-02-26 Thread Ashley Sheridan


Daniel Brown danbr...@php.net wrote:

On Tue, Feb 26, 2013 at 4:27 PM, Curtis Maurand cur...@maurand.com
wrote:
 I have the following:

 $dsn = mysqli://$username:$password@$hostname2/$database;
 $options = array(
 'debug' = 3,
 'result_buffering' = false,
   );
   $dbh = MDB2::factory($dsn, $options);
 if (PEAR::isError($mdb2))
 {
 die($mdb2-getMessage());
 }




 function tallyCart($_u_id,$dbh){
while($row = $result-fetchrow(MDB2_FETCHMODE_ASSOC)) {
 $_showCheckOut=1;
 $_pdetail=new ProductDetail($row{'product_ID'},
 $row{'product_Quantity'}, $_u_id);
  $_getSubTotal += $_pdetail-_subTotal;
  $_counter++;
 }
 }

 I'm getting:  Call to undefined method MDB2_Error::fetchrow()

 anyone have any ideas?  Can I not pass a database handle to a
function?

 Thanks,
 Curtis

Hate to answer a question with a question, but:

1.) Do you have the PEAR package MDB2 installed?
2.) Where is $result defined?  I don't see it in your code snippet
here.

Also, there is no such thing as a stupid question, only a stupid answer...

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

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



Re: [PHP] stripped \n

2013-02-20 Thread Ashley Sheridan
On Wed, 2013-02-20 at 13:47 -0500, Jim Giner wrote:

 On 2/20/2013 1:32 PM, Matijn Woudt wrote:
  On Wed, Feb 20, 2013 at 7:16 PM, John Taylor-Johnston 
  john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
 
  Hi,
  I have a textarea when submitted creates a new form with the textarea
  data in a hidden field:
 
  input name=DPRnarration type=text hidden form=DPRform value=Enter
  call
 
  narration here.
 
  But when this new form gets resubmitted, the \n get stripped?
 
  input name=DPRnarration type=text hidden form=DPRform value=Enter
  callnarration here.
 
  I don't get it.
 
  There is nothing in my code that is stripping the \n?
 
  input name=DPRnarration type=text hidden form=DPRform value=?php
  echo stripslashes($_POST[**DPRnarration]);?
 
  Do I need to put it in another textarea and declare it hidden?
 
 
  An input with type=text is used for single lines, so yes, newlines get
  stripped.
  Either use a textarea with style=display: none, or store the data in a
  session instead.
 
  - Matijn
 
 Actually - an input type=text may be intended for single lines, but my 
 test shows that it does not drop the \ all by itself.
 
 And actually, the poster's question is very difficult to understand, 
 simply because I do believe he doesn't know anything about html or php. 
   Probably building something from examples he has seen.
 
 1 - he doesn't show a textarea tag in his examples
 2 - his sample of his code is such a small fragment we can't tell WHAT 
 he is doing.
 
 Most likely the problem is his use of stripslashes in that last code 
 line he provided.  I wonder if he knows what that does?
 


Also, with the example:

input name=DPRnarration type=text hidden form=DPRform
value=Enter call

narration here.


There is no hidden attribute for input elements, and no form attribute
either. If there's a need to stuff elements with extra attributes then
it's best to use data- attributes.

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




Re: [PHP] phpinfo()

2013-02-20 Thread Ashley Sheridan
On Wed, 2013-02-20 at 14:23 -0500, John Taylor-Johnston wrote:

 
 Design in Motion Webdesign wrote:
 
 
 
  John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote:
 
  I cannot find button2 in phpinfo() when I click it. I was hoping to
  find
  a $_POST[button2] value.
  What am I doing wrong?
 
  input type=button name=button2 id=button2 value=Print Mode
  onclick=formSubmit()
 
  I really wanted to use a button to pass a different condition than a
  input type=submit
 
  Use a different value or name on the input type=submit/ button. 
  Don't use JavaScript to trigger the form like that. Its not necessary 
  and will bite you in the ass if ypu get a visitor who browses without 
  JavaScript, which can include security aware users, blind users, etc
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  Try $_POST['button2']
 
  Best regards.
  Steven
 
 
 $_POST['button2'] does not exist. I'm using radio to get aorund it for 
 now. A button would have been cleaner.
 
 


input type=submit name=button2 value=button/

Not sure what you have against submit buttons, because this will do what
you want and you don't need to be doing whatever it is you're doing with
radio buttons?

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




Re: [PHP] phpinfo()

2013-02-19 Thread Ashley Sheridan


John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote:

I cannot find button2 in phpinfo() when I click it. I was hoping to
find 
a $_POST[button2] value.
What am I doing wrong?

input type=button name=button2 id=button2 value=Print Mode 
onclick=formSubmit()

I really wanted to use a button to pass a different condition than a 
input type=submit

Use a different value or name on the input type=submit/ button. Don't use 
JavaScript to trigger the form like that. Its not necessary and will bite you 
in the ass if ypu get a visitor who browses without JavaScript, which can 
include security aware users, blind users, etc
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] Undefined Variables

2013-02-14 Thread Ashley Sheridan


Roman Gelfand rgelfa...@gmail.com wrote:

Is there a performance hit when a variable is undefined? or, perhaps,
aside from the obvious uncontrolled conditions, are there other
impacts?

Thanks in advance

Aside from all the warnings and potential logic bombs?

You will have a negligible performance hit with all the isset() checks you'll 
be using, but they won't be noticeable, and its preferred to use them than not 
to avoid issues with missing values.
Thanks,
Ash
http://www.ashleysheridan.co.uk

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



Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread Ashley Sheridan
On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:

 On Sun, Jan 27, 2013 at 3:10 AM, jupiter jupiter@gmail.com wrote:
  Hi,
 
  I  have a client.php which calls an external python socket client
  program exec(Client.py), the Client.py calls
  sockobj.connect((localhost, 6)) to connect socket.
 
  If I run the client.php from Linux command line $ ./client.php, it
  works find, no problem at all.
 
  But when I run it from web page http://localhost/client.php, it could
  not connect to socket at following exception in python
  sockobj.connect((localhost, 6)):
 
  sockobj.connect Errno 13 Permission denied
 
  Why it can run from command line, but cannot make socket connection
  from web? Does it need some kind of configuration in php or apache?
  Appreciate any tips and clues.
 
  Thank you.
 
  Kind regards.
  I am puzzled by
 
 First question: why use a separate program and language to call a
 socket? PHP has two ways of doing it, using the Socket extension and
 using the Stream extension. The Stream extension is a little nicer as
 you just use standard PHP file functions on it.
 
 To look here, though, you might want to look at the permissions on
 client.py to make sure it as well as the requisite paths to get to the
 script are readable and executable by the user running your webserver,
 or alternatively, your php scripts if running something like fcgi.
 


I'll take a bet that the Apache server is running as a different user
from your login, and doesn't have permissions to open sockets. You could
either give the Apache user permissions, or put the exec call as part of
an argument of sudo.

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




Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread Ashley Sheridan
On Sun, 2013-01-27 at 21:40 +1100, jupiter wrote:

 On 1/27/13, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
  On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
 
  On Sun, Jan 27, 2013 at 3:10 AM, jupiter jupiter@gmail.com wrote:
   Hi,
  
   I  have a client.php which calls an external python socket client
   program exec(Client.py), the Client.py calls
   sockobj.connect((localhost, 6)) to connect socket.
  
   If I run the client.php from Linux command line $ ./client.php, it
   works find, no problem at all.
  
   But when I run it from web page http://localhost/client.php, it could
   not connect to socket at following exception in python
   sockobj.connect((localhost, 6)):
  
   sockobj.connect Errno 13 Permission denied
  
   Why it can run from command line, but cannot make socket connection
   from web? Does it need some kind of configuration in php or apache?
   Appreciate any tips and clues.
  
   Thank you.
  
   Kind regards.
   I am puzzled by
 
  First question: why use a separate program and language to call a
  socket? PHP has two ways of doing it, using the Socket extension and
  using the Stream extension. The Stream extension is a little nicer as
  you just use standard PHP file functions on it.
 
  To look here, though, you might want to look at the permissions on
  client.py to make sure it as well as the requisite paths to get to the
  script are readable and executable by the user running your webserver,
  or alternatively, your php scripts if running something like fcgi.
 
 
 
  I'll take a bet that the Apache server is running as a different user
  from your login, and doesn't have permissions to open sockets. You could
  either give the Apache user permissions, or put the exec call as part of
  an argument of sudo.
 
 Well, it is apache for both user id and group id if you are running
 from web server. The problem is not which user account, I can run it
 without any problems from command line in any user accounts, the
 problem is it got permission denied when you run from web server.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 


So you've logged on/sudo'd as the Apache user and the command runs?

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




RE: [PHP] Can't connect to MySQL via PHP

2013-01-13 Thread Ashley Sheridan
On Sun, 2013-01-13 at 11:37 -0800, admin wrote:

 
  -Original Message-
  From: tamouse mailing lists [mailto:tamouse.li...@gmail.com]
  Sent: Saturday, January 12, 2013 7:55 PM
  To: admin
  Cc: a...@ashleysheridan.co.uk; Rick Dwyer; php-general@lists.php.net
  Subject: Re: [PHP] Can't connect to MySQL via PHP
  
  On Sat, Jan 12, 2013 at 4:49 PM, admin ad...@buskirkgraphics.com
  wrote:
   As much as the php list would like to force people from using mysql,
  I guess you should not have invented it, if you don't want people to
  still use it.
  
  It's not this php list. It's the php developers. mysql* functions are
  set to be removed in a release coming soon.
  
  Time marches on. mysql* functions were written first, then the mysqli*
  functions were written. mysql* is old, out of date, and not begin
  supported.
  
  Should not have written it? Maybe? But maybe no libraries should have
  been written, nothing should move forward, better ways should not have
  been found.
  
  Maybe you want to do your computing using pebbles, too.
 
 
 
 So let me understand how this works.
 Someone ask for help, no matter what version they are using or function that 
 is currently in place.
 We slam them.
 Call them an idiot.
 
 Not that they ask a question about a function in the CURRENT version. Yes the 
 documentation does fully express the function is depreciated, but let's deal 
 with the now.
 So let's NOT answer the question? (Hello, welcome to MICROSOFT)
 I am very glad 90% of other languages that have list don't have the same 
 approach.
 They would gladly give you the answer, but then go on to express how they may 
 suggest this (with example) because it is (safer, easier, ect...).
 
 Every time I see someone give a simple answer in an approach to help them 
 learn, in comes the marching band of ignorance and they are toting the banner 
 of epic fail.
 This is a list to help people understand php and grow the community and 
 knowledge base of its inner workings. 
 If you want to answer at question please at least use SOMETHING that is 
 conducive to educating them.
 


At no point was I slamming someone for using the old functions, in-fact
I was trying to make a joke of that and point out that the msqli
functions would be better, unless you really do believe that kittens
will kill programmers...

The thing is most of us expect the person asking the question here to
have done at least a little bit of research into the problem, even if
that only extends to I'll Google some of these keywords in the error.
That should at least have produced the same advice about those old
deprecated functions, but I wanted to reiterate it a bit just to be
sure. It can't hurt to know something like that.

The fact is, what you considered a simple answer was bad advice, and
would have just taught more people that those old functions are fine,
when in-fact they are not. I think it's very important to make people
aware of security concerns, especially if they're a beginner with the
language.

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




RE: [PHP] Can't connect to MySQL via PHP

2013-01-12 Thread Ashley Sheridan
On Sat, 2013-01-12 at 12:56 -0800, admin wrote:

 
  -Original Message-
  From: Rick Dwyer [mailto:rpdw...@earthlink.net]
  Sent: Saturday, January 12, 2013 8:26 AM
  To: php-general@lists.php.net
  Subject: [PHP] Can't connect to MySQL via PHP
  
  Hello all.
  
  I used the code below successfully to connect to a MySQL db on one
  hosting provider.  I've moved the code to a new hosting provider with
  new values and it returns:
  
  Access denied for user 'user'@'db.hostprovider.net' (using password:
  YES)
  
  Even though I can copy and paste these three values (host, user and
  pass) and paste into Navicat to make a connection.  So the credentials
  are correct, but they are not authenticating when used in PHP.  I've
  tried making host localhost and 127.0.0.1. both with the same
  result.
  
  Can someone tell me what I am doing wrong here?
  
  Appreciate it.
  
  Thanks,
  --Rick
  
  
  
  $db_name = mydb;
  $vc_host= db.hostprovider.net;
  $vc_user= user;
  $vc_pass= pass;
  
  $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db =
  mysql_select_db($db_name, $connection);
  
  echo mysql_error();
  
  
  
  
  --
  PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
  http://www.php.net/unsub.php
 
 
 Try this for me
 
 ---
 
 $db = mysql_connect($vc_host, $vc_user, $vc_pass); 
 mysql_select_db($db_name, $db);
 
 if (!$db) {
 die('Could not connect: ' . mysql_error());
 }
 echo 'Connected successfully';
 mysql_close($db);
 
 
 
 
 


Please at least use mysqli_* functions. Every time someone recommends we
use mysql_* functions, a kitten kills a programmer.

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




RE: [PHP] Can't connect to MySQL via PHP

2013-01-12 Thread Ashley Sheridan


admin ad...@buskirkgraphics.com wrote:

 

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Saturday, January 12, 2013 10:03 AM
To: admin
Cc: 'Rick Dwyer'; php-general@lists.php.net
Subject: RE: [PHP] Can't connect to MySQL via PHP

 

On Sat, 2013-01-12 at 12:56 -0800, admin wrote: 

 
 
 -Original Message-
 From: Rick Dwyer [mailto:rpdw...@earthlink.net]
 Sent: Saturday, January 12, 2013 8:26 AM
 To: php-general@lists.php.net
 Subject: [PHP] Can't connect to MySQL via PHP
 
 Hello all.
 
 I used the code below successfully to connect to a MySQL db on one
 hosting provider.  I've moved the code to a new hosting provider with
 new values and it returns:
 
 Access denied for user 'user'@'db.hostprovider.net' (using password:
 YES)
 
 Even though I can copy and paste these three values (host, user and
 pass) and paste into Navicat to make a connection.  So the
credentials
 are correct, but they are not authenticating when used in PHP.  I've
 tried making host localhost and 127.0.0.1. both with the same
 result.
 
 Can someone tell me what I am doing wrong here?
 
 Appreciate it.
 
 Thanks,
 --Rick
 
 
 
 $db_name = mydb;
 $vc_host= db.hostprovider.net;
 $vc_user= user;
 $vc_pass= pass;
 
 $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db =
 mysql_select_db($db_name, $connection);
 
 echo mysql_error();
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
Try this for me
 
---
 
$db = mysql_connect($vc_host, $vc_user, $vc_pass); 
mysql_select_db($db_name, $db);
 
if (!$db) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($db);
 
 
 
 
 


Please at least use mysqli_* functions. Every time someone recommends
we use mysql_* functions, a kitten kills a programmer.


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



 

Ash,

  The question was asked about mysql functions. 

As much as the php list would like to force people from using mysql, I
guess you should not have invented it, if you don't want people to
still use it.

 

Shoots a small fluffy kitten with big blue eyes... Waste a cap save a
gui

 

 

 

Actually, the question never mentioned mysql_* functions, so telling someone to 
use them is wrong.

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

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



RE: [PHP] Can't connect to MySQL via PHP

2013-01-12 Thread Ashley Sheridan
On Sat, 2013-01-12 at 19:53 +, Ashley Sheridan wrote:

 
 admin ad...@buskirkgraphics.com wrote:
 
  
 
  
 
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: Saturday, January 12, 2013 10:03 AM
 To: admin
 Cc: 'Rick Dwyer'; php-general@lists.php.net
 Subject: RE: [PHP] Can't connect to MySQL via PHP
 
  
 
 On Sat, 2013-01-12 at 12:56 -0800, admin wrote: 
 
  
  
  -Original Message-
  From: Rick Dwyer [mailto:rpdw...@earthlink.net]
  Sent: Saturday, January 12, 2013 8:26 AM
  To: php-general@lists.php.net
  Subject: [PHP] Can't connect to MySQL via PHP
  
  Hello all.
  
  I used the code below successfully to connect to a MySQL db on one
  hosting provider.  I've moved the code to a new hosting provider with
  new values and it returns:
  
  Access denied for user 'user'@'db.hostprovider.net' (using password:
  YES)
  
  Even though I can copy and paste these three values (host, user and
  pass) and paste into Navicat to make a connection.  So the
 credentials
  are correct, but they are not authenticating when used in PHP.  I've
  tried making host localhost and 127.0.0.1. both with the same
  result.
  
  Can someone tell me what I am doing wrong here?
  
  Appreciate it.
  
  Thanks,
  --Rick
  
  
  
  $db_name = mydb;
  $vc_host= db.hostprovider.net;
  $vc_user= user;
  $vc_pass= pass;
  
  $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db =
  mysql_select_db($db_name, $connection);
  
  echo mysql_error();
  
  
  
  
  --
  PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
  http://www.php.net/unsub.php
  
  
 Try this for me
  
 ---
  
 $db = mysql_connect($vc_host, $vc_user, $vc_pass); 
 mysql_select_db($db_name, $db);
  
 if (!$db) {
 die('Could not connect: ' . mysql_error());
 }
 echo 'Connected successfully';
 mysql_close($db);
  
  
  
  
  
 
 
 Please at least use mysqli_* functions. Every time someone recommends
 we use mysql_* functions, a kitten kills a programmer.
 
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
  
 
 Ash,
 
   The question was asked about mysql functions. 
 
 As much as the php list would like to force people from using mysql, I
 guess you should not have invented it, if you don't want people to
 still use it.
 
  
 
 Shoots a small fluffy kitten with big blue eyes... Waste a cap save a
 gui
 
  
 
  
 
  
 
 Actually, the question never mentioned mysql_* functions, so telling someone 
 to use them is wrong.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 


Sorry, just re-read the OP and realised he was using the mysql_*
functions.

I still stand by my statement of not using them though. People should be
advised that the functions are deprecated fully now and are not safe to
use.

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




Re: [PHP] Pear Page2

2013-01-05 Thread Ashley Sheridan
On Sat, 2013-01-05 at 15:23 +0100, Silvio Siefke wrote:

 Hello,
 
 On Sat, 05 Jan 2013 07:53:04 +
 Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 
  I'm not sure quite what you'd expect such a module to do? Is this for
  templating?
 
 page2 creates complete websites. Would be useful because I'm sitting 
 at the website internationalization. Template engines seem complicated.
 
 
 Thank you for help, Greetings
 Silvio
 


I've just had a quick look at page2, and I can't say I see the point.
You'd end up having to write a lot more code that was harder to manage
by adding each element through a class like that if your site got even
moderately complicated.

There are many templating engines, and some are more complicated than
others, don't write them off just yet. Technically speaking, page2 is a
template engine of a kind, so you're already using one.

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




Re: [PHP] Pear Page2

2013-01-05 Thread Ashley Sheridan


Silvio Siefke siefke_lis...@web.de wrote:

Hello,

On Sat, 05 Jan 2013 14:52:12 +
Ashley Sheridan a...@ashleysheridan.co.uk wrote:

 I've just had a quick look at page2, and I can't say I see the point.
 You'd end up having to write a lot more code that was harder to
manage
 by adding each element through a class like that if your site got
even
 moderately complicated.
 
 There are many templating engines, and some are more complicated than
 others, don't write them off just yet. Technically speaking, page2 is
a
 template engine of a kind, so you're already using one.

Page2 dominated not HTML5. The websites at issue are in HTML5
written.
So an alternative must be sought to Page2.

Thanks for help, Greetings
Silvio

If the pages are already written, why do you want to start changing the way 
they've been built?

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

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



Re: [PHP] Pear Page2

2013-01-05 Thread Ashley Sheridan


Silvio Siefke siefke_lis...@web.de wrote:

Hello,

On Sat, 05 Jan 2013 17:21:05 +
Ashley Sheridan a...@ashleysheridan.co.uk wrote:

 If the pages are already written, why do you want to start changing 
 the way they've been built?

1.) All websites are created manually. (nano + html/css Tags)
2.) The maintenance effort now is not enough.
3.) The programming (PHP) provides opportunities, which I'd like to
meet.
4.) curiosity
5.) enough time 

Me was helped a lot in forums and mailing lists. I would like it back,
because 
that's the idea of ​​Open Source. Maybe I can help someone be in the
distant 
future on a project. For that I must even try to learn once, and read.

Is that all one reason or think I'm wrong?


Thank you for help, Greetings
Silvio

What I would start to do is break out common parts of pages to include files. 
This would be stuff like headers, footers, sidebars, etc.
From there, you could use variables to set things like titles, stylesheets, 
nav items, etc. I've had to do this recently on a project that was written as 
a bunch of static files.
At worst, you could update the page2 templating engine to account for your new 
elements. But like I said, I think the very style page2 uses is extremely 
limiting, and will make maintenance later on.

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

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



Re: [PHP] Pear Page2

2013-01-05 Thread Ashley Sheridan
On Sat, 2013-01-05 at 22:24 +0100, Silvio Siefke wrote:

 Hallo,
 
 On Sat, 5 Jan 2013 15:40:56 -0500
 Tedd Sperling t...@sperling.com wrote:
 
 
  Not mine.
 
 What should me say this two words? You not use nano, ok. Editors enough
 on earth. Or you not write manually? Then share the way! Or use a CMS?
 
 Thank you for help, Kind Regards
 Silvio
 


Personally, I favour CodeIgniter as a framework to handle stuff like
routes and stuff. I do the templates like this:


 1. Call up the template.php view and pass across name of content
view to use for the page/section and other page-specific bits
 2. Template view pulls in header view and populates it with default
head stuff, which can be overridden with stuff from step 1
 3. Template view pulls in the main content view which deals with
that page
 4. Template view pulls in footer view and populates it in the same
way as header

This is the most basic example, but often the template view will deal
with other bits like navigation bars, sidebars, and other shared
sections. You need not limit yourself to one template view either, you
could have several depending on the section of the site.

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




Re: [PHP] Pear Page2

2013-01-04 Thread Ashley Sheridan
On Fri, 2013-01-04 at 20:44 -0600, tamouse mailing lists wrote:

 On Fri, Jan 4, 2013 at 8:18 PM, Silvio Siefke siefke_lis...@web.de wrote:
  Is there something similar to Pear/Page2 module, that can working with 
  HTML5?
 
 Would phptal be of use? http://phptal.org/
 


I'm not sure quite what you'd expect such a module to do? Is this for
templating?

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




Re: [PHP] Shopping Cart Discount System

2012-12-31 Thread Ashley Sheridan


Karl DeSaulniers k...@designdrumm.com wrote:

Hello Everyone,
Hope all are well. Quick and hopefully painless question.
Is there any examples on how to build a discount system
into your shopping cart out there that anyone knows of?
I am using MySQL and PHP. I have built one of my own so far,
but am having trouble making sense of what goes where.

For example. If a product has miscellaneous charges,
lets say.. glitter is extra on your shirt.
How is discounts applied? I mean, as far as discounts go,
lets say its 20% a shirt and this shirt has glitter.
Is it best practice to apply the discount to just the shirt
or the shirt and glitter as a combo discount.
I know this is somewhat dependent on the owners choice
of what he/she wants to give the discount on,
but my question is of the programing of it.
Do I build conditions for the shirt to get a discount applied
then the miscellaneous charges, or combine the totals of the two,
then apply the discount to the sum?

Then lets say there is a cart discount also being applied.
Is it best practice to apply this to the total of items then
add the shipping, rush charges and tax, or to the total of the whole  
cart
including shipping, rush charges then add the tax after applying the  
discount?

Sorry for the run-on question, hope this makes sense enough to merit  
help.

HNY,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com

PS: Because this question could be answered by either database or  
general, is the only reason for the double post.
Wont be making a habit of it.. :)

I would apply the discounts where they made sense from a customer POV. Would 
you expect a t-shirt discount to be applied to only the base item or the 
product as a whole? I'd say tge whole thing. You could have various areas in 
your code that apply discounts at different levels: per item, per group of 
items (bogof, etc), and per basket.


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

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



Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Ashley Sheridan
On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote:

 Hello,
 
 I have created a simple function that prints a personalized greeting by 
 reading
 the greeting contents from a file. I pass the user's name to the function,
 and the function reads the file contents into a string variable. I am then
 using str_replace to replace the word USER in the string with the user's
 name that was passed to the function. Then the function correctly prints
 the personalized greeting as I wish.
 
 My question is, is there another way to do something similar, such as
 embedding a variable name directly into the text file? In other words,
 instead of my text file reading:
 
 Hello USER ...
 
 Can I do something like this:
 
 Hello $user_name ...
 
 and then write my function to replace $user_name with the passed
 parameter prior to printing?
 
 The reason I ask is because I am going to want to do three substitutions,
 and I'd rather not do three str_replace calls if I don't have to. Plus the
 latter seems to be a more robust way of making the changes.
 
 Thanks, and apologies if this has been asked before and I missed it. I'm
 just not sure how to phrase this for a search engine.
 
 Nelson  


You could use an existing templating solution, like Smarty, although for
what you want to do it might be overkill. A few str_replace() calls
shouldn't produce too much overhead, but it depends on the size of the
text string in question. If it's just a couple of paragraphs of text, no
problem, something closer to a whole chapter of a book will obviously be
more expensive.

You could try eval() on the block of text, but if you do, be really
careful about what text you're using. I wouldn't recommend this if
you're using any text supplied by a user. As a last option, you could
have the text stored as separate parts which you join together in one
string later. This might be less expensive in terms of processing power
required, but it also makes maintenance more of a hassle later.


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




Re: [PHP] storing searching docs

2012-12-15 Thread Ashley Sheridan
On Sat, 2012-12-15 at 12:21 -0500, Jim Giner wrote:

 On 12/15/2012 8:26 AM, tamouse mailing lists wrote:
  On Dec 13, 2012 4:50 PM, Jim Giner jim.gi...@albanyhandball.com wrote:
 
  Thanks for all the posts.  After reading and googling all afternoon, I
  think the best approach for me is:
 
  Create two macros in Word (done!) to export each of my .doc files to .txt
  and .pdf formats.
 
  Create a sql table to hold the .txt contents of my .doc files, along with
  a reference to the meeting date and the name of the corresponding .pdf file.
 
  Upload my two sets of files with an ftp client and then use a script to
  load the table with my .txt file data.
 
 
  Why not use php to upload the set of files?
 
  Now I just need a couple of scripts to allow a user to locate a file and
  bring up the pdf for when he wants to read about a meeting.  And a second
  script to accept user input (search words) and perform a query against the
  textual data and present some kind of results - probably a listing
  containing a reference to the meeting date and a tbd-length string showing
  the matching result for each occurrence, ie, something like n chars in
  front of and after the match so the user can see the context of the match.
 
  Sizes - a 28k .doc file grows to 142kb in .pdf format and is only 5kb in
  .txt format.  (actually, if I 'print' the .doc as a pdf instead of using
  the Word's File,Save as, the resulting pdf is only 70kb.  Might need a
  new macro!)
 
  Thanks again!
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 cause I dont' now how php could do such a thing?  The only way I know of 
 is thru a 'file' input on an html page which is a pia since I would have 
 to do it for each file.  With an ftp client I can just drag/drop the 
 files in 10 seconds.  In the future, as I add additional docs, one at a 
 time, I'll have a simple html form for doing that.
 


I believe Chrome supports drag and drop for file inputs now. I do know
that Chrome and Firefox support multiple uploads from one form element
without the need for things like Uploadify.

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




Re: [PHP] storing searching docs

2012-12-13 Thread Ashley Sheridan
On Thu, 2012-12-13 at 18:41 +0100, Matijn Woudt wrote:

 On Thu, Dec 13, 2012 at 5:13 PM, Jim Giner 
 jim.gi...@albanyhandball.comwrote:
 
  On 12/13/2012 10:56 AM, Bastien wrote:
 
 
 
  Bastien Koert
 
  On 2012-12-13, at 9:10 AM, Jim Giner jim.gi...@albanyhandball.com
  wrote:
 
   Thanks for the input gentlemen.  Two opposing viewpoints!
 
  I understand the concept of using files for the docs and a table to
  locate them and id them.  But I am of the opinion that modern dbs are
  capable of handling very large objects (of which these docs are NOT!) much
  easier than years ago, so I am leaning that way still.  It will certainly
  make my search process easier!
 
  More comments anyone?
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  I got away from storing blobs in the db. I noticed significant slowness
  after the db grew to about 12gb in MySQL. Back ups also get affected as
  they take longer. This was older MySQL. But it also affected my mssql
  server the same way.
 
  Nowadays it's files into the file system and data into the db. One thing
  you could consider is reading the contents of the into a db field and just
  store the text to allow the full text search
 
  Bastien
 
   A very clever idea!  I like it - the best of both worlds.  Can you sum
  up a method for getting the text out of the .doc (or .rtf) files so that I
  can automate the process for my past and future documents?
  Is there a single php function that would accomplish this?
 
 
 There's no builtin function for such stuff. doc files are quite tricky to
 parse, but rtf files can be parsed pretty easily. One project is PHPRtfLite
 [1], which provides you an API for doing this.
 
 - Matijn
 
 [1] http://sourceforge.net/projects/phprtf/


As well as rtf, the OpenDoc format is easy to read from PHP. Essentially
it's just a bunch of XML files zipped up. Images are kept in the archive
too, which is a handy way to retrieve thumbnails of docs also!

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




Re: [PHP] Re: preg_replace question

2012-12-12 Thread Ashley Sheridan


Maciek Sokolewicz maciek.sokolew...@gmail.com wrote:

On 12-12-2012 17:11, Curtis Maurand wrote:
 I have several poisoned .js files on a server.  I can use find to
 recursively find them and then use preg_replace to replace the
string.
 However the string is filled with single quotes, semi-colons and a
lot
 of other special characters.  Will
 preg_relace(escapeshellarg($String),$replacement) work or do I need
to
 go through the entire string and escape what needs to be escaped?

 --C

First of all, why do you want to use preg_replace when you're not 
actually using regular expressions??? Use str_replace or stri_replace 
instead.

Aside from that, escapeshellarg() escapes strings for use in shell 
execution. Perl Regexps are not shell commands. It's like using 
mysqli_real_escape_string() to escape arguments for URLs. That doesn't 
compute, just like your way doesn't either.

If you DO wish to escape arguments for a regular expression, use 
preg_quote instead, that's what it's there for. But first, reconsider 
using preg_replace, since I honestly don't think you need it at all if 
the way you've posted 
(preg_replace(escapeshellarg($string),$replacement)) is the way you
want 
to use it.

- Tul

Sometimes if all you know is preg_replace(), everything looks like a nail...

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



Re: [PHP] Storing passwords in session variables

2012-12-11 Thread Ashley Sheridan
On Tue, 2012-12-11 at 08:46 -0400, Paul Halliday wrote:

 Hi,
 
 I have a form that has username and password fields. While the form
 exists and contains various other fields the most common mode of
 operation is to have the form auto submit if it has enough arguments
 in the URL. So, someone is using an external program that has links
 wired as such:
 
 test.php?start=1end=2this=blahthat=arghusername=userpassword=pass
 
 and when they hit that URL it sees it has enough arguments, fires and
 returns the result.
 
 Client - Server is encrypted,  can I toss these into session variables?
 
 The user could be coming from multiple frontends and it would be nice
 to forgo the user/pass in the url; give the username focus on the
 first visit let them drop their creds and then store them into the
 session so with each subsequent hit they can just get their results.
 
 Make sense?
 
 Note: I need to pass the credentials to an external app each time a
 request is made.
 
 Thanks.
 
 -- 
 Paul Halliday
 http://www.pintumbler.org/
 


It looks like you're trying to re-invent authorisation procedures.
Typically, the first request logs a client in and retrieves a hashed
key, which is then used in all subsequent requests so that the server
can correctly verify the client. You can do this the way you suggested
with the session, but you must ensure that the session id is passed
across to your script by each of the connecting clients. That will be
done either as part of the head request, or as an extra parameter in the
URL.

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




Re: [PHP] Storing passwords in session variables

2012-12-11 Thread Ashley Sheridan
On Tue, 2012-12-11 at 08:58 -0400, Paul Halliday wrote:

 On Tue, Dec 11, 2012 at 9:02 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
 On Tue, 2012-12-11 at 08:46 -0400, Paul Halliday wrote: 
 
  Hi,
  
  I have a form that has username and password fields. While the form
  exists and contains various other fields the most common mode of
  operation is to have the form auto submit if it has enough arguments
  in the URL. So, someone is using an external program that has links
  wired as such:
  
  
 test.php?start=1end=2this=blahthat=arghusername=userpassword=pass
  
  and when they hit that URL it sees it has enough arguments, fires 
 and
  returns the result.
  
  Client - Server is encrypted,  can I toss these into session 
 variables?
  
  The user could be coming from multiple frontends and it would be 
 nice
  to forgo the user/pass in the url; give the username focus on the
  first visit let them drop their creds and then store them into the
  session so with each subsequent hit they can just get their results.
  
  Make sense?
  
  Note: I need to pass the credentials to an external app each time a
  request is made.
  
  Thanks.
  
  -- 
  Paul Halliday
  http://www.pintumbler.org/
  
 
 
 
 
 It looks like you're trying to re-invent authorisation
 procedures. Typically, the first request logs a client in and
 retrieves a hashed key, which is then used in all subsequent
 requests so that the server can correctly verify the client.
 You can do this the way you suggested with the session, but
 you must ensure that the session id is passed across to your
 script by each of the connecting clients. That will be done
 either as part of the head request, or as an extra parameter
 in the URL.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
 
 I understand that. The username/pass are NOT for authentication to the
 form, they are being passed to exec();

I would say this is the username/password being used precisely for
authentication, otherwise you wouldn't need to pass them across to
exec()

 So, I guess in this context they are just arguments.
 
 Providing I handle the session properly, does it make sense to toss
 these arguments into session variables?

You can use the session, but the only way your script will know what
session to use is if the clients are sending the session id as part of
their request.




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




Re: [PHP] CSV importer tool

2012-11-27 Thread Ashley Sheridan
On Tue, 2012-11-27 at 23:03 +0100, Leandro Dardini wrote:

 Thank you, but I was looking for a cute code... letting the user to swap
 columns, ignore others, set the number of rows to initially jump, preview
 data...
 
 Leandro
 
 2012/11/27 Jim Lucas li...@cmsws.com
 
  php csv importer script


It shouldn't be too hard to code that. Most examples I've seen pull in
the first 1 or few records to aid the user as an example. Then they're
given a list of the possible fields to match against one by one.

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




Re: [PHP] Variables with - in their name

2012-11-18 Thread Ashley Sheridan
On Sun, 2012-11-18 at 01:37 -0700, Nathan Nobbe wrote:

 On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott 
 ron.pigg...@actsministries.org wrote:
 
  I have made the following variable in a form:  (I am referring the
  select )
 
  ?php
 
  $row['promo_code_prefix']  = 42;
  $row['promo_code_suffix'] = 2;
 
  echo select name=\distributor- . $row['promo_code_prefix'] . - .
  $row['promo_code_suffix'] . \ style=\text-align: center;\\r\n;
 
  ?
 
  It could be wrote:
 
  ?php
 
  echo  $distributor-42-2;
 
  ?
 
  Only PHP is treating the hyphen as a minus sign --- which in turn is
  causing a syntax error.
 
  How do I retrieve the value of this variable and over come the “minus”
  sign that is really a hyphen?
 
 
 php  ${distributor-42-2} = 5;
 php  echo ${distributor-42-2};
 5
 
 I think that's it.
 
 -nathan


I'd just try and avoid the hyphens in the variable names in the first
place if you can. Can you guarantee that everyone working on this system
will know when to encapsulate the variables in braces?

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




Re: [PHP] cron job problem

2012-10-23 Thread Ashley Sheridan
On Tue, 2012-10-23 at 16:59 -0400, Jim Giner wrote:

 On 10/23/2012 4:56 PM, Daniel Brown wrote:
  On Tue, Oct 23, 2012 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.com 
  wrote:
  I have a php script that has been triggered by my hoster's cron process(?)
  to run once a day since last March.  It's been running fine - and I've made
  no changes to it.  Suddenly in the last couple of days it is running twice
  it seems.  The whole process sends an email at its conclusion and the
  receipient tells me today that she's getting two emails only a minute 
  apart.
 
  Any ideas on why this might happen?  I haven't contact my host company yet 
  -
  thought I'd ask around first.
 
   Though not really a PHP question, there are several reasons this
  could happen, including a race condition that is being encountered due
  to a slowdown of the host system or changes to the system's
  environment.  Are the emails she's receiving identical?
 
 Yes - same msg same time
 


Are they definitely only in the cron list once? Could someone have tried
to help by adding the job into the daily.cron, but forgotten to remove
it from the regular crontab?
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] cron job problem

2012-10-23 Thread Ashley Sheridan
On Tue, 2012-10-23 at 17:12 -0400, Jim Giner wrote:

 
 
 On 10/23/2012 5:19 PM, Ashley Sheridan wrote:
 
  
  On Tue, 2012-10-23 at 16:59 -0400, Jim Giner wrote: 
  
   On 10/23/2012 4:56 PM, Daniel Brown wrote:
On Tue, Oct 23, 2012 at 4:48 PM, Jim Giner 
jim.gi...@albanyhandball.com wrote:
I have a php script that has been triggered by my hoster's cron 
process(?)
to run once a day since last March.  It's been running fine - and I've 
made
no changes to it.  Suddenly in the last couple of days it is running 
twice
it seems.  The whole process sends an email at its conclusion and the
receipient tells me today that she's getting two emails only a minute 
apart.
   
Any ideas on why this might happen?  I haven't contact my host company 
yet -
thought I'd ask around first.
   
 Though not really a PHP question, there are several reasons this
could happen, including a race condition that is being encountered due
to a slowdown of the host system or changes to the system's
environment.  Are the emails she's receiving identical?
   
   Yes - same msg same time
   
  
  
  Are they definitely only in the cron list once? Could someone have
  tried to help by adding the job into the daily.cron, but forgotten
  to remove it from the regular crontab?
  -- 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
  
  
  
 
 daily.cron?  regular crontab?  Don't know of what you speak.
 
 This is my only cron-initiated task.  My provider gives me a screen to
 enter the command and the desired time to run it and it's been that
 way for months.  I have had no need to change it so I'm surprised this
 is happening.
   


Crontab is the daemon which runs cron jobs, and some distros have set up
special files called cron.daily (or daily.cron I don't recall),
cron.hourly, etc to make it easier to schedule jobs.

As you're entering this through a control panel (presumably a web-based
one?) I would guess that's not the problem. It could be that the
hostings control panel software has had a hiccup?

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




Re: [PHP] cron job problem

2012-10-23 Thread Ashley Sheridan
On Tue, 2012-10-23 at 18:36 -0400, Jim Giner wrote:

 On 10/23/2012 6:18 PM, David OBrien wrote:
  On Tue, Oct 23, 2012 at 5:31 PM, Daniel Brown danbr...@php.net wrote:
 
  On Tue, Oct 23, 2012 at 5:34 PM, Ashley Sheridan
  a...@ashleysheridan.co.uk wrote:
 
 
  Crontab is the daemon which runs cron jobs, and some distros have set up
  special files called cron.daily (or daily.cron I don't recall),
  cron.hourly, etc to make it easier to schedule jobs.
 
   Quick clarification and correction here:
 
   The cron *daemon* is crond, while the *script* that is
  batch-processed by cron is called the crontab.  When it is executed,
  it is referred to as a cron job.
 
   That said, Ash is right about the rest.  Different OS flavors
  (BSD, Linux, UNIX, SunOS/Solaris, HP-UX, et cetera) often use
  different path and file standards.  Linux, in general, uses a command
  `crontab` which opens the local user's environment-configured editor
  to modify the user's crontab in the spool.
 
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  http://www.php.net/
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  script runs
  ntp updates server time
  script runs again?
 
 But why now?  This process has been running just fine for months.
 


Have you tried removing the job entirely from cron and re-adding it? It
might be enough to kick-start the process into behaving.
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] cron job problem

2012-10-23 Thread Ashley Sheridan
On Tue, 2012-10-23 at 18:51 -0400, Jim Giner wrote:

 On 10/23/2012 6:57 PM, Ashley Sheridan wrote:
  On Tue, 2012-10-23 at 18:36 -0400, Jim Giner wrote:
 
  On 10/23/2012 6:18 PM, David OBrien wrote:
  On Tue, Oct 23, 2012 at 5:31 PM, Daniel Brown danbr...@php.net wrote:
 
  On Tue, Oct 23, 2012 at 5:34 PM, Ashley Sheridan
  a...@ashleysheridan.co.uk wrote:
 
 
  Crontab is the daemon which runs cron jobs, and some distros have set up
  special files called cron.daily (or daily.cron I don't recall),
  cron.hourly, etc to make it easier to schedule jobs.
 
Quick clarification and correction here:
 
The cron *daemon* is crond, while the *script* that is
  batch-processed by cron is called the crontab.  When it is executed,
  it is referred to as a cron job.
 
That said, Ash is right about the rest.  Different OS flavors
  (BSD, Linux, UNIX, SunOS/Solaris, HP-UX, et cetera) often use
  different path and file standards.  Linux, in general, uses a command
  `crontab` which opens the local user's environment-configured editor
  to modify the user's crontab in the spool.
 
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  http://www.php.net/
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  script runs
  ntp updates server time
  script runs again?
 
  But why now?  This process has been running just fine for months.
 
 
 
  Have you tried removing the job entirely from cron and re-adding it? It
  might be enough to kick-start the process into behaving.
 
 Yes my host asked me to do that earlier.  And nope - no better.
 
 I have told them it's gotta be something on their end because I tested 
 the script from a browser displaying what it was doing and it ran fine. 
   Removed my debug settings and ran it from a browser and again it ran 
 fine.  Re-scheduled the cron task and it ran wrong.
 


It does sound like it's definitely a problem their end. Could you alter
the script in some way to check for a token set on the correct schedule?
Or, perhaps rename the script and set up the cron to it again, so that
if there is a secondary link to it in cron it will fail, and might give
you an idea about where it's being called from.

I know this is all a crazy attempt to prove it's a problem with the
hosting, but from experience they can sometimes be slow to recognise it
without a lot of definite proof.

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




Re: [PHP] PDO

2012-10-22 Thread Ashley Sheridan
On Mon, 2012-10-22 at 23:27 +0200, Silvio Siefke wrote:

 Hello,
 
 i have built php 5.4.7 on Ubuntu with the configure Arguments like on my 
 Gentoo System. But on Gentoo run the website without Problems, under Ubuntu
 want not work. I become in error.log:
 
 [22-Oct-2012 21:15:00 UTC] PHP Fatal error:  Call to a member function 
 prepare() on a non-object in html/index.html on line 23
 
 U use PHP FPM with Nginx. 
 
 The configure Arguments:
 http://pastebin.geany.org/qz8TP/
 
 The Script which work:
 ?php
 require_once (db.php);
 
 $query = $db-prepare(SELECT id, title, date FROM bloggen ORDER BY date DESC 
 LIMIT 0,5);
 if (!$query) {die(Execute query error, because:  . $db-errorInfo());}
 
 $query-execute();
 
 while ($row = $query-fetch(PDO::FETCH_ASSOC)) {
 echo pa href=\/blog/post.html?id=.$row['id'].\ 
 title=\.(htmlentities($row['title'], ENT_QUOTES, 
 UTF-8)).\.(htmlentities($row['title'], ENT_QUOTES, 
 UTF-8))./a/p\n;
 }
 
 $row = null;
 $query = null;
 $db = null;
 ?
 
 
 Has someone a idea what is there wrong?
 
 
 Thanks for help and nice Day.
 
 Silvio
 


It's a bit odd that you're parsing all .html files as if they were PHP
(little bit of a waste, and does mean you'll have an extra step when
configuring a server to run the code)

That aside, I don't see 23 lines of code in your example, so I'm
assuming you've snipped a lot of the beginning (you've not mentioned in
particular which line in your excerpt is the 23rd). What's in your
db.php include? Are there any checks on whether a connection has been
established or not there?
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Re: User Timezone

2012-10-21 Thread Ashley Sheridan


Karl DeSaulniers k...@designdrumm.com wrote:


On Oct 21, 2012, at 5:01 AM, Maciek Sokolewicz wrote:

 On 21-10-2012 01:11, Karl DeSaulniers wrote:
 Thanks for the response. Yes, for the US I plan on calculating by
 state, but
 this website is not geared to just the US.
 So I am looking for a solution that lets me also calculate by
 country/region.
 Was looking on google and found geoip, but not sure if this will
do
 the job
 I am looking for.
 Anyone with experience on geoip that can send pointers?

 Thanks,


 Best,
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 Geo IP is based on IP, and I must warn you that IP data is not
 always
 accurate. Especially here in Europe, companies that are based in
 multiple countries sometimes only register their IPs in a single
 country, and share them between all the countries they are active
 in.
 This will give you wrong data from GeoIP. The time difference will
 only be 1 hour at max, but still.


 That was what my own suspicions were leading to.
 I am familiar with the fact that ips can be spoofed.
 Thanks for the corroboration.

 Best,

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 As Bart said, IP is not ideal for this situation.

 Since you do have information about the location of that person (as
 in country and possible state), you can find out the timezone via a
 static database.

 The HTML5 geolocation tool is nice, and would certainly help a lot!
 However, be aware of the fact that it only works if there is the
 device on which the browser runs actually has the ability to find
 out its location. Many smartphones have GPS chips, but most PCs
 don't. Asking a PC where are you located? the PC will answer How
 should I know?.

 Luckily for you, the way of country and state is pretty easy. I've
 handed you a list to find it in the USA. For most countries in the
 world, there's a simple 1:1 mapping of timezone and country
(http://en.wikipedia.org/wiki/List_of_time_zones_by_country
 ), there are however 21 countries which have multiple timezones. In
 these cases, you'll need extra information to be able to distinguish

 between them.

 For the USA, you already have a way.
 For (ex-)colonical islands and such (such as for France), you could
 always add them to the country list:
 - France
 - France (Marquesas Islands)
 - France (Gambier)
 etc.
 Thus treating them as separate countries for your timezone db.

 In Russia, Canada, Australia, New Zealand, Brasil, Indonesia,
 Kiribati, Mexico,Congo, Ecuador, Micronesia, Kazakhstan and Mongolia

 you'll need to know their province / state to more accurately assess

 the ideal timezone.

 So for most countries, it's a simple 1:1 translation. For the above
 countries, you'll need some extra info, and translate further based
 on that. You should be able to find the info required yourself, it
 just takes a while to collect it.

 Alternatively, and this is the most simple way; since you're asking
 people for their country and such, simply also ask them about their
 timezone. Don't bother automating and putting a heck of a lot of
 time into hard to realize solutions, when you can ask a very simple
 and easy-to-answer question to the browser instead. :)

 - Tul


Yes, I had thought about asking the user his/her timezone, but being
that the product will be bought by some people who may have no idea, I

figured I would try and see if I can set it up myself.
Maybe if the country has a province, i could ask the user then what
province and get my 1:2 that way. If it is a country I can get the
timezone for, just skip that question.
Thanks for the thoughts!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com

Don't most browsers include this information in the HTTP headers?
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



RE: [PHP] foreach

2012-10-16 Thread Ashley Sheridan
On Tue, 2012-10-16 at 10:11 -0400, Steven Staples wrote:

  -Original Message-
  From: Matijn Woudt [mailto:tijn...@gmail.com]
  Steve,
  
  Please watch your language on this list.
  
  - Matijn
  
 
 My apologies, I guess using $foo == $bar would have been a better choice... I 
 forget sometimes, I am used to chatting with my close friends, where stuff 
 like that is pretty tame.
 
 I meant no disrespect to anyone.
 
 Steve Staples.
 
 


I wouldn't have said the language was violent, maybe just a tad too
'Friday', but hey.

I also prefer my braces lined up like that. Sure it results in a few
more lines, but it sure makes more sense when I'm going over old code.

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




  1   2   3   4   5   6   7   8   9   10   >