php-general Digest 20 Mar 2006 07:20:19 -0000 Issue 4025

Topics (messages 232214 through 232228):

Re: PHP, SQL, AJAX, JS and populating a SelectBox?
        232214 by: tedd
        232221 by: dave
        232222 by: paulm

Re: Updating a single line in a file
        232215 by: Al

Paypal IPN and PHP
        232216 by: Leonard Burton
        232218 by: Richard Davey
        232219 by: Stan Busk

Re: showing any mysql query in a table, help!
        232217 by: Curt Zirzow

Invoices
        232220 by: Leonard Burton
        232223 by: Kevin Kinsey
        232228 by: Weber Sites LTD

Mail function problems
        232224 by: Paul Goepfert

SNMP problem is TCP
        232225 by: wood-gd

array_search function bugged?
        232226 by: je killen
        232227 by: Richard Davey

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
sry bout that it seems i was logged in :) try this on
"http://www.ajaxfreaks.com/tutorials/6/0.php"; it's called "Making a
Google Suggest-like application"


Dave:

A most excellent example, but a horrible place to put it. The links are all screwed up and confusing. The pages are not designed well (i.e., way off right for me) and errors on their statistics. Link to your site is broke.

But, I was able to salvage your code to produce my own example.

http://www.xn--ovg.com/ajax_pop-down

This ajax stuff is pretty neat.

Would you permit me to post this example elsewhere? I'll provide credit to you.

tedd


--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
as u wish :)

tedd wrote:
>> sry bout that it seems i was logged in :) try this on
>> "http://www.ajaxfreaks.com/tutorials/6/0.php"; it's called "Making a
>> Google Suggest-like application"
> 
> 
> Dave:
> 
> A most excellent example, but a horrible place to put it. The links are
> all screwed up and confusing. The pages are not designed well (i.e., way
> off right for me) and errors on their statistics. Link to your site is
> broke.
> 
> But, I was able to salvage your code to produce my own example.
> 
> http://www.xn--ovg.com/ajax_pop-down
> 
> This ajax stuff is pretty neat.
> 
> Would you permit me to post this example elsewhere? I'll provide credit
> to you.
> 
> tedd
> 
> 

--- End Message ---
--- Begin Message ---
oh, just realized smth :) the tutorial is not mine i have used with
success and also posted there but the credit for the tutorial is of:
NickName:       Gast
Member Since:   03/26/2005
Location:       Surrey, England
Website:        http://www.nmcmahon.co.uk
he must have the credit for it :)

dave wrote:
> as u wish :)
> 
> tedd wrote:
>>> sry bout that it seems i was logged in :) try this on
>>> "http://www.ajaxfreaks.com/tutorials/6/0.php"; it's called "Making a
>>> Google Suggest-like application"
>>
>> Dave:
>>
>> A most excellent example, but a horrible place to put it. The links are
>> all screwed up and confusing. The pages are not designed well (i.e., way
>> off right for me) and errors on their statistics. Link to your site is
>> broke.
>>
>> But, I was able to salvage your code to produce my own example.
>>
>> http://www.xn--ovg.com/ajax_pop-down
>>
>> This ajax stuff is pretty neat.
>>
>> Would you permit me to post this example elsewhere? I'll provide credit
>> to you.
>>
>> tedd
>>
>>
> 

-- 
Paul Marinas, netadm @ RDS Craiova.
GnuPG Key http://pgp.rdscv.ro
____________________________________________________________________________
RCS&RDS  Craiova
Tel.: +40351.400.444
Fax : +40351.400.445
http://www.rcs-rds.ro
____________________________________________________________________________
Privileged/Confidential Information may be contained in this message.
If you are not in the addresses indicated in this message (or
responsible fordelivery of the message to such person), you may not
copy or deliver this message to anyone. In such a case, you should
destroy this message and kindly notify the sender by reply e-mail.

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
For small DBs and where I don't expect very heavy traffic, I simply put 
everything in an array, where the keys are unique.

Arrays are quite easy to work with for your type of application

