[PHP] php and forms

2003-03-20 Thread b b


 
Hi,
 This could be a silly mistake or it could be a sign
of configuratin problems. Simply put, my submitted
form variables are not reaching the recieving end:

 A form:

   




A recieving file testForm.php:
 
 testVar is : %s", $testVar);
?>




When entering value like testtest in the form element
I still get the following in the recieving file:
  
testVar is : 


 i.e. the form variable is not submitted or not
recieved. I also tried doing it through the url
.../testForm.php?testVar=whatever  and still the
testVar is empty. 

 Is there a configuration problem I should be aware of
as clearly it is not a code issue? Also want to add
that php has been functioning otherwise including
using database connectivity ... So do I have to set a
variable in the configuration files of Apache to
enable  forms and url variables to be processed? 

 If anybody could shed a light on this I would be most
greatful

 Thanks,
b.

__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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



[PHP] File download

2003-04-03 Thread b b
 
 Hi,
 Anybody knows the solution to the following:
 I am trying to force the download of a file called
dadada.txt.
 I have a file named downloadFile.php 
 It is invoked like this:
   dadada.txt

 However within the downloadFile.php the $daFile
argument is empty. This is the file:

  You are not autherized to view this 

page");
}

?>


 A download happens but the downloaded file name is
"downloadFile" and not "dadada.txt" 

 Why would you think this is happening?

Cheers.


__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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



[PHP] File Download?

2003-04-03 Thread b b

 Hi,
 Why would the $daFile in the following code be
resolved to "". I am passing it via the url.
  You are not autherized to view this 
 
page");
}

?> 


 

__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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



Re: [PHP] File Download?

2003-04-03 Thread b b

 It would be:
 path/fileName

 I tried to print the _GET['daFile'] however if I am
using the header function in the same file then it
won't print a thing. In fact it starts downloading.
The only thing is that it doesn't catch the correct
file name (though it downloads the actual daFile).

