php-general Digest 29 May 2008 07:05:37 -0000 Issue 5485

2008-05-29 Thread php-general-digest-help

php-general Digest 29 May 2008 07:05:37 - Issue 5485

Topics (messages 274780 through 274798):

Re: Calendar Date Help
274780 by: Robert Cummings
274782 by: Mark Weaver

Re: looking a regular expresion
274781 by: Boyd, Todd M.

Re: In case this helps... (Calendar Date Help)
274783 by: Mark Weaver
274784 by: Robert Cummings
274785 by: Robert Cummings
274786 by: Mark Weaver
274787 by: Mark Weaver

Reloading changes JS files?
274788 by: Skip Evans
274790 by: Skip Evans
274792 by: Wolf
274795 by: Jim Lucas

Query refuses to recurse all rows
274789 by: celtic.aolohr.com
274791 by: Chris
274793 by: Wolf
274796 by: Jim Lucas
274797 by: celtic.aolohr.com

Re: Query refuses to recurse all rows {RESOLVED]
274794 by: celtic.aolohr.com

Help mms (Get audio Stream)
274798 by: Shelley

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---

On Wed, 2008-05-28 at 14:27 -0400, Mark Weaver wrote:
 Hi all,
 
 I've put this off as long as possible, however I think I've reached an 
 impasse.
 
 I've got an application that I've been writing. One of the modules for 
 this app is an event calendar. I've got the calendar to the place where 
 it displays the current month as well as previous and future months. The 
   place I'm stuck is it will only show months in the past or the future 
 that are months in the current year.
 
 Basically the method I'm using to move backward and forward is with Unix 
 timestamps.
 
 1. When the calendar first loads the what is checked for;
   // passed in via $_GET
   $what == current, prev, or next
a. current is the default
   $now = time()
   $prev = date('n',$now)-1
   $next = date('n',$now)+1
b. Timestamp values are then stored in an array and then
   sent to client in session cookie which is then accessed
   upon each subsequent request to display the event calendar.
 
 My question/boggle is why, when the calendar advances to 
 December(current year) it will display January, but of the current year. 
 The same happens in reverse.
 
 Once I reach the end of the year either in the past or future the month 
 increases or decreases accordingly, but the year doesn't change. Since 
 the year value isn't changing the month calendar days that are displayed 
 simply repeat themselves.
 
 I know there's something I'm missing, but I am definitely not seeing 
 what it is...
 
 /** code below /
 
 $cal = new Calendar;
 $calpos = array();
   
 // check incoming values
 if ($what === current){
   $cal-setCal(0,0,0,date('n'),1);
   $now = time();
   $prev = $cal-getStamp(date('n',$now)-1,1);
   $next = $cal-getStamp(date('n',$now)+1,1);
   $calpos['curr'] = $now;
   $calpos['prev'] = $prev;
   $calpos['next'] = $next;
   $_SESSION['calendar'] = $calpos;
 } 
 elseif($what === prev){
   $peek = $_SESSION['calendar'];
   $now = $peek['prev'];
   $cal-setCal(0,0,0,date('n',$now),1);
   $prev = $cal-getStamp(date('n',$now)-1,1);
   $next = $cal-getStamp(date('n',$now)+1,1);
   $calpos['curr'] = $now;
   $calpos['prev'] = $prev;
   $calpos['next'] = $next;
   $_SESSION['calendar'] = $calpos;
 }
 elseif($what === next){
   $peek = $_SESSION['calendar'];
   $now = $peek['next'];
   $cal-setCal(0,0,0,date('n',$now),1);
   $prev = $cal-getStamp(date('n',$now)-1,1);
   $next = $cal-getStamp(date('n',$now)+1,1);
   $calpos['curr'] = $now;
   $calpos['prev'] = $prev;
   $calpos['next'] = $next;
   $_SESSION['calendar'] = $calpos;
 }
 
 
 function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
$stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
^
^
^
You don't want the current year. Fix this to a request year.

// Using the stamp the various necessary properties are set for the
// object
 
 function getStamp($dateStr,$dayVal=1){
return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
 }
^
^
^
Similarly.

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

---End Message---
---BeginMessage---

Robert Cummings wrote:

function 

[PHP] Help mms (Get audio Stream)

2008-05-29 Thread Shelley
1. URL
http://pub.qmoon.net/WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint

2. Call method

HTTP GET:
GET / WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint HTTP/1.1
Host: pub.qmoon.net

3.  return (string)

?xml version=1.0 encoding=utf-8 ?
string xmlns=http://www.qmoon.net/;mms://pub.qmoon.net/audio/string

How can I listen to the audio stream with PHP?
Anybody some suggestions?

Thank you in advance.


-- 
Regards,
Shelley


Re: [PHP] Reloading changes JS files?

2008-05-29 Thread Richard Heyes

img src='/image/bulk.jpg?112344324' /

anything after the question mark will get ignored by the browser. Except 
that the browser will think that it is a new URL that it has never seen 
before and it will call to the server for a fresh copy of the file.


Another options is instead of a question mark use a forward slash. This 
may be Apache specific though. Eg.


img src='/image/bulk.jpg/112344324' /

ISTR question marks are not search engine friendly, so for pages this 
may be a preferred option.


--
  Richard Heyes

 In Cambridge? Employ me
http://www.phpguru.org/cv

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] Reloading changes JS files?

2008-05-29 Thread Per Jessen
Skip Evans wrote:

 Hey all,
 
 I have an HTML template file I read into a PHP
 script and then after supplying dynamic data I
 send the template to the browser with
 
 echo $html;
 
 The HTML template contains many JS files in the
 head.../head section referenced like this:
 
 script src=ajax/players.js
 type=text/javascript/script
 
 My question is this: how can I cause the JS files
 on the header.html file to be reloaded to the
 browser when ever they have been modified?

When you do an explicit refresh or reload in your browser, it should
ignore whatever it's got cached and refetch your javascript files
regardless. 


/Per Jessen, Zürich


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



[PHP] Embed images in emails

2008-05-29 Thread Iñigo Medina García
Hi,

I'm trying to send emails with embed and dynamic images: a normal tell a
friend feature which sends the email with item's data: author, title,
image-cover, etc.

Ideas PEAR and mime classes apart?

thanks

   iñigo

-- 

Iñigo Medina García 
Librería Díaz de Santos 
Madrid (Spain)
Dpt.Desarrollo

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



[PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay
Hello,

I'm adding functionality to allow a user to copy data on a page to the
clipboard using JS. This can be done simply with:

  window.clipboardData.setData('Text','String to copy to clipboard');

The string from PHP needs to contain line breaks when copied into the
clipboard. This works when I use \n, e.g. 'This string\nspans
multiple\nlines' but how do I escape this string when outputting it from
PHP?

addslashes() seems the obvious choice, but as it escapes backslashes, the \n
chars end up in the clipboard!



Using hard new lines in the argument passed to the JS function doesn't work
as this causes JS errors:

DOESN'T WORK:
script type=text/javascript

var sCopy = 'String to copy
to clipboard';

/script

input type=button value=COPY
onclick=window.clipboardData.setData('Text',sCopy); /



Any ideas?

Thanks,
Edward


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



Re: [PHP] Reloading changes JS files?

2008-05-29 Thread Per Jessen
Richard Heyes wrote:

 When you do an explicit refresh or reload in your browser, it
 should ignore whatever it's got cached and refetch your javascript
 files regardless.
 
 With Interweb Explorer you need to hold down CTRL and CLICK on refresh
 (as opposed to pressing CTRL+R say) to get a fresh copy. I guess it
 depends on the headers you send on the page. Doing this will send a:
 
 Cache-Control: no-cache
 
 request header.

Any cache-instructions on the request are really for intermediate caches
and proxies only.  The webserver itself doesn't do anything with them. 
If you send an unconditional fetch, you will get a document served.  I
don't know if an explicit refresh will cause the browser to do
conditional gets or not, but it probably will.


/Per Jessen, Zürich


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



Re: [PHP] Escaping JavaScript strings

2008-05-29 Thread Richard Heyes

 ...

This is a PHP function that escapes strings so you can output them as a 
JS string. IIRC it assumes you're using single quotes to enclose your 
strings.


/**
* Function to appropriately escape a string so it can be output
* into javascript code.
*
* @param  string $string Input string to escape
* @return string Escaped string
*/
function escapeString($string)
{
$js_escape = array(\r = '\r',
   \n = '\n',
   \t = '\t',
   '  = \\',
   '\\' = '');

return strtr($string, $js_escape);
}

--
  Richard Heyes

 In Cambridge? Employ me
http://www.phpguru.org/cv

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] Reloading changes JS files?

2008-05-29 Thread Richard Heyes

When you do an explicit refresh or reload in your browser, it should
ignore whatever it's got cached and refetch your javascript files
regardless. 


With Interweb Explorer you need to hold down CTRL and CLICK on refresh 
(as opposed to pressing CTRL+R say) to get a fresh copy. I guess it 
depends on the headers you send on the page. Doing this will send a:


Cache-Control: no-cache

request header.

--
  Richard Heyes

 In Cambridge? Employ me
http://www.phpguru.org/cv

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] SOLVED: Calendar Date Help

2008-05-29 Thread Mark Weaver

Mark Weaver wrote:

Hi all,

I've put this off as long as possible, however I think I've reached an 
impasse.