Here is a snip I wrote recently
function write_data_file($courses_array){       
        
        $file_str= base64_encode(serialize($courses_array));            
//base64 required because of special chars
        
        $fh = fopen(DATA_FILE_FP, "wb");
        if(!$fh) die("<p style=\"color:red\">Code error in update_data_file(), 
\"DATA_FILE\" could not be opened. Check file system.</p>");
        
if (flock($fh, LOCK_EX)) { // do exclusive lock
                fwrite($fh, $file_str);
flock($fh, LOCK_UN); // release lock } else die("<p style=\"color:red\">Code error, could not lock \"DATA_FILE\". Contact tech support.</p>");
        fclose($fh);
        
//No need to restore data dir and file to 755 and 644.
        return;
}//end function 

To get your array back just like it was.

function get_all_courses(){

        $file_str= base64_decode(file_get_contents(DATA_FILE_FP));              
                                //base64 required

        return  unserialize($file_str);                                         
                                                        //returns data array
}//end function







smr78 wrote:
Hi,
What is the best method to update a single line in a text file?
I have a file made of identifiers, that is pointed on by a htaccess file and used by a server to give access to a web site.
The file content is like this :
login1:pass1\r\n
login2:pass2\r\n
....
loginn:passn\r\n
loginn1:passn1\r\n
....
lastlogin:lastpass\r\n

This file can be modified in three ways
update a single line when a user updates its profile
delete a single line when the webmaster makes a user inactive
append a line when the webmaster makes a user active

the difficulties are :
there is not the same number of users and lines in this file,
we dont know at which line are the identifiers of a user,
when updating identifiers, we must keep new line characters at the end.

So what are the best functions to use to read and rewrite the file?

file() which puts all the content in an array, including the new line characters? (if so, we need to use array_search() or array_keys() to find where are the identifiers

fread() or file_get_contents() which puts all the content in a string? I tried this way and use eregi_replace() to find where are the identifiers, replace them by new value. But sometimes, I get errors where the new line characters are suppressed between two users identifiers or where an identifier is repeated like this :

loginx:passx\r\n
loginx:passx\r\n
loginn:passnloginn1:passn1\r\n
loginn2:passn2\r\n

Here is my code :
<? php
//reading the actual file content
$length=filesize($filename);
$fp=fopen($filename,"r");
$str=fread($fp,$length);
fclose($fp);

//in case of updating
$str=eregi_replace($oldlogin.":".$oldpass,$newlogin.":".$newpass,$str);
//in case of deleting
$str=eregi_replace($oldlogin.":".$oldpass,"",$str);

//rewriting the file
$handle = fopen($filename,"w+")
fwrite($handle,$str,strlen($str))

//in case of inserting a new user

$str=$newlogin.":".$newpass."\r\n";
$handle = fopen($filename,"a")
fwrite($handle,$str,strlen($str))
?>
I know in "deleting" case, the eregi_replace pattern is so that the new line characters will not be removed, but this is not a problem

I'll try to use file() function and array_keys() and let you know.
Thanks

--- End Message ---
--- Begin Message ---
HI All,

I am putting together an site and will accept payments via Paypal's
IPN.  I have came across many classes for this so I am curious if
anyone has any recommendations?

Does anyone know if the IPN framework has changed since 2003 as it
seems that the latest information I have on it is from 2003.  I have
looked around the Paypal site and it does not indicate when or if any
changes have been made.  I mainly need to know so if I use a 3rd pty
class I will not have to pull my hair out.

Thanks,

--
Leonard Burton, N9URK
[EMAIL PROTECTED]

"The prolonged evacuation would have dramatically affected the
survivability of the occupants."

--- End Message ---
--- Begin Message ---
On 19 Mar 2006, at 18:32, Leonard Burton wrote:

I am putting together an site and will accept payments via Paypal's
IPN.  I have came across many classes for this so I am curious if
anyone has any recommendations?

Isn't there a full proper PayPal API now? IPN hasn't changed in ages, but I don't think it is their preferred way of accessing PayPal any more, and certainly isn't the most streamlined.

Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services

--- End Message ---
--- Begin Message ---
Hi,

You can look at my script. It is available here:
http://www.maxprog.com/scripts/paypal_ipn/index.html

I made it to sale software licenses, it generates and sends receipts by e-mail to the customers with a copy to you, formats and sends the customer data as XML to you by e-mail, saves the sales to Excel sheets, one per month and currency, handles refunds, reversed payments and e-checks and handles all kind of errors including sending e-mails.

~/Stan

HI All,

I am putting together an site and will accept payments via Paypal's
IPN.  I have came across many classes for this so I am curious if
anyone has any recommendations?

Does anyone know if the IPN framework has changed since 2003 as it
seems that the latest information I have on it is from 2003.  I have
looked around the Paypal site and it does not indicate when or if any
changes have been made.  I mainly need to know so if I use a 3rd pty
class I will not have to pull my hair out.

Thanks,

--
Leonard Burton, N9URK
[EMAIL PROTECTED]

"The prolonged evacuation would have dramatically affected the
survivability of the occupants."

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


--- End Message ---
--- Begin Message ---
On Sun, Mar 19, 2006 at 05:12:06AM +0000, [EMAIL PROTECTED] wrote:
> Ok...
> it has to be a way to do such a thing.
> I do i get the column names?
> I can get the number of columns using mysql_num_fields() right?
> but what if i want to get the columns name? Wich functtion and how should i 
> use?

  http://php.net/mysql_fetch_field

Something like:

$result = mysql_query($sql);

$j = mysql_num_fields($result);
for($i = 0; $i < $j; $j++ ) {
  $field = mysql_fetch_field($result, $i);
  echo $field->name;
}


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
HI All,

What do you all use for keeping track of invoices?

I looked at a few open source projects (including
http://billing-software.us/) and it seems that there is not really a
good Open Source Project out there for invoices.  Am I wrong?

What would be nice is a project with a good API that would allow other
projects to use its invoice handling capabilities.  It would be nice
if it weren't designed for one specific situation.

Have I missed the boat here?  Is there a nice OS Invoice program that
will do all this?  Has anyone considered starting one?

Thanks,

--
Leonard Burton, N9URK
[EMAIL PROTECTED]

"The prolonged evacuation would have dramatically affected the
survivability of the occupants."

--- End Message ---
--- Begin Message ---
Leonard Burton wrote:

HI All,

What do you all use for keeping track of invoices?

I looked at a few open source projects (including
http://billing-software.us/) and it seems that there is not really a
good Open Source Project out there for invoices.  Am I wrong?

What would be nice is a project with a good API that would allow other
projects to use its invoice handling capabilities.  It would be nice
if it weren't designed for one specific situation.

Have I missed the boat here?  Is there a nice OS Invoice program that
will do all this?  Has anyone considered starting one?

Thanks,

--
Leonard Burton, N9URK

PHP has become a bit of a breeze for me to use, thanks
to its authors (who came up with a nice syntax and great
docs) and its community (who didn't flame me too much
when I was a newbie, less than 5 years ago).

As a result, my business is managed by a "home grown"
app --- calendar, checkbook management, invoicing,
task list, local messaging, some accounting computations,
mileage computation, expense records, etc.

ATM, I'm adding "trouble tickets" to the mix, and a few
other ditties.

Now, if there's nothing else out there, I can imagine
it would be nice to release it, but, as I mention, I'm
a relative "newbie", and started coding it 4 years ago
and much of it is have never been updated.  Much is from
before I learned that web standards existed (I learned
HTML from reading the source created by MS FrontPage
Express in the late 1990s, [ugh!!!]), and I'm not a geek
by training (so, I've a shelf of books on OOP and still
haven't a great handle on it, but there again comes PHP
to the rescue), so "open sourcing" it might well take
so much cleaning up that it would kill me.  And if it's
not cleaned up, it'd probably be as traumatic as appearing
on American Idol in a Speedo (at my age, not very pretty
at all; or you can sub in "hosting a Tupperware party in the
nude" if you wish, but who would?).

Anyway, I guess my point was, "rolling your own isn't the
end of the world" (unless you want the world to see it).

All that said, have you looked at Hermes, CentraView (not
PHP, IIRC) or NOLA?  ATM, I can't even recall what NOLA
does, but I seem to recall that it was fairly generic (may
have been more of a retail-frontend).

Also, a quick Googling turns up a rather long list at:

     http://cbbrowne.com/info/financefreesoft.html

Good luck, HTH,

Kevin Kinsey

--
Stability itself is nothing else than a more sluggish motion.

--- End Message ---
--- Begin Message ---
Check out : http://www.sugarcrm.com/crm/

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP & MySQL Forums : http://www.weberforums.com
Search for PHP Code from your browser http://toolbar.weberdev.com 
Free Uptime Monitor : http://uptime.weberdev.com
SEO Data Monitor http://seo.weberdev.com
 

-----Original Message-----
From: Kevin Kinsey [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 19, 2006 10:40 PM
To: Leonard Burton
Cc: PHP-General
Subject: Re: [PHP] Invoices

Leonard Burton wrote:

>HI All,
>
>What do you all use for keeping track of invoices?
>
>I looked at a few open source projects (including
>http://billing-software.us/) and it seems that there is not really a 
>good Open Source Project out there for invoices.  Am I wrong?
>
>What would be nice is a project with a good API that would allow other 
>projects to use its invoice handling capabilities.  It would be nice if 
>it weren't designed for one specific situation.
>
>Have I missed the boat here?  Is there a nice OS Invoice program that 
>will do all this?  Has anyone considered starting one?
>
>Thanks,
>
>--
>Leonard Burton, N9URK
>  
>

PHP has become a bit of a breeze for me to use, thanks to its authors (who
came up with a nice syntax and great
docs) and its community (who didn't flame me too much when I was a newbie,
less than 5 years ago).

As a result, my business is managed by a "home grown"
app --- calendar, checkbook management, invoicing, task list, local
messaging, some accounting computations, mileage computation, expense
records, etc.

ATM, I'm adding "trouble tickets" to the mix, and a few other ditties.

Now, if there's nothing else out there, I can imagine it would be nice to
release it, but, as I mention, I'm a relative "newbie", and started coding
it 4 years ago and much of it is have never been updated.  Much is from
before I learned that web standards existed (I learned HTML from reading the
source created by MS FrontPage Express in the late 1990s, [ugh!!!]), and I'm
not a geek by training (so, I've a shelf of books on OOP and still haven't a
great handle on it, but there again comes PHP to the rescue), so "open
sourcing" it might well take so much cleaning up that it would kill me.  And
if it's not cleaned up, it'd probably be as traumatic as appearing on
American Idol in a Speedo (at my age, not very pretty at all; or you can sub
in "hosting a Tupperware party in the nude" if you wish, but who would?).

Anyway, I guess my point was, "rolling your own isn't the end of the world"
(unless you want the world to see it).

All that said, have you looked at Hermes, CentraView (not PHP, IIRC) or
NOLA?  ATM, I can't even recall what NOLA does, but I seem to recall that it
was fairly generic (may have been more of a retail-frontend).

Also, a quick Googling turns up a rather long list at:

      http://cbbrowne.com/info/financefreesoft.html

Good luck, HTH,

Kevin Kinsey

--
Stability itself is nothing else than a more sluggish motion.

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

--- End Message ---
--- Begin Message ---
Hi all,

Has anyone had this problem before?  I have a web server that resides
on a windows platform (According to phpinfo()).  I used the php mail
function to send out a test message to make sure that the mail
function would work when needed.  I sent out the test message and I
didn't get an email sent to me.  This is what I did, I created the
following variables:

$to = "[EMAIL PROTECTED]";
$subject ="Test";
$message ="This is a test"
$headers = "From: Paul " .
                  "<[EMAIL PROTECTED]>\r\n";
$headers .= "X-Sender:  <[EMAIL PROTECTED]>\r\n";
$headers .="X-Mailer: PHP\r\n";
$headers .="Return-Path: <[EMAIL PROTECTED]>\r\n";

I put them in the mail function as parameters
mail($to,$subject,$message,$headers).


Ok now this is what is found in phpinfo():

sendmail_from no value no value
sendmail_path no value no value
SMTP             no value no value
smtp_port        25           25

Do these values need to be set?  if so, how do that on a remote
server?  I don't think I have access to the httpd config file or
php.ini file.

Thanks
Paul

--- End Message ---
--- Begin Message ---
Hello
//---- I sorry my english
//----my script is control TCP protocol --------

$ip=83.190.177.45;  // IP
$community=public; //community (password)
echo $stan = '12'; // deletetcb - del connect

 $LocalAddress =
snmpwalk("$ip","$community","tcp.tcpConnTable.tcpConnEntry.tcpConnLocalAddre
ss");
 $LocalPort =
snmpwalk("$ip","$community","tcp.tcpConnTable.tcpConnEntry.tcpConnLocalPort"
);
 $RemAddress =
snmpwalk("$ip","$community","tcp.tcpConnTable.tcpConnEntry.tcpConnRemAddress
");
 $RemPort =
snmpwalk("$ip","$community","tcp.tcpConnTable.tcpConnEntry.tcpConnRemPort");

 echo $wynik='1.3.6.1.2.1.6.13.1.'.zamiana($LocalAddress[$id],"IpAddress:
").'.'.$LocalPort[$id].'.'.zamiana($RemAddress[$id], "IpAddress:
").'.'.$RemPort[$id];

 snmpset($ip, $community, $wynik, i, $stan);

//-- zamiana($LocalAddress[$id],"IpAddress: ") this is function
//-- Is error

12
1.3.6.1.2.1.6.13.1.0.0.0.0.135.0.0.0.0.0
Warning: snmpset(): Could not add variable:
system.sysUpTime.6.1.2.1.6.13.1.0.0.0.0.135.0.0.0.0.0 i 12 in e:\program
files\apache group\apache\users\snmp\pliki\porty_set.php on line 70

//-- hellp Me. My e-mail [EMAIL PROTECTED]

--- End Message ---
--- Begin Message --- The following code does not produce the correct results (for my purposes):

function code($str, $match, $formula)
 {
for($i = 0; $i < count($str); $i++)
 {
$formula[$i] = array_search($str[$i], $str);// <<======|| no bueno
  //print $formula[$i]; not right
 if($formula[$i] < $i)
  {$str[$i] = '';}
  }
 //print'<br>'; //----- etc (lots more code)------->

The code takes a string of ascii letters forming a word and is supposed to create a list of indexes in the proper sequence for reconstructing the word. The object of the code in context is to take any word and create an array of unique letters with no repeats so that gd can be used to produce images of each letter. The letters are then reassembled in the browser to form the word. The $formula above is supposed to tell the browser in what sequence to display each letter, including using the same letter image in repeat locations. For this it fails miserably.

These are the results of test steps:

dissatisfaction (the test word)
Processed input string:   dissatisfaction (code output at key step to verify) at creation of formula:    012245128410511314 (formula sampled at ' no bueno' line in code) from browser source array:    012245128410511314 (formula pasted from browser javascript source)

The letter images spell out:
disstfisntidfiiait which is in accordance with the formula as far as I can tell.

Is this a bug or am I misusing this function?
server platform: FreeBSD v6.0
Apache version: 1.3.34
php version: 5.1.2

There is one other weakness I've discovered, if arrays are created in one code sequence and are called to print in loops more than once or processed in different code sections. The second time the same array is called it has significantly degraded, loosing values from index positions.

the seems to be no bug report accommodation in the php.net site so I'm posting here.
Thanks in advance,
JK

--- End Message ---
--- Begin Message ---
On 19 Mar 2006, at 22:46, je killen wrote:

The code takes a string of ascii letters forming a word and is supposed to create a list of indexes in the proper sequence for reconstructing the word. The object of the code in context is to take

Ignoring your code (and the supposed 'bug') for a second - why don't you just use the count_chars() function? After all, it is designed to do almost exactly what you are trying to recreate here.

http://uk2.php.net/manual/en/function.count-chars.php

the seems to be no bug report accommodation in the php.net site so I'm posting here.

I'm not sure you looked very hard. There is a link that says 'reporting bugs' in the top nav, which takes you here: http:// bugs.php.net/

Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services

--- End Message ---

Reply via email to