Re: [PHP] Algorithm Help

2013-10-01 Thread John Meyer

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



Re: [PHP] strlen ?

2013-07-05 Thread John Meyer

Jim Giner wrote:
Trying to manage line breaks in some output I'm generating and using 
strlen to measure the lengths of the strings I'm printing. Discovered 
something strange (to me!) in that strlen is returning +1 more than it 
should.


The strings are from a query of my database - simple name fields. But 
everyone of them is coming back with a length that is one more than I 
see.


Ex.

Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.

I've looked at my data and counted the chars - there is no extra space 
at the beginning or end in my table.


Anyone have an explanation?


Does strlen count the line feed?

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



Re: [PHP] strlen ?

2013-07-05 Thread John Meyer

MOTS:  never take any input on faith.


Jim Giner 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.





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



Re: [PHP] REQUEST

2013-05-29 Thread John Meyer

Jim Giner wrote:

On 5/29/2013 5:45 PM, Tedd Sperling wrote:


PS: I think it probably best not to rise to the bait from people who 
forgot to turn off their cap's key.




You call it bait?  I call it stupidity.  Once no, more than once YES.



Why not both?

Cue cute taco shell girl.

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



[PHP] isset empty or ...?

2013-03-30 Thread John Taylor-Johnston

I'm using

if($mydata-DPRresponselocationaddress1 != )

is this the same as

if (!isset($mydata-DPRresponselocationaddress))
http://php.net/manual/en/function.isset.php

or

if (!empty($mydata-DPRresponselocationaddress))
http://php.net/manual/en/function.empty.php

or is there another function I have not learned yet? I don't really get 
the difference between isset and empty.


John

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



[PHP] MOSSCon in Louisville in May! Submit your proposal this week!

2013-03-27 Thread John List
Preparations are in full swing for the very first Midwest Open Source 
Software Conference (MOSSCon), to be held in Louisville on May 18-19. 
Your help in spreading the word and helping us fill out our schedule of 
presentations and workshops would be appreciated.


This is going to be a great networking event for the whole region! 
Louisville is in such a central location, it can draw from a very wide area.


We have a great venue: the University of Louisville's Student Activities 
Center, with several large halls, a number of smaller meeting rooms, and 
plenty of exhibit space available for groups and businesses to make 
their presence known.


We are working on a broadly based Open theme, that can include open 
source hardware, open data, etc., as well as the full gamut of open 
source software.


We already have some super presentations lined up. But there are still 
plenty of pieces that need to come together. Right now we are 
concentrating on filling out our schedule with more presentations and 
workshops. And soliciting sponsors.


If you're involved with Open Source (or open anything) you definitely 
want to be a part of this. I encourage you to consider speaking or doing 
a presentation or workshop on a subject in your area of interest and/or 
expertise.


Check out the conference website at http://mosscon.org/. Click on Be a 
Speaker for details on submitting your proposal.


But get to it! The deadline for submitting your preliminary proposal is 
this Friday, March 29!


http://mosscon.org/

Spread the word and submit your proposal.

Thanks,

John Hicks


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



[PHP] Populate input from another form

2013-03-08 Thread John Taylor-Johnston

I have a form

form action=CRTP_Query.php id=CRTP_Query method=post 
target=_CRTPinput value=Query form=CRTP_Query type=submit/form


OnSubmit, I want to include data from another form (form=DPRform).

input name=DPRsurname type=text form=DPRform size=20 
value=?php echo stripslashes($_POST[DPRsurname]);?


I should use a hidden identical field and use form=CRTP_Query:

input name=DPRsurname type=hidden form=CRTP_Query value=?php 
echo stripslashes($_POST[DPRsurname]);?


But I have no idea how to populate the hidden field with the data from 
the viewable field. PHP cannot do this onsubmit, can it?


Anyone have an example to show me please?

Do I need to use jquery?

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



[PHP] Re: Populate input from another form

2013-03-08 Thread John Taylor-Johnston