I've got an application that I've been writing. One of the modules for 
this app is an event calendar. I've got the calendar to the place where 
it displays the current month as well as previous and future months. The 
 place I'm stuck is it will only show months in the past or the future 
that are months in the current year.


Basically the method I'm using to move backward and forward is with Unix 
timestamps.


1. When the calendar first loads the what is checked for;
// passed in via $_GET
$what == current, prev, or next
  a. current is the default
$now = time()
$prev = date('n',$now)-1
$next = date('n',$now)+1
  b. Timestamp values are then stored in an array and then
sent to client in session cookie which is then accessed
upon each subsequent request to display the event calendar.

My question/boggle is why, when the calendar advances to 
December(current year) it will display January, but of the current year. 
The same happens in reverse.


Once I reach the end of the year either in the past or future the month 
increases or decreases accordingly, but the year doesn't change. Since 
the year value isn't changing the month calendar days that are displayed 
simply repeat themselves.


I know there's something I'm missing, but I am definitely not seeing 
what it is...


/** code below /

$cal = new Calendar;
$calpos = array();
   
// check incoming values

if ($what === current){
$cal-setCal(0,0,0,date('n'),1);
$now = time();
$prev = $cal-getStamp(date('n',$now)-1,1);
$next = $cal-getStamp(date('n',$now)+1,1);
$calpos['curr'] = $now;
$calpos['prev'] = $prev;
$calpos['next'] = $next;
$_SESSION['calendar'] = $calpos;
}   
elseif($what === prev){

$peek = $_SESSION['calendar'];
$now = $peek['prev'];
$cal-setCal(0,0,0,date('n',$now),1);
$prev = $cal-getStamp(date('n',$now)-1,1);
$next = $cal-getStamp(date('n',$now)+1,1);
$calpos['curr'] = $now;
$calpos['prev'] = $prev;
$calpos['next'] = $next;
$_SESSION['calendar'] = $calpos;
}
elseif($what === next){
$peek = $_SESSION['calendar'];
$now = $peek['next'];
$cal-setCal(0,0,0,date('n',$now),1);
$prev = $cal-getStamp(date('n',$now)-1,1);
$next = $cal-getStamp(date('n',$now)+1,1);
$calpos['curr'] = $now;
$calpos['prev'] = $prev;
$calpos['next'] = $next;
$_SESSION['calendar'] = $calpos;
}


function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){   
  $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));

  // Using the stamp the various necessary properties are set for the
  // object

function getStamp($dateStr,$dayVal=1){
  return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
}



Just in case:
The solution was right in front of my all along. When setting the 
calendar object I was giving the class everything it needed except the 
{year} value. I _ass_-umed it was being set auto-magically; possibly by 
fairies or tree elves. Turns out I needed to set that parameter. Imagine 
that... :)

--
$cal-setCal(0,0,0,date('n',$now),1);
--
function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
   $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
   
--

Solution:
setCal function from Calendar Class:
function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1,$yrVal)

current: $cal-setCal(0,0,0,date('n',time()),1,date('Y',time()));

$prev value coming from session cookie
$now = $session['prev'];
prev: $cal-setCal(0,0,0,date('n',$now),1,date('Y',$now));

$next value coming from session cookie
$now = $session['next'];
next: $cal-setCal(0,0,0,date('n',$now),1,date('Y',$now));

It all works very nicely now.

Thank you Robert for the push to seriously scrutinize my code.

--
Mark
-
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==
Powered by CentOS5 (RHEL5)

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



RE: [PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay

 
 This is a PHP function that escapes strings so you can output them as a 
 JS string. IIRC it assumes you're using single quotes to enclose your 
 strings.
 
  /**
  * Function to appropriately escape a string so it can be output
  * into javascript code.
  *
  * @param  string $string Input string to escape
  * @return string Escaped string
  */
  function escapeString($string)
  {
  $js_escape = array(\r = '\r',
 \n = '\n',
 \t = '\t',
 '  = \\',
 '\\' = '');
 
  return strtr($string, $js_escape);
  }


Just what was needed - thanks Richard.

Edward

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



[PHP] IMAP connection to specific directory

2008-05-29 Thread Niall Jackson

Hi,

I am attempting to set up a group webmail client wherein certain emails 
can be stored separately from the normal mailbox system and retrieved 
for viewing by any user via a separate mechanism to the normal client.


According to the documentation, I should be able to connect to this 
store using something of the form:


imap_open({localhost/imap}/path/to/maildir, u, p);

or perhaps:

imap_open({localhost/imap}#driver.maildir/path/to/maildir, u, p);

Various combinations of path, permissions, and so on all, without fail, 
yield the error Mailbox does not exist, or must be subscribed to. 
Attempting to subscribe to the mailbox does not fix this, and since one 
of the paths tried was that of a mailbox accessible through the normal 
route:


imap_open({localhost/imap}INBOX, u, p);

I can only assume that I'm doing something wrong.

Can anyone assist? Specifically, I need to know:

* Are there any pitfalls associated with setting the mailbox up? (eg. 
path restrictions, permissions, ownership, format.) We're using maildir 
format elsewhere, it seems to be the most suitable.


* How exactly should the imap_open command be written to access such a 
mailbox? Are there other commands needed as well (eg. imap_subscribe)?


Thanks in advance,

Niall

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



[PHP] How to Using xsl with .odt files

2008-05-29 Thread Priyanka
How to import the stylesheet from a .odt file and modify it and use it for 
creating a document.

Can we use xsl functions for this process. If yes, then what are the required 
xsl functions?

Re: [PHP] Help mms (Get audio Stream)

2008-05-29 Thread Gabriel Sosa
what do you wanna do ?? just a bridge? or try to play it?? in that
case you can't.
i think you should get the streamming and try to play it with flash

saludos

On Thu, May 29, 2008 at 4:05 AM, Shelley [EMAIL PROTECTED] wrote:
 1. URL
 http://pub.qmoon.net/WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint

 2. Call method

 HTTP GET:
 GET / WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint HTTP/1.1
 Host: pub.qmoon.net

 3.  return (string)

 ?xml version=1.0 encoding=utf-8 ?
 string xmlns=http://www.qmoon.net/;mms://pub.qmoon.net/audio/string

 How can I listen to the audio stream with PHP?
 Anybody some suggestions?

 Thank you in advance.


 --
 Regards,
 Shelley




-- 
Los sabios buscan la sabiduría; los necios creen haberla encontrado.
Gabriel Sosa


Re: [PHP] How to Using xsl with .odt files

2008-05-29 Thread Per Jessen
Priyanka wrote:

 How to import the stylesheet from a .odt file and modify it and use it
 for creating a document.
 
 Can we use xsl functions for this process. If yes, then what are the
 required xsl functions?

Doesn't really sound like a PHP-related question, but yes it is all
possible.  The .odt file is plain XML, you can XSL to fiddle with it. 


/Per Jessen, Zürich


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



[PHP] Re: A Little Something.

2008-05-29 Thread Michelle Konzack
Am 2008-05-28 08:40:09, schrieb Philip Thompson:
 It's amazing how someone so involved in security would provide any of  
 this information. Name, job, location, phone numbers, Internet  
 contact. You might as well have given the name of your children as  
 well. Nevermind, I'll go find that out on Google. =P
 END OF REPLIED MESSAGE 

This is NOT the problem...
I was talking about the tracking of my activities around the world since
I have customers in Iran, Turkey, Syria, Lebanon,  Moroco,  Germany  and
Swiss.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] How to Using xsl with .odt files

2008-05-29 Thread Wolf
 Priyanka [EMAIL PROTECTED] wrote: 
 How to import the stylesheet from a .odt file and modify it and use it for 
 creating a document.
 
 Can we use xsl functions for this process. If yes, then what are the required 
 xsl functions?

EASY!!!  Just STFW for XSL and ODT

This might help: http://healthlinks.washington.edu/howto/beyondgoogle.html

Then, once you understand what you are trying to work with, you can plug PHP 
into the search and see what PHP functions work best for what you are trying to 
accomplish.

And when you get stuck, POST THE CODE and we'll be glad to help you iron out 
the issues you have.

Wolf

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



Re: [PHP] Re: A Little Something.

2008-05-29 Thread Wolf

 Michelle Konzack [EMAIL PROTECTED] wrote: 
 Am 2008-05-28 08:40:09, schrieb Philip Thompson:
  It's amazing how someone so involved in security would provide any of  
  this information. Name, job, location, phone numbers, Internet  
  contact. You might as well have given the name of your children as  
  well. Nevermind, I'll go find that out on Google. =P
  END OF REPLIED MESSAGE 
 
 This is NOT the problem...
 I was talking about the tracking of my activities around the world since
 I have customers in Iran, Turkey, Syria, Lebanon,  Moroco,  Germany  and
 Swiss.
 
 Thanks, Greetings and nice Day
 Michelle Konzack
 Systemadministrator

Then get SMART about your surfing.

Set up your browser to use a burn alias, a yahoo email account you never check 
(or hotmail or whatnot) set to an ex-lover's name and post under an anonymous 
account.

But don't B*tch about a website that doesn't look/work like *YOU* think it 
should look/work when you arbitrarily block things that either don't have an 
impact or that *YOU* are not willing to take responsibility for your own 
actions.

Oh, you must be part of that ME generation who's unable to take 
responsibility for things.