Cheers,
r.
--- Jason Wong <[EMAIL PROTECTED]> wrote:
> On Friday 04 April 2003 13:51, b b wrote:
> 
> >  Why would the $daFile in the following code be
> > resolved to "". I am passing it via the url.
> >   > session_start();
> > if($_SESSION['isValidSession'] == 'Y'){
> > $daFile = $_GET['daFile'];
> 
>  - What URL are you using?
>  - Have you taken case into account?
>  - What does print_r($_GET) give you?
> 
> -- 
> Jason Wong -> Gremlins Associates ->
> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet
> Applications Development *
> --
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> --
> /*
> Before borrowing money from a friend, decide which
> you need more.
>   -- Addison H. Hallock
> */
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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



[PHP] Prefilled forms

2003-11-18 Thread b b

 Hi there,
 I have installed linux/apache/php (again) recently on
my machine. When I run an application off my server,
fill out a form, submit it and then click back to edit
some entries, the form comes up blank. This happen for
apps running off my server only. Is it something with
my php.ini, or is it an apache setting ... It is
making debugging very hard. Anybody seen this problem
before?

 Thankyou dearly.


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



RE: [PHP] Prefilled forms

2003-11-18 Thread b b

 I don't think you understood my question. Off course
you have to store data in a database  or a session var
if you want to retrieve them later on.

 My problem is not there. I hava a form, I click
submit and right after that I hit back. Usually in
most cases the form will be prefilled with what I
entered. In my case I am getting a totally blank form.
This is only hapenning with forms from my server. 

 

Cheers,
R.
--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> [snip]
>  I have installed linux/apache/php (again) recently
> on my machine. When
> I run an application off my server, fill out a form,
> submit it and then
> click back to edit some entries, the form comes up
> blank. This happen
> for apps running off my server only. Is it something
> with my php.ini, or
> is it an apache setting ... It is making debugging
> very hard. Anybody
> seen this problem before?
> [/snip]
> 
> Yes, several of us have seen it, many times in fact.
> Imagine that.
> Browsers, being the stateless wonders that they are,
> do not 'maintain'
> the information. You have some choices through.
> Retrieve the variables
> from the database, save them in a session variable
> and retrieve them
> from there, or do some other imaginative method of
> 'maintaining' the
> variables until you are done with this particular
> group of variables.
> 
> I invite you to STFW and STFA for the answers to
> your dilemna. Have a
> pleasant day and happy coding!!
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



RE: [PHP] Prefilled forms

2003-11-18 Thread b b


 The Problem again:
 I have a form, I fill it, click submit and then hit
back. Usually in other sites I see the data that I
attempted to submit. Forms originating from my site
are  coming up blank.

In respnonse to your reply:
 I am using mozilla 5 or netscape 7. Same result in
both. However, this doesn't happen with other sites
using the same borwser ... Actually this never
happened with my last configuration. ONly now that I
reinstalled apache/php and actually linux that I am
getting this behaviour from my own server only.

 I am suspecting a php.ini setting that I have set or
set off or an apache conf detail that is causing this.
Bowser setting is a possibility but why then is it not
behaving this way with other sites?




--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> [snip]
>  I don't think you understood my question. Off
> course
> you have to store data in a database  or a session
> var
> if you want to retrieve them later on.
> 
>  My problem is not there. I hava a form, I click
> submit and right after that I hit back. Usually in
> most cases the form will be prefilled with what I
> entered. In my case I am getting a totally blank
> form.
> This is only hapenning with forms from my server. 
> [/snip]
> 
> This AFAIK is the expected behaviour. Once you have
> submitted the form
> all of the input values will be blank when you
> return to the form unless
> you do something to specifically reload the
> variables into the form.
> YMMV from OS to OS, browser to browser. There is
> only one realiable way
> to do it cross-platform and these were mentioned
> above. You never
> mentioned your server config, your browser, your OS,
> so I am only making
> a S.W.A.G. at it. There is nothing IIRC that you can
> configure in the
> php.ini, httpd.conf, or other configuration file.
> You may have a browser
> setting that affects this, but since we know not
> your browser type it
> would be hard to help you locate that.


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



RE: [PHP]{OT} Prefilled forms

2003-11-18 Thread b b

 What???
 You ahve sent me like three private emails. You did
reply all which sends me a private message and a
message from the list. I replied to the one that had
only your email address in it by mistake.  mama mia

--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> [snip]
> > Have you consulted an Apache list? Googled for
> > answers? Anything like
> > that?
> 
>  No, this sounded like a basic thing. I can't
> believe
> I having to deal with it. See even if I submit this
> email and then click back I will see exactly what I
> typed. If that form was originating from my server
> it
> would probably be blank.
> [/snip]
> 
> Please do not privately respond to list mails unless
> asked specifically
> to do so as the person you respond to may not be
> available to help.
> 
> Please google for an answer to this, do some
> research yourself. See what
> you can find.


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



RE: [PHP] Prefilled forms

2003-11-18 Thread b b

 Actually I am going back to the same URL. I am
thinking it is an apache conf setting. See after I
submit this email I can click back and will see the
text that I am writing right now. If that form was
coming from my server, it would be empty I am sure.

 Problem again: I have a form, fill it, click submit,
then immidiately click back. Usually I see the data
that I attempted to submit but on my server it shows a
blank form.

Cheers.

--- "Vail, Warren" <[EMAIL PROTECTED]> wrote:
> From my experience, Jay's explanations are correct,
> but let me try another
> tack.
> 
> It is my understanding that when you press the back
> button on a browser, the
> browser tries to present the page the same way it
> presented it the first
> time it was presented, from information it saved in
> it's history stack.
> When you came to this page the first time, it
> presented an empty form.  When
> you go back to the same URL (using the back button)
> it presents the same
> empty form.
> 
> When you press the submit button, you are probably
> telling the browser to
> post your filled in data to a different URL, and the
> back button takes you
> away from that URL to the one with the empty form. 
> It may be possible to
> fake out the browser, by having it post form data to
> the same URL as the one
> presenting the empty form, but I would be surprised
> if that worked the same
> for all browsers.  Perhaps this is the situation
> where you saw it appear to
> retain your data.
> 
> So much for the problem you are encountering, one of
> your next challenges
> will be the following;
> 
> If you enter a page with a POST as in the submission
> of a form with a method
> of post, and then click submit on that page, going
> on to a third page (again
> with a post), and then click the back button, most
> browsers will complain
> (both IE and Netscape do).  Seems that if a URL was
> entered via a "post" and
> you manage to click back to that same page, the
> browser appears to not save
> enough information to re-present the page, and will
> ask you to click the
> refresh button.  For this reason, I make it a
> practice of directing all my
> forms to one URL that will process the form data,
> and then redirect the
> browser to a new url (see the header function) for
> presenting the next page.
> This causes the browser to replace the "post" url
> with the redirection url
> (always a get), so that the back button will only
> remember the redirected or
> get pages.  I haven't found a more elegant solution,
> so if there is another
> out there, I'd appreciate hearing about it.
> 
> good luck,
> 
> Warren Vail
> 
> -Original Message-
> From: Jay Blanchard
> [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 18, 2003 1:09 PM
> To: b b; [EMAIL PROTECTED]
> Subject: RE: [PHP] Prefilled forms
> 
> 
> [snip]
>  I don't think you understood my question. Off
> course
> you have to store data in a database  or a session
> var
> if you want to retrieve them later on.
> 
>  My problem is not there. I hava a form, I click
> submit and right after that I hit back. Usually in
> most cases the form will be prefilled with what I
> entered. In my case I am getting a totally blank
> form.
> This is only hapenning with forms from my server. 
> [/snip]
> 
> This AFAIK is the expected behaviour. Once you have
> submitted the form
> all of the input values will be blank when you
> return to the form unless
> you do something to specifically reload the
> variables into the form.
> YMMV from OS to OS, browser to browser. There is
> only one realiable way
> to do it cross-platform and these were mentioned
> above. You never
> mentioned your server config, your browser, your OS,
> so I am only making
> a S.W.A.G. at it. There is nothing IIRC that you can
> configure in the
> php.ini, httpd.conf, or other configuration file.
> You may have a browser
> setting that affects this, but since we know not
> your browser type it
> would be hard to help you locate that.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



Re: [PHP]{OT} Prefilled forms

2003-11-18 Thread b b

 Some people don't read carefully before responding. I
didn't say he sent me a private email!!! Anyway it
would be appropriate not to forget to take out the
email addresses other than the php-general... when
clicking reply-all. I just don't see how someone who
forgets and includes your address (so that you get
duplicate responses, 8 from this person so far)
complains that you replied to the wrong version. And
he does it in the general list. That is not right.

 


--- John Nichel <[EMAIL PROTECTED]> wrote:
> b b wrote:
> >  What???
> >  You ahve sent me like three private emails. You
> did
> > reply all which sends me a private message and a
> > message from the list. I replied to the one that
> had
> > only your email address in it by mistake.  mama
> mia
> 
>  From what I've seen, Jay has had both your email
> address AND the list 
> address on his replies.  He's not being rude by
> asking this, he's asking 
> this to help someone who may have this problem in
> the future.  If you 
> reply/find a solution off list, it won't be
> archived, therefore it will 
> not be searchable by future users.
> 
> 
> Of course, this would have so much more meaning if
> people actually 
> searched the archives.
> 
> 
> -- 
> By-Tor.com
> It's all about the Rush
> http://www.by-tor.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



Re: [PHP]{OT} Prefilled forms

2003-11-18 Thread b b

   What is not right is tell me in public about it
when he actually sent me private messges himself
(accidentally). I also accidentally replied to the
wrong duplicate email that he sent (so in fact it is
his fault that he got the private message from me).
Whats not right is to make it look like I am sending
out personal emails to users when I was replying to a
message sent to me. 
Again read and think before interfering. You really
aren't helping much. In other words, mind your own ...


 

--- John Nichel <[EMAIL PROTECTED]> wrote:
> b b wrote:
> >  Some people don't read carefully before
> responding. I
> > didn't say he sent me a private email!!!
> 
> You're right, you didn't say he sent you A private
> email.  You said, 
> "You ahve sent me like three private emails."
> 
> > Anyway it
> > would be appropriate not to forget to take out the
> > email addresses other than the php-general... when
> > clicking reply-all.
> 
> You mean like you forgot to do when replying to Jay
> and the list at the 
> same time?
> 
> > I just don't see how someone who
> > forgets and includes your address (so that you get
> > duplicate responses, 8 from this person so far)
> > complains that you replied to the wrong version.
> 
> He didn't complain...he asked that you not reply
> privately to him or 
> anyone else on the list unless asked to do so. 
> There's a reason for 
> this, which I explained earlier.  You reply
> privately, and it won't be 
> archived here
> 
> http://marc.theaimsgroup.com/?l=php-general&r=1&w=2
> 
> > And
> > he does it in the general list. That is not right.
> 
> What's not right?  That he replied to you and the
> list?  Or that a long 
> time helper of this community asked you not to do
> something, and you 
> took it personal?
> 
> Regardless, I'm not going to go back and forth with
> this all night.
> 
> 
> 
> -- 
> By-Tor.com
> It's all about the Rush
> http://www.by-tor.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



[PHP] Prefilled forms (solved)

2003-11-18 Thread b b

 Alright lets clean the slate here. I think we all
mean well and that is what counts. I apologize if I
offended anybody. 

 Incidentally I can't quite explain the solution to my
dillemma. The following is a description of the
Problem and the Solution:

Problem:
 I am running apache/php server. If I populate a form,
send it and then click back I see a blank form. 

Solution:
I had some prefilled form elements where I set the
value of such form element. For example I had 
input type = "hidden" VALUE="whatever" ... at the
beginning of the form.

 when I took that hidden variable out and had it at
the end of the form after all the other elements I the
problem was solved. Actually any element with its
value preset should go to the end of the form. In that
case when I hit back my form was prefilled the way I
submitted it. 

 It is funny I have been doing this for a while and
this is the first time I had to investigate such a
problem. I am using mozilla 5.00 or netscape 5.0 on
linux. I presume explorer wouldn't have that problem.

 Hope you don't run into this problem and waste few
hours pulling hair like I did. 

 Cheers and thanks to everyone who tried to help me. 



__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



Re: [PHP] Prefilled forms (solved)

2003-11-18 Thread b b

 No I am saying that if you have:



 and you click submit then if you click back to see
the form the value you set w2 will be blank. If you
reverse the order however then you will see what you
entered in w2


--- "John W. Holmes" <[EMAIL PROTECTED]> wrote:
> b b wrote:
> 
> > Problem:
> >  I am running apache/php server. If I populate a
> form,
> > send it and then click back I see a blank form. 
> > 
> > Solution:
> > I had some prefilled form elements where I set the
> > value of such form element. For example I had 
> > input type = "hidden" VALUE="whatever" ... at the
> > beginning of the form.
> > 
> >  when I took that hidden variable out and had it
> at
> > the end of the form after all the other elements I
> the
> > problem was solved. Actually any element with its
> > value preset should go to the end of the form. In
> that
> > case when I hit back my form was prefilled the way
> I
> > submitted it. 
> 
> Are you saying you have something like this:
> 
> 
> 
> 
> in order to set a default value? If that's the case,
> you'll never get 
> your value of "foo" from the textbox as the hidden
> value will overwrite it.
> 
> The entire issue is up to the client's browser and
> has nothing to do 
> with PHP. It's up to each browser whether it keeps
> your values or not; 
> I've seen it happen both ways with different
> browsers.
> 
> -- 
> ---John Holmes...
> 
> Amazon Wishlist:
> www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals –
> www.phparch.com
> 
> 
> 
> 


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



[PHP] Query Batch

2003-11-18 Thread b b

 Jhon you mentioned that one may send a batch of
queries with mysql_list? maybe I understood you wrong.


 I am translating an MS-SQL application into
mysql/php. I need to be able to send a batch of
queries all at once. For example:
 $qStr = " Insert into A(name, address)
values('$name', '$address') ; Insert into B(personID,
department ...)values (@@identity, '$department');" ;

 $result= mysql_query($qStr, $link) ;


 In this case I inserted in two tables. for some
reason it doesn't allow me to have to sql statements
in $qStr. Is there a way around that.

 My other option is to have one sql statement per
query  but this would be very inefficient if I
have ti do  tens of inserts in one batch ...

 Cheers.
 

__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



[PHP] php and tables

2001-11-27 Thread b

i have created a program that allows users to make custom sql queries to
a mysql db and display the output to the browser.
the program works as desired but what i would like to do is display the
data in a table.
as there can be up to 4 columns with up to 13 different titles, i cannot
hard code this info in.
i would like to have the title used in the query to the be the title of
the table with the relevant data
below in an easily read format.

here is a sample of my code can any one help???

function db_search(){
global
$search,$search0,$search1,$search2,$search3,$where,$boulean,$variable;

// from the subnet and the host make the ip address
$ip_addr = $ip . $address;

// check to see if the variable is empty and discard other wise add the
contents to $field

if(!empty($search)) {
$field .= "$search, "; }
if(!empty($search0)) {
$field .= "$search0, "; }
if(!empty($search1)) {
$field .= "$search1, "; }
if(!empty($search2)) {
$field .= "$search2, "; }

if(!empty($where)) {
$field1 .= "$where "; }
if(!empty($search3)) {
$field1 .= "$search3 "; }
if(!empty($boulean)) {
$field1 .= "$boulean "; }
if(!empty($variable)) {
$field1 .= "'$variable' "; }

//strip the last character off of $field

$field = substr($field,0,strlen($field)-2);
//$field1 = substr($field1,0,strlen($field1)-2);

// prepare the query
$sql = "select $field from machine $field1 ";
print $field;

// action the query
$result = mysql_query($sql)
or die ("Cannot do query, query = $sql");

// Printing results in HTML
   print "\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
print "\t\n";
   foreach ($line as $col_value) {
   print "\t\t$col_value\n";
}
   print "\t\n";
   }
   print "";
   print "\n";

print "";

echo "\n\nYour Job has Completed\n\n\n\n\nBack";
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] $B:#F|$N;q6b7+$j$O(B

2001-06-28 Thread $B
$B!&!&!&(B $B:#F|$N;q6b7+$j$G$*:$$j$NJ}$O(B $B!&!&!&(B
http://www.justinmail.net/ma01/pa01.htm
$B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  
$B!&!&!&(B  $B!&!&!&!&(B
$B#1#0#0K|1_$^$G$4M;;qCW$7$^$9!#(B
$BF|K\A49q!&:#F|Cf$K4V$K9g$$$^$9$N$G(B
$B@h$:$O>e5-#U#R#L$K%"%/%;%9!*(B

$B%&%'%V%U%!%$%J%s%9$N%Q%$%*%K%"(B
   ::: $B&9)(B ::

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] Fileinfo and MSWord bug

2009-05-16 Thread b

PHP 5.2.6
file-4.17-15.el5_3.1
Fileinfo installed through PECL

Checking certain MSWord files, I'm getting back (sans quotes) 
"application/msword application/msword". Someone reported (in the manual 
comments) this same thing back in 2007:

http://ca2.php.net/manual/en/ref.fileinfo.php#79063

Can anyone shed any light on how/why this is happening? Specifically, is 
this a bug in Fileinfo, file (the app), the Word doc, or the magic file 
itself? I'd love to investigate this further but am having some trouble 
searching online. Narrowing it down to a specific target would be most 
helpful. I don't see anything about it at bugs.php.net and I'd rather 
try to figure out if the problem is PHP-related before filing a bug.


For now, I'm doing the following:

$fi = new finfo(FILEINFO_MIME, FINFO_PATH);
$type = $fi->file($file['tmp_name']);

$split = explode(' ', $type);
$type = $split[0];

Pretty hackish. If anyone has a better solution in the meantime, I'd be 
most appreciative.


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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-27 Thread b

hessi...@hessiess.com wrote:

Something that seriously annoys me about PHP is the fact that it has
a configuration file which can *completely* change the behaviour of
the language.


Perhaps you're not at all clear on the purpose of a configuration file.

> I am seriously considering moving to a different language because of 
this.


I guess you could look for a language that has a parser with 0 
configuration options. Sounds like a bundle of fun.


Meanwhile, why don't you consider a) moving to a new host; or, b) 
setting up your own server so you can ~shudder~ *configure* it however 
you like.



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



Re: [PHP] Re: PHP Security

2009-06-02 Thread b

Grant Peel wrote:

???


I think you can safely assume that was a joke.

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



Re: [PHP] PHP as Language

2009-07-24 Thread b

On 07/24/2009 02:06 PM, Kyle Smith wrote:

Martin Scotta wrote:

Hi all

Is there a formal definition for the php language?
Where I can found it?

I've STW with no results.


Not sure if this is what you mean, but PHP stands for "PHP: Hypertext
Processor"

- Kyle



I think Martin is looking for the formal definition of the language, not 
the name. Wikipedia has a bunch of links worth checking:


http://en.wikipedia.org/wiki/PHP#Notes

Nothing jumps out at me, though.

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



[PHP] preg_match too greedy

2009-07-29 Thread b
I'm trying to figure out how to test if a string matches *exactly* 
another string, using a regexp pattern. The manual says that ereg() is 
deprecated (in favour of what?) and preg_match() is giving me trouble. 
The problem is that I'm passing the end-of-line delimiter ($) but it 
seems to be ignored. An example:


-- snip --
header('Content-type: text/plain');
$url = '/foo(/)?';
$test = 'foo/bar';
$pattern = '%^'.$url.'$%U';

echo "${url} :: ${test}\n";

echo (preg_match($pattern, $test) != false)
? 'match'
: 'no match';
-- snip --

I expected 'no match' but get 'match'.

The reason for the (/)? is to allow for a trailing slash. I've added a 
'$' to specify that I want to test for the exact string. However, 
preg_match() tests for the existence of a string and appears to ignore 
the '$'.


How do I do this?

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



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 02:07 PM, Jim Lucas wrote:

b wrote:

I'm trying to figure out how to test if a string matches *exactly*
another string, using a regexp pattern. The manual says that ereg() is
deprecated (in favour of what?) and preg_match() is giving me trouble.
The problem is that I'm passing the end-of-line delimiter ($) but it
seems to be ignored. An example:

-- snip --
header('Content-type: text/plain');
$url = '/foo(/)?';
$test = 'foo/bar';
$pattern = '%^'.$url.'$%U';

echo "${url} :: ${test}\n";

echo (preg_match($pattern, $test) != false)
 ? 'match'
 : 'no match';
-- snip --

I expected 'no match' but get 'match'.

The reason for the (/)? is to allow for a trailing slash. I've added a
'$' to specify that I want to test for the exact string. However,
preg_match() tests for the existence of a string and appears to ignore
the '$'.

How do I do this?



cut/paste your code and it works for me.

Jim Lucas



Works, meaning you get 'match', or 'no match'? It should be the latter, 
but I'm seeing the former.


I'm using 5.2.9, btw.

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



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 03:03 PM, Ben Dunlap wrote:

Jim Lucas wrote:

I expected 'no match' but get 'match'.

[8<]

cut/paste your code and it works for me.


Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What
version do you have?


5.2.9


If I might suggest a couple of simplifications that would make it easier to
follow/troubleshoot:


$url = '/foo(/)?';


I don't think you need parentheses around your second forward-slash. If you had
multiple characters that were optional you'd want to group them in parentheses,
but here I think it just makes the regex harder to read.


Really? I think it makes it crystal clear that it's the '/' that is 
optional. In any case, it makes no difference.





echo (preg_match($pattern, $test) != false)


The " != false " here is redundant.


Understood. But what you think is redundancy is, to me, clarity in 
programming. I happen to think that boolean tests shouldn't ride on 
whether or not an array returned from a function is empty or not (or a 
freaking boolean). If what I'm looking for is a "false" then that's what 
I'll test for.



Combined with the ternary operator, the logical switchbacks make me a

> little dizzy (especially this close to lunchtime).




Oh, you're one of those people who can't stand the sight of a ternary 
operator. Buck up, son, it's good for ya ;-)


(Seriously: I don't understand why ternaries freak some people out. It's 
plain as day!)



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



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 07:48 PM, Daniel Kolbo wrote:


code works (no match) for me too on php 5.2.6 build date May 2 2008
18:01:20 with dumbdows NT.

preg_match fails but for a reason other than what I think you may be
expecting.  It fails b/c of the first forwards slash in $url.  The regex
engine doesn't even get past the second character let alone reaching the
end of line anchor.


The forward slash shouldn't be an issue as the delimiter is '%'. The 
full pattern is:


%^/foo/?$%U



Also, your code works (no match) with this first forward slash removed:
$url = 'foo(/)?'


But the string happens to start with a forward slash.


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



Re: [PHP] preg_match too greedy

2009-07-29 Thread b

On 07/29/2009 11:18 PM, Daniel Kolbo wrote:

b wrote:

On 07/29/2009 07:48 PM, Daniel Kolbo wrote:

code works (no match) for me too on php 5.2.6 build date May 2 2008
18:01:20 with dumbdows NT.

preg_match fails but for a reason other than what I think you may be
expecting.  It fails b/c of the first forwards slash in $url.  The regex
engine doesn't even get past the second character let alone reaching the
end of line anchor.

The forward slash shouldn't be an issue as the delimiter is '%'. The
full pattern is:

%^/foo/?$%U



Also, your code works (no match) with this first forward slash removed:
$url = 'foo(/)?'

But the string happens to start with a forward slash.



i am not talking about the delimiter
your pattern is:
%^/foo/?$%U
your test string is:
'foo/bar'


AAARRRGG! Sorry, that's a typo! It should be:

$test = '/foo/bar';

I guess that explains a lot. For the record, I had to type that in 
because this latest version of Thunderbird crashes whenever I paste into 
it. (note to self: downgrade that, stat!)






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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 08:53 AM, Peter Ford wrote:


Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'



Fedora11 (2.6.29.6-213.fc11.i586)

$ file excel.xls
excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, 
Code page: 1252, Author: ??, Last Saved By: 
ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun 
Nov  6 18:04:20 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, 
Security: 0


$ file -i excel.xls
excel.xls: application/vnd.ms-excel; charset=binary

Using 5.2.9, the OP's script prints:
application/vnd.ms-excel; charset=binary

I wonder if the problem lies with the documents themselves. Last May, I 
posted a msg here about how FileInfo was reporting back 
"application/msword application/msword" for some (but not all) Word 
docs. I never received a reply about it but came up with a hack to split 
on the space, if present.


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



Re: [PHP] Formatting plain text file

2009-07-30 Thread b

On 07/30/2009 06:29 PM, Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct formatted
tables similar to HTML?




Are you thinking of a CSV file that you can open in a spreadsheet prog? 
Or, do you literally mean a plaintext file with columns? For the latter, 
you'd need to measure the max char length of each "column" for every 
line in the file, then go back and print each line using str_pad().



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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-30 Thread b

On 07/30/2009 10:15 AM, Ashley Sheridan wrote:

On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:

>>

You could email it to me, which I presume is better if you replied
back just to me and not the list?


Just copying the list back on in this one now. I don't know of any
places that you could upload a file to off the top of my head. Anyone
have any links?



Just google "upload file"; there are a bunch of sites that do this to 
choose from.


(I've never used any so I can't recommend one over the others)


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



Re: [PHP] Character encoding

2009-08-05 Thread b

On 08/05/2009 07:05 AM, Sándor Tamás (HostWare Kft.) wrote:

Hi,

I have a mysql database, which the users can insert comments. As the users can 
be from different countries, with different character encoding, the mysql table 
can contain various special characters.

How can I be sure to display these comments properly? I've found the 
mb_convert_encoding, and for some characters it works okay, but there are some 
really special characters which displayed as a '?'.

Does anybody know some workarounds?

Thanks,
SanTa


Use UTF-8. Create your database and its tables with UTF-8 char encoding. eg.

ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

Note there's no hyphen.

Also, make sure the *data* is converted. You can use iconv for that.

Next, ensure that the browser knows how to display the text. Use either 
a header or a meta tag (or both):




This is especially important for the page with the comments form.

Any SQL file with your data (for import) should have the following at 
the top:


SET NAMES 'utf8';

If you export a dump make sure that line is present before trying to import.

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



[PHP] Using javascript function from php

2005-03-10 Thread b
Hi,
I am just learning php, and am currently converting some jsp pages to php.  
I used the follwing code in jsp to toggle between two images


function toggle(imagename,src1,src2){
if(document.images && document.images[imagename])
{
image1=new Image;
image1.src=src1;
if(document.images[imagename].src != image1.src){document.images[imagename].src = image1.src}
else{document.images[imagename].src=src2}
}
}
start code snippet. out.println(" out.println("onclick=\"toggle('" + child + "image','images/" + type + ".jpg','images/" + childimg "');return(false);\""); out.println(">"); out.println(""); end code snippet... I have tried many different ways to achieve this in php, but nothing works. This is my latest attempt start code snippet. print(" echo " {\n"; echo " image1=new Image;\n"; echo " image1.src=images/$type.jpg;\n"; echo " if(document.images[" . $child . "image].src != image1.src){document.images[" . $child . "image].src = image1.src}\n"; echo " else{document.images[" . $child . "image].src=images/$childimg}\n"; echo " }\n"; echo "};\n"; echo "return(false);\">\n"; print("\n\n"); print("\n"); end code snippet. Could someone please let me know how to do this Cheers Barb -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: Using javascript function from php

2005-03-10 Thread b
It's OK I worked it out.
On Fri, 11 Mar 2005 15:44:55 +1100, <[EMAIL PROTECTED]> wrote:
Hi,
I am just learning php, and am currently converting some jsp pages to  
php. I used the follwing code in jsp to toggle between two images


function toggle(imagename,src1,src2){
if(document.images && document.images[imagename])
{
image1=new Image;
image1.src=src1;
if(document.images[imagename].src != image1.src){document.images[imagename].src = image1.src}
else{document.images[imagename].src=src2}
}
}
start code snippet. out.println(" out.println("onclick=\"toggle('" + child + "image','images/" + type + ".jpg','images/" + childimg "');return(false);\""); out.println(">"); out.println(""); end code snippet... I have tried many different ways to achieve this in php, but nothing works. This is my latest attempt start code snippet. print(" echo " {\n"; echo " image1=new Image;\n"; echo " image1.src=images/$type.jpg;\n"; echo " if(document.images[" . $child . "image].src != image1.src){document.images[" . $child . "image].src = image1.src}\n"; echo " else{document.images[" . $child . "image].src=images/$childimg}\n"; echo " }\n"; echo "};\n"; echo "return(false);\">\n"; print("\n\n"); print("\n"); end code snippet. Could someone please let me know how to do this Cheers Barb -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] php image and javascript include

2008-09-07 Thread b

javasac wrote:

[lots of stuff ...]



I'm guessing that was the *output* of the PHP file, not the script itself.

You've got a couple different errors here. The first is that you're not 
creating img tags. All you have here is the path to the image. A browser 
isn't going to do anything with that.


> 
> images/box_bottom_lft.jpg 

Second, at least one of the image paths is relative to your own desktop 
computer's drive (why is it that this always happens on a Windows box?)


> 
> C:/wamp/www/yojoe-web/html/site/images/box_top_rht.jpg 


Also, in the future, it'd be better to trim out the completely 
unnecessary bits. That's an awful lot of (bloated) HTML and javascript 
to wade through.


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



Re: [PHP] tedd's back from vacation

2008-09-10 Thread b

tedd wrote:

hi gang:

For those who wondered where I went -- I was on vacation.

I would have announced it before I left, but I was afraid that someone 
would have broken into my collection of stuff.


I'll post pictures of my vacation soon.

Oh, I had lot's of fun -- so much so, I broke my big toe on my left foot 
-- that's having serious fun! That was a dance someone should have 
recorded.


Cheers,

tedd


OK, this is getting ridiculous. I think we need a new PHP list. 
Something like [EMAIL PROTECTED] sounds about right.


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



Re: [PHP] New Server Install

2008-09-10 Thread b

Robbert van Andel wrote:

I am working on a new webserver running Fedora 9.  I installed php-mysql and
php-mssql via yum.  When I try to connect to our mysql server using php, I
get the following error: Can't connect to MySQL server on 'mysqlservername'
(13)

Here's the weird part, I can connect to the mysql database server just fine
from the web server's command line so I'm pretty confident that it's not a
firewall issue.  While trying to connect using PHP, I see no packets leaving
the webserver. 

 


I'd guess it's SELinux blocking it. This will allow apache to connect to 
a remote server:



/usr/sbin/setsebool -P httpd_can_network_connect=1

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



Re: [PHP] Paypal Integration

2008-09-16 Thread b

Ashley Sheridan wrote:


I don't recommend HSBC at all. They make you jump your code through so
many hoops and their documentation was awful. I don't know why large
companies think it's acceptable to produce bad/out-of-date documentation
and expect it all to be OK.



Thanks for the heads-up. I also did have a look at 2Checkout some time 
ago but found it pretty sketchy, as someone else pointed out.


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



Re: [PHP] Associative array issues with loading values after initialization

2008-09-19 Thread b

Thomas Bolioli wrote:
I should add, it is not working with this funciton, which could be the 
source of the issue.


function dropbox_from_list($list, $selected_index){
   while ($nex = next($list)) {


I'd use foreach() here and avoid next(). At least, reset the array 
first. And maybe pass the array by reference:


function dropbox_from_list(&$list, $selected_index)
{
  foreach($list as $k => $v)
  {


   $k = key($nex);
   if (strcmp($selected_index, $k) == 0) {
   $select = ' SELECTED';
   }
   else {
   $select = '';
   }
   print("".$nex[$k]."");
   }
}


Maybe you should also add what it is that's "not working".




Thomas Bolioli wrote:

The below function is not working.
function crm_get_country_list(){
global $dbh;
   $result = mysql_query("SELECT * FROM countries ORDER BY 
pk_country_id ASC", $dbh) or die(mysql_error());

   $country_list = array(' ' =>' ');


Are you starting with an empty key & value so that you'll have an empty 
option in your select list? Why not just print an empty one?



   while ($row = mysql_fetch_assoc($result)){
   $country_list[$row['pk_countryID']] = $row['country_name'];
   }
return $country_list;
}


Start with the obvious: what does $country_list contain when it's returned?

Again, some details about what you're getting would go a long way toward 
getting some advice.


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



Re: [PHP] was [PHP] Re: render html

2008-09-21 Thread b

tedd wrote:

At 8:17 AM +0200 9/21/08, Lupus Michaelis wrote:

Michelle Konzack a écrit :

$body = "helloierhellohello";

^
Should be 


  Definitely no :




  Or maybe for buggy browsers ?



 >>>  Definitely no ???  <<<

I've always found this confusing.



I think this page explains the roots of the confusion very well:

Empty elements in SGML, HTML, XML, and XHTML
http://www.cs.tut.fi/~jkorpela/html/empty.html


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



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Lamp Lists wrote:

Hi,
Right now I use one file, usually called functions.php, with all functions I'm 
going to use most likely on every page.
Then, I create each function I'm going to use once in a while as separate file.
Pro: I would include a function when I'm going to use.
Con: I have to write extra include line to call function. And have bunch of 
files (functions) in function folder.

I was talking to co-workers few days ago and they said I complicate my
life to much and putting ALL functions in one file is just fine and
I'll not be able to see difference in "real situations".



When not using a framework (eg. Cake) i also usually keep a single file 
and include it. I think it depends on how many functions you have. If 
you've got a really huge functions.php and most of them are used only in 
one or two scripts, then you probably shouldn't be loading it into every 
script. Otherwise, i wouldn't be too concerned about it.


Of course, you should also think about using classes if that makes sense 
for what you're doing.


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



Re: [PHP] calling functions from one or multiple files

2008-09-24 Thread b

Ashley Sheridan wrote:

On Wed, 2008-09-24 at 12:37 -0400, b wrote:

Lamp Lists wrote:

Hi, Right now I use one file, usually called functions.php, with
all functions I'm going to use most likely on every page. Then, I
create each function I'm going to use once in a while as separate
file. Pro: I would include a function when I'm going to use. Con:
I have to write extra include line to call function. And have
bunch of files (functions) in function folder.

I was talking to co-workers few days ago and they said I
complicate my life to much and putting ALL functions in one file
is just fine and I'll not be able to see difference in "real
situations".


When not using a framework (eg. Cake) i also usually keep a single
file and include it. I think it depends on how many functions you
have. If you've got a really huge functions.php and most of them
are used only in one or two scripts, then you probably shouldn't be
loading it into every script. Otherwise, i wouldn't be too
concerned about it.

Of course, you should also think about using classes if that makes
sense for what you're doing.

I tend to try and group functions I use on a site, with common ones 
going into a generic functions.php file. This avoid the problems of 
overly large function files included on every page, as chances are

you won't need every function.



Done that, but not so much anymore. It depends on how specialised the 
functions (and sections) are. Usually an administration section can do 
with a separate file (while also including the general one). But, for 
other areas, it'll work fine until you find that you need a function 
that's in another file.


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



Re: [PHP] Sepating MySQL result set into html tables

2008-09-26 Thread b

Thodoris wrote:

Hello everybody,
   I have a mysql result set that I want to print out in an html table. 
But some times it gets so big that I will probably need to separate it 
in to multiple ones. I wrote a function that separates the result set 
into three ones like this:


...

But I really need to tell the function in how many tables I need the 
result set to be separated. How can I do this?


What can I put instead of this for 3 tables: (($j == $limit-1) || ($j == 
(2*$limit)-1))


I can't find the algorithm although I think I have done this before but 
I can't remember how.




Why not just use LIMIT in your query and make several?

Why do you need to split the data into multiple tables, anyway?


   $table = "";

   $table .= "";


That's going to give you badly-formatted HTML.

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



[PHP] $B$4M;;q$N$40FFb(B

2001-07-13 Thread $B%"%]%m4k2h(B
$B!&!&!&(B $B:#F|$N;q6b7+$j$G$*:$$j$NJ}$O(B $B!&!&!&(B
http://www.justinmail.net/ma02/pa01.htm
$B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  $B!&!&!&(B  
$B!&!&!&(B  $B!&!&!&!&(B
$B#1#0#0K|1_$^$G$4M;;qCW$7$^$9!#(B
<$B.@Z

$BF|K\A49q!&:#F|Cf$K4V$K9g$$$^$9$N$G(B
$B@h$:$O>e5-#U#R#L$K%"%/%;%9!*(B

$B%&%'%V%U%!%$%J%s%9$N%Q%$%*%K%"(B
  ::: $B%"%]%m4k2h(B ::


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] rename failes if file name contains single quotes

2003-01-31 Thread $B%X!<%s(B $B%H!<%^%9(B
when i try to rename a file with single quote(s) in the
(Bfile name, e.g.
(B
(Brename("/tmp/foo 'n bar", "/tmp/foobar");
(B
(Brename fails with "there is no such file".
(Bwhats wrong?
(B
(Bthanx,
(B
(Bakagisan
(B
(B__
(BDo You Yahoo!?
(BYahoo! BB is Broadband by Yahoo!  http://bb.yahoo.co.jp/
(B
(B
(B-- 
(BPHP General Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php



[PHP] pg_connect $B$,;H$($J$$(B

2003-02-08 Thread $BNS(B $B7C72(B
$B;O$a$^$7$F!#(Blin $B$H?=$7$^$9!#(B
(B
(Bphp$B$N(Bpg_connect$B$G(BpostgreSQL $B$K@\B3$r;n$_$^$7$?$,!"4X?t$,(B
$B8+$D$+$j$^$;$s$H%(%i!<$,=P$F$7$^$$$^$7$?!#F1MM$J8=>]$,Ax(B
$B6x$7$?J}$,$$$?$h$&$G$9$,!"4N?4$J2r7hJ}K!$O8+$D$+$j$^$;$s(B
$B$G$7$?!#$I$J$?$+$,2r7hJ}K!$r$4B8CN$G$7$?$i!"CN7C$r$*B_$7(B
$B$/$@$5$$!#(B
(B
(B
(B
(B
(B__
(BDo You Yahoo!?
(BYahoo! BB is Broadband by Yahoo!
(Bhttp://bb.yahoo.co.jp/
(B
(B
(B-- 
(BPHP General Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to uncompress PHP

2003-02-08 Thread $BNS(B $B7C72(B
Hi, I am Lin.
(B
(BWhen I execute a command
(B
(Bgzip -d php-4_3_0_tar.gz
(B
(Bon the linux. The system show the following error.
(B
(Bgzip: php-4_3_0_tar.gz: not in gzip format
(B
(BHow can I uncompress this file.
(B
(B__
(BDo You Yahoo!?
(BYahoo! BB is Broadband by Yahoo!
(Bhttp://bb.yahoo.co.jp/
(B
(B
(B-- 
(BPHP General Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Is the session ID of php4 made like a session cookie?

2001-05-21 Thread $B>>K\!!8y0l(B

Is it possible to erase at the same time the session data of php4 closes a browser?

Please teach a method, 
when a browser is closed and session data can be canceled.

- now Environment
OS RedHatLinux6.2
php 4.0.5 
At php.ini, it is session.cookie_lifetime = 0.; session.cache_limiter = nocache ;

// Ichirou.Tanaka.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Reverse (or backward?) Infinity Loop

2004-10-19 Thread Bruno B B Magalhães
Hi guys,
I have a normal categories table:
catId
catParentId
catName
catStatus
But I want when a user enters on:
http://hostname/site/products/catId1/catId7/catId13/../../contentId.html
A listing should apear like that:
• Category 1
 • Category 7
  • Category 13
• Category 2
• Category 3
• Category 4
• Category 5
A reverse (or backward) loop! We need to get the last category and then 
follow the ParentId until the 0 ParentId. Have anybody made this before 
(I hope so)?

Many Thanks,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mixing classes

2004-10-20 Thread Bruno B B Magalhães
Hi Tomy,
I did the same thing!
I´ve used a class called framework to encapsulate everything... here is 
what looks like:

framework.inc.php
http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.5-dev
*/
session_start();
/**
* Include Core Classes
*/
require_once(FRAMEWORK_DIR.'core/framework.class.php');
require_once(FRAMEWORK_DIR.'core/preferences.class.php');
require_once(FRAMEWORK_DIR.'core/languages.class.php');
require_once(FRAMEWORK_DIR.'core/database.class.php');
require_once(FRAMEWORK_DIR.'core/authentication.class.php');
require_once(FRAMEWORK_DIR.'core/input.class.php');
require_once(FRAMEWORK_DIR.'smarty/smarty.class.php');
require_once(FRAMEWORK_DIR.'core/output.class.php');
require_once(FRAMEWORK_DIR.'core/modules.class.php');
require_once(FRAMEWORK_DIR.'core/validation.class.php');
require_once(FRAMEWORK_DIR.'core/filters.class.php');
/**
* Include Shared Classes
*/
include_once(FRAMEWORK_DIR.'shared/categories.class.php');
?>
framework.class.php

/**
* Project: BBBM Framework
* File: framework.class.php
*
* @desc Main Framework Class
* @link http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.5-dev
*/
class framework
{
	var $preferences;
	var $database;
	var $authentication;
	var $input;
	var $output;
	var $modules;
	var $validation;
	var $filters;
	var $languages;
	
	var $controller;
	
	/**
	* PHP 4 Constructor
	*/
	function framework()
	{
		$this->preferences = new preferences();// Preferences Layer
		$this->languages = new languages();	// Language Layer
		$this->database = new database($this->preferences);		// Database Layer
		$this->input = new input();		// Input Layer		
		$this->modules = new modules($this->database);			// Modules Layer
		$this->authentication = new authentication($this->database);	// 
Authentication Layer
		$this->output = new output($this->preferences,$this->languages);	// 
Ouput Layer
		$this->validation = new validation();	// Validation functions
		$this->filters = new filters();		// Filters Functions
	}
	
	function is_valid_controller($contoller='')
	{
		if($contoller != '')
		{
			$contoller = addslashes(strip_tags($contoller));
			$this->database->build_table(array('controllers'));
			
			$query = 'SELECT
	controllerStatus
FROM
	'.$this->database->table['controllers'].'
WHERE
	controllerPath=\''.$contoller.'\'
';
			
			$this->database->query($query);
			
			if($this->database->num_rows() > 0)
			{
$this->database->fetch_array();

if($this->database->row['controllerStatus'] > 0)
{
	$this->controller = $contoller;
	return true;
}
else
{
	$this->controller = false;
	return false;
}
			}
			else
			{
$this->controller = false;
return false;
			}
		}
		else
		{
			return false;
		}
	}
}
?>

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mixing classes

2004-10-20 Thread Bruno B B Magalhães
Hi Tomy,
I did the same thing!
I´ve used a class called framework to encapsulate everything... here is 
what looks like:

framework.inc.php
http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.5-dev
*/
session_start();
/**
* Include Core Classes
*/
require_once(FRAMEWORK_DIR.'core/framework.class.php');
require_once(FRAMEWORK_DIR.'core/preferences.class.php');
require_once(FRAMEWORK_DIR.'core/languages.class.php');
require_once(FRAMEWORK_DIR.'core/database.class.php');
require_once(FRAMEWORK_DIR.'core/authentication.class.php');
require_once(FRAMEWORK_DIR.'core/input.class.php');
require_once(FRAMEWORK_DIR.'smarty/smarty.class.php');
require_once(FRAMEWORK_DIR.'core/output.class.php');
require_once(FRAMEWORK_DIR.'core/modules.class.php');
require_once(FRAMEWORK_DIR.'core/validation.class.php');
require_once(FRAMEWORK_DIR.'core/filters.class.php');
/**
* Include Shared Classes
*/
include_once(FRAMEWORK_DIR.'shared/categories.class.php');
?>
framework.class.php

/**
* Project: BBBM Framework
* File: framework.class.php
*
* @desc Main Framework Class
* @link http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.5-dev
*/
class framework
{
	var $preferences;
	var $database;
	var $authentication;
	var $input;
	var $output;
	var $modules;
	var $validation;
	var $filters;
	var $languages;
	
	var $controller;
	
	/**
	* PHP 4 Constructor
	*/
	function framework()
	{
		$this->preferences = new preferences();// Preferences Layer
		$this->languages = new languages();	// Language Layer
		$this->database = new database($this->preferences);		// Database Layer
		$this->input = new input();		// Input Layer		
		$this->modules = new modules($this->database);			// Modules Layer
		$this->authentication = new authentication($this->database);	// 
Authentication Layer
		$this->output = new output($this->preferences,$this->languages);	// 
Ouput Layer
		$this->validation = new validation();	// Validation functions
		$this->filters = new filters();		// Filters Functions
	}
	
	function is_valid_controller($contoller='')
	{
		if($contoller != '')
		{
			$contoller = addslashes(strip_tags($contoller));
			$this->database->build_table(array('controllers'));
			
			$query = 'SELECT
	controllerStatus
FROM
	'.$this->database->table['controllers'].'
WHERE
	controllerPath=\''.$contoller.'\'
';
			
			$this->database->query($query);
			
			if($this->database->num_rows() > 0)
			{
$this->database->fetch_array();

if($this->database->row['controllerStatus'] > 0)
{
	$this->controller = $contoller;
	return true;
}
else
{
	$this->controller = false;
	return false;
}
			}
			else
			{
$this->controller = false;
return false;
			}
		}
		else
		{
			return false;
		}
	}
}
?>

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP framework

2004-10-23 Thread Bruno B B Magalhães
Igor,
the problem on using a framework is that you have to learn it before 
you take advantage of its features, I mean you must consider the 
learning curve in your time schedule.
There are pretty good frameworks out there, but each one with your pros 
and cons, and with your own goals, I mean, a strong and reliable 
framework doesn´t mean it is extensible or even template driven, or 
also even easy to learn.

I developed my own framework, witch I am using on almost all my 
projects (course I won´t kill a fly with a hammer!) for one year and 
half, and still on version 0.5dev! :)

Some of then:
http://www.zope.org
http://www.fusebox.org
http://www.mojavi.org
http://www.binarycloud.com
http://www.eZpublish.com
http://amb.sourceforge.net
http://www.phpmvc.net
http://phrame.itsd.ttu.edu
http://www.horde.org
Best Regards,
Bruno B B Magalhães
On Oct 23, 2004, at 4:04 PM, Igor wrote:
I need to develop an PHP/MySql application (about 20 db tables and 70
screens).  I was wandering if there is a solid framework out there that
could help development.
Also, I would appreciate any recommendations for books/docs on good
development practices and php app. architecture.
Thanks!
Igor
--
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] enterprise php application automated testing

2004-10-23 Thread Bruno B B Magalhães
Well,
we call it pre-testing, the only way, and the better one, is doing it 
with the future users of your system!

Regards,
Bruno B B Magalhães

On Oct 23, 2004, at 10:00 PM, blackwater dev wrote:
Hello all,
I know I can use simpletest to test my application at the class level
but I need a tool to test it at a much higher level.  I need something
to enter data in forms, click links, etc.  I have played some with
simpletest's web tester without much luck.  I am just curious how
others are effectively testing their large php enterprise
applications?  Years ago I wrote Visual test scripts and it had a
feature where I could record all my keystrokes as I entered, clicked,
etc...I guess I am curious if there is anything like that..open
source?
Any suggestions are welcome.
Thanks!
--
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] $GLOBALS, any probolems?

2005-02-09 Thread Bruno B B Magalhães
Hi guys,
is there any problems using $GLOBALS superglobal to carry all my global 
classes instances?

For example:
$GLOBALS['myclass'] = new myclass();
Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Simple Licensing System

2005-04-08 Thread Bruno B B Magalhães
Hi Guys!
I need a help with a licensing system, I want something very simple, 
for example a simple var store into the configuration file, and witch 
is sent to a server called licenses.hostname.com.br, and this one 
returns true or false... I don't wanna use SOAP or XML. Does any body 
have a simple idea for it?

Best Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Simple Licensing System

2005-04-09 Thread Bruno B B Magalhães
Hi Richard,
And how do I generate this, and how would I check it?!?!
Thanks,
Bruno B B Magalhaes
On Apr 8, 2005, at 11:48 PM, Richard Lynch wrote:
On Fri, April 8, 2005 1:06 pm, Bruno B B Magalhães said:
I need a help with a licensing system, I want something very simple,
for example a simple var store into the configuration file, and witch
is sent to a server called licenses.hostname.com.br, and this one
returns true or false... I don't wanna use SOAP or XML. Does any body
have a simple idea for it?
Best Regards,
Bruno B B Magalhaes
Generate an SSH key-pair.
Give them the public key, or use that to "sign" their license.
Then you can just test that it's signed.
--
Like Music?
http://l-i-e.com/artists.htm

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


Re: [PHP] Re: class calling script

2005-04-12 Thread Bruno B B Magalhães
Well,
I have a framework class witch loads and stores all classes in it.
I can´t post the all code, but some I cam:
Loading a core class like a database class:
 
---
	function loadcore(&$handler, $class_name = '')
	{
		if($class_name != '')
		{
			if(is_object($this->_crs->$class_name))
			{
$handler =& $this->_crs->$class_name;
return true;
			}
			elseif(file_exists($this->core_dir.$class_name.$this- 
>core_sfx.$this->php_sfx))
			{
require_once($this->core_dir.$class_name.$this->core_sfx.$this- 
>php_sfx);

if(class_exists($class_name))
{
	$handler = new $class_name(&$this);
	$this->_crs->$class_name =& $handler;
	return true;
}
else
{
	$handler = false;
	return false;
}
			}
			else
			{
$handler = false;
return false;
			}
		}
		else
		{
			$handler = false;
			return false;
		}
	}
 
---

Loading a module class:
 
---
	function loadmodule($module_name = 'default_module', $module_method =  
'default_method', $method_vars = null)
	{
		if($module_name != '')
		{
			if(is_object($this->_mdl->$module_name))
			{
if(method_exists($this->_mdl->$module_name, $module_method))
{
	$this->_mdl->$module_name->$module_method($method_vars);
	return true;
}
			}
			elseif(file_exists($this->module_dir.$module_name.$this- 
>module_sfx.$this->php_sfx))
			{
require_once($this->module_dir.$module_name.$this- 
>module_sfx.$this->php_sfx);

if(class_exists($module_name))
{
	$this->_mdl->$module_name = new $module_name(&$this);
	
	if(method_exists($this->_mdl->$module_name, $module_method))
	{
		$this->_mdl->$module_name->$module_method($method_vars);
		return true;
	}
	return true;
}
else
{
	return $this->_mdl->$module_name = false;
	return false;
}
			}
			else
			{
return $this->_mdl->$module_name = false;
return false;
			}
		}
		else
		{
			return $this->_mdl->$module_name = false;
			return false;
		}
	}
 
---

I hope it will help you out.
Best Regards,
Bruno B B Magalhaes
On Apr 12, 2005, at 11:09 AM, Jason Barnett wrote:
[EMAIL PROTECTED] wrote:
Hi there, I have been testing a possible solution to reduce the  
ammount of
interface calling scriptsto my class files. Currently each class has  
a calling script. I am
For PHP5 you can try __autoload().  It provides for you a last-chance /
just in time loading of a class file.  The main drawback of using this
is that there is (currently) only one __autoload() function allowed,  
but
this limitation should be removed once PHP5.1.0 gets rolled out.

thinking of setting up a url like /currentdir/packagename/classname,  
mind you this is only a test but is it a
good or bad bad idea ?I have run into troubles getting get queries  
because its calling the
classname in the query alreadyso /packagename/classname?test=1 doesnt  
work.

Using rewrite rules would be another way you could do it.  Or you could
have one "main" include file that would set some variable (call it
$base_dir) that points to the filesystem folder that is your root
directory.  I.e.

/** "main" include file */
$base_dir = dirname(__FILE__) . '/';
/** now include some other global classes relative to this $base_dir */
include_once ($base_dir . 'path/from/docroot/to/class.php');
?>

/** some other script loads main config file */
require_once '/path/to/main.php';
/** now get your required classes */
require_once $base_dir . 'path/to/some/class.php';
?>
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html? 
name=PHP&submitform=Find+search+plugins
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Syntax highlighting of odd language

2004-11-05 Thread Bruno B B Magalhães
Aaron,
why don't you use a very simle sintax like this one:
$code = 'function what() { do oddname; %oddsyntax }';
function highlight_code($code)
{
	$oddsyntax = array('oddsyntax','oddsyntax2','oddsyntax3');
	
	for($i = 0; $i <= count($oddsyntax)-1; $i++)
	{
		$highlighted_code = eregi_replace($oddsyntax[$i],''.$oddsyntax[$i].'',$code);
	}
	return $code;
}

echo highlight_code($code);
Regards,
Bruno B B Magalhães
On Nov 5, 2004, at 6:39 PM, Aaron Gould wrote:
Could any of you privide some leads in regard to highlighting syntax 
of an odd language?  I have a large amount of snippits of legacy code 
from our company's primary application. The code used is "BBx" (a 
variant of Basic).

I'm attempting to show this code on a web page, but with highlighting 
of keywords and variables/numbers.  I've already got a list of the 
language's 250-odd keywords in a file.

I saw a "Text_Highlighter" PEAR class, but that seems to only do a 
bunch of predefined popular languages (ie. SQL, PHP, C).

Please don't ruin my Friday afternoon and tell me I'll need to dig 
into regular expressions.  :)

--
Aaron Gould
Parts Canada - Web Developer
--
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] keywords generation

2004-11-05 Thread Bruno B B Magalhães
Hi People,
well, I am building a very sophisticated(?) CMS, and I am thinking to 
implement a keyword automatically generation function... I thought on 
the following structure:

==
$submited_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing 
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud 
exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea 
commodo consequat. Duis autem vel eum iriure dolor in hendrerit in 
vulputate velit esse molestie consequat, vel illum dolore eu feugiat 
nulla facilisis at vero eros et accumsan et iusto odio dignissim qui 
blandit praesent luptatum zzril delenit augue duis dolore te feugait 
nulla facilisi. ';

generate_keywords($submited_text);
function generate_keywords($text)
{
if(isset($text) && $text != '')
{
$words_to_ignore = array('/a/',
'/to/',
'/of/',
'/from/'
);
$words = str_word_count(preg_replace($words_to_ignore,'',$text),1);
foreach($words as $var=>$val)
{
$total[$val] = substr_count($text,$val);

}

}
}
=
How can I sort the resulting array by value, without loosing its 
relations.

Is there a faster way of doing this?
Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: keywords generation

2004-11-05 Thread Bruno B B Magalhães
Hi,
no problem at all...
well, the script is incomplete cause I don´t know how to sort the 
$total array by value... for example:
Array
(
[Lorem] => 1
[ipsum] => 1
[dolor] => 5
[sit] => 1
[met] => 1
[consectetuer] => 1
[dipiscing] => 1
[elit] => 2
[sed] => 1
[dim] => 0
[nonummy] => 1
[nibh] => 1
[euismod] => 1
[tincidunt] => 1
[ut] => 5
[loreet] => 0
[dolore] => 3
[mgn] => 0
[liqum] => 0
[ert] => 0
[volutpt] => 0
[Ut] => 1
[wisi] => 1
[enim] => 1
[d] => 19
[minim] => 1
[venim] => 0
[quis] => 1
[nostrud] => 1
[exerci] => 1
[ttion] => 0
[ullmcorper] => 0
[suscipit] => 1
[lobortis] => 1
[nisl] => 1
[liquip] => 1
[ex] => 2
[e] => 49
[commodo] => 1
[consequt] => 0
[Duis] => 1
[utem] => 1
[vel] => 3
[eum] => 1
[iriure] => 1
[in] => 5
[hendrerit] => 1
[vulputte] => 0
[velit] => 1
[esse] => 1
[molestie] => 1
[illum] => 1
[eu] => 5
[feugit] => 0
[null] => 2
[fcilisis] => 0
[t] => 39
[vero] => 1
[eros] => 1
[et] => 5
[ccumsn] => 0
[ius] => 1
[odio] => 1
[dignissim] => 1
[qui] => 3
[blndit] => 0
[present] => 0
[lupttum] => 0
[zzril] => 1
[delenit] => 1
[ugue] => 1
[duis] => 1
[te] => 4
[fcilisi] => 0
)

Which is the word and it total occurrence in the text... Now I want to 
sort it from the highest values to the lowest... and then return a 
keyword string as:

$keywords = 'dolor,t,eu,te,in';
Got it?
Thanks,
Bruno B B Magalhaes
On Nov 5, 2004, at 7:42 PM, M. Sokolewicz wrote:
Bruno b b magalhães wrote:
Hi People,
well, I am building a very sophisticated(?) CMS, and I am thinking to 
implement a keyword automatically generation function... I thought on 
the following structure:
==
$submited_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing 
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud 
exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea 
commodo consequat. Duis autem vel eum iriure dolor in hendrerit in 
vulputate velit esse molestie consequat, vel illum dolore eu feugiat 
nulla facilisis at vero eros et accumsan et iusto odio dignissim qui 
blandit praesent luptatum zzril delenit augue duis dolore te feugait 
nulla facilisi. ';
generate_keywords($submited_text);
function generate_keywords($text)
{
if(isset($text) && $text != '')
{
$words_to_ignore = array('/a/',
'/to/',
'/of/',
'/from/'
);
$words = 
str_word_count(preg_replace($words_to_ignore,'',$text),1);
foreach($words as $var=>$val)
{
$total[$val] = substr_count($text,$val);
}
   }
}
=
How can I sort the resulting array by value, without loosing its 
relations.
Is there a faster way of doing this?
Regards,
Bruno B B Magalhaes
Yes!!! DO NOT USE REGEXPS WHEN YOU DON'T NEED THEM! :) (not to be 
rude, but you *really* don't need them. You're doing SIMPLE 
str-replacements, which goes at LEAST a factor 20 faster using 
str_replace thant using *any* regexp function.)

Just remember the following:
from fastest to slowest:
str_replace
str_ireplace
preg_replace
ereg_replace
eregi_replace
If you're not doing any regexp magic, use str_replace (or str_ireplace 
as of PHP 5). As quotes from the str_replace section of the PHP 
manual:
[snip]If you don't need fancy replacing rules (like regular 
expressions), you should always use this function instead of 
ereg_replace() or preg_replace().[/snip].

Also, what does:
[snip]$words = 
str_word_count(preg_replace($words_to_ignore,'',$text),1);[/snip] do. 
The result is not used after storing it, nor is it returned in any 
way...?

Now, at the end you have the $total array, and you discard it at the 
end... how... useful? (void return)

hope those remarks help you, and if you consider me rude, just blame 
it on a very early shift I had today

--
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] Re: keywords generation

2004-11-05 Thread Bruno B B Magalhães
Finally a solution for those who needs! :)
==FUNCTION== 

function generate_keywords($text,$number=10)
{
	$iwords = array('a',
	'to',
	'of',
	't',
	'e'
	);

	if(isset($text) && $text != '' && $text=strtolower($text))
	{
		foreach($iwords as $var=>$val)
		{
			$text = str_replace($val,'',$text);
		}
		
		foreach(str_word_count($text,2) as $var=>$val)
		{
			$total[$val] = substr_count($text,$val);
		}
		
		arsort($total,SORT_NUMERIC);
		
		return implode(',',array_keys(array_slice($total, 0, $number)));
	}
}
==EXAMPLE=== 
===
$submited_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing  
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna  
aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud  
exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea  
commodo consequat. Duis autem vel eum iriure dolor in hendrerit in  
vulputate velit esse molestie consequat, vel illum dolore eu feugiat  
nulla facilisis at vero eros et accumsan et iusto odio dignissim qui  
blandit praesent luptatum zzril delenit augue duis dolore te feugait  
nulla facilisi. ';

echo generate_keywords($submited_text);
======== 


Thanks to Tularis and Sokolewicz .
Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: keywords generation (ANOTHER)

2004-11-05 Thread Bruno B B Magalhães
Hi,
I am trying to categorize the keywords... for example, if a word shows  
at the begin probably it´s more important, but how many occurrences is  
also important...
Does someone knows Google´s formula? hehe

This code is working more or less as expected!
Many Thanks,
Bruno
===EXAMPLE== 
=
$submited_text = 'Polones e atracao no Match Race Brasil
Karol Jablonski, segundo colocado no ranking mundial, tentara acabar  
com o domínio de Torben Grael na competicao
 Sao Paulo – O polones Karol Jablonski, de 38 anos, sera uma das  
atracoes da terceira e ultima etapa do Match Race Brasil, competicao  
barco contra barco que sera disputada de 18 a 21 de novembro, no Rio de  
Janeiro. Segundo colocado no ranking mundial de match race da Federacao  
Internacional de Vela (Isaf), o velejador tentara acabar com o domínio  
de Torben Grael, bicampeao invicto da competicao.
 Radicado na Alemanha, Jablonski e comandante do sindicato italiano  
Toscana Challenge, que se prepara para a America´s Cup de 2007.  
Experiente, ele tem entre os seus maiores títulos o da Admiral´s Cup de  
1993. No ranking mundial de match race, ele soma 10.060 pontos, contra  
10.468 do norte-americano Ed Baiard, líder da lista da Isaf.
 A tripulacao de Jablonski na etapa carioca do Match Race Brasil  
contara ainda com os poloneses Piotr Przybylski, Dominik Zycki e Jacek  
Wysocki, todos velejadores experientes em competicoes barco contra  
barco.
 Torben Grael, bicampeao olímpico da classe Star, venceu as cinco  
etapas disputadas do Match Race Brasil – tres da edicao do ano passado  
e duas em 2004. Comandante do barco Brasil 1, que disputara a Volvo  
Ocean Race, a mais importante regata de volta ao mundo, Torben teve  
100% de aproveitamento, por exemplo, na etapa de Ilhabela, vencendo as  
11 regatas disputadas.
 “A participacao de Jablonski e muito importante. Nossa prioridade  
sempre foi trazer atletas de classes olímpicas, mas dessa vez  
resolvemos convidar um especialista em match race para desafiar o  
Torben”, comentou Enio Ribeiro, diretor da Vela Brasil, organizadora da  
competicao. “Teremos certamente uma etapa de alto nível tecnico no Rio  
de Janeiro.”
 O Match Race Brasil e disputado em veleiros Beneteau 40.7  
rigorosamente iguais. Os quatro barcos sao escolhidos pela organizacao  
e sorteados para os participantes.
';
===FUNCTION  
CODE===
echo generate_keywords($submited_text,23);

function generate_keywords($text,$number=10)
{
$iwords = array(' muito ');

if(isset($text) && $text != '' && $text=strtolower($text))
{
foreach($iwords as $var=>$val)
{
$text = str_replace($val,' ',$text);
}
		foreach(str_word_count($text,1) as $var=>$val)
		{
			if(strlen($val) >= 5)
			{
$total[$val] =  
((strpos($text,$val)+2)*(strpos($text,$val)+2))*((substr_count($text,$va 
l)+2)*0.75);
			}
		}
		
		asort($total,SORT_NUMERIC);

		return implode(',',array_keys(array_slice($total, 0, $number)));
	}
}
 
===

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


Re: [PHP] Javascript and php

2004-11-07 Thread Bruno B B Magalhães
Reinhart,
picture_url.'"';

if($i <= mysql_num_rows($result)-2)
{
echo ',';
}
}
?>
Here is how I do in my developments.
Regards,
Bruno B B Magalhães
On Nov 7, 2004, at 8:44 AM, Reinhart Viane wrote:
Hey all,
Hope some of you also work on sundays :)
I have a little javascript which displays a images (with previous / 
next
thing)
Now, i populate the javascript array with an php array:

</pre><br>
<pre style="margin: 0em;"><!-- Begin
NewImg = new Array (
<?php
while($row = mysql_fetch_object($result)){
echo "\"".$row->picture_url."\",";
}
?>
"../pictures/7_stripper3.jpg",
"../pictures/7_stripper2.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
...

As you can see i echo the url of the picture.
After each picture url there needs to be a ','
But not after the last picture.
At this moment all pictures have the ',' after there url, even the last
one.
Any way to determine if the url is the url of the last picture and thus
not printing a ',' behind that last one?
Thx in advance,
Reinhart
  _
Reinhart Viane
 <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
Domos || D-Studio
Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 
--
fax +32 15 43 25 26

STRICTLY PERSONAL AND CONFIDENTIAL
This message may contain confidential and proprietary material for the
sole use of the intended
recipient.  Any review or distribution by others is strictly 
prohibited.
If you are not the intended
recipient please contact the sender and delete all copies.


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


[PHP] Authentication Class

2004-11-16 Thread Bruno B B Magalhães
Hi guys,
well, I wrote a class for a big project (a framework), and here it is,  
I was wondering if someone have any suggestions regarding flexibility  
and security.

Course it uses specific framework classes but it's quite understable..
==
http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.5dev
*/
class authentication
{
var $domain;

var $database;

var $authenticated = false;

var $access_section = '';
var $access_level = '0';

var $post;
var $session;
var $cookie;
	var $userid;
	var $username;
	var $password;
	var $sessionid;
	var $remember_me;
	
	var $errormsg;
	
	var $tables = array('users','usersgroups');
	
	/**
	* PHP 4 Constructor
	*/
	function authentication(&$database)
	{
		$this->database =& $database;
		$this->database->build_table($this->tables);
		$this->domain = $_SERVER['HTTP_HOST'];
	}
	
	/**
	* Start Authentication Process
	*/
	function authenticate($access_section='',$access_level=0)
	{
		if($access_level > 0)
		{
			$this->access_level	= $access_level;
			$this->access_section	= $access_section;
			
			$this->check_post();
			$this->check_session();
			$this->check_cookie();
			
			if($this->post == true)
			{
$this->auth($this->username,$this->password,$this->access_level);
			}
			elseif($this->cookie == true)
			{
$this->auth_check($this->username,$this->sessionid,$this- 
>access_level);
			}
			elseif($this->session == true)
			{
$this->auth_check($this->username,$this->sessionid,$this- 
>access_level);
			}
			else
			{
$this->authenticated = false;
			}
		}
		else
		{
			$this->authenticated = true;
		}
	}

/**
* Authentication Process
*/
function auth($username='',$password='',$accesslevel=0)
{
$query = 'SELECT
*
FROM
'.$this->database->table['users'].' AS users,
'.$this->database->table['usersgroups'].' AS 
groups
WHERE
users.userGroup=groups.groupId
AND
users.userName=\''.$username.'\'
AND
users.userPassword=\''.$password.'\'
AND
users.userStatus > \'0\'
AND
groups.groupStatus > \'0\'
LIMIT
1';
		$this->database->query($query);
		
		if($this->database->num_rows() > 0)
		{
			$this->database->fetch_array();
			
			if($this->database->row['groupLevel'] >= $accesslevel)
			{
$this->authenticated = true;

$this->userid = $this->database->row['userId'];
$this->session_write('username',$this->database->row['userName']);
$this->session_write('userlevel',$this->database- 
>row['groupLevel']);

if(isset($this->remember_me))
{
	$this->cookie_write('username',$this->database->row['userName']);
	$this->cookie_write('sessionid',session_id());
}

$update_query = 'UPDATE
			'.$this->database->table['users'].'
		 SET
			userSession=\''.session_id().'\',
			userLastvisit = NOW()
		 WHERE
			userId=\''.$this->database->row['userId'].'\'';

$this->database->query($update_query);
}
else
{
$this->logout();
$this->authenticated = false;
$this->errormsg = 'error_noaccessprivileges';
}
}
else
{
$this->logout();
$this->authenticated = false;
$this->errormsg = 'error_unauthorized';
}
}
/**
* Authentication Check Process
*/
function auth_check($username='',$sessionid='',$accessle

[PHP] Array unset

2004-11-16 Thread Bruno B B Magalhães
Hi,
I my system can handle invisible modules, so they can't show in the  
menu but stills works... here is the code:

$c = count($modules)-1;
for($i = 0; $i <= $c; $i++)
{
if($modules[$i]['moduleVisibility'] == 0)
{
unset($modules[$i]);
}
}
	$m = 0;
	$c = count($modules)-1;
	
	for($i = 0; $i <= $c ; $i++)
	{
		if($modules[$i]['modulePath'] ==  
$framework->modules->module['modulePath'])
		{
			$output .= '
			';
		}
		else
		{
			$output .= '
			';
		}
		
		if($framework->output->get_config_vars('modulename'.str_replace('  
','',$modules[$i]['moduleName'])))
		{
			$output .=  
$framework->output- 
>get_config_vars('modulename'.$modules[$i]['moduleName']);
		}
		else
		{
			$output .= $modules[$i]['moduleName'];
		}
		
		$output .= '';
		
		if($i < $c)
		{
			$output .= '|';
		}
		
		$m++;
		$m++;
	}

	$output .= '';
	return $output;
	
The problem is that when I delete an specific array, it outputs  
something like this:

(
[0] => Array
(
[moduleId] => 4
[moduleName] => Contents
[modulePath] => contents
[moduleAliasPath] =>
[moduleController] => administration
[moduleLevel] => 5
[moduleOrder] => 0
[moduleVisibility] => 1
[moduleType] => none
[moduleStatus] => 1
)
[2] => Array
(
[moduleId] => 1
[moduleName] => System
[modulePath] => system
[moduleAliasPath] =>
[moduleController] => administration
[moduleLevel] => 5
[moduleOrder] => 2
[moduleVisibility] => 1
[moduleType] => default
[moduleStatus] => 1
)
[3] => Array
(
[moduleId] => 2
[moduleName] => Logout
[modulePath] => logout
[moduleAliasPath] =>
[moduleController] => administration
[moduleLevel] => 5
[moduleOrder] => 3
[moduleVisibility] => 1
[moduleType] => alias
[moduleStatus] => 1
)
)
So, the question, how resort the numeric values to 1,2,3,4?
Regards,
Bruno
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Auto-load class if it doesn't exists!

2004-11-16 Thread Bruno B B Magalhães
Hi people,
is it possible to have a solution that works like an autoloader... for 
example:

$myclass = new class();
but if this class wasn't loaded yet, it loads by itself... egg:
if(class_exists(class))
{
 $myclass = new class();
}
else
{
 require_once(PATH_DIR.'class.class.php');
$myclass = new class();
}
Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Authentication Class

2004-11-16 Thread Bruno B B Magalhães
Is this good or bad? heheh!
Regards,
Bruno B B Magalhaes
On Nov 16, 2004, at 3:31 PM, raditha dissanayake wrote:
Bruno B B Magalhães wrote:
Hi guys,
well, I wrote a class for a big project (a framework), and here it 
is,  I was wondering if someone have any suggestions regarding 
flexibility  and security.
Wow it's the most artistic piece of php i have ever seen.
--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload
--
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] Re: [PHP-DB] OOP vs Functions and includes

2004-11-16 Thread Bruno B B Magalhães
Pablo,
This is a very complex discussion... But generalizing, a LOT, OO is  
more appropriated for big systems due to its extensibility and easy  
maintenance, while procedural approach works best for small  
applications that don't require to much updates and aren't too complex.

Here is a example of a controller of my framework, can you imagine it  
using procedural approach?  
(http://www.yourhostname.com/controller/articles)

http://www.bbbm.com.br/
* @copyright 2004 Bruno B B Magalhaes
* @author Bruno B B Magalhaes <[EMAIL PROTECTED]>
* @package BBBM Framework
* @version 0.7-dev
*/
define('FRAMEWORK_DIR',dirname(__FILE__).'/framework/');
require_once(FRAMEWORK_DIR.'framework.inc.php');
/**
* Starting Framework
*/
$framework = new framework();
/**
* Checking if it's a valid and installed Controller
*/
if(isset($framework->input->uri['1']))
{
	$framework->benchmark->mark('framework','loading_called_controller');
	if(!$framework->load_controller($framework->input->uri['1']))
	{
		echo '[FRAMEWORK FATAL ERROR] There are no registered or active  
controllers!';
		exit;
	}
}
else
{
	$framework->benchmark->mark('framework','loading_default_controller');
	if(!$framework->load_controller())
	{
		echo '[FRAMEWORK FATAL ERROR] There are no registered or active  
controllers!';
		exit;
	}
}

/**
* Getting all modules from this controller and module information from  
database
*/
$framework->benchmark->mark('framework','loading_controller_modules');
$framework->modules->get_modules($framework- 
>controller['controllerPath']);

/**
* Configuring Output (Templates dirs, Compile dirs, etc)
*/
$framework->benchmark->mark('framework','configuring_controller');
$framework->output->configure_controller($framework- 
>controller['controllerPath']);

/**
* If a controller needs authentication, try to authenticate!
*/
$framework->benchmark->mark('framework','authenticating_controller');
$framework->authentication->authenticate($framework- 
>controller['controllerPath'],$framework- 
>controller['controllerLevel']);
if(!$framework->authentication->authenticated)
{
	if(isset($framework->authentication->errormsg))
	{
		$framework->output->assign('errormsg',$framework->authentication- 
>errormsg);
	}
	$framework->output->display($framework- 
>controller['controllerPath'].'.templates/login.tpl',session_id());
	$framework->benchmark->stop('framework');
	exit;
}
	
/**
* Getting Module Information, if exists, else get the default module  
for this controller
*/
if(isset($framework->input->uri['2']))
{
	$framework->benchmark->mark('framework','loading_called_module');
	$framework->modules->get_module($framework->input->uri['2']);
}
else
{
	$framework->benchmark->mark('framework','loading_default_module');
	$framework->modules->get_module();
}

/**
* Starting module initialization routines
*/
$framework->benchmark->mark('framework','initializing_module');
if(isset($framework->modules->module) && $framework->modules->module !=  
'' && $framework->modules->module != false &&  
is_array($framework->modules->module))
{
	/**
	* If a module needs authentication, try to authenticate!
	*/
	$framework->benchmark->mark('framework','authenticating_module');
	if($framework->controller['controllerLevel'] <  
$framework->modules->module['moduleLevel'])
	{
		$framework->authentication->authenticate($framework->modules- 
>module['modulePath'],$framework->modules->module['moduleLevel']);
		if(!$framework->authentication->authenticated)
		{
			if(isset($framework->authentication->errormsg))
			{
$framework->output->assign('errormsg',$framework->authentication- 
>errormsg);
			}
			$framework->output->display($framework- 
>controller['controllerPath'].'.templates/login.tpl',session_id());
			$framework->benchmark->stop('framework');
		}
	}
	
	/**
	* Checking if the called module is an alias, and if the alias exists  
and exits after it!
	*/
	$framework->benchmark- 
>mark('framework','checking_and_loading_alias_module');
	if($framework->modules->module['moduleType'] == 'alias')
	{
		if(isset($framework->modules->module['moduleAliasPath']) &&  
$framework->modules->module['moduleAliasPath'] != '' &&  
fil

[PHP] Auto Class loading

2004-11-17 Thread Bruno B B Magalhães
Continuing the classes questions...
I have a class loader called 'load_core_class($class=''), but if $class 
equals to all I would like to load all classes in the core directory, 
include then AND start then this way:

$this->$loadedclassname = new $loadedclassname;
Is it possible?
Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Is it a good idea?

2004-11-20 Thread Bruno B B Magalhães
Hi guys,
In my framework I have some classes that depends from others (like 
authentication depends of database)... So I wrote is method inside the 
framework class, and I would like to know if is it an intelligent 
solution or not:

class dependent
{
function dependent (&$framework)
{
$independent =& $framework->load_core_class('independent');
}
}
AND THE LOADING METHOD:
function load_core_class($class='')
{
if(!class_exists($class))
{
if(file_exists($this->core_dir.$class.'.class.php'))
{
include_once($this->core_dir.$class.'.class.php');
return $this->core->$class =& new $class($this);
}
else
{
return false;
}
}
elseif(!isset($this->core->$class))
{
return $this->core->$class =& new $class($this);
}
else
{
    return $this->core->$class;
}
}
Best regards to you all,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to $_POST from a grid

2004-11-24 Thread Bruno B B Magalhães
Hy David,
well here is my code... I use smarty templating system for parsing  
values, but should give you a very clear idea of what must to be done.

== MODULES LISTING TEMPLATE  
==
{include file="$controllerTemplates/head.tpl"}


{#head_name#}
{#head_path#}
{#head_level#}
{#head_order#}
{#head_visibility#}
{#head_type#}
{#head_status#}
{#head_actions#}

{section name=m loop=$modules}



{$modules[m].moduleName}
{$serverPath}{$modules[m].moduleController}/ 
{$modules[m].modulePath}
{html_options  
options=$levelrange selected=$modules[m].moduleLevel}
{html_options  
options=$orderrange selected=$modules[m].moduleOrder}
{$smarty.config.visibility_invisible}{$smarty.config.visibility_visible}
{$smarty.config.type_none}{$smarty.config.type_alias}{$smarty.config.type_default}
{$smarty.config.status_inactive}{$smarty.config.status_active}
{if $smarty.session.userlevel >= 9}{/if}


{sectionelse}
{#message_no_modules#}
{/section}

{include file="$controllerTemplates/foot.tpl"}
 
==

If you are not using smarty, just think the {section} tag as  
foreach($modules as $module) {  } our also a faster one for($i=0;  
$i < $t; $i++) {  }  where $t = count($modules)-1;.

Best Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Lazy anwsers (WAS: mysql_connect vs mysql_pconnect)

2004-11-27 Thread Bruno B B Magalhães
Hey Guys,
I don´t know if anyone agrees with me, but I really dismiss this kind 
of comment: http://www.google.com/search?q=mysql&ie=UTF-8&oe=UTF-8

In fact, before I ask anything in this forum, I do search others 
sources (including google, phpbuilder, phpfreaks, sf.net, ,php.net,...) 
and I believe that others do too. So I think that this is the worst 
kind of comment or suggestion someone can receive.

Sorry everybody.
Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] identifying the country of the people who connect to web site / portal

2004-11-27 Thread Bruno B B Magalhães
Hi,
course you can, you should search harder for it, but I will facilitate 
for you! :o)

http://www.phpclasses.org/browse/package/1477.html
Best Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Comment Speed

2004-11-27 Thread Bruno B B Magalhães
Does anyone has a solid benchmark about comments speed.. I mean, too 
many comments will decrease speed of the PHP scripts...

I've tried without success using a class, and also a simple micro-time 
operation... Well, cause the file is evaluated before it is executed, I 
didn't had success.

Any idea?
Regards,
Bruno B B Magalhaes 

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


[PHP] Implementing database cache.

2004-12-08 Thread Bruno B B Magalhães
Hi again guys,
does anybody have am idea of witch are the required functions to 
implement a database query cache? I have a very nice and fast database 
layer, witch I use in all my projects (about 19 sites and a lot of 
others hot-sites and systems like intranet and extranets). Here is my 
idea of the functions:

is_cached();
read_cache();
clear_cache();
write_cache();
And what is the fastest way, shared memory perhaps? And I would have to 
use serialize function to store query results right? and about the 
cache name (or cache_id whatever) I was thinking about using a md5 hash 
of the query itself.

I would love any ideas! :)
Nice regards.
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Implementing database cache.

2004-12-08 Thread Bruno B B Magalhães
I am using mysql with cache results enable, but as every addicted I 
want more and more... course I have to benchmark it to see if its 
worth...

Regards,
Bruno B B Magalhães
On Dec 8, 2004, at 8:34 PM, John Holmes wrote:
Bruno B B Magalhães wrote:
Hi again guys,
does anybody have am idea of witch are the required functions to 
implement a database query cache?
What database are you using? I think most of the common ones already 
have a cache built into them that you'd just have to enable. That'd be 
the best route, imo.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
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] Friendly URL

2004-12-10 Thread Bruno B B Magalhães
Hi guys,
As part of my framework I have a URI decoder so it explode, remove  
unnecessary data (as GET query) amd put it into an array...

Is there any better way of doing this (faster?), just wondering.
if(isset($_SERVER['REQUEST_URI']) === true)
{
$path = explode('/',$_SERVER['SCRIPT_NAME']);

$total_paths = count($path);
$path = 
stristr($_SERVER['REQUEST_URI'],$path[$total_paths-1]);
			$path = explode('/',$path);
			
			$total_paths = count($path);
			
			$i = 0;
			
			for($i=0;$i<$total_paths;$i++)
			{
$get_string = false;

$get_string = stristr($path[$i],'?');

if($get_string)
{
	$get_string = "\\".$get_string;
	$this->uri[$i] =  
strtolower(addslashes(strip_tags(eregi_replace($get_string,'',$path[$i]) 
)));
}
else
{
	$this->uri[$i] = strtolower(addslashes(strip_tags($path[$i])));
}
			}
		}

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


Re: [PHP] Friendly URL

2004-12-11 Thread Bruno B B Magalhães
Richard,
well a much simpler solution than my old one:
$this->uri =  
explode('/',basename($_SERVER['SCRIPT_NAME']).$_SERVER['PATH_INFO']);

Many thanks for your help,
Bruno B B Magalhaes
On Dec 10, 2004, at 11:57 PM, Richard Lynch wrote:
$_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME'] or ...
It's all in there, though you might have to tear it apart a bit to get
exactly what you want.
Bruno B B Magalhães wrote:
Hi Richard,
well but I want also the file it self to be included in it...
Regards,
Bruno B B Magalhaes
But I need
On Dec 10, 2004, at 8:20 PM, Richard Lynch wrote:
Bruno B B Magalhães wrote:
Hi guys,
As part of my framework I have a URI decoder so it explode, remove
unnecessary data (as GET query) amd put it into an array...
Is there any better way of doing this (faster?), just wondering.
if(isset($_SERVER['REQUEST_URI']) === true)
{
$path = explode('/',$_SERVER['SCRIPT_NAME']);
$total_paths = count($path);
$path = 
stristr($_SERVER['REQUEST_URI'],$path[$total_paths-1]);
$path = explode('/',$path);
$total_paths = count($path);
$i = 0;
for($i=0;$i<$total_paths;$i++)
{
$get_string = false;
$get_string = stristr($path[$i],'?');
if($get_string)
{
	$get_string = "\\".$get_string;
	$this->uri[$i] >>
strtolower(addslashes(strip_tags(eregi_replace($get_string,'',$path[ 
$i
])
)));
}
else
{
	$this->uri[$i] = strtolower(addslashes(strip_tags($path[$i])));
}
			}
		}
I could be wrong, but I think you've just re-written the code that is
already in PHP to give you $_SERVER['PATH_INFO']

--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Infinity and nested categories

2004-12-12 Thread Bruno B B Magalhães
Hi again everybody,
well, I've asked it before, but I couldn't work on this at all.
As some knows I have a system witch has a category system. The generic  
part of the site is handled by a generic module called contents...  
generic like products, services, company, etc. Where the content layout  
and structure is quite the same.

Well suppose that I have this:
http://www.the_company.com/site/products/product_one/requirements/ 
requirements.html

Where:
site/	< the controller
products/  <- alias module for content module
product_one/   <- top category
requirements/<- nested category
<-- as many nested categories as needed
requirements.html <- article is called searching using it without  
the .html, witch is used to know that it is an article and not a  
category. ('WHERE article_path='requirements' AND category_id='022')

My problem is that how can I handle those categories! and  
build a three of it.

I am using PHP5 and MySQL 4.1
Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Infinity and nested categories

2004-12-14 Thread Bruno B B Magalhães
Thanks Richard!
Helped a lot!
Regards,
Bruno B B Magalhaes
On Dec 13, 2004, at 4:16 PM, Richard Lynch wrote:
Bruno B B Magalhães wrote:
Hi again everybody,
well, I've asked it before, but I couldn't work on this at all.
As some knows I have a system witch has a category system. The generic
part of the site is handled by a generic module called contents...
generic like products, services, company, etc. Where the content 
layout
and structure is quite the same.

Well suppose that I have this:
http://www.the_company.com/site/products/product_one/requirements/
requirements.html
Where:
site/   < the controller
products/  <- alias module for content module
product_one/   <- top category
requirements/<- nested category
 <-- as many nested categories as needed
requirements.html <- article is called searching using it without
the .html, witch is used to know that it is an article and not a
category. ('WHERE article_path='requirements' AND category_id='022')
My problem is that how can I handle those categories! and
build a three of it.
Is it a true hierarchy, or is it a heterarchy?
In other words, can "sub_category_57" appear in *TWO* different 
branches
in the tree?

If *NOT*, then you really don't need all the nested categories in your
URL:  As soon as you have the "bottom" category, you've already got all
the others in your database.
Of course, you could simply walk through $_SERVER['PATH_INFO'] and 
build
your category list:


--
Like Music?
http://l-i-e.com/artists.htm
--
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] Not quite PHP, but related...

2004-12-10 Thread Bruno B B Magalhães
Hi you all,
is that possible using .htaccess to redirect every request to a 
specified script?

for example if you have:
http://www.yoursite.com/en/articles/blab.html
where there isn't a en dir., so it would be redirected to
public_html/site
I could use error page, but it won't receive post, get, cookie and 
session headers.

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


[PHP] Slow Zend Optimizer

2004-12-14 Thread Bruno B B Magalhães
Hi guys,
I've installed the zend Optimizer with my Mac OS X, Apache 1.2, PHP5. 
And guess what, it became about 40% slower!!!

My framework was running for example in the modules administration 
(admin area) at 0.104ms, and now the average is 0.2ms - 0.24ms

Does anybody have any idea of what hell is this optimizer optimizing?!?1
Regards,
Bruno
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Frameworks

2004-12-22 Thread Bruno B B Magalhães
Hi everybody,
well I was measuring my framework performance on a real production 
server...  And the average execution time with 20 requests per second 
is 0.025 seconds. Course it will change according to the server 
hardware, but I am searching for a REALLY fast framework environment 
that can actually run on a production server. I want to know about your 
experiences with, best practices, everything you guys can share I will 
love! BTW, my framework is ground up on OO and has:

CORE
- Database access (mysql only for now)
- input access (with sanitization routines in GET, POST, SESSION, 
COOKIES)
- template engine (modified version of smarty)
- authentication layer (mysql, flat files)
- error handler (logs and shows errors)
- benchmark class (starts automatically with a process called 
'framework' how original!)

FILTERS
- ubb code filter
- xhtml filter
SHARED
- validation class (lots of input validation)
and its multilingual, fetched from the database.
Best Regards,
Bruno B B Magalhaes

[PHP] GMT

2005-01-04 Thread Bruno B B Magalhães
Hi you all,
How do you work with GMT time-zones? I mean, I´ve developed a support 
system, with projects, bugs, tasks, etc... but as I user date()ç,I is 6 
hours late from my client´s time-zone...

And I would like to make it a little more dynamic than just put a 
variable in the code and add to the hour.

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] GMT

2005-01-04 Thread Bruno B B Magalhães
i Travis and Tobias,
I've modified a simple function, and incorporated it to my framework's 
datetime.class.php witch handles all date and time conversion... Here 
it is:

=
	var $server_timezone_offset	=	-5;
	var $default_timezone_offset	=	+1;
	var $local_timezone_offset	=	0;
	
	function timezone($offset=null)
	{
		if(is_integer($offset))
		{
			$this->local_timezone_offset = $offset-$this->server_timezone_offset;
			return time()+3600*$this->local_timezone_offset;
		}
		elseif(is_integer($this->default_timezone_offset))
		{
			$this->local_timezone_offset = $this->default_timezone_offset - 
$this->server_timezone_offset;
			return time()+3600*$this->local_timezone_offset;
		}
		else
		{
			return time();
		}
	}
=

Nice regards to you all,
Bruno B B Magalhães
On Jan 4, 2005, at 12:44 PM, Travis Conway wrote:
Here has always been a problem I run into with GMT translation.  You 
have to make sure that the system you are working with is set to the 
correct time zone so that any application trying to automatically 
figure out the time have the starting point.  This is easy enough in 
Windows, but can mean making sure your /etc/localtime (See 
http://www.linuxforum.com/linux_tutorials/68/1.php) is correct in 
linux. Of course there are GUI tools to help with this also for those 
non-console people. Unfortunately some people rely on shared servers 
where you do not have root access to change /etc/localtime.

Therefore you must have an overloadable function to return the time in 
GMT. Where it can accept an offset or rely on the systems timezone.

To me, it seems best to just use a variable.  Print out the time, then 
do a correct offset for it.

But for something already done, see 
http://us3.php.net/manual/en/function.gmdate.php

Travis
- Original Message - From: "Bruno B B Magalhães" 
<[EMAIL PROTECTED]>
To: 
Sent: Tuesday, January 04, 2005 5:04 AM
Subject: [PHP] GMT


Hi you all,
How do you work with GMT time-zones? I mean, I´ve developed a support 
system, with projects, bugs, tasks, etc... but as I user date()ç,I is 
6 hours late from my client´s time-zone...

And I would like to make it a little more dynamic than just put a 
variable in the code and add to the hour.

Regards,
Bruno B B Magalhães
--
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] Pagination Optimization

2005-01-07 Thread Bruno B B Magalhães
Hi guys,
currently I have a function in my framework´s mysql driver , that fetch 
paginated results... Here it´s:

===
/*
*  Fetch paginated results
*/
function fetch_paginated($query='',$page=1,$itens=20)
{
$this->query($query.' LIMIT 
'.(($page*$itens)-$itens).','.$itens);

if($this->num_rows() > 0)
{
while($this->fetch_array())
{
$results[] = $this->row;
}
}
else
{
return null;
}

$this->query($query.' LIMIT 0,'.(($page*$itens)-$itens));
$this->pages_before = ceil($this->num_rows()/$itens);

$this->query($query.' LIMIT 
'.($page*$itens).',100');
$this->pages_after = ceil($this->num_rows()/$itens);

$this->query($query);
$this->total_pages = ceil($this->num_rows()/$itens);

return $results;
}
===
My question is: Is there ANY way to speed up this function, or any way 
to fetch paginated results quicker? I had a project list, without 
pagination, and when I added the pagination function, it slowed down up 
to 0.0125 secs. Before it was running at 0.0600 more or less, and now 
it´s running at 0.07 to 0.075...

Best Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Pagination Optimization

2005-01-08 Thread Bruno B B Magalhães
Thanks for your help, in fact helped a lot... Now my function only 
performs 2 queries, here it is:

===
function fetch_paginated($query='',$page=1,$itens=20)
{
$this->query($query);
$total_rows = $this->num_rows();
if($total_rows > $itens)
{
$this->total_pages = ceil($total_rows/$itens);
$this->pages_before = ceil($page - 1);
$this->pages_after = ceil($this->total_pages - $page);

$this->query($query.' LIMIT 
'.(($page*$itens)-$itens).','.$itens);

while($this->fetch_array())
{
$results[] = $this->row;
}
}
elseif($total_rows > 0)
{
while($this->fetch_array())
{
$results[] = $this->row;
}

$this->total_pages = '1';
$this->pages_before = '0';
$this->pages_after =  '0';
}
else
{
return null;
}
        
return $results;
}
===
Regards,
Bruno B B Magalhães
On Jan 7, 2005, at 10:09 PM, M. Sokolewicz wrote:
first of all, you're running 4 queries here. 4 queries is a lot! 
Especially when you don't need more than 2 ;)
the problem here is that your queries are pretty "unknown" to this 
function. Although it does a nice result for that unknowing, there's a 
few minor things that make it faster.

First of all, would be using less queries.
What I usually do is issue a query like this:
"SELECT count(some_unique_col) WHERE 
(that_where_clause_youre_using_in_the_select_query)"
then, we do some math.

$pages_before = $page-1;
$rows_before = $pages_before*$itens;
$rows_after = $total_number_of_rows-($page*$itens);
$pages_after = ceil($rows_after/20);
Then do the actual selecting of the rows using the limit.
The thing that makes it slow in your example is the fact that 4 times 
you're selecting ALL data from the relevant rows, and buffer it. You 
buffer it, but don't use any of it, except for the number of rows. 
Mysql does a far quicker job at this than PHP would, so use mysql. :)
Then, you're using 3 queries to determine the rows around the page; 
even though, with a bit of simple math, you can calculate it. And 
trust me on this, simple math is faster ;)

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


[PHP] UBB Code correct use

2005-01-11 Thread Bruno B B Magalhães
Hi people,
I have a small class that encodes and decodes ubb code, no problem with 
this.. But..

My question is, what is the correct use of the translation routines in 
a CMS... I meam:

When creating a new article:
New article form  ---> UBB Encode ---> Database
  |
 Eg.  encoded to [b]
When editing an article:
Database ---> UBB Decode ---> Edit form ---> UBB Encode ---> Database
  |
  Eg. [b] becomes 
When viewing in the site:
Database ---> UBB Decode ---> Display
Did you get what my question is? :)
What is the correct order... I mean, because I am having problems when 
editing an article all the BRs are being duplicated, and other problems 
that have to do with the order.

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


[PHP] Checking if

2005-01-11 Thread Bruno B B Magalhães
Hi people,
how to determine if the last char of a string is a '/'...
The problem, a webpage can be accessed by www.domain.com/page.php or  
www.domain.com/page.php/

Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Checking if

2005-01-12 Thread Bruno B B Magalhães
Richard,
my solution right know is:
if(substr($url,-1) != '/')
{
$url = $url.'/';
}
Simple and fast... :)
Regards,
Bruno B B Magalhaes
On Jan 12, 2005, at 3:37 PM, Richard Lynch wrote:
Bruno B B Magalhães wrote:
how to determine if the last char of a string is a '/'...
The problem, a webpage can be accessed by www.domain.com/page.php or
www.domain.com/page.php/
In addition to the two fine answers posted so far:
if ($string[strlen($string)-1] == '/'){
  echo "It ends in '/'\n";
}
else{
  echo "It does NOT end in '/'\n";
}
substr and the above will be fastest, if it matters (probably not).  
The
different in performance between substr and array reference is 
negligible,
I think.

preg_match is more flexible if you need to maybe some day figure out 
the
last several letters in weird combinations.

substr will be useful if you might some day need more letters, but not 
in
weird combinations.

The array usage may be more natural if you are already tearing apart 
the
string character by character in other bits of the same code.

YMMV
--
Like Music?
http://l-i-e.com/artists.htm

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


[PHP] Dates, times, timezones...

2005-01-19 Thread Bruno B B Magalhães
Hi everybody,
How do you save the date and time in the database? Time stamp or date 
and time? GMT timezone or the server timezone, or maybe the "configs" 
timezone? And when displaying apply user timezone to the GMT date?

I think it's easier to save in timestamp format, so it's easy to 
convert to any format and to do math with dates Is this the way?

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


[PHP] URGENT: Break-lines disappearing.

2005-01-20 Thread Bruno B B Magalhães
Hi you all,
I am having a very big problem... I have an article module in a system, 
when an user creates an article it's parsed (as everything else in the 
system) by an input class, after, it is checked for emptily and after 
is build an insert query... But the break-lines just disappear... I've 
tested right before parsing to the database build query function and 
the breaks are there! And the build query function is this:

	function insert_query($table='',$values='')
	{
		if($table != '' && $values != '')
		{
			foreach($values as $var=>$val)
			{
$insert_vars[] = $var;
$insert_vals[] = $val;
			}
			return $this->query('INSERT INTO '.$table.' 
('.implode(',',$insert_vars).') VALUES 
(\''.implode('\',\'',$insert_vals).'\') ');
		}
		else
		{
			return false;
		}
	}

And the sanitize function is:
function sanitize($input_data, $sanitize = true)
{
if(is_array($input_data))
{
foreach($input_data as $input_key=>$input_value)
{
$output_data[$input_key] = 
$this->sanitize($input_value,$sanitize);
}
return $output_data;
}
elseif($sanitize)
{
return addslashes($input_data);
}
else
{
return $input_data;
}
}
Where are the break-lines?!?!? I am really desperate! Please! I am 
using MySQL and PHP4.

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


[PHP] Formating

2005-07-05 Thread Bruno B B Magalhães

Hi everybody,

I've searched the docs for a generic way to format strings and  
numbers...


For example I have a brazilian zipcode witch is stored in database as  
22252970 and must be formatted as N-NNN,  where N is a number.  
Also I have a tax id with is also stored as numeric value only, for  
example 05117635472 and outputted as NNN.NNN.NNN-NN... Is that any  
way that I can do it generic, storing the formatting strings ('N- 
NNN') with languages strings, so it is localised and this would be  
parsed as:


string::format($string, $format);

Best Regards,
Bruno B B Magalhaes

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



Re: [PHP] Formating

2005-07-07 Thread Bruno B B Magalhães

Hi Richard,

On Jul 5, 2005, at 6:20 PM, Richard Lynch wrote:

On Mon, July 4, 2005 6:48 pm, Bruno B B Magalhães said:

For example I have a brazilian zipcode witch is stored in database as

Is she a Good Witch, or a Bad Witch? :-)


Ups, hehehehe!


22252970 and must be formatted as N-NNN,  where N is a number.
Also I have a tax id with is also stored as numeric value only, for
example 05117635472 and outputted as NNN.NNN.NNN-NN... Is that any
way that I can do it generic, storing the formatting strings ('N-
NNN') with languages strings, so it is localised and this would be
parsed as: string::format($string, $format);


//Untested code:
function format($string, $format){
  $slen = strlen($string);
  $flen = strlen($format);
  $result = '';
  for ($f = 0, $s = 0; $f <= $flen && $s <= $slen; $f++){
$fc = $format[$f];
$sc = $string[$s];
switch($fc){
  case 'N':
if (!strstr('0123456789', $sc)){
  //Suitable error for mal-formed data here.
  //$fc should be a digit, but it's not.
}
$result .= $sc;
$s++;
  break;
  //Assume you need 'C'haracter data at some point in the future:
  case 'C':
if (!stristr('abcdefghijklmnopqrstuvwxyz', $fc)){
  //more error-code (see above)
}
$result .= $sc;
$s++;
  break;
  default:
$result .= $fc;
  break;
}
  }
  return $result;
}

I also don't think you want to tie it into "Locale" unless the data  
itself

is tagged with Locale, rather than the viewer's Locale.

A US zip code is N[-] no matter what language you are  
viewing it in.


I was thinking about that, but for example the dates and times  
current are formatted language specific..
I was thinking about applying this internationalisation also to those  
strings and number, but probably as you said that's not a good idea  
after all.


But, either way, MANY thanks for your wonderful help.

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



[PHP] TimeStamp BEFORE 1970

2005-07-07 Thread Bruno B B Magalhães

Well,

I've read the manual, and the ADOdb Date package functions, and I am  
not using this because I want to keep my framework simple, flexible,  
and fast.


Well, I just want a simple way to translate dates (I know what is the  
input format) to unix timestamp, with ability to do this with dates  
before 1970, and after 2023, is there any way?


My current system the PHP's microtime it's Ok, but one of ours test  
servers is running windows, and also some clients, so I rrealy need a  
overall solution.


Here is my datetime class.

/ 
 
***

*  @name Date and Time Class (./framework/libraries/datetime.class.php)
*  @version 1.0.0
*  @dependencies None
 


*  @package B3M Platform™ 1.5.0
*  @author B3M Development Team <[EMAIL PROTECTED]>
*  @copyright 2004 by Bruno B B Magalhaes
*  @copyright 2005 by B3M Development Team
*  @link http://www.bbbm.com.br/platform/
 
***/

class datetime
{
/ 
*

*  Get microtime
 
*/

function timestamp($input = null)
{
if(is_null($input))
{
return (float)array_sum(explode(' ', (microtime() +  
datetime::server_timezone_offset(;

}
else
{
return (float)array_sum(explode(' ', strtotime($input)));
}
}

/ 
*

*  Format a microtime
 
*/

function format($timestamp = 0, $format = 'm/d/Y H:m:s')
{
return date($format, $timestamp);
}

/ 
*

*  Get server's time-zone offset in seconds
 
*/

function server_timezone_offset()
{
if(!defined('_SERVER_TIMEZONE_OFFSET'))
{
return (float)date('Z');
}
else
{
return (float)_SERVER_TIMEZONE_OFFSET;
}
}
}
?>

Thanks everybody!

Best Regards,
Bruno B B Magalhaes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] TimeStamp BEFORE 1970

2005-07-07 Thread Bruno B B Magalhães

Hi Richard,

Well, I took a look at, and I think it is TOO complex to handler a  
simple thing..


Well, that's my little contribution:

function str2time($input = '12/31/1969')
{
$year= substr($input, -4);

$input= substr_replace($input, 1976 , -4);

return floor(strtotime($input) + (($year - 1976) *  
(31557376.189582)));

}

It work with ONLY a few hours more or less compared to my MacOS  
strtotime function, now I don't know which one is more accurate..


Well, why did you choose the year 1976, because it's an bisixth(?)  
year. So it was a matter of simple math.


I would appreciate any help from everybody to:

As I suppose that the last 4 digits are the year, I would like a  
pattern that could match a four digits number inside a string.


Any body know how many seconds and microseconds have a year, I found  
a round number (31557376.189582).


Well, any help is appreciate.

At least now I can work on a windows box.

Best Regards,
Bruno B B Magalhaes

On Jul 7, 2005, at 3:42 PM, Richard Davey wrote:


Hello Bruno,

Thursday, July 7, 2005, 7:04:44 PM, you wrote:

BBBM> I've read the manual, and the ADOdb Date package functions, and
BBBM> I am not using this because I want to keep my framework simple,
BBBM> flexible, and fast.

BBBM> Well, I just want a simple way to translate dates (I know what
BBBM> is the input format) to unix timestamp, with ability to do this
BBBM> with dates before 1970, and after 2023, is there any way?

Personally I'd use the Pear Date package. It's stable, well formed and
will do exactly what you require: http://pear.php.net/package/Date

Even if you don't like the thought of using it - you can always pour
over the source code to look at their methods and see how they handle
it.

Best regards,

Richard Davey


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



Re: [PHP] TimeStamp BEFORE 1970

2005-07-07 Thread Bruno B B Magalhães

Hi Folks,

Well I think I got it, at least it's working more or less to me now...
I really would appreciate any comments or suggestions.

function str2time($input = '12/31/1969')
{
if(($output = strtotime($input)) !== -1)
{
return $output;
}
else
{
preg_match('([0-2][0-9][0-9][0-9])', $input, $year);
preg_replace('([0-2][0-9][0-9][0-9])', '1976', $input);
return floor(strtotime($input) + (($year[0] - 1976) *  
(31557376.189582)));

    }
}

Thanks a lot!

Best Regards,
Bruno B B Magalhaes

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



Re: [PHP] TimeStamp BEFORE 1970

2005-07-07 Thread Bruno B B Magalhães

Hi Edward,

thanks for replying!

On Jul 7, 2005, at 10:44 PM, Edward Vermillion wrote:
One problem is that there's no accounting for leap years, but I  
don't know if that's gonna cause you any problems or not.


Course it have, when we multiply the year offset by 31557376.189582  
we are using the total seconds of an year, we normally don't use  
cause from 4 to 4 years we add a day (Pope Gregory XIII, Bregorian  
Calendar decreted in 1 March of 1582). So using the extra seconds we  
are, in theory adding that one more day.


The other thing I noticed is that the 'match' bit you have in there  
as "year[0]" should be "$year[1]". $year[0] will return the
whole string that was matched, not just the actual match part  
between the parenthesis. Although I think you would get the
same thing with your set up. And you will need to put a delimiter  
in the regex part, right now it looks like it's going to treat
the parenthesis as the delimiter which will make the return for the  
match not work. ie:


" preg_match('([0-2][0-9][0-9][0-9])', $input, $year); " -- $year  
will be empty...


should be " preg_match('/([0-2][0-9][0-9][0-9])/', $input, $year); "

or " preg_match('/([0-1][0-9][0-7][0-9])/', $input, $year); " -- to  
restrict it to 1970 or before


but it could also be " preg_match('/([\d]{4})/', $input, $year); "  
-- if you don't really need to validate the the year


There's other problems that I can see with the math logic in the  
return, like why 1976?, why would you want to generate
a positive number that will conflict with dates before 1970? but it  
could just be that I'm not thinking the math all the way
through, and what you eventually want to do with the dates once you  
store them.


Why 1976, because it's a leap year and is between valid range for  
windows systems.


Let me try to explain the rest.

First I get the input year... which by the way is working fine here...
preg_match('([0-2][0-9][0-9][0-9])', $input, $year);

Second I replace by a valid year between 1970 and 2025
preg_replace('([0-2][0-9][0-9][0-9])', '1976', $input);

After calculate the date difference from 1976 to given date... let's  
say 01/01/1936.
So we have... -40... and now multiply by number of seconds in a year  
(31557376.189582) before Gregorian Calendar, and we will get:  
-1262295047.583


Now we calculate the timestamp from 01/01/1976: 189313200

Now we have the final equation: 189313200 + (-1262295047.583).

The result is a negative timestamp: -1072981847.583  Which if we put  
in a date function, we would get: 01/01/1936.

Magic! We have negative timestamp in windows!

Was it clear, or I am dreaming awake? hehehehhe

Best Regards,
Bruno B B Magalhaes

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



Re: [PHP] TimeStamp BEFORE 1970 AND AFTER 2035

2005-07-07 Thread Bruno B B Magalhães
Just a quick fix, as now I've tested in a real environment, with a  
real application, and now it's working 100%, well, I think so.


/ 
*

*  Stritotime workaround for dates before 1970 and after 2038
 
*/

function str2time($input = '01/01/1969')
{
if(($timestamp = strtotime($input)) !== -1 && $timestamp !==  
false)

{
return (float)$timestamp;
}
else
{
preg_match('([0-9][0-9][0-9][0-9])', $input, $year);
$input = str_replace($year[0], '1976', $input);
return (float)floor(strtotime($input) + (($year[0] -  
1976) * (31557376.189582)));

}
}

Shoot!

Best Regards,
Bruno B B Magalhaes

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



[PHP] How to read PHP variables.

2005-07-12 Thread Bruno B B Magalhães

Hi you all!

That's my problem: I have a configuration files with the following  
structure...


$vars['varname'] = 'varvalue';

And I would like to have a module to change those parameters, but I  
don't know how to write a pattern to match it...


Thanks in advance...

Best Regards,
Bruno B B Magalhaes

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



Re: [PHP] Re: How to read PHP variables.

2005-07-15 Thread Bruno B B Magalhães

Hi everybody,

well I don´t want to include and use those variables or  set then. I  
want to read the file, parse the vars to a form, so the user can  
change the system configs using the web instead of FTP...


I am thinking reading using a simple include, and then clean the file  
contents and write the strings..


Best Regards,
Bruno B B Magalhães

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



[PHP] Get recursive array

2006-02-06 Thread Bruno B B Magalhães

Hi guys..

well I have a little "problem", I succeeded on retrieving a value by  
it's key, but I want a clean and faster method... Let me explain:


I have the following function which I use to set variables in my  
framework like (configs, requests, etc)...



/***
* @function_name set_vars
* @function_type Method
* @function_input None
* @function_description None
***/
function set_var($key = '', $value = null)
{
if(is_array($key))
{
if(count($key))
{
foreach($key as $key_key => $key_value)
{
$this->vars[$key_key] = $key_value;
}
}
}
elseif(is_array($value))
{
if(count($value))
{
foreach($value as $value_key => $value_value)
{
$this->vars[$key][$value_key] = $value_value;
}
}
}
else
{
$this->vars[$key] = $value;
}
}

For example I have:

$this->vars['config']['database_type'] = 'mysql'; or...
$this->vars['http']['get'] = 'b';

But now I want a function that gets those values and subvalues, but  
there is one small catch, I need to dynamically get parsed arguments  
and check if key exists and returns it... I tried func_num_args, and  
func_get_args, without success.


Any ideas?

Regards,
Bruno B B Magalhaes

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



[PHP] Get recursive array

2006-02-06 Thread Bruno B B Magalhães

Hi guys..

well I have a little "problem", I succeeded on retrieving a value by  
it's key, but I want a clean and faster method... Let me explain:


I have the following function which I use to set variables in my  
framework like (configs, requests, etc)...



/***
* @function_name set_vars
* @function_type Method
* @function_input None
* @function_description None
***/
function set_var($key = '', $value = null)
{
if(is_array($key))
{
if(count($key))
{
foreach($key as $key_key => $key_value)
{
$this->vars[$key_key] = $key_value;
}
}
}
elseif(is_array($value))
{
if(count($value))
{
foreach($value as $value_key => $value_value)
{
$this->vars[$key][$value_key] = $value_value;
}
}
}
else
{
$this->vars[$key] = $value;
}
}

For example I have:

$this->vars['config']['database_type'] = 'mysql'; or...
$this->vars['http']['get'] = 'b';

But now I want a function that gets those values and subvalues, but  
there is one small catch, I need to dynamically get parsed arguments  
and check if key exists and returns it... I tried func_num_args, and  
func_get_args, without success.


Any ideas?

Regards,
Bruno B B Magalhaes

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



  1   2   3   4   5   6   7   8   9   >