Scratch that, IE does not like form elements outside the /form!!?? :,(
I can't a form within a form either, unless ... I float a div??.

John Taylor-Johnston wrote:

I have a form

form action=CRTP_Query.php id=CRTP_Query method=post 
target=_CRTPinput value=Query form=CRTP_Query 
type=submit/form


OnSubmit, I want to include data from another form (form=DPRform).

input name=DPRsurname type=text form=DPRform size=20 
value=?php echo stripslashes($_POST[DPRsurname]);?


I should use a hidden identical field and use form=CRTP_Query:

input name=DPRsurname type=hidden form=CRTP_Query value=?php 
echo stripslashes($_POST[DPRsurname]);?


But I have no idea how to populate the hidden field with the data from 
the viewable field. PHP cannot do this onsubmit, can it?


Anyone have an example to show me please?

Do I need to use jquery?



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



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

2013-03-04 Thread John Taylor-Johnston

 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,


input value=Update type=submit input name=DPRmode value=Enter 
Data type=submit


I want to open a different window when I press: input name=DPRmode 
value=Enter Data type=submit


I guess the best I can hope for is to try

input name=DPRmode value=Enter Data type=submit 
onclick=OpenWindow()


button type=button onclick=OpenWindow()Submit/button will not 
submit the form contents.


Thanks,


Re: [PHP] Open form in new window

2013-03-04 Thread John Taylor-Johnston



If you want to open a new page in response to a submit button press 
(using PHP) you may be out of luck. I don't know of a way to do it 
without involving another language. Opening a different page in the 
*same* window, yes. Otherwise, no. But watch the other replies. Maybe 
someone knows something I don't. Paul 

Nope. Out of luck.


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



[PHP] Open form in new window

2013-03-03 Thread John Taylor-Johnston

I have many different submit button.
input value=Update type=submit
input name=DPRmode value=Enter Data type=submit

When php processes value=Enter Data, I would like to open a new 
window, but only if I click this one.


Possible? I knw ther is an HTML target= thingy. Can PHP do anything magic?


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



[PHP] stripped \n

2013-02-20 Thread John Taylor-Johnston

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?


Re: [PHP] phpinfo()

2013-02-20 Thread John Taylor-Johnston



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.



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



Re: [PHP] parsing select multiple=multiple

2013-02-19 Thread John Taylor-Johnston


tamouse mailing lists wrote:

I hate arrays. :D

Here's a small snippet showing how it works, I hope:

foreach ($DPRpriority as $item = $value) {
   echo li .$item.: .$value['name']. selected:
.$value['selected']. /li\n;
}

Question 1: when did we have to add [] to a input name to turn it into 
an array?


input type=checkbox name=DPRlocationdetails[] value=Unknown

According to phpinfo() it still comes out as 
$_POST['DPRlocationdetails'] without [].


Are the [] necessary?
--
Question 2:
I was looking at some code in the Manual, where someone used isset and 
is_array.


How necessary is if(isset($_POST['DPRlocationdetails']))

and then to use: if(is_array($_POST['DPRlocationdetails']))

That seems like over kill?
--
Question 3:

My code works, perfectly. In this case, I decided to attack some 
check-boxes first. The resulting function will work for select 
multiple too..


Does anyone see me doing something wrong in my code below?

My questions are:

Is this the only way to pass Unknown, Family Home or Apartment 
into the function?


Is this correct?

 if ($_POST['DPRlocationdetails'] == Unknown)

Somebody once told me I had to do it this way?

 if (Unknown == $_POST['DPRlocationdetails'])

John

snip---

form action=foo.php id=DPRform method=postinput value=Update 
type=submit
input type=checkbox name=DPRlocationdetails[] value=Unknown ?php 
filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown
input type=checkbox name=DPRlocationdetails[] value=Family Home 
?php filter_value($_POST['DPRlocationdetails'],Family Home); ? 
Family Home
input type=checkbox name=DPRlocationdetails[] value=Apartment 
?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment

/form

?php
function filter_value($tofilter,$tofind) {
foreach($tofilter as $value){
if ($value == $tofind) echo checked;
}
}
?



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



[PHP] phpinfo()

2013-02-19 Thread John Taylor-Johnston
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


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



[PHP] if (empty versus if (isset

2013-02-19 Thread John Taylor-Johnston

What is the difference between?

if (empty... http://www.php.net/manual/en/function.empty.php Determine 
whether a variable is empty

and
if (isset... http://php.net/manual/en/function.isset.php Determine if a 
variable is set and is not *|NULL|*


I have an input type=radio value=something.

If it is not checked, it is NOT empty, because it has a value, right?
But it is NOT set, right?

Is this empty, because it's value is ?

input type=text value=

Just trying to understand ... :)


[PHP] parsing select multiple=multiple

2013-02-18 Thread John Taylor-Johnston
I am capable with select name=DPRpriority. (I suppose I did it 
correctly? :p )
But I haven't the first clue how to parse a select multiple and 
multiply select name=DPRtype.

Would anyone give me a couple of clues please? :)
Thanks,
John

   Priority:
   select name=DPRpriority form=DPRform
 option value=1 ?php if ($_POST[DPRpriority] == 1) 
{echo selected;} ?1/option
 option value=2 ?php if ($_POST[DPRpriority] == 2) 
{echo selected;} ?2/option
 option value=3 ?php if ($_POST[DPRpriority] == 3) 
{echo selected;} ?3/option

 option value=4 ?php
 if (empty($_POST[DPRpriority])) {echo selected;}
 if ($_POST[DPRpriority] == 4) {echo selected;} 
?4/option

   /select


   select multiple=multiple name=DPRtype form=DPRform
 option value=1. Crimes Against Persons1. Crimes 
Against Persons/option

 option value=2. Disturbances2. Disturbances/option
 option value=3. Assistance / Medical3. Assistance / 
Medical/option
 option value=4. Crimes Against Property4. Crimes 
Against Property/option
 option value=5. Accidents / Traffic Problems5. 
Accidents / Traffic Problems/option
 option value=6. Suspicious Circumstances6. Suspicious 
Circumstances/option
 option value=7. Morality / Drugs7. Morality / 
Drugs/option
 option value=8. Miscellaneous Service8. Miscellaneous 
Service/option

 option value=9. Alarms9. Alarms/option
   /select


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



Re: [PHP] parsing select multiple=multiple

2013-02-18 Thread John Taylor-Johnston



 select multiple=multiple name=DPRtype form=DPRform
 option value=1. Crimes Against Persons1. Crimes Against
Persons/option
 option value=2. Disturbances2. Disturbances/option
 option value=3. Assistance / Medical3. Assistance /
Medical/option
 option value=4. Crimes Against Property4. Crimes Against
Property/option
 option value=5. Accidents / Traffic Problems5. Accidents /
Traffic Problems/option
 option value=6. Suspicious Circumstances6. Suspicious
Circumstances/option
 option value=7. Morality / Drugs7. Morality /
Drugs/option
 option value=8. Miscellaneous Service8. Miscellaneous
Service/option
 option value=9. Alarms9. Alarms/option
   /select





Do test this, but I think all that's required is you make the name an array:

select name=DPRpriority[] form=DPRform
  

Something like this?

if $DPRpriority[0] == 7. Morality / Drugs { echo selected; }

I hate arrays. :D

http://php.net/manual/en/language.types.array.php

?php
$DPRpriority[]  = array(
   1= a,
   1  = b,
   1.5  = c,
   true = d,
);
var_dump($array);
?



Re: [PHP] PHP fails to install on Ubuntu 12.10. What's going on?

2013-02-14 Thread John Iliffe
On Thursday 14 February 2013 14:20:06 Chris Bergstresser wrote:
 Hi all --
 
I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
 12.10 machine image, and type apt-get install php5 it seems to
 install fine.  But if I then type php -version I get PHP Parse
 error:  syntax error, unexpected end of file in Command line code on
 line 1.
 
What went wrong?  How can I fix it?
 
 -- Chris
type php --version

There are two - preceding the word version.

J.

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



[PHP] Expansion of Apache definitions

2013-01-10 Thread John Iliffe
I recently made a posting on the Apache users group regarding recovering 
the client IP address using the $_SESSION['REMOTE_ADDR'] function in PHP.

I received the following caveat from another developer:

-start quote
You may want to update that.

Since 2.4, apache makes the distinction between the the two different
REMOTE_ADDR candidates: the peer making the TCP connection,
and the client making the HTTP request.  In other words, the nearest
proxy and the end-user.  The latter is of course very easy to spoof,
but is nevertheless the one most applications want.
--end quote

Is there any development underway in PHP to have both of these addresses 
available in the $_SESSION global variable?  

Regards,

John

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



Re: [PHP] Boolean type forced on string assignment inside if statement

2013-01-03 Thread John Iliffe
On Thursday 03 January 2013 10:26:39 Jim Giner wrote:
 On 1/2/2013 2:02 PM, Marc Guay wrote:
  Something else that's happening with this, which makes it a Bad Idea
  (tm) is that when the operator is or, as it is in my real life
  scenerio, the 2nd variable occasionally doesn't get populated if the
  first one returns true.
  
  if ($a = foo || $b = bar){
  
   echo $a.br /.$b;
  
  }
  
  Returns
  foo
  
  And even worse, because I have this in a loop, what can happen is that
  if $b gets populated on one loop, it doesn't get reset for the next
  one so the data gets seriously bungled.
  
  Moral of the story:  Don't be so fancy on your first day back after
  vacation.  :)
  
  Marc
 
 You actually use statements like that in order to populate vars?
 Whatever happened to simple to understand, easy to maintain coding
 practices?
 
 The only time I use a single '=' symbol in an if statement is when I
 forget to use two of them!  Must be my old school, old languages habits
 but this style of programming reminds me of the days when we used to
 pack empty spaces in assembler code with constants or byte-size vars in
 order to save memory back when memory was the most precious resource one
 had.

I have been watching this discussion with some amusement and I recall the 
days mentioned by Jim very well indeed!

First, did the original poster realize that he was assigning a value to the 
variable $a in the 'if' statement?  Assuming that he did, and this is not 
just a typo, then remember how the if statement evaluates an OR condition; 
that is, if the first variable is 'true' then the true path is followed 
because there is no reason to go further.  So the result is EXACTLY what 
one would expect.  $a is true (ie it is not set to a 'false' value, 
whatever PHP uses for false) and $b is bar because that is what it is set 
to.  Since the evaluation is within a bracket, the interior values ($a, $b) 
are set BEFORE the if condition is evaluated.

I see neither a bug in PHP nor a variance from the expected result here.

Regards,

John

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



Re: [PHP] Boolean type forced on string assignment inside if statement

2013-01-03 Thread John Iliffe
On Thursday 03 January 2013 11:33:22 Marc Guay wrote:
  First, did the original poster realize that he was assigning a value
  to the variable $a in the 'if' statement?
 
 Hello,
 
 Yes, I did, and if you read my responses you can see that I came to
 the realisations you describe.  I don't think that anyone suggested
 there was a bug.
 
  $a is true (ie it is not set to a 'false' value,
  whatever PHP uses for false) and $b is bar because that is what it
  is set to.  Since the evaluation is within a bracket, the interior
  values ($a, $b) are set BEFORE the if condition is evaluated.
 
 Regarding this I'm a bit confused.  In the case of an OR operator, $b
 is not bar because it follows the true path as you said earlier.
 Probably just a glitch in the English language.  I'll file a bug for
 that.
 
 Marc

Hi Marc:

I'm not at all sure of that.

There are two things happening in parallel here: first the interior of the 
brackets is evaluated as necessary, in this case the $a is set to foo and 
the $b is set to bar.  Then the exterior part of the statement is 
evaluated:  if ($a. ).  It is this last operation that results in the 
path selection through the code, and in this case $a is true, $b is not 
evaluated.  mind you I'm basing this on my university basic programming 
course from almost 50 years ago :-)  

Regards,

John

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



[PHP] Session data lost in Firefox

2012-10-26 Thread John Boy
Hi

I have a wesite where PHP session data is passed page to page then shells 
out to Paypal for payment then back to my website for completion of 
transaction and update of mysql file. When using Firefox our session data 
and POST data from Paypal is lost. This has happend only recently and has 
worked happily in the past. Works in other browsers too. Anyone heard of 
same problems?

mywebpage - session data-mywebpage2-session data-paypal page-POST data 
+ session data-mywebpage3

-- 
Johniboy 



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



Re: [PHP] Session data lost in Firefox

2012-10-26 Thread John Boy
Looks like it was a corrupted Paypal cookie lurking about on my test
machine. Clearing all Paypal cookies cured the problem.
Hours can be spent looking for needles like this in a very complex haystack
and it turns out to be the simplest solution that's not even related
directly to the programming. Thanks, Andrew for the prompting!
However if this happened on a punter's computer the same would happen - so
is there a way of coding the removal of third party cookies to avoid this
problem?


Andrew Ballard aball...@gmail.com wrote in message 
news:cac1b6rsbydmopeulin0fjmax-vap_uas_1w6e-nr-1shwm+...@mail.gmail.com...
 On Fri, Oct 26, 2012 at 8:49 AM, John Boy 
 serv...@greenholdings.co.ukwrote:

 Hi

 I have a wesite where PHP session data is passed page to page then shells
 out to Paypal for payment then back to my website for completion of
 transaction and update of mysql file. When using Firefox our session data
 and POST data from Paypal is lost. This has happend only recently and has
 worked happily in the past. Works in other browsers too. Anyone heard of
 same problems?

 mywebpage - session data-mywebpage2-session data-paypal page-POST 
 data
 + session data-mywebpage3

 --
 Johniboy


 Just a thought - does this depend on using third party cookies between 
 your
 site and PayPal? If so, do you have them disabled in Firefox?

 Andrew
 



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



[PHP] base64_decode

2012-10-02 Thread John Taylor-Johnston
Without anyone infecting their machines, can someone tell me what this 
is? I found a phishing site on my DreamHost server. DreamHost has been 
very helpful.

We found a file containing this code.
What is it? What does it contain?

?php 
eval(base64_decode('Pz4gPC9kaXY+DQo8ZGl2IGlkPSJmb290ZXIiPjxhIGhyZWY9Imh0dHA6Ly93ZWItaG9zdGluZy1jbGljay5jb20vIiB0aXRsZT0iV2ViIGhvc3RpbmciPldlYiBob3N0aW5nPC9hPg0KPCEtLSAyNyBxdWVyaWVzLiAwLjU2MSBzZWNvbmRzLiAtLT4NCjwvZGl2Pg0KPD9waHAgd3BfZm9vdGVyKCk7ID8+DQo8L2JvZHk+DQo8L2h0bWw+IDw/'));?


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



[PHP] Re: {ATTENTION} Re: [PHP] base64_decode

2012-10-02 Thread John Taylor-Johnston

Interesting.
Thanks.
It was a footer.php in a webpress theme.
I was wondering if it was a portal someone was using to get onto my server.
I changted ftp passwords and begun using sftp, but phishing code is 
still leaking onto my sites. My wordpress copies are up to date and 
DreamHost has no real answers as to how someone is uploading and 
expanding *.tar.gz files.


Thanks,
john

Rodrigo Silva dos Santos wrote:



Hello John.

This code generates the following html:


? /div
div id=footera href=*MailScanner has detected a possible fraud 
attempt from web-hosting-click.com claiming to be* 
http://web-hosting-click.com/; title=Web hostingWeb hosting/a

!-- 27 queries. 0.561 seconds. --
/div
?php wp_footer(); ?
/body
/html ?

Appears that is nothing dangerous, only unauthorized advertising.




Em 02-10-2012 14:27, John Taylor-Johnston escreveu:
Without anyone infecting their machines, can someone tell me what 
this is? I found a phishing site on my DreamHost server. DreamHost 
has been very helpful.

We found a file containing this code.
What is it? What does it contain?

?php 
eval(base64_decode('Pz4gPC9kaXY+DQo8ZGl2IGlkPSJmb290ZXIiPjxhIGhyZWY9Imh0dHA6Ly93ZWItaG9zdGluZy1jbGljay5jb20vIiB0aXRsZT0iV2ViIGhvc3RpbmciPldlYiBob3N0aW5nPC9hPg0KPCEtLSAyNyBxdWVyaWVzLiAwLjU2MSBzZWNvbmRzLiAtLT4NCjwvZGl2Pg0KPD9waHAgd3BfZm9vdGVyKCk7ID8+DQo8L2JvZHk+DQo8L2h0bWw+IDw/'));?






--
John Taylor-Johnston

Département de Langues modernes
Cégep de Sherbrooke, Sherbrooke, Québec
http://cegepsherbrooke.qc.ca/~languesmodernes/
http://cegepsherbrooke.qc.ca/~languesmodernes/wiki/



[PHP] array.sorting.php

2012-09-04 Thread John Taylor-Johnston

Hi,
Sorting question. http://www.php.net/manual/en/array.sorting.php
I'm using ksort, which sorts like this.
I don't want to use strolower.
Is there a function/switch in one of the sort functions where I could 
get another aphabetical sort?


http://www.php.net/manual/en/array.sorting.php has a lot of options. I,m 
not sure which one I should choose.


This is what I get:

LABRADOR CITY
LACOSTA
LARGE
Labrador
Labrador City
Labrador Sea
Lacosta
Large
labrador
labrador sea
lacosta
large


This is what I want:

LABRADOR
Labrador
labrador
LABRADOR CITY
Labrador City
Labrador Sea
labrador sea
LACOSTA
Lacosta
lacosta
LARGE
Large
large

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



Re: [PHP] array.sorting.php

2012-09-04 Thread John Taylor-Johnston

The problem is I'm sorting the key. The alphabetical thing is in the key.

David OBrien wrote:



On Tue, Sep 4, 2012 at 1:15 PM, John Taylor-Johnston 
jt.johns...@usherbrooke.ca mailto:jt.johns...@usherbrooke.ca wrote:


Hi,
Sorting question. http://www.php.net/manual/en/array.sorting.php
I'm using ksort, which sorts like this.
I don't want to use strolower.
Is there a function/switch in one of the sort functions where I
could get another aphabetical sort?

http://www.php.net/manual/en/array.sorting.php has a lot of
options. I,m not sure which one I should choose.

This is what I get:

LABRADOR CITY
LACOSTA
LARGE
Labrador
Labrador City
Labrador Sea
Lacosta
Large
labrador
labrador sea
lacosta
large


This is what I want:

LABRADOR
Labrador
labrador
LABRADOR CITY
Labrador City
Labrador Sea
labrador sea
LACOSTA
Lacosta
lacosta
LARGE
Large
large

-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php


natsort
natcasesort 




Re: [PHP] array.sorting.php

2012-09-04 Thread John Taylor-Johnston


David OBrien wrote:
On Tue, Sep 4, 2012 at 1:15 PM, John Taylor-Johnston 
jt.johns...@usherbrooke.ca mailto:jt.johns...@usherbrooke.ca wrote:


Hi,
Sorting question. http://www.php.net/manual/en/array.sorting.php
I'm using ksort, which sorts like this.
I don't want to use strolower.
Is there a function/switch in one of the sort functions where I
could get another aphabetical sort?

http://www.php.net/manual/en/array.sorting.php has a lot of
options. I,m not sure which one I should choose.

This is what I get:

LABRADOR CITY
LACOSTA
LARGE
Labrador
Labrador City
Labrador Sea
Lacosta
Large
labrador
labrador sea
lacosta
large


This is what I want:

LABRADOR
Labrador
labrador
LABRADOR CITY
Labrador City
Labrador Sea
labrador sea
LACOSTA
Lacosta
lacosta
LARGE
Large
large


natsort
natcasesort 
I'm sorting the key. It doesn't work. ksort is the only choice I have, 
right?


Ok, let's approach this question differently.
Right now the frequency of each word is in value.
How do I put the frequency of each word in the key?

I'm fuzzy when it comes to arrays. I can do this is MySQL. All I need is 
an id and two varchars and then I know how to sort any way I want. But I 
am processing dynamic text files. MySQL is not an option; data changes 
too much. PHP is faster and more efficient. I'm just no good at arrays.


Here is my code:
---snip---
$mynewstring = http://foo.com/bigtextfile.txt;;

$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
$freq[$word]++;
}