Wolf

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



Re: [PHP] SOLVED: Calendar Date Help

2008-05-29 Thread Robert Cummings
On Thu, 2008-05-29 at 07:37 -0400, Mark Weaver wrote:
 Mark Weaver wrote:
  Hi all,
  
  I've put this off as long as possible, however I think I've reached an 
  impasse.
  
  I've got an application that I've been writing. One of the modules for 
  this app is an event calendar. I've got the calendar to the place where 
  it displays the current month as well as previous and future months. The 
   place I'm stuck is it will only show months in the past or the future 
  that are months in the current year.
  
  Basically the method I'm using to move backward and forward is with Unix 
  timestamps.
  
  1. When the calendar first loads the what is checked for;
  // passed in via $_GET
  $what == current, prev, or next
a. current is the default
  $now = time()
  $prev = date('n',$now)-1
  $next = date('n',$now)+1
b. Timestamp values are then stored in an array and then
  sent to client in session cookie which is then accessed
  upon each subsequent request to display the event calendar.
  
  My question/boggle is why, when the calendar advances to 
  December(current year) it will display January, but of the current year. 
  The same happens in reverse.
  
  Once I reach the end of the year either in the past or future the month 
  increases or decreases accordingly, but the year doesn't change. Since 
  the year value isn't changing the month calendar days that are displayed 
  simply repeat themselves.
  
  I know there's something I'm missing, but I am definitely not seeing 
  what it is...
  
  /** code below /
  
  $cal = new Calendar;
  $calpos = array();
 
  // check incoming values
  if ($what === current){
  $cal-setCal(0,0,0,date('n'),1);
  $now = time();
  $prev = $cal-getStamp(date('n',$now)-1,1);
  $next = $cal-getStamp(date('n',$now)+1,1);
  $calpos['curr'] = $now;
  $calpos['prev'] = $prev;
  $calpos['next'] = $next;
  $_SESSION['calendar'] = $calpos;
  }   
  elseif($what === prev){
  $peek = $_SESSION['calendar'];
  $now = $peek['prev'];
  $cal-setCal(0,0,0,date('n',$now),1);
  $prev = $cal-getStamp(date('n',$now)-1,1);
  $next = $cal-getStamp(date('n',$now)+1,1);
  $calpos['curr'] = $now;
  $calpos['prev'] = $prev;
  $calpos['next'] = $next;
  $_SESSION['calendar'] = $calpos;
  }
  elseif($what === next){
  $peek = $_SESSION['calendar'];
  $now = $peek['next'];
  $cal-setCal(0,0,0,date('n',$now),1);
  $prev = $cal-getStamp(date('n',$now)-1,1);
  $next = $cal-getStamp(date('n',$now)+1,1);
  $calpos['curr'] = $now;
  $calpos['prev'] = $prev;
  $calpos['next'] = $next;
  $_SESSION['calendar'] = $calpos;
  }
  
  
  function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){   
$stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
// Using the stamp the various necessary properties are set for the
// object
  
  function getStamp($dateStr,$dayVal=1){
return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
  }
  
 
 Just in case:
 The solution was right in front of my all along. When setting the 
 calendar object I was giving the class everything it needed except the 
 {year} value. I _ass_-umed it was being set auto-magically; possibly by 
 fairies or tree elves. Turns out I needed to set that parameter. Imagine 
 that... :)
 --
 $cal-setCal(0,0,0,date('n',$now),1);
 --
 function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
 $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
 

I don't really want to say I told you so, but that's one of the two
lines I denoted as incorrect in my first response ;)

 Solution:
 setCal function from Calendar Class:
 function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1,$yrVal)
 
 current: $cal-setCal(0,0,0,date('n',time()),1,date('Y',time()));
 
 $prev value coming from session cookie
 $now = $session['prev'];
 prev: $cal-setCal(0,0,0,date('n',$now),1,date('Y',$now));
 
 $next value coming from session cookie
 $now = $session['next'];
 next: $cal-setCal(0,0,0,date('n',$now),1,date('Y',$now));
 
 It all works very nicely now.
 
 Thank you Robert for the push to seriously scrutinize my code.

It's far more important to learn to build complex code from simple code,
than to try and understand complex code and then refactor it to simple
code. Just a thought for the future since as it stands you have a very
convoluted system of moving back and forth between months.

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


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



Re: [PHP] Embed images in emails

2008-05-29 Thread Bastien Koert
On Thu, May 29, 2008 at 6:11 AM, Iñigo Medina García 
[EMAIL PROTECTED] wrote:

 Hi,

 I'm trying to send emails with embed and dynamic images: a normal tell a
 friend feature which sends the email with item's data: author, title,
 image-cover, etc.

 Ideas PEAR and mime classes apart?

 thanks

   iñigo

 --
 
 Iñigo Medina García
 Librería Díaz de Santos
 Madrid (Spain)
 Dpt.Desarrollo

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


You'll need to create a HTML email, and then embed the image with the img
tag, using the entire path to the image as the source attribute

img src='http://www.mysite.com/images/thisimage.jpg'

You may want to look at some email that you get that have images in them and
just view the source.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Embed images in emails

2008-05-29 Thread Per Jessen
Bastien Koert wrote:

 You'll need to create a HTML email, and then embed the image with the
 img tag, using the entire path to the image as the source attribute

Not necessarily, images may simply be sent as an attachment with
type image/jpeg etc. 


/Per Jessen, Zürich


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



Re: [PHP] Embed images in emails

2008-05-29 Thread Shawn McKenzie

Per Jessen wrote:

Bastien Koert wrote:


You'll need to create a HTML email, and then embed the image with the
img tag, using the entire path to the image as the source attribute


Not necessarily, images may simply be sent as an attachment with
type image/jpeg etc. 



/Per Jessen, Zürich



I haven't done it in a while but I believe you need a multipart mime 
email with:


Content-Type: image/jpeg
Content-Disposition: inline

unless you want it to be a separate attachment.

-Shawn

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



Re: [PHP] Embed images in emails

2008-05-29 Thread Richard Heyes

You'll need to create a HTML email, and then embed the image with the
img tag, using the entire path to the image as the source attribute


Not necessarily, images may simply be sent as an attachment with
type image/jpeg etc.

/Per Jessen, Zürich



I haven't done it in a while but I believe you need a multipart mime 
email with:


Content-Type: image/jpeg
Content-Disposition: inline

unless you want it to be a separate attachment.


This may help:

http://www.phpguru.org/static/htmlMimeMail5.html

--
  Richard Heyes

 In Cambridge? Employ me
http://www.phpguru.org/cv

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] SOLVED: Calendar Date Help

2008-05-29 Thread Mark Weaver

Robert Cummings wrote:

function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
$stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));



I don't really want to say I told you so, but that's one of the two
lines I denoted as incorrect in my first response ;)


:P  indeed you did... it just took me a while before it dawned on me. I 
just wasn't seeing it until the Mule got tired of trying to climb a 
vertical cliff!




Thank you Robert for the push to seriously scrutinize my code.


It's far more important to learn to build complex code from simple code,
than to try and understand complex code and then refactor it to simple
code. Just a thought for the future since as it stands you have a very
convoluted system of moving back and forth between months.

Cheers,
Rob.


The particular block of code you're referring to definitely needs to be 
re factored, however at the moment I don't know enough about php to 
accomplish that. I think one of the bad habits I got into early on was 
coding verbosely so I wouldn't have to comment as much. That definitely 
doesn't serve very well at times.


--
Mark
-
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==
Powered by CentOS5 (RHEL5)

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



[PHP] Problem with Object references in an array via for loop

2008-05-29 Thread David Moylan

I have a snippet of code like this which works fine in PHP4.


$secs = array();
foreach($_GET['sids'] as $sid){
  $secs[$sid] = new CustomSecurity();
  $secs[$sid]-set(array('customSecurityID' = $sid));
}

However, in PHP5 (5.2.4) the array has the proper keys in it but all of 
the array values in $secs seem to point to the same instance. 
Basically, the customSecurityID value inside each array value (object 
instance) should match the array key, but all of the customSecurityID 
values are set to the last $sid value during the final iteration which 
tells me the array values are not 3 separate instances, but references 
to the same instance.


I'm having a hard time seeing how this isn't a bug.  On each iteration 
of the loop I'm using a new variable $secs[$sid] which is previously 
unassigned and assigning it via the new operator to a new instance.


Is this a bug or a strange reference behavior that I don't understand?

How can you fill arrays with multiple new instances?

Thanks.

Dave

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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread Gabriel Sosa
try doing this

$secs = array();
foreach($_GET['sids'] as $sid){
 $obj = null;
 $obj = new CustomSecurity();
 $obj-set(array('customSecurityID' = $sid));
 $secs[] =  $obj;
}


i just don't know if the operator - it's working wll over object arrays


saludos

On Thu, May 29, 2008 at 1:31 PM, David Moylan [EMAIL PROTECTED] wrote:
 I have a snippet of code like this which works fine in PHP4.


 $secs = array();
 foreach($_GET['sids'] as $sid){
  $secs[$sid] = new CustomSecurity();
  $secs[$sid]-set(array('customSecurityID' = $sid));
 }

 However, in PHP5 (5.2.4) the array has the proper keys in it but all of the
 array values in $secs seem to point to the same instance. Basically, the
 customSecurityID value inside each array value (object instance) should
 match the array key, but all of the customSecurityID values are set to the
 last $sid value during the final iteration which tells me the array values
 are not 3 separate instances, but references to the same instance.

 I'm having a hard time seeing how this isn't a bug.  On each iteration of
 the loop I'm using a new variable $secs[$sid] which is previously unassigned
 and assigning it via the new operator to a new instance.

 Is this a bug or a strange reference behavior that I don't understand?

 How can you fill arrays with multiple new instances?

 Thanks.

 Dave

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





-- 
Los sabios buscan la sabiduría; los necios creen haberla encontrado.
Gabriel Sosa

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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread David Moylan
Nope.  Same performance.  I originally had something like this (minus 
the assigment to null) but I thought the confusion was in the variable 
assignment so I went directly to the array.  I've tried your code 
exactly and get the same thing, assignment to null doesn't help.


Dave

Gabriel Sosa wrote:

try doing this

$secs = array();
foreach($_GET['sids'] as $sid){
 $obj = null;
 $obj = new CustomSecurity();
 $obj-set(array('customSecurityID' = $sid));
 $secs[] =  $obj;
}


i just don't know if the operator - it's working wll over object arrays


saludos

On Thu, May 29, 2008 at 1:31 PM, David Moylan [EMAIL PROTECTED] wrote:

I have a snippet of code like this which works fine in PHP4.


$secs = array();
foreach($_GET['sids'] as $sid){
 $secs[$sid] = new CustomSecurity();
 $secs[$sid]-set(array('customSecurityID' = $sid));
}

However, in PHP5 (5.2.4) the array has the proper keys in it but all of the
array values in $secs seem to point to the same instance. Basically, the
customSecurityID value inside each array value (object instance) should
match the array key, but all of the customSecurityID values are set to the
last $sid value during the final iteration which tells me the array values
are not 3 separate instances, but references to the same instance.

I'm having a hard time seeing how this isn't a bug.  On each iteration of
the loop I'm using a new variable $secs[$sid] which is previously unassigned
and assigning it via the new operator to a new instance.

Is this a bug or a strange reference behavior that I don't understand?

How can you fill arrays with multiple new instances?

Thanks.

Dave

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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread Gabriel Sosa
I thought this line it may help, not actually the null
$secs[] =  $obj;

i will still researching about this

On Thu, May 29, 2008 at 2:08 PM, David Moylan [EMAIL PROTECTED] wrote:
 Nope.  Same performance.  I originally had something like this (minus the
 assigment to null) but I thought the confusion was in the variable
 assignment so I went directly to the array.  I've tried your code exactly
 and get the same thing, assignment to null doesn't help.

 Dave

 Gabriel Sosa wrote:

 try doing this

 $secs = array();
 foreach($_GET['sids'] as $sid){
  $obj = null;
  $obj = new CustomSecurity();
  $obj-set(array('customSecurityID' = $sid));
  $secs[] =  $obj;
 }


 i just don't know if the operator - it's working wll over object arrays


 saludos

 On Thu, May 29, 2008 at 1:31 PM, David Moylan [EMAIL PROTECTED] wrote:

 I have a snippet of code like this which works fine in PHP4.


 $secs = array();
 foreach($_GET['sids'] as $sid){
  $secs[$sid] = new CustomSecurity();
  $secs[$sid]-set(array('customSecurityID' = $sid));
 }

 However, in PHP5 (5.2.4) the array has the proper keys in it but all of
 the
 array values in $secs seem to point to the same instance. Basically, the
 customSecurityID value inside each array value (object instance) should
 match the array key, but all of the customSecurityID values are set to
 the
 last $sid value during the final iteration which tells me the array
 values
 are not 3 separate instances, but references to the same instance.

 I'm having a hard time seeing how this isn't a bug.  On each iteration of
 the loop I'm using a new variable $secs[$sid] which is previously
 unassigned
 and assigning it via the new operator to a new instance.

 Is this a bug or a strange reference behavior that I don't understand?

 How can you fill arrays with multiple new instances?

 Thanks.

 Dave

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





-- 
Los sabios buscan la sabiduría; los necios creen haberla encontrado.
Gabriel Sosa

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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread David Moylan
Well, I did that except I'm providing the key explicitly.  However, I've 
tried it now without the key and it's the same except for the key value. 
 Very frustrating.


Dave

Gabriel Sosa wrote:

I thought this line it may help, not actually the null
$secs[] =  $obj;

i will still researching about this

On Thu, May 29, 2008 at 2:08 PM, David Moylan [EMAIL PROTECTED] wrote:

Nope.  Same performance.  I originally had something like this (minus the
assigment to null) but I thought the confusion was in the variable
assignment so I went directly to the array.  I've tried your code exactly
and get the same thing, assignment to null doesn't help.

Dave

Gabriel Sosa wrote:

try doing this

$secs = array();
foreach($_GET['sids'] as $sid){
 $obj = null;
 $obj = new CustomSecurity();
 $obj-set(array('customSecurityID' = $sid));
 $secs[] =  $obj;
}


i just don't know if the operator - it's working wll over object arrays


saludos

On Thu, May 29, 2008 at 1:31 PM, David Moylan [EMAIL PROTECTED] wrote:

I have a snippet of code like this which works fine in PHP4.


$secs = array();
foreach($_GET['sids'] as $sid){
 $secs[$sid] = new CustomSecurity();
 $secs[$sid]-set(array('customSecurityID' = $sid));
}

However, in PHP5 (5.2.4) the array has the proper keys in it but all of
the
array values in $secs seem to point to the same instance. Basically, the
customSecurityID value inside each array value (object instance) should
match the array key, but all of the customSecurityID values are set to
the
last $sid value during the final iteration which tells me the array
values
are not 3 separate instances, but references to the same instance.

I'm having a hard time seeing how this isn't a bug.  On each iteration of
the loop I'm using a new variable $secs[$sid] which is previously
unassigned
and assigning it via the new operator to a new instance.

Is this a bug or a strange reference behavior that I don't understand?

How can you fill arrays with multiple new instances?

Thanks.

Dave

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







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









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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread Robert Cummings
On Thu, 2008-05-29 at 14:01 -0300, Gabriel Sosa wrote:
 try doing this
 
 $secs = array();
 foreach($_GET['sids'] as $sid){
  $obj = null;
  $obj = new CustomSecurity();
  $obj-set(array('customSecurityID' = $sid));
  $secs[] =  $obj;
 }

No, no, no. If it's a reference issue you need to do the following:

?php

$secs = array();
foreach($_GET['sids'] as $sid)
{
   unset( $obj );
   $obj = new CustomSecurity();
   $obj-set(array('customSecurityID' = $sid));
   $secs[] = $obj;
}

?

Assignment of null won't break a reference, it'll just make the value
refer to null. You need unset to break the reference. Personally, I'd
like to see the class definition to see what happens inside the set()
method.

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


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



[PHP] preg_match_all

2008-05-29 Thread Chris W
What I want to do is find all links in an html file.  I have the pattern 
below.  It works as long as there is only one link on a line and as long 
as the whole link is one line.  It seems there should be a way to get 
this to work with more than one link on a single line.  The work around 
I have done for now is to read the whole file into a buffer and remove 
all new lines and then add a new line after every closing a tag.  Then 
process each line.  There has to be a better way.


Any Ideas?  Also note I don't want to find any a tags that don't have an 
href there probably aren't any but just in case.



preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, $Line, $matches, 
PREG_PATTERN_ORDER);


--
Chris W
KE5GIX

Protect your digital freedom and privacy, eliminate DRM, 
learn more at http://www.defectivebydesign.org/what_is_drm;


Ham Radio Repeater Database.preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, 
$Line, $matches, PREG_PATTERN_ORDER);
http://hrrdb.com


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



Re: [PHP] preg_match_all

2008-05-29 Thread Robert Cummings
On Thu, 2008-05-29 at 13:07 -0500, Chris W wrote:
 What I want to do is find all links in an html file.  I have the pattern 
 below.  It works as long as there is only one link on a line and as long 
 as the whole link is one line.  It seems there should be a way to get 
 this to work with more than one link on a single line.  The work around 
 I have done for now is to read the whole file into a buffer and remove 
 all new lines and then add a new line after every closing a tag.  Then 
 process each line.  There has to be a better way.
 
 Any Ideas?  Also note I don't want to find any a tags that don't have an 
 href there probably aren't any but just in case.
 
 
 preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, $Line, $matches, 
 PREG_PATTERN_ORDER);

Your preg isn't going to return the URLs (even if it works), it's going
to return the labels of the links. But anyways...

?php

$content = implode( '', @file( 'http://www.php.net' ) );

if( preg_match_all(
'#(a[^]+href[^]+)(.*)/a#Umis', $content, $bits ) )
{
print_r( $bits );
}

?

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


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



[PHP] Javascript control on Firefox 2/3 with flash 9

2008-05-29 Thread jencisson

my page include some javascript to control the play,rewind..and other functions 
of the swffile showEdit.swf, it works in Safari/IE with flash-plugin 8/9 
installed but  not works in Firefox  with flash plugin 9(would reports 
obj.play() is not a function, is any one point out what is the problem or there 
are techniques i can use?

the source codes
script
function show(){
 var obj=document.getElements(showEdit);//it works in Firefox
 obj.play();//it works in IE,but not in Firefox.
}
/script

  object classid=clsid:D27CDB6E-AE6D-11cf-96B8-44455354 
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0;
 width=202 height=498 id=showEdit
param name=movie value=flash/show_edit.swf /
param name=quality value=high /
param name=allowScriptAccess value=sameDomain /
param name=FlashVars value=userid=rasy /
param name=name value=FlashVars /
embed src=flash/show_edit.swf width=202 height=498 quality=hight 
pluginspage=http://www.macromedia.com/go/getflashplayer; 
type=application/x-shockwave-flash allowscriptAccess=sameDomain 
FlashVars=userid=rasy name=FlashVars name=showEdit
/embed
  /object

_
多个邮箱同步管理,live mail客户端万人抢用中
http://get.live.cn/product/mail.html

Re: [PHP] preg_match_all

2008-05-29 Thread Robert Cummings
On Thu, 2008-05-29 at 14:20 -0400, Robert Cummings wrote:
 On Thu, 2008-05-29 at 13:07 -0500, Chris W wrote:
  What I want to do is find all links in an html file.  I have the pattern 
  below.  It works as long as there is only one link on a line and as long 
  as the whole link is one line.  It seems there should be a way to get 
  this to work with more than one link on a single line.  The work around 
  I have done for now is to read the whole file into a buffer and remove 
  all new lines and then add a new line after every closing a tag.  Then 
  process each line.  There has to be a better way.
  
  Any Ideas?  Also note I don't want to find any a tags that don't have an 
  href there probably aren't any but just in case.
  
  
  preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, $Line, $matches, 
  PREG_PATTERN_ORDER);
 
 Your preg isn't going to return the URLs (even if it works), it's going
 to return the labels of the links. But anyways...

Actually it returned both, just not how I had thought first. I forgot to
delete the above after I realized. My solution below works
nonetheless :)

 ?php
 
 $content = implode( '', @file( 'http://www.php.net' ) );
 
 if( preg_match_all(
 '#(a[^]+href[^]+)(.*)/a#Umis', $content, $bits ) )
 {
 print_r( $bits );
 }
 
 ?
 
 Cheers,
 Rob.


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


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



Re: [PHP] Javascript control on Firefox 2/3 with flash 9

2008-05-29 Thread Wolf

 [EMAIL PROTECTED] wrote: 
 
 my page include some javascript to control the play,rewind..and other 
 functions of the swffile showEdit.swf, it works in Safari/IE with 
 flash-plugin 8/9 installed but  not works in Firefox  with flash plugin 
 9(would reports obj.play() is not a function, is any one point out what is 
 the problem or there are techniques i can use?
 
 the source codes
 script
 function show(){
  var obj=document.getElements(showEdit);//it works in Firefox
  obj.play();//it works in IE,but not in Firefox.
 }
 /script

Sure, GO CHECK WITH A JAVASCRIPT LIST!

There is no PHP code anywhere here.

HTH,
Wolf


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



[PHP] form validation

2008-05-29 Thread Sudhakar
i need to validate a field in a form where a user enters a reference number
this can be letters, numbers and special characters also so i have not
written any special preg match as the username is a combination. the only
check i am doing is if there are any white spaces and if a user simple
presses the space bar and does not enter value i display a message to enter
the reference number and even if there are white spaces followed by the
reference number i have used trim method. i have checked in the database
even if there are white spaces followed by reference number due to trim()
method the data in the table is being inserted whithout those white spaces.

following is the code i am presently using

$referencenumber = trim($_POST[referencenumber]);

if(strlen($referencenumber) == 0)
{
$error.=liReference number cannot be blank /li br /;
}

this code works perfectly fine and does what it is supposed to, however i am
using techniques to avoid sql injection. following is the technique i have
used

if(get_magic_quotes_gpc())
{
$username = stripslashes($_POST[username]);
}

else
{
$username = $_POST[username];
}

due to this even if i use

if(get_magic_quotes_gpc())
{
$lodgementnumber = stripslashes($_POST[lodgementnumber]);
}

else
{
$lodgementnumber = trim($_POST[lodgementnumber]);
}

if(strlen($lodgementnumber) == 0)
{
$error.=reference number cannot be blank;
}

the validation is not doing what it does in the code i mentioned at the
begining.

i need to use techniques to avoid sql injection and i also need the
validation to work.

how can i fix this.

please advice.

thanks.


[PHP] sql injection

2008-05-29 Thread Sudhakar
i have implemented a way to avoid sql injection from the php website from
this url
http://in.php.net/mysql_real_escape_string  from the Example #3 A Best
Practice query section of this page

following are the steps i have followed after the form values are submitted
to a php file.

step 1.

if(get_magic_quotes_gpc())
{
$username = stripslashes($_POST[username]);
.
}

else
{
$username = $_POST[username];
.
}

step 2.

$conn = mysql_connect($hostname, $user, $password);

step 3.

$insertquery = sprintf(INSERT INTO table (`username`, ...) VALUES ('%s',
...), mysql_real_escape_string($username, $conn), ...);

step 4.

 if(!$conn)
 {
header(Location: http://website/dberror.html;);
exit;
 }

 else
 {
mysql_select_db($database, $conn);

$insertqueryresult = mysql_query($insertquery);


 if(!$insertqueryresult) {
 header(Location: http://website/error.html;);
 exit;  }

 }

with the above method i am able to insert values into the table even with if
i enter the ' special character which can cause problems.

i have also used a simple sql insert query like

$insertquery = INSERT INTO table(username, ...) VALUES ('$username', ...);

when i used this simple insert query and if i entered ' in the form and
submitted the form the php file is unable to process the information entered
because of the ' character and as per the code error.html file is being
displayed where as if i use

$insertquery = sprintf(INSERT INTO table (`username`, ...) VALUES ('%s',
...), mysql_real_escape_string($username, $conn), ...);

even if i enter any number of ' characters in more than 1 form field data is
being inserted into the table

a)
so i am thinking that the steps i have taken from the php site is correct
and the right way to avoid sql injection though there are several ways to
avoid sql injection.

b)
for example if i enter data in the form as = abc'''def for name, the data in
the table for the name field is being written as abc'''def

based on how i have written the steps to avoid sql injection is this the
right way for the data to be stored with ' characters along with the data
example as i mentioned = abc'''def

please answer the questions a) and b) if there is something else i need to
do please suggest what needs to be done exactly and at which step.

any help will be greatly appreciated.

thanks.


[PHP] validating # sign in php

2008-05-29 Thread Sudhakar
my question is about validation using php. i am validating a username which
a user would enter and clicks on a image to find

if that username is available. example if a user enters abc#123 php file is
reading this value as abc ONLY which i do not

want instead the php file should read as abc#123. following is the sequence
of pages. please advice the solution.

first page = register.php here a user enters a username and clicks on an
image to find out if the username is available or

not. using a javascript function of onclick i am reading the value entered
in the form in javascript as
=
var useri = document.registrationform.username
var valueofuseri = document.registrationform.username.value

var recui = /^\s{1,}$/g;

if ((useri.value==null) || (useri.value==) || (useri.length==) ||
(useri.value.search(recui)) -1)
{
alert(Please Enter a User Name)
return false
}

window.open(checkusernamei.php?theusernameis=+valueofuseri,
titleforavailabilityi, width=680,  height=275, status=1,

scrollbars=1, resizeable=yes);



i have used a alert message in javascript to display the value, javascript
is able to capture all the characters entered

which is abc#123

second page = checkusernamei.php = this file uses GET to read what was
entered in the form.

$username = $_GET[theusernameis];

if( $username ==  ||  !preg_match(/^[a-z0-9]+(?:_[a-z0-9]+)?$/i,
$username) )
{
echo username is blank or has special characters;
}

the # sign is being ignored only if the image is clicked in order to check
the username, if the user enters abc#123 and

clicks the submit button without clicking on the checkuser image button then
my php validation for username shows an error

message.

==
if( $username ==  ||  !preg_match(/^[a-z0-9]+(?:_[a-z0-9]+)?$/i,
$username) )
{ echo display error message for username; }
==
now the problem is with clicking the image only and passing the value to
checkusernamei.php using GET method
i have also used an echo statement in checkusernamei.php as
echo value of username is . $username; = this displays abc and not abc#123

how can i fix this problem wherein checkusernamei.php will be able to read
abc#123. also in this checkusernamei.php file i

have a select query which will read if the username already exists in the
table. presently as checkusernamei.php is reading

abc ONLY the select query is also passing abc and not abc#123

$select = Select username from table where username = '$username';

please advice.

thanks.


Re: [PHP] sql injection

2008-05-29 Thread Gabriel Sosa
YOU can write (') characters in the database.. that fine..

mysql_real_escape_string avoid injections doing that: escaping characters
then when you put in a form

abc'''def

the query will be

INSERT . (name.) VALUES ( 'abc\'\'\'def'

each ' = \'

for me the steps are right

saludos

On Thu, May 29, 2008 at 4:10 PM, Sudhakar [EMAIL PROTECTED] wrote:
 i have implemented a way to avoid sql injection from the php website from
 this url
 http://in.php.net/mysql_real_escape_string  from the Example #3 A Best
 Practice query section of this page

 following are the steps i have followed after the form values are submitted
 to a php file.

 step 1.

 if(get_magic_quotes_gpc())
 {
 $username = stripslashes($_POST[username]);
 .
 }

 else
 {
 $username = $_POST[username];
 .
 }

 step 2.

 $conn = mysql_connect($hostname, $user, $password);

 step 3.

 $insertquery = sprintf(INSERT INTO table (`username`, ...) VALUES ('%s',
 ...), mysql_real_escape_string($username, $conn), ...);

 step 4.

  if(!$conn)
  {
 header(Location: http://website/dberror.html;);
 exit;
  }

  else
  {
 mysql_select_db($database, $conn);

 $insertqueryresult = mysql_query($insertquery);


  if(!$insertqueryresult) {
  header(Location: http://website/error.html;);
  exit;  }

  }

 with the above method i am able to insert values into the table even with if
 i enter the ' special character which can cause problems.

 i have also used a simple sql insert query like

 $insertquery = INSERT INTO table(username, ...) VALUES ('$username', ...);

 when i used this simple insert query and if i entered ' in the form and
 submitted the form the php file is unable to process the information entered
 because of the ' character and as per the code error.html file is being
 displayed where as if i use

 $insertquery = sprintf(INSERT INTO table (`username`, ...) VALUES ('%s',
 ...), mysql_real_escape_string($username, $conn), ...);

 even if i enter any number of ' characters in more than 1 form field data is
 being inserted into the table

 a)
 so i am thinking that the steps i have taken from the php site is correct
 and the right way to avoid sql injection though there are several ways to
 avoid sql injection.

 b)
 for example if i enter data in the form as = abc'''def for name, the data in
 the table for the name field is being written as abc'''def

 based on how i have written the steps to avoid sql injection is this the
 right way for the data to be stored with ' characters along with the data
 example as i mentioned = abc'''def

 please answer the questions a) and b) if there is something else i need to
 do please suggest what needs to be done exactly and at which step.

 any help will be greatly appreciated.

 thanks.




-- 
Los sabios buscan la sabiduría; los necios creen haberla encontrado.
Gabriel Sosa

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



[PHP] authentication verification

2008-05-29 Thread DeadTOm
So the user comes to the site and they're presented with a log in page.
They enter their username and password and php checks a mysql database for
a matching username and password.
In the case of a match, php then sets a cookie on their browser with a
value of 1 for authenticated and 0 for not authenticated. Every subsequent
page the user views checks the status of this cookie and if it's a zero it
kicks them back to the log in page. This cookie expires in 5 days and
after that they'll have to log in again.
I'm aware that this is terribly easy to circumvent by creating/modifying a
cookie with the 1 value and the site thinks you've passed muster.
What is a better way of doing this?

--

DeadTOm
http://www.mtlaners.org
[EMAIL PROTECTED]
A Linux user since 1999.



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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread David Moylan
Solved this.  I tried setting a class variable directly and didn't have 
the same issue (should have tried that long ago).  So that told me that 
my error was somewhere in some lower level code when I initialize my 
objects.  I tracked it down to a problem where I wasn't cloning properly 
when I needed to (since PHP4 passes by value, and 5 by reference).


Sorry for the bandwidth and thanks for the help.

Dave


Robert Cummings wrote:

On Thu, 2008-05-29 at 14:01 -0300, Gabriel Sosa wrote:

try doing this

$secs = array();
foreach($_GET['sids'] as $sid){
 $obj = null;
 $obj = new CustomSecurity();
 $obj-set(array('customSecurityID' = $sid));
 $secs[] =  $obj;
}


No, no, no. If it's a reference issue you need to do the following:

?php

$secs = array();
foreach($_GET['sids'] as $sid)
{
   unset( $obj );
   $obj = new CustomSecurity();
   $obj-set(array('customSecurityID' = $sid));
   $secs[] = $obj;
}

?

Assignment of null won't break a reference, it'll just make the value
refer to null. You need unset to break the reference. Personally, I'd
like to see the class definition to see what happens inside the set()
method.

Cheers,
Rob.



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



Re: [PHP] Problem with Object references in an array via for loop

2008-05-29 Thread David Moylan
Also, for the record:  Referring to the objects in the array directly 
works fine.  So, syntax like


$secs[$sid] = new CustomSecurity();
$secs[$sid]-load($sid);

is fine, as I would expect.  Don't have to define it to a simple 
variable like $obj in the code below.  Further, if I then do


$sec = $secs[$sid];

in the loop $sec refers correctly to object instances without the need 
to unset it.


Thanks again.

Dave

David Moylan wrote:
Solved this.  I tried setting a class variable directly and didn't have 
the same issue (should have tried that long ago).  So that told me that 
my error was somewhere in some lower level code when I initialize my 
objects.  I tracked it down to a problem where I wasn't cloning properly 
when I needed to (since PHP4 passes by value, and 5 by reference).


Sorry for the bandwidth and thanks for the help.

Dave


Robert Cummings wrote:

On Thu, 2008-05-29 at 14:01 -0300, Gabriel Sosa wrote:

try doing this

$secs = array();
foreach($_GET['sids'] as $sid){
 $obj = null;
 $obj = new CustomSecurity();
 $obj-set(array('customSecurityID' = $sid));
 $secs[] =  $obj;
}


No, no, no. If it's a reference issue you need to do the following:

?php

$secs = array();
foreach($_GET['sids'] as $sid)
{
   unset( $obj );
   $obj = new CustomSecurity();
   $obj-set(array('customSecurityID' = $sid));
   $secs[] = $obj;
}

?

Assignment of null won't break a reference, it'll just make the value
refer to null. You need unset to break the reference. Personally, I'd
like to see the class definition to see what happens inside the set()
method.

Cheers,
Rob.






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



Re: [PHP] authentication verification

2008-05-29 Thread Robert Cummings
On Thu, 2008-05-29 at 14:20 -0600, DeadTOm wrote:
 So the user comes to the site and they're presented with a log in page.
 They enter their username and password and php checks a mysql database for
 a matching username and password.
 In the case of a match, php then sets a cookie on their browser with a
 value of 1 for authenticated and 0 for not authenticated. Every subsequent
 page the user views checks the status of this cookie and if it's a zero it
 kicks them back to the log in page. This cookie expires in 5 days and
 after that they'll have to log in again.
 I'm aware that this is terribly easy to circumvent by creating/modifying a
 cookie with the 1 value and the site thinks you've passed muster.
 What is a better way of doing this?

Use PHP session engine... and set:

$_SESSION['loggedIn'] = true;

Then you can check THAT value and they can't modify it.

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


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



Re: [PHP] authentication verification

2008-05-29 Thread Greg Maruszeczka
On Thu, 29 May 2008 14:20:02 -0600 (MDT)
DeadTOm [EMAIL PROTECTED] wrote:

 So the user comes to the site and they're presented with a log in
 page. They enter their username and password and php checks a mysql
 database for a matching username and password.
 In the case of a match, php then sets a cookie on their browser with a
 value of 1 for authenticated and 0 for not authenticated. Every
 subsequent page the user views checks the status of this cookie and
 if it's a zero it kicks them back to the log in page. This cookie
 expires in 5 days and after that they'll have to log in again.
 I'm aware that this is terribly easy to circumvent by
 creating/modifying a cookie with the 1 value and the site thinks
 you've passed muster. What is a better way of doing this?
 
 --
 
 DeadTOm
 http://www.mtlaners.org
 [EMAIL PROTECTED]
 A Linux user since 1999.
 
 
 

Sessions.

http://php.net/manual/en/ref.session.php

-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus

Those who are possessed by nothing possess everything.
-- Morihei Ueshiba

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



[PHP] Re: A Little Something.

2008-05-29 Thread tedd

At 8:31 PM +0200 5/28/08, Michelle Konzack wrote:


I have customers in Iran, Turkey, Syria, Lebanon,  Moroco,  Germany  and
Swiss.


Sounds like a sandwich.  :-)

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] preg_match_all

2008-05-29 Thread Mario Guenterberg
On Thu, May 29, 2008 at 01:07:11PM -0500, Chris W wrote:
 What I want to do is find all links in an html file.  I have the pattern  
 below.  It works as long as there is only one link on a line and as long  
 as the whole link is one line.  It seems there should be a way to get  
 this to work with more than one link on a single line.  The work around  
 I have done for now is to read the whole file into a buffer and remove  
 all new lines and then add a new line after every closing a tag.  Then  
 process each line.  There has to be a better way.

 Any Ideas?  Also note I don't want to find any a tags that don't have an  
 href there probably aren't any but just in case.


 preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, $Line, $matches,  
 PREG_PATTERN_ORDER);

Hi...

I have a little function to explode URLs with the following pattern:

$str = filename;

$pattern = '=^.*a .* href\=(.*[://]|[:])(\S+)[^]*(.*)/a.*$=ims';

while (preg_match($pattern, $line, $exploded_url)) {
some usefull stuff
returns an array ($exploded_url)
}

$exploded_url[1] = protocoll;
$exploded_url[2] = URL;
$exploded_url[3] = name of the URL;

greetings
MG

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GCS/CM d- s++: a+ C$ UBL*$ P++ L+++ E--- W+++ N+ o-- K- w O- M-
V-- PS++ PE++ Y PGP+++ t--- 5 X R++ tv- b+++ DI D  G++ e* h
r+++ y
--END GEEK CODE BLOCK--

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



[PHP] A problem with fgets()

2008-05-29 Thread Usamah M. Ali
Hello,

I have a function that picks up a random entry from a file consisting
of city names, each name on a separate line. The random value is
generated by rand() before fseek()ing to the position determined by
it. The problem is that when using fgets() to get a random line, it
returns a part of the city name, not the whole name. AFAIK, fgets()
reads a whole line, and even if it's in the middle of a line, it reads
the whole next line.

Some sample of the city names file is as follows:

Amsterdam
Zurich
Alexandria
Dallas
Rome
Berlin

And the scripts outputs them weirdly enough something like:
Amster
andria
Da
me
Berlin

Here's the function:

?php
function getCity($file)
{
// Try to open the file
if (!file_exists($file) || !($handle = fopen($file, r)))
{
die('Could not open file for reading.');
}

$size = filesize($file);
$randval = rand(0, $size);

// Seek to a random position in the file
fseek($handle, $randval);

// Get random city name
$line = trim(fgets($fp, 2048));

fclose($fp);

// If line was empty, try again
if(empty($line))
{
$line = getCity($file);
}

return($line);
}
?

I'm using XAMPP on Windows, PHP 5.2.1.

What am I missing here?

Regards,
Usamah

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



[PHP] PHP Code I Must find

2008-05-29 Thread John Taylor-Johnston

A web site deploys what I think are UTF characters to mask email addresses.
Is there there a php function I can use to generate this? Or was this 
hand-done?
It is crackable, but a darned good stab at the problem of spiders at the 
same.

Any feedback, info or code would be appreciated,
John

John Taylor-Johnston wrote:

My source is this page:
http://www.grandlodge.mb.ca/contact.html
John

/div align=centerTo report a technical problem with this site 
please a 
href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097;;contact 
the webmaster/a./div/


/In UTF code:

mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097;

would be this in latin characters:

mailto:[EMAIL PROTECTED]/


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



Re: [PHP] PHP Code I Must find

2008-05-29 Thread Jeremy Privett

John Taylor-Johnston wrote:
A web site deploys what I think are UTF characters to mask email 
addresses.
Is there there a php function I can use to generate this? Or was this 
hand-done?
It is crackable, but a darned good stab at the problem of spiders at 
the same.

Any feedback, info or code would be appreciated,
John

John Taylor-Johnston wrote:

My source is this page:
http://www.grandlodge.mb.ca/contact.html
John

/div align=centerTo report a technical problem with this site 
please a 
href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097;;contact 
the webmaster/a./div/


/In UTF code:

mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097; 



would be this in latin characters:

mailto:[EMAIL PROTECTED]/



http://www.asciitable.com/
http://www.php.net/ord

The rest should be easy to figure out on your own.

--
Jeremy Privett
C.E.O.  C.S.A.
Omega Vortex Corporation

http://www.omegavortex.net

Please note: This message has been sent with information that could be 
confidential and meant only for the intended recipient. If you are not the 
intended recipient, please delete all copies and inform us of the error as soon 
as possible. Thank you for your cooperation.


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



Re: [PHP] PHP Code I Must find

2008-05-29 Thread TG

You could look at the email cloaking routine that Joomla uses.

Here's a starting point:
http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,references:joomla.framework:html:jhtmlemail-cloak/

-TG

- Original Message -
From: John Taylor-Johnston [EMAIL PROTECTED]
To: PHP-General php-general@lists.php.net
Date: Thu, 29 May 2008 19:08:34 -0400
Subject: [PHP] PHP Code I Must find

 A web site deploys what I think are UTF characters to mask email addresses.
 Is there there a php function I can use to generate this? Or was this 
 hand-done?
 It is crackable, but a darned good stab at the problem of spiders at the 
 same.
 Any feedback, info or code would be appreciated,
 John
 
 John Taylor-Johnston wrote:
  My source is this page:
  http://www.grandlodge.mb.ca/contact.html
  John
 
  /div align=centerTo report a technical problem with this site 
  please a 
  

href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097;;contact
 
  the webmaster/a./div/
 
  /In UTF code:
 
  

mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#046;#109;#098;#046;#099;#097;
 
  would be this in latin characters:
 
  mailto:[EMAIL PROTECTED]/


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



Re: [PHP] preg_match_all

2008-05-29 Thread Eric Butera
On Thu, May 29, 2008 at 2:07 PM, Chris W [EMAIL PROTECTED] wrote:
 What I want to do is find all links in an html file.  I have the pattern
 below.  It works as long as there is only one link on a line and as long as
 the whole link is one line.  It seems there should be a way to get this to
 work with more than one link on a single line.  The work around I have done
 for now is to read the whole file into a buffer and remove all new lines and
 then add a new line after every closing a tag.  Then process each line.
  There has to be a better way.

 Any Ideas?  Also note I don't want to find any a tags that don't have an
 href there probably aren't any but just in case.


 preg_match_all(/( *a[^]*href[^]+)(.*)\/a/, $Line, $matches,
 PREG_PATTERN_ORDER);

 --
 Chris W
 KE5GIX

 Protect your digital freedom and privacy, eliminate DRM, learn more at
 http://www.defectivebydesign.org/what_is_drm;

 Ham Radio Repeater Database.preg_match_all(/(
 *a[^]*href[^]+)(.*)\/a/, $Line, $matches, PREG_PATTERN_ORDER);
 http://hrrdb.com


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



Why not use DOMDocument with getElementsByTagName('href') [1]

http://us2.php.net/manual/en/domdocument.getelementsbytagname.php

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



Re: [PHP] preg_match_all

2008-05-29 Thread Eric Butera
On Thu, May 29, 2008 at 8:13 PM, Eric Butera [EMAIL PROTECTED] wrote:
 Why not use DOMDocument with getElementsByTagName('href') [1]

 http://us2.php.net/manual/en/domdocument.getelementsbytagname.php


Sorry there was an error in that.  It felt wrong when I sent it so I
looked again.  Here is a snippet I'm using on a project right now, so
I know it works. ;)

$dom = DOMDocument::loadHTML($vo-htmlCopy);
foreach ($dom-getElementsByTagName('a') as $node) {
if ($node-hasAttribute('href')) {
$linkVO = new ...;
$linkVO-url= $node-getAttribute('href');
$linkVO-name   = $node-nodeValue;

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



Re: [PHP] PHP Code I Must find

2008-05-29 Thread John Taylor-Johnston

Ok.

?php
$mystring = [EMAIL PROTECTED];
#How can I generate $mystring in ascii characters?
echo ??($mystring);
?



lists-php wrote:

that's not UTF, rather just the html representation of the ascii
codes for the characters. [someone else has already pointed you to an
ascii table.]

when put in the context of the mailto:; it's actually fairly easy
for a bot to identify and decode (i'm not saying that they do, but
it's not hard). if you're going to use this approach you may want to
make the e-mail addresses user-readable, but unlinked. while still
easily decoded, most bots won't waste time trying to decode every
string like that that they encounter (at least not yet).

  - Rick


 Original Message 
  

Date: Thursday, May 29, 2008 07:08:34 PM -0400
From: John Taylor-Johnston [EMAIL PROTECTED]
To: PHP-General php-general@lists.php.net
Subject: [PHP] PHP Code I Must find

A web site deploys what I think are UTF characters to mask email
addresses.
Is there there a php function I can use to generate this? Or was
this hand-done?
It is crackable, but a darned good stab at the problem of spiders
at the same.
Any feedback, info or code would be appreciated,
John

John Taylor-Johnston wrote:


My source is this page:
http://www.grandlodge.mb.ca/contact.html
John

  
/div align=centerTo report a technical problem with this site 
please a 
href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;#11

4;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;#1
01;#046;#109;#098;#046;#099;#097;contact  the
webmaster/a./div/

/In UTF code:

mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#06
4;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;#0
46;#109;#098;#046;#099;#097;

would be this in latin characters:

mailto:[EMAIL PROTECTED]/


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



-- End Original Message --


  


Re: [PHP] A problem with fgets()

2008-05-29 Thread Chris
Usamah M. Ali wrote:
 Hello,
 
 I have a function that picks up a random entry from a file consisting
 of city names, each name on a separate line. The random value is
 generated by rand() before fseek()ing to the position determined by
 it. The problem is that when using fgets() to get a random line, it
 returns a part of the city name, not the whole name. AFAIK, fgets()
 reads a whole line, and even if it's in the middle of a line, it reads
 the whole next line.

fseek doesn't go to the start of a line, it goes to a particular byte -
so that's where the problem lies (not with fgets). There's no function
(that I could see) which would go to the start of the line based on that
offset (I guess you could fseek to a particular spot then reverse char
by char until you find a newline - but that'll be rather slow for
anything that has a long line).


You could read the whole thing into an array and do a rand on that:

$cities = file('filename.txt');

// take 1 off from the max number as $cities is a 0 based array
$number_of_cities = sizeof($cities) - 1;

$city_number = rand(0, $number_of_cities);
$city = $cities[$city_number];

Though if you have a big file that reads the whole thing into memory etc.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] A problem with fgets()

2008-05-29 Thread Usamah M. Ali
On Fri, May 30, 2008 at 3:38 AM, Chris [EMAIL PROTECTED] wrote:
 fseek doesn't go to the start of a line, it goes to a particular byte -
 so that's where the problem lies (not with fgets). There's no function
 (that I could see) which would go to the start of the line based on that
 offset (I guess you could fseek to a particular spot then reverse char
 by char until you find a newline - but that'll be rather slow for
 anything that has a long line).


 You could read the whole thing into an array and do a rand on that:

 $cities = file('filename.txt');

 // take 1 off from the max number as $cities is a 0 based array
 $number_of_cities = sizeof($cities) - 1;

 $city_number = rand(0, $number_of_cities);
 $city = $cities[$city_number];

 Though if you have a big file that reads the whole thing into memory etc.


I didn't say fseek() goes to the start of a line. I said that fgets()
should read a whole line, no matter where the pointer is at. I've
already managed to get the result I want by using file() as you've
suggested and array_rand(), and the result is very good.

I just need to figure out why when using fgets() with fseek() 
rand(), the script returns partial strings form the city names.

Regards,
Usamah

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



Re: [PHP] A problem with fgets()

2008-05-29 Thread Chris


 I just need to figure out why when using fgets() with fseek() 
 rand(), the script returns partial strings form the city names.

Because fseek doesn't necessarily put you at the start of a line.

It puts you anywhere (which could be the start, middle, 3 chars from the
end) according to the number of bytes you tell it to start at.

Then fgets reads the rest of the line.

A file that looks like this:

(numbers are the bytes for ease of explanation)

123456789

is going to be different to a file that looks like this:

1234
56
789

and if you tell me you want to start at byte 5, then in file 1, that's
the middle - in file 2 that's the start of the second line (#4 is a
newline char :P).

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] A problem with fgets()

2008-05-29 Thread Usamah M. Ali
On Fri, May 30, 2008 at 4:21 AM, Chris [EMAIL PROTECTED] wrote:


 I just need to figure out why when using fgets() with fseek() 
 rand(), the script returns partial strings form the city names.

 Because fseek doesn't necessarily put you at the start of a line.

 It puts you anywhere (which could be the start, middle, 3 chars from the
 end) according to the number of bytes you tell it to start at.

 Then fgets reads the rest of the line.

 A file that looks like this:

 (numbers are the bytes for ease of explanation)

 123456789

 is going to be different to a file that looks like this:

 1234
 56
 789

 and if you tell me you want to start at byte 5, then in file 1, that's
 the middle - in file 2 that's the start of the second line (#4 is a
 newline char :P).


So you're confirming that fgets() doesn't necessarily read a whole
line? This user note existed on the manual's page of fgets() since
2004 and nobody deleted it or commented about:

rstefanowski at wi dot ps dot pl
12-Aug-2004 09:03

Take note that fgets() reads 'whole lines'. This means that if a file
pointer is in the middle of the line (eg. after fscanf()), fgets()
will read the following line, not the remaining part of the currnet
line. You could expect it would read until the end of the current
line, but it doesn't. It skips to the next full line.

That was my source of confusion.

Regards,
Usamah

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



[PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread Weston C
This might be a dumb question with an obvious answer somewhere,  but
I'm wondering if it's possible to build php extensions as shared
objects that plug into the PHP binary much like an apache shared
module plugs into apache.

Is PECL close to this?

Sorry if this is obvious. Searches on the topic are pretty noisy given
that php's installation as a shared module itself for Apache are a
fairly popular topic.

Thanks,

Weston

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



Re: [PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread Chris
Weston C wrote:
 This might be a dumb question with an obvious answer somewhere,  but
 I'm wondering if it's possible to build php extensions as shared
 objects that plug into the PHP binary much like an apache shared
 module plugs into apache.

Yes.

See http://www.php.net/dl (though a lot of hosts disable this
functionality for security reasons).

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread Weston C
On Thu, May 29, 2008 at 7:11 PM, Chris [EMAIL PROTECTED] wrote:
 See http://www.php.net/dl (though a lot of hosts disable this
 functionality for security reasons).

Fortunately, I'll have full control of the hosting environment in the
context this matters. :)

dl is  definitely interesting, but I'm worried that runtime invocation
might mean performance hits. Is there a way to do load/startup time
inclusion?

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



Re: [PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread mike
On 5/29/08, Weston C [EMAIL PROTECTED] wrote:

 Fortunately, I'll have full control of the hosting environment in the
 context this matters. :)

 dl is  definitely interesting, but I'm worried that runtime invocation
 might mean performance hits. Is there a way to do load/startup time
 inclusion?

you could put it in your php ini file

extension = foo.so

then I believe the impact will be on the first instance for that php
engine. so in fastcgi mode, you'd only have the hit once every
PHP_FCGI_MAX_REQUESTS when the child restarts...

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



Re: [PHP] Help mms (Get audio Stream)

2008-05-29 Thread Shelley
My test result is that it works on Windows platform, but not on Linux.
Maybe that's because it is Microsoft Media Services protocol?

Whatever, I can not hear anything on Firefox 3 Beta 5 on Ubuntu.

2008/5/29 Gabriel Sosa [EMAIL PROTECTED]:

 what do you wanna do ?? just a bridge? or try to play it?? in that
 case you can't.
 i think you should get the streamming and try to play it with flash

 saludos

 On Thu, May 29, 2008 at 4:05 AM, Shelley [EMAIL PROTECTED] wrote:
  1. URL
  http://pub.qmoon.net/WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint
 
  2. Call method
 
  HTTP GET:
  GET / WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint HTTP/1.1
  Host: pub.qmoon.net
 
  3.  return (string)
 
  ?xml version=1.0 encoding=utf-8 ?
  string xmlns=http://www.qmoon.net/;mms://pub.qmoon.net/audio/string
 
  How can I listen to the audio stream with PHP?
  Anybody some suggestions?
 
  Thank you in advance.
 
 
  --
  Regards,
  Shelley
 



 --
 Los sabios buscan la sabiduría; los necios creen haberla encontrado.
 Gabriel Sosa


--
Regards,
Shelley - http://phparch.cn

-- 
Regards,
Shelley


[PHP] A bit 0T - WAMPSERVER

2008-05-29 Thread Ryan S
Hello all!
Had some big problems with XAMPP crashing my windows (Vista) laptop 8 times out 
or 10 (actual figures) as I started XAMPP so have shifted over to WAMPSERVER2
So far so good, no crash... but their website seems to be down and need one 
small tidbit... if anyone of you are using WAMPSERVER can you tell me how to 
change MySqls default login?
its on root/no password presently... want to change it to root/something
Thanks!
Ryan
 --
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)




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



Re: [PHP] A bit 0T - WAMPSERVER

2008-05-29 Thread Chris
Ryan S wrote:
 Hello all!
 Had some big problems with XAMPP crashing my windows (Vista) laptop 8 times 
 out or 10 (actual figures) as I started XAMPP so have shifted over to 
 WAMPSERVER2
 So far so good, no crash... but their website seems to be down and need one 
 small tidbit... if anyone of you are using WAMPSERVER can you tell me how to 
 change MySqls default login?
 its on root/no password presently... want to change it to root/something

STW?

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] PHP Code I Must find

2008-05-29 Thread John Taylor-Johnston

Seen that in the manual. I'll need a routine of some sort I guess.
I'll get my cookie cutters out tomorrow and see what I can create.
I make cool gingerbread men, for a dude.
**htmlentities() does most of what I want, sort of.

**lists-php wrote:

you might try looking at the php manual. start with: 
http://www.php.net/manual/en/function.ord.php and go from there.
  

?php
$mystring = [EMAIL PROTECTED];
# How can I generate $mystring in ascii characters?
echo ($mystring in ascii charachters);
?



lists-php wrote:


that's not UTF, rather just the html representation of the ascii
codes for the characters. [someone else has already pointed you to
an ascii table.]

when put in the context of the mailto:; it's actually fairly easy
for a bot to identify and decode (i'm not saying that they do, but
it's not hard). if you're going to use this approach you may want
to make the e-mail addresses user-readable, but unlinked. while
still easily decoded, most bots won't waste time trying to decode
every string like that that they encounter (at least not yet).

  - Rick


 Original Message 
  
  

Date: Thursday, May 29, 2008 07:08:34 PM -0400
From: John Taylor-Johnston [EMAIL PROTECTED]
To: PHP-General php-general@lists.php.net
Subject: [PHP] PHP Code I Must find

A web site deploys what I think are UTF characters to mask email
addresses.
Is there there a php function I can use to generate this? Or was
this hand-done?
It is crackable, but a darned good stab at the problem of spiders
at the same.
Any feedback, info or code would be appreciated,
John

John Taylor-Johnston wrote:



My source is this page:
http://www.grandlodge.mb.ca/contact.html
John

  
  

/div align=centerTo report a technical problem with this
site  please a 
href=mailto:#119;#101;#098;#109;#097;#115;#116;#101;#

11
4;#064;#103;#114;#097;#110;#100;#108;#111;#100;#103;
#1 01;#046;#109;#098;#046;#099;#097;contact  the
webmaster/a./div/

/In UTF code:

mailto:#119;#101;#098;#109;#097;#115;#116;#101;#114;#
06
4;#103;#114;#097;#110;#100;#108;#111;#100;#103;#101;
#0 46;#109;#098;#046;#099;#097;

would be this in latin characters:

mailto:[EMAIL PROTECTED]/



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



-- End Original Message --


  
  


-- End Original Message --


  


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