#natcasesort($freq);
ksort($freq);

John


Re: [PHP] array.sorting.php

2012-09-04 Thread John Taylor-Johnston

Matijn Woudt wrote:

Taken from the natsort manual page comments:

?php
/**
 * keyNatSort does a natural sort via key on the supplied array.
 *
 * @param   $array  The array to natural sort via key.
 * @param   $saveMemory If true will delete values from the original
array as it builds the sorted array.
 * @return  Sorted array on success. Boolean false if sort failed or
null if the object was not an array.
 */

PS. Please bottom post on this and probably any mailing list
  


I've tried it.
I don't see it sorting anything?
http://cegepsherbrooke.qc.ca/~languesmodernes/test/keynatsort.php

$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
   $freq[$word]++;
}

function keyNatSort($array, $saveMemory=false)
{
   if(is_array($array))
   {
   $keys = array_keys($array);
   if(natsort($keys))
   {
   $result = array();
   foreach($keys as $key)
   {
   $result[$key] = $array[$key];
   if($saveMemory)
   unset($array[$key]);
   }

   }
   else
   $result = false;
   }
   else
   $result = null;

   return $result;
}

keyNatSort($freq);

echo table\n;
foreach ($freq as $key = $val) {
#   echo $key = $val br /\n;
   echo trtd.str_replace(_,  , $key)./tdtd$val/td/tr\n;
}
echo /table\n;

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



[PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston

Hi,

?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
$freq[$word]++;
}

ksort($freq);
print_r ($freq);
?

If I have my terminology right, ksort($freq) sorts the array by the key. 
And that works fine.

But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|

Thanks,
John

Array
(
[] = 1
[a] = 165
[about] = 4
[academy] = 4
[accident] = 3
[accidental] = 1
[accused] = 1
[achieve] = 1
[across] = 1
[act] = 3
[addition] = 1
[address] = 1
[adult] = 3
[advise] = 2
[advised] = 1
[advising] = 2
[advisory] = 4
[after] = 2
[aged] = 1
[aggravated] = 1
[airport] = 4
[alarm] = 2
[alcohol] = 5
[alert] = 1
[all] = 2
[allegedly] = 2
[allow] = 1
[along] = 2
[also] = 14
[altercation] = 2
[am] = 16




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



Re: [PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston



?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
 $freq[$word]++;
}

ksort($freq);
print_r ($freq);
?

ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|

ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort and sort
are asc, krsort and rsort are desc equivalents.
- Matijn

Sort does not work seamlessly.


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



Re: [PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston



?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
 $freq[$word]++;
}

ksort($freq);
print_r ($freq);
?

ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|

ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort and sort
are asc, krsort and rsort are desc equivalents.
- Matijn

I'm fuzzy when it comes to arrays. I never get what I want right.

Sort does not work seamlessly. I have my key and

sort($freq);
print_r ($freq);

looks like:

Array
(
...
[1000] = 172
[1001] = 176
[1002] = 179
[1003] = 441
)

This is what I want:

Array
(
...
[and] = 172
[of] = 176
[to] = 179
[the] = 441
)

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



Re: [PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston


Serge Fonville wrote:

Have you looked at http://php.net/manual/en/array.sorting.php?

2012/9/3 John Taylor-Johnston jt.johns...@usherbrooke.ca 
mailto:jt.johns...@usherbrooke.ca



?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
 $freq[$word]++;
}

ksort($freq);
print_r ($freq);
?

ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words
are more frequent.
There is no |ascending/descending option to ksort?|

ksort sorts by key, if you want by value, look at sort.

As to asc/desc sort, they just have a different name. ksort
and sort
are asc, krsort and rsort are desc equivalents.
- Matijn

I'm fuzzy when it comes to arrays. I never get what I want right.

Sort does not work seamlessly. I have my key and

sort($freq);
print_r ($freq);

looks like:

Array
(
...
[1000] = 172
[1001] = 176
[1002] = 179
[1003] = 441
)

This is what I want:

Array
(
...
[and] = 172
[of] = 176
[to] = 179
[the] = 441
)



I'm beginning to think I should plug this into a MySQL table, where I 
would be at home.
But right now, I'll be stubborn and go read 
http://php.net/manual/en/array.sorting.php.

Merci Serge,
John



Re: [PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston


   ?php
   ...
   $words = preg_split('/[[:space:]]+/',$mynewstring);

   foreach ($words as $word) {
 $freq[$word]++;
   }

   ksort($freq);
   print_r ($freq);
   ?


   Sort does not work seamlessly. I have my key and
   sort($freq);
   print_r ($freq);
   looks like:

   Array
   (
...
[1000] = 172
[1001] = 176
[1002] = 179
[1003] = 441
   )

   This is what I want:

   Array
   (
...
[and] = 172
[of] = 176
[to] = 179
[the] = 441

   )


http://php.net/manual/en/array.sorting.php is pretty clear. But my 
problem is that sort ($freq) destroyed my key.





Re: [PHP] ksort by value

2012-09-03 Thread John Taylor-Johnston

That works, thanks.
I think I'll put this into MySQL eventually. sort by key would do it 
better, and I will need to more.


Serge Fonville wrote:
Sort does not maintain the association between key and value. Use 
asort to sort on value while maintaining the key.


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 





2012/9/3 John Taylor-Johnston jt.johns...@usherbrooke.ca 
mailto:jt.johns...@usherbrooke.ca



?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);

foreach ($words as $word) {
 $freq[$word]++;
}

ksort($freq);
print_r ($freq);
?


Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:

Array
(
...
[1000] = 172
[1001] = 176
[1002] = 179
[1003] = 441
)

This is what I want:

Array
(
...
[and] = 172
[of] = 176
[to] = 179
[the] = 441

)


http://php.net/manual/en/array.sorting.php is pretty clear. But my
problem is that sort ($freq) destroyed my key.







Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-02 Thread John Taylor-Johnston



On Sun, Sep 2, 2012 at 6:23 AM, John Taylor-Johnston
jt.johns...@usherbrooke.ca wrote:

See:
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.php
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.phps

In $mystring, I need to extract everything between |News Releases| and
-30.

The thing now is $mystring might contain many instances of |News Releases|
and -30.

How do I deal with this? My code only catches the first instance.

Thanks for you help so far.

John


You could use substr to retrieve the rest of the string and just start
over (do it in a while loop to catch all).
Though, it's probably not really efficient if you have long strings.
You'd be better off with preg_match. You can do it all with a single
line of code, albeit that regex takes quite some time to figure out if
not experienced.

- Matijn

PS. Please don't top post on this and probably any mailing list.
Matijn, I'm a habitual top quoter. Horrible :)) But bottom quoting is 
not intuitive. But the are the rules, so I will be a good poster :))


I will have very, very long strings. It will be a corpus of text, of 
maybe 1-2 megs of text.


I'm not terribly experienced. How would I while loop this?

I am reading preg-match and the examples, but I don't really follow.
http://www.php.net/manual/en/function.preg-match.php

I admit, I don't know what |/php/imeans.|

|?php
// The i after the pattern delimiter indicates a case-insensitive search
if (preg_match(/php/i, PHP is the web scripting language of choice.)) {
echo A match was found.;
} else {
echo A match was not found.;
}
? |







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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-02 Thread John Taylor-Johnston

Frank Arensmeier wrote:
 See:
 http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.php
 http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.phps

 In $mystring, I need to extract everything between |News 
Releases| and

 -30.

 My approach would be to split the hole text into smaller chunks 
(with e.g. explode()) and extract the interesting parts with a regular 
expression. Maybe this will give you some ideas:


 $chunks = explode(-30-, $mystring);
 foreach($chunks as $chunk) {
 preg_match_all(/News Releases\n(.+)/s, $chunk, $matches);
 var_dump($matches[1]);
 }

 The regex matches all text between News Releases and the end of 
the chunk.


 /frank


I could live with that, I think. Here is the output:
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test2.php

Here are the newbie questions

Why is there more than one array?

array(1)

What are string(190) and string string(247)? Why are they named like that?
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test2.php
Please explain the / (.+)/s in /News Releases\n(.+)/s?

My question is:
Is one array not better? (My next step will be to parse the array to 
find the frequency of each word ... an array.)



array {
[0]= Residential Fire Determined to be Accidental in Nature

(SUMMER BROOK, ON) – May 31, 2012 – The Police Department has determined 
the cause of a residential fire to be accidental in nature.



[1]=
Residential Fire Determined to be Accidental in Nature

(SUMMER BROOK, ON) – June 3rd, 2012 – The Police Department has arrested 
two suspects in the case of a residential fire on May 31st. It is now 
believe the fire was not accidental in nature.



}










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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-02 Thread John Taylor-Johnston



See:
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.php
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.phps

In $mystring, I need to extract everything between |News Releases| and
-30.

The thing now is $mystring might contain many instances of |News
Releases|
and -30.

How do I deal with this? My code only catches the first instance.

Thanks for you help so far.

John

I do find it intuitive actually, when reading things back your 
answer is after the question, which makes sense. The other way 
around doesn't? 

I'll never get it. Newest work on top of the pile, instead of digging :))
On Sun, Sep 2, 2012 at 4:33 PM, Frank Arensmeier 
farensme...@gmail.com wrote:

My approach would be to split the hole text into smaller chunks (with e.g. 
explode()) and extract the interesting parts with a regular expression. Maybe 
this will give you some ideas:
$chunks = explode(-30-, $mystring);
foreach($chunks as $chunk) {
 preg_match_all(/News Releases\n(.+)/s, $chunk, $matches);
 var_dump($matches[1]);
}
The regex matches all text between News Releases and the end of the chunk.

It shouldn't be needed to explode the string first, you could do that
with a single preg_match_all. (Sorry, can't remember how anymore, it's
been a while since I last used PCRE ).
I'll get the PCRE eventually. Never had much time for PERL after PHP 
stated anyhow :)p



I think the split by -30- works nicely.


2) How could I suck it into one nice easy to handle array? 
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test2.php


|$mynewarray=|array {
  [0]= Residential Fire Determined to be Accidental in Nature ...
  [1]= Arrest Made in Residential Fire ...
}


Thanks,
John

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



[PHP] array_push

2012-09-02 Thread John Taylor-Johnston

How can I clean this up?
My approach would be to split the hole text into smaller chunks (with 
e.g. explode()) and extract the interesting parts with a regular 
expression. Maybe this will give you some ideas:

$chunks = explode(-30-, $mystring);
foreach($chunks as $chunk) {
 preg_match_all(/News Releases\n(.+)/s, $chunk, $matches);
 var_dump($matches[1]);
}
The regex matches all text between News Releases and the end of 
the chunk.

2) How could I suck it into one nice easy to handle array?

|$mynewarray=|array {
  [0]= Residential Fire Determined to be Accidental in Nature ...
  [1]= Arrest Made in Residential Fire ...
} 
I was hoping preg_match_all would return strings.  I w/as hoping 
|$matches[1] was a string.|/


source: http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.phps
result: http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.php

This is ugly. How can I clean this up like this?

$mynewarray= array {
  [0]= Residential Fire Determined to be Accidental in Nature ...
  [1]= Arrest Made in Residential Fire ...
}

I wanted to push $matches[] (which I hoped was a string, not an array). 
I probably don't understand what preg_match_all did.


Now I have arrays nested inside the array(). How can I clean it up?

http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.php



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-02 Thread John Taylor-Johnston

tamouse mailing lists wrote:
Just to prove me right, our mail clients start quoting from the top too :)p

tamouse mailing lists wrote:

On Sun, Sep 2, 2012 at 11:31 AM, John Taylor-Johnston
jt.johns...@usherbrooke.ca wrote:

I'll never get it. Newest work on top of the pile, instead of digging :))

Usually order reverse in flow conversations your do?




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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-02 Thread John Taylor-Johnston

tamouse mailing lists wrote:

On Sun, Sep 2, 2012 at 7:57 PM, John Taylor-Johnston
jt.johns...@usherbrooke.ca wrote:

Just to prove me right, our mail clients start quoting from the top too :)p

Exactly. The quoting starts from the *top*. The problem is that the
cursor to start typing is also put there by default.
Step back before MS Outlook started that trend, which, of course, one
could *change* if one wanted to. The standard proforma for mail,
usenet, notes, bbs's, and most other forms (c.f. the Well, etc) were
all bottom post, or even better intermingled with ONLY the relevant
parts used, not the entire message.


I like the part where you said the cursor starts a the top by default :)p
But hey, I can follow established convention and bottom post.
I'm a renegade. Richard Stallman is my hero. :) But let's not tease each 
other too much and block the very good work of this list.


I have always been a fan of PHP, and this php-general list. I used to 
PERL, but found the posters impolite to the extent of nasty. Since this 
list got started, everyone has been especially nice, polite and helpful. 
And that is why I come back. I'm a newbie at best. I ask questions. I 
try to learn from pseudo coding, applying that to what I can create. 
When I hit a juncture or rough patch, I post my code and you folks help 
me out.


Thanks everyone! :)

John

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



Re: [PHP] array_push

2012-09-02 Thread John Taylor-Johnston


Frank Arensmeier wrote:

2 sep 2012 kl. 19.48 skrev John Taylor-Johnston:

Why not add two lines of code within the first loop?

$chunks = explode(-30-, $mystring);
foreach($chunks as $chunk) {
 preg_match_all(/News Releases\n(.+)/s, $chunk, $matches);
 foreach($matches[1] as $matched_text_line) {
$mynewarray[] = $matched_text_line;
 }
}

Besides the regex, this is pretty basic php.

/frank

Thanks!
I'm still a newbie, (10 years later). I'm still fuzzy when it comes to 
arrays.

John

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



[PHP] load rtf file

2012-09-02 Thread John Taylor-Johnston
I have a big giant RTF file. I could convert it to plain text. BUT can 
PHP do it for me?


Also:

I want to read the text file into a string. This does the job well, right?
http://php.net/manual/en/function.file-get-contents.php

This is it? Not more complicated?

|?php
$homepage = file_get_contents('http://www.example.com/text.txt');
echo $homepage;
? |

What about this?
http://www.php.net/manual/en/function.file.php

||?php
|$lines = file('http://www.example.com/');|
|echo $lines;
?|

Is there any big difference?

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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-09-01 Thread John Taylor-Johnston

See:
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.php
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.phps

In $mystring, I need to extract everything between |News Releases| and 
-30.


The thing now is $mystring might contain many instances of 
|News Releases| and -30.


How do I deal with this? My code only catches the first instance.

Thanks for you help so far.

John


You can use strpos() to find the location of News Releases then you
can again use strpos() to find the location of -- 30 -- but you will
want to feed strpos() an offset for matching -- 30 -- (specifically
the position found for News Releases). This ensures that you only
match on -- 30 -- when it comes after News Releases. Once you have
your beginning and start offsets you can use substr() to create a
substring of the interesting excerpt. Once you have the excerpt in hand
you can go back to tamouse's recommendation above.

Cheers,
Rob.



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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-08-20 Thread John Taylor-Johnston




This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like you're, Charlie's,
it's, etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).

When you've arranged all that, splitting on white space is trivial:

$words = preg_split('/[[:space:]]+/',$text);

and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:

foreach ($words as $word) {
 $freq[$word]++;
}

For output, you may want to sort the array:

ksort($freq);


That's awesome. Thanks!
Let me start with my first problem:

I want to extract All Occurrences of text AFTER News Releases and 
before -30-.


http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html

How do I do that?

Yeah, I am still asking first year questions :)) Every project brings 
new challenges.


John


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



[PHP] How do I do count the occurrence of each word?

2012-08-18 Thread John Taylor-Johnston

I want to parse this text and count the occurrence of each word:

$text = 
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html; #Can I 
do this?

$stripping = strip_tags($text); #get rid of html
$stripping = strtolower($stripping); #put in lowercase


First of all I want to start AFTER the expression News Releases and 
stop BEFORE the next occurrence of -30-


#This may occur an undetermined number of times on 
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html




Second, do I put $stripping into an array to separate each word by each 
space  ?


$stripping = implode( , $stripping);


Third how do I count the number of occurrences of each word?

Sample Output:

determined = 4
fire = 7
patrol = 3
theft = 6
witness = 1
witnessed = 1


?php
$text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
#echo strip_tags($text);
#echo \n;
$stripping = strip_tags($text);

#Get text between News Releases and stop before the next occurrence of 
-30-


#$stripping = str_replace(\r,  , $stripping);# getting rid of \r
#$stripping = str_replace(\n,  , $stripping);# getting rid of \n
#$stripping = str_replace(  ,  , $stripping);# getting rid of the 
occurrences of double spaces


#$stripping = strtolower($stripping);

#Where do I go now?
?


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



[PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston
I'm a teacher. I want to use PHP to interface with Google and see if a 
student has plagiarized.


I don't see many open-source projects on the subject, so I want to 
create my own script.


How can I use PHP to interface with Google and see if this text exists 
on the internet?


If this is possible, I need some ideas on how to parse the text and 
input it into Google.


Then I might like to get a percentage idea of how this text compares to 
a site that Google has indexed.



$SampleText = Lorem ipsum dolor sit amet, test link adipiscing elit. 
Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc 
iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet 
at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis 
luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget 
metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla 
nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo 
vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.


John


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



Re: [PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston

Can I use PHP to interface with Google? Any possible examples of this?

Let's start with the first step. :)

I'm sure proprietary sites like http://www.compilatio.net/ for example connects 
to search engines. They cannot be crawling the net too. That would be crazy.

(I'm a top quoter. It's more intuitive.)

Thanks Ash.

John



Ashley Sheridan wrote:

On Wed, 2012-02-15 at 21:56 -0500, John Taylor-Johnston wrote:

How can I use PHP to interface with Google and see if this text exists
on the internet?



Wow, that's a pretty big project you're chewing there. A quick search 
shows that there are some project out there to detect plagiarism, but 
I think for university calibre there's a hefty sum of money required.




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



Re: [PHP] Connect to Google

2012-02-16 Thread John Taylor-Johnston

I'm a top quoter.
I would parse the text first. Phrase by phrase, or phrase segments.
Then spit out a report.

Marc Guay wrote:

If that's not good enough, can you explain how you would like it to
function?  Would the whole paper be scanned phrase-by-phrase for
matches and then spit out a report?


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



[PHP] Need Part-time Coder

2011-12-27 Thread John R. Cornell II
Email PHP sample for consideration


Re: [PHP] Novice question

2011-10-31 Thread John Allsopp
 cURL is the best one in my experience, but you have to manage security
 yourself. Meaning: Remember to escape/encode data.

 http://php.net/manual/en/book.curl.php

Thanks everyone, appreciated, I'll investigate ..

Cheers
J

 --
 01723 376477

 Cost-free marketing: http://www.flowmarketing.co.uk/

 Affordable marketing guidance for small businesses:
 http://www.amilliontweaks.co.uk/

 Effective marketing services for SMEs: coming soon at
 http://www.surgemarketing.co.uk

 Professional Internet marketing consultancy:
 http://www.johnallsopp.co.uk


 --
 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




-- 
01723 376477

Cost-free marketing: http://www.flowmarketing.co.uk/

Affordable marketing guidance for small businesses:
http://www.amilliontweaks.co.uk/

Effective marketing services for SMEs: coming soon at
http://www.surgemarketing.co.uk

Professional Internet marketing consultancy: http://www.johnallsopp.co.uk


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



[PHP] Novice question

2011-10-30 Thread John Allsopp
Hi

I'm afraid I've fallen a little out of touch with PHP dev, so a stupid
question for you.

I want to write a script that requests a URL and then reads that website
.. I'm interested to map web structures. My web host is saying I'll need
URL file access enabled but that it's a) a security risk and b)
deprecated.

So .. what's the good / proper / acceptable / secure way of reading in
URLs in PHP or .. isn't there one?

Cheers
J

-- 
01723 376477

Cost-free marketing: http://www.flowmarketing.co.uk/

Affordable marketing guidance for small businesses:
http://www.amilliontweaks.co.uk/

Effective marketing services for SMEs: coming soon at
http://www.surgemarketing.co.uk

Professional Internet marketing consultancy: http://www.johnallsopp.co.uk


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



Re: [PHP] mysqli sql question

2011-08-31 Thread John Black

On 31.08.2011 11:23, Peet Grobler wrote:

Is it possible to get the actual sql that is being used to query or
update the database?
E.g
$sth = $dbh-prepare (update table set field=?, field2=? where id=?);
mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10);
$sth-execute();

Something like $sth-sql? Or $dbh-sql?
Thanks in advance,
Peet


Hi Peet,

not sure if there is a method to echo the sql but you can set your 
development MySQL server to log all queries to a log file.
Use the log file with tail and you'll get a live view of all queries the 
server attempts to process.


Open my.cnf / my.ini and add the following line:
log= /path/to/log/mysqld_query.log
or
log=D:\logs\mysqld_query.log

More info here: http://dev.mysql.com/doc/refman/5.1/en/query-log.html

I hope this helps ... ohh and don't forget to clear the log every now 
and then because it will get HUGE quickly.

--
John



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



Re: [PHP] Dreaded Premature end of script headers

2011-08-26 Thread John Black

On 26.08.2011 07:56, tamouse mailing lists wrote:

I'm encountering this on a script, but I can't figure out where it's
actually failing. How do I debug this problem???



What does you log say?
Make sure that you turn error reporting on and crank up the info it 
spits out.


I always develop with:
display_errors = On
error_reporting = E_ALL | E_STRICT

also make sure that
output_buffering = Off
or you will not see some error.

Looks like someone was faster ;(

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



Re: [PHP] Dealing with multiple form submissions

2011-08-25 Thread John Black

On 24.08.2011 21:38, Mike Mackintosh wrote:

On Aug 24, 2011, at 11:52, John Blacks...@network-technologies.org  wrote:

On 08/24/2011 03:04 AM, Jason Pruim wrote:

Wondering what everyone does to prevent multiple form submissions?
My form is simply getting emailed to my email, and it redirects to a success 
page when submitted...
Would it be as simple as doing something with the cache control? Basically I'm 
trying to avoid someone submitting a form... Then hitting back, and submitting 
again, then hitting back I think you get the idea...
What do you all do?
Jason Pruim

I am using $_SESSION for this. Set a value on the initial page, a timestamp is 
a good choice, then validate the value on the receiving script and clear the 
value.
I like to use a timestamp because it will allow you to deny a comment which 
took too long to submit.

I've always tended to stay away from session for that, as when the browser 
closes/restarts, the page is accessible again.


True, a SESSION can be reset by closing the browser but I am not trying 
to deny a user from submitting different information again. I want to 
prevent them from submitting the same data again by accident (back 
button or refresh).


A visitor, enters on the form UI page, the session is set, user submits 
and the form will reset the value in session to null or destroy it.


If the visitor attempts to resubmit by using refresh then it will fail 
because session does not contain an expected value anymore. That value 
is generated on the UI page.


If the user goes back with the back button then the browser should 
display the page from cache. The script will not be called and it will 
not create a new session value.
If the browser does not use the cache it will have to reload the form. 
This will create a new session value and an empty form so the user may 
type a new message. This is like attempting to submit a new message and 
is something I don't block.



I do it this way because I don't want to prevent a visitor to submit new 
information and I don't think that the original question wanted that.

--
John

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



Re: [PHP] Dealing with multiple form submissions

2011-08-25 Thread John Black

On 25.08.2011 15:00, Andreas wrote:

Am 25.08.2011 11:01, schrieb John Black:

True, a SESSION can be reset by closing the browser but I am not
trying to deny a user from submitting different information again. I
want to prevent them from submitting the same data again by accident
(back button or refresh).

what about storing an md5 of the message body in the db?


Sure you can do all kinds of things with a database but I try to avoid 
unnecessary connection to the db because they are expensive.
It all comes down to how badly you want to prevent the same message to 
be sent twice.


I have seen bots submit the same message from multiple IPs and some will 
even modify the message a bit by adding some random data to the end. So 
I am not sure how effective a simple md5 check will be.

--
John

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



Re: [PHP] Dealing with multiple form submissions

2011-08-25 Thread John Black

On 25.08.2011 15:48, Ashley Sheridan wrote:

So its the same message except for the bits at the bottom that are different? 
Sounds like its not the same message then.
Ash


True, it is a message which has been intentionally modified to appear 
different even though 99.9% of the content is the same. Most humans will 
view the message as the same but it is not.


Anyway, the OP should have a few ideas now how to implement something 
that may work for his scenario.

--
John



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



Re: [PHP] PHP within XML?

2011-08-25 Thread John Black

On 25.08.2011 16:06, Ron Piggott wrote:

I am trying to figure out if it is possible to have PHP work within an XML 
document.
Right now the PHP is displayed as a comment.
Thoughts anyone?
Ron


How are you executing the XML file? By calling it with your browser?
You may need to tell your webserver that you want to treat your xml file 
as a PHP document.


You can use .htaccess for this and add something like this:
Files YourXMLFile
 ForceType application/x-httpd-php
/Files

Hope this helps.
--
John



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



Re: [PHP] Dealing with multiple form submissions

2011-08-24 Thread John Black

On 08/24/2011 03:04 AM, Jason Pruim wrote:

Wondering what everyone does to prevent multiple form submissions?
My form is simply getting emailed to my email, and it redirects to a success 
page when submitted...
Would it be as simple as doing something with the cache control? Basically I'm 
trying to avoid someone submitting a form... Then hitting back, and submitting 
again, then hitting back I think you get the idea...
What do you all do?
Jason Pruim



Hi,
I am using $_SESSION for this. Set a value on the initial page, a 
timestamp is a good choice, then validate the value on the receiving 
script and clear the value.


I like to use a timestamp because it will allow you to deny a comment 
which took too long to submit.


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



Re: [PHP] PayPal IPN

2011-07-28 Thread John Black

On 28.07.2011 03:58, Jason Pruim wrote:

Hey everyone,
So I know this is related pretty strictly to paypal... But I also know that you 
all most likely use it :)
So with that said... Has anyone successfully setup the IPN with paypal? I'm 
trying to figure out to get it up and working...


Hi Jason,
I might be able to help you with that. I don't have IPN integrated into 
my site yet but I have a script running which is inserting the 
transaction values into my db. It also sends out e-mails since I am 
testing how my existing subscriptions are handled so I don't run into 
any surprises when I turn on automation.


You need to import the .sql into your mysql db and edit the settings at 
the top of the ipn file. Then rename the ipn file to something nobody 
should be able to guess and tell PayPal about it ... let me know if you 
run into trouble...


http://www.sendspace.com/file/77iofs
md5: 09f3f92050264c370ada7944555373ce PayPal IPN.zip

Good luck
--
John

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



Re: [PHP] Membership site

2011-07-28 Thread John Black
I would like to add some info about storing the password hash in the 
database.


I recently tested how quickly one can brute force a simple md5('foo') 
hash with a modern GPU. The results have been truly eye opening
I have been able to break hundreds of hashes with my ATI 6870 in a 
couple of days. Even with passwords in the 8 char length range ... and 
even salted ones.


The problem is that md5 is optimized for speed. Which is nice if you 
want to hash a file but it offers an attacker the option to brute force 
your password.
The solution is to hash multiple times and if possible using a different 
hashing algorithm.

http://php.net/crypt can help you here.

I wrote a new password class for my own projects which will use crypt() 
with sha512, sha256, blowfish if available or fall back to a 3000 round 
md5().
This approach makes it impractical to bruteforce the hash because every 
single test will have to run md5() 3000 times before it can validate a 
single hash.
This also adds a delay to the login process but the hash is only checked 
once


The code is released under the BSD license so you may use it in a 
commercial application as well. The zip contains the class file and two 
sample pages demonstrating how to use the class.


Here is a download link, let me know if you like it or have any questions.

http://www.2shared.com/file/kocAJ2HO/class_password.html
md5: 4ee41496a9d1bc147e5025699e2b764e class_password.zip

--
John


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



Re: [PHP] Membership site

2011-07-28 Thread John Black

On 28.07.2011 11:13, John Black wrote:

This approach makes it impractical to bruteforce the hash because every
single test will have to run md5() 3000 times before it can validate a
single hash.
--
John


I am sorry, I made a mistake here, 3000 times is not enough for this.
The actual code for the md5 portion looks like this:

$this-hash_rounds['md5'] = 3000;
for( $x=0 ; $x  $this-hash_rounds['md5'] ; ++$x)
{
 $hash = md5($salt.md5($salt.$hash).md5($hash.$salt));
}

--
John

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



Re: [PHP] Membership site

2011-07-28 Thread John Black

On 28.07.2011 12:53, Alex Nikitin wrote:

Just as a word of caution to everyone on this list, mcrypt version of
blowfish (which is implemented by php) (in linux) has an 8bit bug in it, and
thus should not be used for hashing passwords even as backup. Basically if
you use a character such as say a British pound in your password, blowfish
with php will generate, a wrong hash and allow for some extensive
collisions. For example a hash for ac followed by a pound or euro or any
of those extended chars (that are present on European keyboards and such)
and a hash for just that char, would be the same! If you want I can show you
with some demo code. But until fixed, don't use blowfish with php on linux
at least, if you can.


Very interesting, thanks for the heads up.
So if you use the class change
  $this-hash_supported = 'sha256|sha512|blowfish|md5';
to
  $this-hash_supported = 'sha256|sha512|md5';
So blowfish can not be used.

Problem:
Using salt: Vi4mT5vCge5SWQRH7onIlo
hash this: ac€
$2a$08$Vi4mT5vCge5SWQRH7onIleRMijSY4OVXS8.4diEKLENMF5Dd7HcjC
hash this: €
$2a$08$Vi4mT5vCge5SWQRH7onIleRMijSY4OVXS8.4diEKLENMF5Dd7HcjC

hash this: ac£
$2a$08$Vi4mT5vCge5SWQRH7onIle.3A9uIUxgFol/7HjY04C.oWQVa2nvw.
hash this: £
$2a$08$Vi4mT5vCge5SWQRH7onIle.3A9uIUxgFol/7HjY04C.oWQVa2nvw.

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



[PHP] 9970318527584

2011-02-18 Thread John Taylor-Johnston

9970318527584
Could this number refer to a date()? In late 2009?
How could I calculate it?

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



Re: [PHP] php running as module or cgi?

2010-11-12 Thread John Hicks

On 11/11/2010 02:14 PM, Didier Gasser-Morlay wrote:

On 11/11/2010 12:04 PM, Richard Quadling wrote:

On 11 November 2010 00:46, Aln...@ridersite.org  wrote:

Briefly, what are the trade offs on a typical shared host?

I've done a little research and can't seem to find anything outstanding
either way.

Seems like as an Apache module is faster. This argument makes sense.

CGI is more secure, this argument doesn't seem too persuasive to me. 
Maybe

I'm missing something.

Thanks


As a module, any misbehaving script is running within the same space
as all the other scripts. If a script is able to knock out PHP (for
any reason), all the script go.

With CGI, they are run in separate spaces. No direct communication
(unless the scripts are sharing memory by some way). If a script
knocks out PHP, that script dies. Everything else keeps on going.

The main downside to CGI (as I understand things), is that for each
invocation of the script, PHP has to do the complete build up and tear
down every single time. For every single script.

With FastCGI, when the server starts, a pool of ready to go php
instances are created. So a script is called, the build up part is
already done.

In terms of speed, I'd guess you'd have to be working pretty hard to
see the difference between module/isapi and fast-cgi.



If I am not mistaken, An apache module can even bring down the whole 
web server if it really misbehaves.


So this leaves the choice between CGI  FatsCGI.

CGI setup/teardown is only an issue for site with a fairly high 
traffic. It really depends on the type of site you intend to build.




To me, the main security issue with mod_php in a virtual domain 
configuration is that it runs as the apache user and therefore any php 
code can read any files accessible to apache.  If you have clients 
maintaining their own php code, they can access the code (and passwords 
and databases) of your other clients.


I've never used cgi but I hope that it allows you to avoid this problem. 
Am I correct?


--John



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



Re: [PHP] Re: strtotime

2010-10-17 Thread John Taylor-Johnston

Yaay, I'm 45 now :).

Here is another nifty piece of code I found. How does this work? What is 
31556926?


function calculateAge($birthday){
return floor((time() - strtotime($birthday))/31556926);
}

echo calculateAge('1965-10-17');

http://ca.php.net/manual/en/function.floor.php

--
$birthday = '1965-08-30';

//calculate years of age (input string: -MM-DD)

  function birthday ($birthday){
list($year,$month,$day) = explode(-,$birthday);
$year_diff  = date(Y) - $year;
$month_diff = date(m) - $month;
$day_diff   = date(d) - $day;
#  if ($day_diff  0 || $month_diff  0)
if (($month_diff == 0  $day_diff  0) || $month_diff  0)
  $year_diff--;
return $year_diff;
  }

echo birthday ($birthday);


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



[PHP] strtotime

2010-10-16 Thread John Taylor-Johnston

$now=date(Y-m-d);

A = $mydata-birthday = 1928-02-12;
B = $mydata-birthday = 1965-03-18;
C = $mydata-birthday = 1976-04-11;

I'm doing a demographic sort.

How do I calculate whether $mydata-Birthday falls into these categories 
below?
I'm working my way right now through the manual: 
http://ca.php.net/manual/en/function.strtotime.php.


I cannot just calculate:
$mydata-birthday - $now  = X age bracket.


80+ year category |  A  |
70+ year category
60+ year category
50+ year category
40+ year category |  B  |
30+ year category |  C  |
21+ year category

Thans for any inspiration. I can find and hack code. I'm just like to 
understand it myself.


John

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



[PHP] Re: strtotime

2010-10-16 Thread John Taylor-Johnston

According to this, I'm 44 not 45 :)p

$birthday = '1965-08-30';

//calculate years of age (input string: -MM-DD)

  function birthday ($birthday){
list($year,$month,$day) = explode(-,$birthday);
$year_diff  = date(Y) - $year;
$month_diff = date(m) - $month;
$day_diff   = date(d) - $day;
if ($day_diff  0 || $month_diff  0)
  $year_diff--;
return $year_diff;
  }

echo birthday ($birthday);



John Taylor-Johnston wrote:
I'm working my way right now through the manual: 
http://ca.php.net/manual/en/function.strtotime.php.





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



Re: [PHP] Re: SEO Experts?

2010-09-27 Thread john

 On 9/26/2010 8:09 AM, David Mehler wrote:
 Hello,
 Do we have any SEO experts on this list? I'm not one, learning only,
 reading a book and a few articles/tutorials from webmasters, and I'm
 wanting to optimize an existing site to get the best search rank
 possible. Some techniques, dos and don'ts would be appreciated.
 Thanks.
 Dave.

Sure, it's what I do.

Well first you need to work out which keyphrases to optimise for, and
that's not obvious. Search Google for keyword tool external to find a
Google tool that tells you something about the demand for a phrase and the
competition for it.

What you are trying to find are phrases that a) are very very relevant to
your client, b) have lots of demand traffic, and c) don't have too much
competition.

The other thing to check is whether anyone else is making money at your
selected phrases, so search for them in Google and see if people are
advertising.

Then group your phrases: so wet dog becomes a keyphrase group that
includes phrases like getting rid of wet dog smell, avoiding wet dog
shake and so on.

You are building a site to satisfy the keyphrase groups you've identified,
so then one way or another you want a wet dog page that's optimised for
that phrase, which means you mention wet dog a few times especially in
the headline and page title and don't mention lots of other things.

Then you want some links from other people's pages, Twitter, Delicious,
YouTube and so on to your wet dog page, preferably text links that include
the phrase wet dog.

Then you watch your Analytics data to check that people who arrive on your
site are satisfied and covert into sales (or signups or whatever you are
doing). If not, you run a Google Website Optimizer test to improve things
like your headline, photos and so on.

If you like, run through http://www.flowmarketing.co.uk and fill in the
form where you get stuck. It's obviously a work in progress :-) and I'll
complete the page that you end up at.

By all means email me the website and I can be more specific.

Good luck :-)

Cheers
J
http://www.johnallsopp.co.uk


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



Re: [PHP] contant /

2010-04-08 Thread John Black

On 04/08/2010 06:51 PM, Andre Polykanine wrote:
 2. (Just a suggestion) It's better to put the SQL tables and
 fields between grave accents (backquotes).

But if you do that then you will have to remove them again when you 
decide to switch or support PostgreSQL.


--
John
After coming into contact with a religious man I always feel I must wash 
my hands.

[Friedrich Nietzsche]

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



[PHP] Wordpress/PHP question

2010-03-22 Thread John Tamm-Buckle
Hi all,

I'm storing generated data as a post in wordpress using the wp_insert_post
function, which works great.  Users click a submit button and the things
are saved, hurrah!

However, on clicking the submit button I want to automatically navigate to
the post.  This has been less successful.  I've tried using:

header('Location: /?p=' . $postId);

In this case, where $postId = wp_insert_post($generated_text), and
$generated_text is the object that saves the output to a post.

Now when I try to save I get the following error:

Cannot modify header information - headers already sent by (output started
at /Users/sv/source/wpm/public_html/wp-content/themes/mystique/header.php:6)
in */Users/sv/source/wpm/public_html/wp-content/plugins/wpm/wpm.php* on
line *64*

Line 64 contains the header('Location: /?p=' . $postId); line.

Thanks!

John


-- 
Out now:
Kvist 002 - Raglani - Web of Light - 12
Kvist 003 - EOD - untitled - 12
Kvist 004 - JD Emmanuel - Solid Dawn - CD
Kvist 005 - Guillaume Gargaud - Here - CD

Coming soon:
Kvist 006 - Tom Hamilton - Pieces for Kohn/Formal  Informal Music - CD

www.kvistrecords.com


Re: [PHP] best way to set up an include path for a multi-level project?

2010-03-16 Thread John Black

On 03/16/2010 06:57 PM, Robert P. J. Day wrote:

   i have a project (let's call it proj) which lives in the proj
directory and which contains several subdirs, some of which might
contain their own subdirs and so on.  some of those subdirs might
contain utility classes that i want to include or require elsewhere,
so i want to be able to just:
   require 'util.php';
and have the PHP include path do the right thing.  right now, it's
ugly, as in, having PHP files that do:
   require '../../proj/util.php';
meaning every single file that wants to include another proj-related
file has to know its relative position in the proj hierarchy.   barf.


I used to use auto detecting absolute paths but switched to relative 
paths when a client decided to switch  his hosting company, I *think* it 
was GoDaddy. They required relative paths when using the shared SSL 
server or the browser would throw errors.


It is really not bad as long a you keep your directory structure 
consistent. I have never received a bug report because of an include 
path issue. It also does not matter where the root directory of the app 
is located since everything is relative anyway. There is also no need 
for the user to configure anything because of the relative paths.


So I just set $include = './include/abc/def/' at the top of the 
executing php page and use it further down. You make $include a global 
or simply pass $include to functions or classes when they need to 
include files. I use the later approach.


As I said I never had a problem with it, it just requires consistency.

--
John
Eine der erstaunlichsten Erscheinungen ist, daß man sich einbildet,
von abhängigen Menschen unabhängige Meinungen erwarten zu dürfen.
[Sigmund Graff]

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



Re: [PHP] best way to set up an include path for a multi-level project?

2010-03-16 Thread John Black

On 03/16/2010 08:50 PM, John Black wrote:

So I just set $include = './include/abc/def/' at the top of the


correction, I set $include to the relative path of the include directory 
and then use it like this:


$include = '../../include/';

require $include.'abc/file1.php';
require_once $include.'abc/def/file2.php';
require_once $include.'file3.php';

Still works the same way but since all my include files are in include 
or some sub directory of it this works perfect.



--
John
Vorurteil ist das Kind von Ignoranz.
[William Hazlitt]

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



Re: [PHP] Load simulation tests

2010-03-09 Thread John Black

Ashley Sheridan wrote:

I was wondering if there were any ways to simulate loads on a PHP script
running on the server? Basically, I'd just like to take one of my sites
through a dry-run so to speak and simulate x number of visitors.
Ideally, I'd prefer something that didn't have to be installed on the
remote server. Also, it would have to be something I could use from
within Linux, as I only have Windows running as a VM, and I'm not sure
it would work as intended if run though a VM.
Have any of you used such tools, and if so, are there any you'd
recommend?
Ash


I have used JMeter in the past.
Since it is written in Java it will run just fine on Linux. Setting up a 
test scenario may take some time but it can browse your page like a 
regular user would (with delays) and supply input where required. This 
is executed from a client machine and does not require anything to be 
installed on your server.


http://jakarta.apache.org/jmeter/

--
John



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



Re: [PHP] Mail Function In PHP

2010-03-08 Thread John Black

On 03/08/2010 06:18 PM, Richard Quadling wrote:

On 8 March 2010 13:06, Teus Benschopteusjanne...@gmail.com  wrote:

On Mon, 2010-03-08 at 10:21 +, Richard Quadling wrote:

Contrary to popular belief, to send an email you do not need to have
your own SMTP server. All you need to know is the SMTP server
responsible for your recipients email.

[...]
above. But at times it happens that the receiving smtp server refuses to
accept mail from the sender since the sender is not known to be a good
smtp server, and at times it could get blacklisted. Rules like this get
tightened up because of the desire to curb spam at the source.

Teus.

So, say I did go and setup a local SMTP relay, how would I make it
known that it was a real smtp server and not just some script
pushing spam?


You can use SPF, DomainKeys plus valid DNS information.
I have setup SPF records for my domains. If you attempt to send E-Mail 
as if it was sent from my server then any server doing SPF record 
checking will not accept or simply drop your message.


I have not setup DomainKeys since SPF has served me well but I will 
configure it soon.


--
John
Insanity in individuals is something rare - but in groups, parties, 
nations and epochs, it is the rule.

[Friedrich Nietzsche]

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



Re: [PHP] Mail Function In PHP

2010-03-08 Thread John Black

On 03/08/2010 10:45 PM, John Black wrote:

You can use SPF, DomainKeys plus valid DNS information.
I have setup SPF records for my domains. If you attempt to send E-Mail
as if it was sent from my server then any server doing SPF record
checking will not accept or simply drop your message.
I have not setup DomainKeys since SPF has served me well but I will
configure it soon.


woops, forgot to add that I doubt that you'll be able to get a pure 
webserver to do this for you, reliably, since some smtp servers will 
call your server back and check if the e-mail account exists. I'd assume 
that the server will drop the mail if your script sending server is not 
even running smtp on port 25.


--
John
Niemand ist frei, der über sich selbst nicht Herr ist.
[Matthias Claudius]

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



Re: [PHP] mysqli_connect problem

2010-03-01 Thread John Black

On 03/01/2010 07:54 PM, Thomas H. George wrote:

?php  ...
$alien_description = $_POST['aliendescription'];
$what_they_did = $_POST['whattheydid'];
$email = $_POST['email'];
...
$query = INSERT INTO aliens_abduction (first_name, last_name, 
when_it_happened, how_long,   .
how_many, alien_description, what_they_did, fang_spotted, other, 
email)  .
VALUES ('$first_name', '$last_name', '$when_it_happened', 
'$how_long', '$how_many',  .
'$alien_description', '$what_they_did', '$fang_spotted', '$other', 
'$email');



Any suggestions?
Tom


Yes I have one. Whatever book you are using, burn it then shoot it!

Without looking at the query, it is most likely failing because you are 
inserting un-escaped data into your database.
So when you enter something like: Goa'uld into your alien database then 
it will fail because you have an unescaped control character.
This code, when freely accessible, will ensure that your database will 
be compromised quickly. Search for SQL Injection on Google.


Unfortunately I can not recommend a good beginners guide since most of 
the ones I have seen teach this kind of stuff but hopefully someone else 
on this list can.


BTW, you can do your mysql connection this way and get the error 
returned plus the SQL query.


mysqli_query($link, $sql) or die(p$sql/p.mysqli_error($link));
--
John
Gerechtigkeit entspringt dem Neid; denn ihr oberster Grundsatz ist: 
Allen das Gleiche.

[Walther Rathenau]

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



[PHP] Help preserving sentence structure

2010-02-26 Thread John Tamm-Buckle
Hi, new to this list...

I'm adapting some code that generates text and want to keep the syntax.  In
the original version the output was iterated from an array in pre tags.
 That was fine for what it was, but it's now a word press plugin and the
pre tags get in the way.  How do I keep the sentence structure without
using pres?  Also, I'm quite new to PHP in general... :)  Any help would
be much appreciated!

Below is an extract of the code with some highlighting for emphasis:

function wpm_display_generator() {

if (isset($_POST['submit_button'])) {

// the form was submitted to this script - generate
// and display
require_once 'lib/generator.php';
require_once lib/util.php;
require_once lib/vocabulary.php;
require_once lib/widgets.php;

$vocab = Vocabulary::getInstance();
$cats = $vocab-getCategories();
$catName = '';
$sentence = '';
if (isset($_POST['category_choice'])) {
$catName = $cats[$_POST['category_choice']];
$gen = new wordGenerator($_POST['category_choice'],
$_POST['length_choice']);
$lines = $gen-generate();
foreach ($lines as $line) {
$sentence .= pre . $line . /pre;
}
}

require 'sentence.php';
}
else {
require 'generator_form.php';
}
}


Many thanks,

John

-- 
Out now:
Kvist 002 - Raglani - Web of Light - 12
Kvist 003 - EOD - untitled - 12
Kvist 004 - JD Emmanuel - Solid Dawn - CD
Kvist 005 - Guillaume Gargaud - Here - CD

Coming soon:
Kvist 006 - Tom Hamilton - Pieces for Kohn/Formal  Informal Music - CD

www.kvistrecords.com


Re: [PHP] Uninstalling PHP?

2010-02-26 Thread John Black

On 02/27/2010 06:09 AM, Austin Powers wrote:

It is purely a guess that I need to start again from a complete clean setup
(reformatting my hard disk and reinstall OS X again) but that is pretty much
out of the question.
I guess my question is:
How can I completely uninstall PHP so that I can start again?


Hello,

Someone should be able to help you if you can provide us with the steps 
you tried and where you failed.


--
John
Der unmündige Untertan ruft die Polizei. Der mündige Bürger informiert
seinen Anwalt.
[Nikolaus Cybinski]

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



Re: [PHP] Sending e-mail via socket

2010-02-23 Thread John Black

On 02/23/2010 01:16 AM, Andre Polykanine wrote:

Hello everyone,
I've just subscribed to the list, and I already have a question.
what I need to do is to send mail using sockets. Actually, the
built-in Mail() function is great and I wouldn't have to search for
something else if I didn't need more than one message to be sent at a
time. Say, I have ten or a hundred of users who want to receive a
notification about new blog entries. If I use the mail() function in
the loop, it will be performed too slow since it constantly opens and
closes the door, I mean, the SMTP connection.


Have you figured it out yet?
I have written a SMTP function a couple of years ago which will talk to 
any SMTP server directly via socket. The only limitation I have noticed 
is that it does not support encrypted logins but that can be added, I 
just never bothered to do it.


So let me know if you still require it and I'll dig it out.

--
John
Ihr führt Krieg? Ihr fürchtet euch vor einem Nachbarn? So nehmt doch die
Grenzsteine weg - so habt ihr keinen Nachbarn mehr. Aber ihr wollt den
Krieg und deshalb erst setztet ihr die Grenzsteine.
[Friedrich Nietzsche]

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



Re: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread John Black

On 02/22/2010 09:39 PM, Slack-Moehrle wrote:

Hi All,
I have Forms that I submit for processing. I have seen examples of people using 
either $_POST or $_REQUEST.
When would I choose one over the other?


When you don't care how you get the data use $_REQUEST.
$_REQUEST will contain $_GET,$_POST,$_COOKIE in the order specified in 
php.ini. Don't know what the default is.



$_POST[j_orderValue]


Don't do that, PHP will bitch that you are attempting to use a constant 
as a string or something like that. Make sure you enable error reporting 
in php.ini and use

display_errors = On
error_reporting = E_ALL | E_STRICT
for development but not on your server unless you log only.



$_POST['j_orderValue']


There are a few ways to write this properly, depending on how you use 
it. The above is how I usually use it but this is also possible.

x = $_POST['j_orderValue'] = that is how I write it
x = $_POST[j_orderValue] = also ok because it is a stirng
for $x=0; $x  10, $x++ )
$foo[$x] = $_POST[j_orderValue$x]
 is also possible

echo foo $_POST[j_orderValue];
echo foo {$_POST['j_orderValue']};
 and a few more, there was a great thread a while back which listed 
every possible combination.



Single quotes is best, correct to prevent sql injection?


SQL injects happen when you use the $_RESQUEST[] information, as is, in 
your SQL string.


SELECT * FROM foo WHERE XXX=$_REQUEST['yyy'] = very bad!

You should be doing:

... code sanity check here.
- is a number really number, length and so on ...

Then if you use a MySQL database you would escape the string like this
$tmp = mysql_real_escape_string($_REQUEST['yyy']);

and use it like this.
SELECT * FROM foo WHERE XXX=$tmp

mysql_real_escape_string() protect from SQL injection by escaping your 
string according to what your charset requires.


--
John
Nur wer im Wohlstand lebt, schimpft auf ihn.
[Ludwig Marcuse]

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



Re: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread John Black

On 02/22/2010 10:37 PM, Michael Shadle wrote:

On Mon, Feb 22, 2010 at 1:30 PM, David Murphyda...@icewatermedia.com  wrote:

Richard,
The use of $_REQUEST it no more a security hole than $_GET or $_REQUEST,
they should ALL be treats as bad data until normalized and sanitized.  The
claim that it opens a security hole  is  just false, that’s like saying PHP
is insecure, its not it just allows for lazy coding such as $_REQUEST.



It represents a way for people to exploit coders who don't know any better.
Expecting a cookie value to come through in $_REQUEST but you could
override using a query string parameter makes for easy exploitation.


And how is this more secure? I can create a cookie, send post or get on 
my client machine and send anything I want to the server. Just because 
you are getting a cookie does not mean that you created it :)


So you might as well use request because the data can not be trusted 
either way.


--
John
Gerechtigkeit entspringt dem Neid; denn ihr oberster Grundsatz ist: 
Allen das Gleiche.

[Walther Rathenau]

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



Re: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread John Black

On 02/22/2010 11:17 PM, Michael Shadle wrote:

Secure might be the wrong term here. As you can easily change GET to
POST and vice-versa and send any cookies you like, this is why I tried
to revise my statement and quantify it better... in a properly coded
app it doesn't present much issue. However, it encourages laziness and
PHP's barrier to entry is so easy that there is a lot of people who
consider a cookie to be trusted, and overriding it with a simple GET
parameter is too easy of an attack vector. At least make it difficult.


Just because someone believes that a cookie is something that can be 
trusted does not make it so. A properly coded app should not care how 
the client sends the information, only that the information is it valid 
and expected.


A cookie is the same thing as $_POST or $_GET data but it can be stored 
for a period of time, what happens to the stored data is out of our 
control. Treating one any different from the other is just wrong and 
will create apps with security holes.


For anybody who would like to try the GUI version of tampering with data 
sent to the server checkout TamperData for FireFox.


--
John
Klarmachen zum Ändern!
http://www.youtube.com/v/AYM-_qfytfA

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



Re: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread John Black

On 02/22/2010 11:42 PM, Michael Shadle wrote:

The difference here is you can at least have some control over the data
and expect it in a certain fashion. Also the behavior of cookies vs. get
vs. post are different (cookies have length and expiration limits, get
has length limits, post has server confgured limits)


The cookie and post/get part is all mixed up now :)

I use $_COOKIE when I want cookie information but I know that the data 
is not to be trusted and is easily fabricated.


When reading get or post I just use $_REQUEST nowadays because I don't 
have to care how the submitting form is written. This makes my form 
handling data more portable.


--
John
You may say I'm a dreamer, but I'm not the only one,
I hope some day you'll join us, And the world will live as one.
[John Lennon]

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



Re: [PHP] How to secure this

2010-02-13 Thread John Allsopp

Robert Cummings wrote:

Ashley Sheridan wrote:

On Fri, 2010-02-12 at 16:12 -0500, Robert Cummings wrote:


John Allsopp wrote:

Hi everyone

There may be blinding bits of total ignorance in this so don't 
ignore the obvious.


This is a security question, but a sentence of background: I'm 
writing software for a mapping/location website and I want to be 
able to provide something others can plug into their website that 
would display their map.


So I'm providing a URL like 
http://www.mydomain.com?h=300w=250username=namepassword=password


The idea is they can define their own height and width and it plugs 
in as an iframe.


That takes the username and password and throws it over web 
services to get back the data from which we can create the map.


My question (and it might be the wrong question) is how can I not 
give away the password to all and sundry yet still provide a 
self-contained URL?
MD5() (or SHA()) hash the information and supply that along with the 
settings. Then you know it was generated by your site. So you can do 
the following:


?php

$height = 300;
$width = 250;
$username = 'username';
$key = md5( SECRET_SALT-$heigh-$width-$username );

$url = 
http://www.mydomain.com?h=$heightw=$widthusername=$usernamekey=$key;; 



?

Then when you get this URL via the iframe, you re-compute the 
expected key and then compare it against the given key. Since only 
you know the SECRET_SALT value then nobody should be able to forge 
the key.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP




What about requiring them to sign in the first time to use your service,
and then give them a unique id which i tied to their details. You could
then get them to pass across this id in the url. You could link their
account maybe to some sorts of limits with regards to what they can
access maybe?


Presumably they ARE logged in when you create this URL for them... 
otherwise someone else could generate it :)


Cheers,
Rob.
Well no they are not logged in, it's just an embedded iframe so that's 
my main issue with my method, anyone could look at the web page source, 
pinch the URL of the iframe and they'd have the username and password.


I'd got as far as MD5, but not the Secret Salt bit.

The thing that warped my head was .. if the URL then becomes
http://www.mydomain.com?h=$heightw=$widthusername=$usernamekey=$key 
that's the same thing isn't it ..  a URL anyone could use anywhere? In a 
sense, we would have simply created another password, the MD5 key, which 
was a valid way to get into the system.


So then validating the domain from a list stops anyone using it anywhere 
and means we can switch it off by domain if we need to.


And .. we're not passing the password, right? We're not mixing that into 
the MD5? We are just saying, if you have the right username, if we know 
you've come via our code (secret salt), and you're from an approved 
domain, we'll let you in.


Sorted, I think .. unless you spot any faulty reasoning in the above. 
Thanks very much guys :-)


J







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



[PHP] How to secure this

2010-02-12 Thread John Allsopp

Hi everyone

There may be blinding bits of total ignorance in this so don't ignore 
the obvious.


This is a security question, but a sentence of background: I'm writing 
software for a mapping/location website and I want to be able to provide 
something others can plug into their website that would display their map.


So I'm providing a URL like 
http://www.mydomain.com?h=300w=250username=namepassword=password


The idea is they can define their own height and width and it plugs in 
as an iframe.


That takes the username and password and throws it over web services to 
get back the data from which we can create the map.


My question (and it might be the wrong question) is how can I not give 
away the password to all and sundry yet still provide a self-contained URL?


Thanks in advance :-)

Cheers
J



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



[PHP] PHP will NOT display this on my dev machine: Warning: session_start()...

2010-02-11 Thread John Black

I am running into a strange problem and I hope someone might have an
idea why this is happening.

My installation of PHP will *NOT* display the warning message below on 
my development machine where it should display it (sample code at the 
bottom).

Warning: session_start() [function.session-start]: Cannot send session
cache limiter 

After receiving a bug report from a customer I tested my code on a XAMPP
setup and, sure enough, it displayed the warning message.
But on my machine, I can't find a message in my php log, it is as if 
this problem does not even exist (on my dev machine).


My dev setup is:
OS: ARCH 64bit (about a month out of date)
PHP Dev stuff:
  Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8k DAV/2 SVN/1.6.6
  PHP/5.3.1 with Suhosin-Patch
  xdebug-2.0.5-2-x86_64

php.ini
  error_reporting = E_ALL | E_STRICT
  display_errors = On
  display_startup_errors = On
  log_errors = On
  html_errors = On
  

phpinfo() confirms that these settings are in effect
display_errors  On  On
error_reporting 32767   32767

So does anybody have any clue as to what could be causing this problem 
of not getting a warning message?


Here is sample code:
pThe warning should be below this line/p
?PHP session_start(); ?
pThe warning should be above this line/p

Which should produce the message below between the lines:
Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent ( output started at file_name on
line 2 )

but on my machine all I get is this in html source of the output:
pThe warning should be below this line/p
pThe warning should be above this line/p

thx
--
John
Staat heißt das kälteste aller kalten Ungeheuer.  Kalt lügt es auch; und
diese Lüge kriecht aus seinem Munde: 'Ich, der Staat, bin das Volk.'
[Friedrich Nietzsche]


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



Re: [PHP] PHP will NOT display this on my dev machine: Warning: session_start()...

2010-02-11 Thread John Black

Adam Richardson wrote:

Do you have output buffering turned on?


THANK YOU!
That was it, for some reason ARCH has a tweaked php.ini in their main
repo, that sucks.

Thank you, I have been looking all over to fix this!

--
John


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



Re: [PHP] Simple code obfuscation

2010-02-10 Thread John Black

Brian Dunning wrote:
 But I do want to add some level of code obfuscation to prevent them 
from making simple changes to my code that allow them to exceed the 
privileges they've purchased.


I have used PHP Processor 1.5 from http://gridinsoft.com for this. Back 
when I was looking around it was the only offering which did not require 
me to modify my source code and it does not require the clients to 
install anything. This one is not free but it is very reasonably priced.


It is also a PHP editor but I never used it for that. You can simply 
import a fully project, I used to run a project with multiple subdirs 
and about 1.5MB of source code through it.
It can remove all newline and linefeed chars, replace $variable with 
$asdFDG and do the same with functions and classes.


You can exclude global variables, functions or classes by using a simple 
checkbox list.


This program has performed very well but I stopped using it because 
sometimes it clashed with pages containing javascript, PHP and html so I 
would have to test everything twice.
Using it on pure PHP scripts should work flawless and I will probably 
start using this program again for my license handling class.


I know that this tool is available for free on some websites but make 
sure you purchase the latest edition. The program had a bug when 
generating random variables or function names. I reported it and they 
fixed it, so get the patched version or you will not be very happy :)


--
John
RIP jacky.network-technologies.org
[r...@jacky /]# uptime
 05:09:18 up 607 days, 23:17

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



Re: [PHP] Re: MySQL ID -- what happens when you run out of range?

2010-01-25 Thread John Meyer

On 1/25/2010 1:19 PM, Nathan Rixham wrote:

Parham Doustdar wrote:

Hello there,
A friend called me today and was wondering what happens if the ID colomn of
an MYSQL database, set to autoinc reaches the int limit. Will it return and
begin choosing the ID's that have been deleted, or... what?


you change it to bigint before that happens :)

for a more accurate answer ask on the mysql forum?



Or the e-mail list: my...@lists.mysql.com (though I understand the 
cross-pollination)



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



[PHP] If the first four characters are 0000, then do {}

2010-01-25 Thread John Taylor-Johnston

I am reading the manual: http://ca.php.net/manual/en/ref.strings.php

$mydata-restored = -00-00;

How do I express this? If the first four characters are , then do {}

What I am looking for is in strpos(), no?

if ()
{
}

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



[PHP] intermittent failure of php date

2010-01-18 Thread John Corry
I maintain a site that is generating some strange behavior...

It's a custom built event registration app.

Events have event_dates that are stored in the MySQL db.

This code retrieves the event title and event date for display on the
registration acknowledgment page:

$q2 = SELECT title, event_date, DATE_FORMAT(event_date, '%M %d, %Y') AS
formatted_event_date FROM events WHERE id = . $eid . ;;
 $result = mysql_query($q2);
 if ($result) {
   $row = mysql_fetch_array($result);
   $title = $row['title'];

   if(strtotime($row['event_date'])) {
  $event_date = date(F m, Y, strtotime($row['event_date']));
   } else {
  $event_date = $row['formatted_event_date'];
   }

Sometimes, it doesn't work.

Every 3rd or 4th registration notification email comes through with an empty
value for event_date.

There are no other references to the variable $event_date.

It works most of the time.

There's no pattern I can see. I even tried to force it to show a date by
selecting a formatted date and displaying that if the original programmer's
strtotime failed.

Where do you look for help with intermittent failures of a date field in the
DB?


-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] Re: intermittent failure of php date

2010-01-18 Thread John Corry
The field in the DB is defined as type date.

I've had several event registrations for an upcoming event come through. THe
event date is '2010-01-27'.

2 of the 5 event registrations contained empty values for the date.

wtf?

On Mon, Jan 18, 2010 at 10:23 AM, John Corry jcorry.li...@gmail.com wrote:

 I maintain a site that is generating some strange behavior...

 It's a custom built event registration app.

 Events have event_dates that are stored in the MySQL db.

 This code retrieves the event title and event date for display on the
 registration acknowledgment page:

 $q2 = SELECT title, event_date, DATE_FORMAT(event_date, '%M %d, %Y') AS
 formatted_event_date FROM events WHERE id = . $eid . ;;
  $result = mysql_query($q2);
  if ($result) {
$row = mysql_fetch_array($result);
$title = $row['title'];

if(strtotime($row['event_date'])) {
   $event_date = date(F m, Y, strtotime($row['event_date']));
} else {
   $event_date = $row['formatted_event_date'];
}

 Sometimes, it doesn't work.

 Every 3rd or 4th registration notification email comes through with an
 empty value for event_date.

 There are no other references to the variable $event_date.

 It works most of the time.

 There's no pattern I can see. I even tried to force it to show a date by
 selecting a formatted date and displaying that if the original programmer's
 strtotime failed.

 Where do you look for help with intermittent failures of a date field in
 the DB?


 --
 John Corry
 PHP developer - 3by400, Inc
 http://www.3by400.com




-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] order by ASC

2010-01-16 Thread John Taylor-Johnston

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does not 
order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?

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



Re: [PHP] order by ASC

2010-01-16 Thread John Taylor-Johnston

It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(rollnumber AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(`rollnumber` AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST('rollnumber' AS int)


You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near 'int) ASC' 
at line 1


I'll keep trying.

Robert Cummings wrote:

CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does 
not order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way 
in PHP?


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



Re: [PHP] order by ASC

2010-01-16 Thread John Taylor-Johnston

Did some googling. This worked:
ORDER BY CAST(`rollnumber` AS SIGNED)

What is the difference? My problem in the meanwhile must be my version 
of MySQL?


John Taylor-Johnston wrote:

It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(rollnumber AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(`rollnumber` AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST('rollnumber' AS int)


You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near 'int) ASC' at line 1


I'll keep trying.

Robert Cummings wrote:

CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does 
not order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way 
in PHP?





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



[PHP] parse date field

2010-01-14 Thread John Taylor-Johnston

How do I parse a date field from mysql?

I was hoping this would work:

$mydata-birthday = 2007-02-13;
#What month is it?
echo date(F, $mydata-birthday);
#What year is it?
echo date(Y, $mydata-birthday);

What am I missing? All I get is December 1969. Hmmm?

I am looking at the manual:
http://ca.php.net/manual/en/function.date.php
http://ca.php.net/manual/en/function.mktime.php
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html


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



Re: [PHP] parse date field

2010-01-14 Thread John Taylor-Johnston

Super, thanks. 5:14 a.m. - My head is fogging :p

vikash wrote:

Use strttotime() function. This will work as intended.

$mydata-birthday = strtotime(2007-02-13);
#What month is it?
echo date(F, $mydata-birthday);
#What year is it?
echo date(Y, $mydata-birthday);

On Thu, Jan 14, 2010 at 3:31 PM, John Taylor-Johnston 
john.taylor-johns...@cegepsherbrooke.qc.ca 
mailto:john.taylor-johns...@cegepsherbrooke.qc.ca wrote:


How do I parse a date field from mysql?

I was hoping this would work:

$mydata-birthday = 2007-02-13;
#What month is it?
echo date(F, $mydata-birthday);
#What year is it?
echo date(Y, $mydata-birthday);

What am I missing? All I get is December 1969. Hmmm?

I am looking at the manual:
http://ca.php.net/manual/en/function.date.php
http://ca.php.net/manual/en/function.mktime.php
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html


-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] IDE - SVN - dev server - live server

2010-01-14 Thread John Corry
I am working on designing an documenting a process for our team to use to
manage code updates/changes.

What we've been doing has been ghastly: a bunch of developers using
dreamweaver's 'check in/out' functions, all using the same FTP login, to FTP
files to the production server.

It turns out the site we're working on together is a bit too complex for
this, so it's on me to come up with a better way.

I'm a big fan of SVN and think we'll be light years ahead of where we are
presently by using SVN to manage code revisions.

So, I've set up an SVN repository on our dedicated server and imported all
of the live-site code. Then I set up a dev virtual host (dev.domain.com) and
exported all of the code in my repository to that vhost's DocRoot. So...that
gave me a copy. Next, I copied the MySQL db to a separate db that we'll use
for the dev server...so dev code doesn't query the live db. Then of course,
I had to edit the config files that have DSN information in them to make
sure my dev site actually uses my dev db.

Here's where the problems start to creep in...

If I export the whole repository from SVN to the dev DocRoot directory, I'm
going to overwrite the config files that have DSN info in them. Similarly,
there are some javascript files that declare variables like var base_url = '
http://mysite.com'...those variables need to be set once for the environment
(my local IDE? the dev server? the production server?) and then not messed
with afterward.

After an SVN commit, it's really easy to svn export svn://localhost/mysite
/path/to/my/dev_server

Simple, all of the code in the repository goes to the dev server.

The issue I'm having is that there are a number of files that I do NOT want
to be copied from the repository to the dev server, except on
rare occasions.

So, I can choose to add the files to my svn:ignore in my working copy so
they aren't committed/updated. But I can't ensure that all of the developers
take this step and it's not a reliable way to keep those select files in the
repository out of my dev server.

Or, I can write a shell script that does the SVN export, then overwrites the
selected config files with master versions that are stored somewhere else
and not edited by any of the team. One problem with that though, is that our
main javascript file tends to be edited/changed and it's one that can create
problems if that base_url var isn't appropriate to the server it's on.

Or, in all of my PHP files, I can write the config values into switch
statements:
switch($_SERVER['HTTP_HOST']) {
  case 'mysite.local':
 // local IDE config directives
  case 'dev.mysite.com':
 // dev server config directives
  // etc...
}

...but that leaves the production server DSN sitting around in development
code, which I'd like to avoid, and I don't have an analogous solution for my
javascript files.

JS question: is there a js way to do the same thing? Evaluate the js
equivalent of PHP's $_SERVER['HTTP_HOST']? If there is, I think this
solution will work.

This has got to be a fairly typical workflow and problem.

What are some of the strategies you folks use for designing your flow of
code from local IDE to SVN to dev server to production server?

-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


  1   2   3   4   5   6   7   8   9   10   >