[PHP] json_encode strange behavior

2013-05-31 Thread Bruno Hass de Andrade
Hi.

I'm encoding some data with json_encode to use with jquery. All working
fine, postgres query, my jquery, etc. But when I cast json_encode in my
array, the result is an json object ordered by the array index, in my case
the id of my clients.

This is right? Is the intended behavior?
Anyway, I fixed by putting quotes around the array key.


Code that order by array key:
 $lista = new sig;
$r = $lista-doQuery(SELECT cliente_id, razao_social FROM
clientes.clientes ORDER BY razao_social ASC);
 while ( ($o = pg_fetch_object($r)) )
{
 $niveis[$o-cliente_id] = $o-razao_social;
}
echo json_encode($niveis);


Postgres result:

cliente_id - razao_social
10 - Client A
  5 - Client B
  1 - Client C

json_encode output:

{1:Client C,5:Client B,10:Client A}




This works fine (note the quotes around the array index):

$lista = new sig;
$r = $lista-doQuery(SELECT cliente_id, razao_social FROM
clientes.clientes ORDER BY razao_social ASC);
 while ( ($o = pg_fetch_object($r)) )
{
 $niveis[.$o-cliente_id.] = $o-razao_social;
}
echo json_encode($niveis);

Postgres result:

cliente_id - razao_social
10 - Client A
  5 - Client B
  1 - Client C

json_encode output:

{10:Client A,5:Client B,1:Client C}






Thanks!



--
-

Bruno Hass
(51) 8911-9274


[PHP] Updating to 5.3.6

2011-06-20 Thread Bruno Coelho

I realize this is a basic matter, but I've installed PHP 5.3.1 with XAMPP for 
Mac OS. 
How can I update my PHP version now? 


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



Re: [PHP] Updating to 5.3.6

2011-06-20 Thread Bruno Coelho

I've installed through XAMPP. The latest version of XAMPP still has PHP 5.3.1


A 2011/06/20, às 18:50, Sean Greenslade escreveu:

 How did you install it? Why can't you just uninstall it and reinstall with 
 the new version?
 
 On Jun 20, 2011 12:52 PM, Bruno Coelho brunocsncoe...@gmail.com wrote:
  
  I realize this is a basic matter, but I've installed PHP 5.3.1 with XAMPP 
  for Mac OS. 
  How can I update my PHP version now? 
  
  
  Thanks. 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  



Re: [PHP] Greate day for you,

2010-04-07 Thread Bruno Fajardo
2010/4/7 Nilesh Govindarajan li...@itech7.com:
 On 04/07/10 21:41, Chris G wrote:

 http://sites.google.com/site/vfgbyuhoi6/kewe2w


 Bloody asshole spammer.
 Is there no spam filter at lists.php.net ?

It was probably a virus or a trojahn, not intentionally sent to the
list by the OP...


 --
 Nilesh Govindarajan
 Site  Server Administrator
 www.itech7.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



Re: [PHP] PHP MySQL Insert Statements

2010-03-11 Thread Bruno Fajardo
2010/3/11 Martine Osias webi...@gmail.com:
 Hi,

 My insert statements on this web page don't execute. The select statements
 do work. This tells me that the database connection is working. The username
 and password are the administrator's. What else could prevent the insert
 statements from executing?

Would you mind giving us some hints about how the INSERT statements looks like?

Thanks.


 Thank you.


 Martine

 --
 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] Execution order of PHP

2010-03-10 Thread Bruno Fajardo
2010/3/10 Auke van Slooten a...@muze.nl

 Hi,

 In a hobby project I'm relying on the order in which the following piece of 
 PHP code is executed:

 $client-system-multiCall(
  $client-methodOne(),
  $client-methodTwo()
 );

 Currently PHP always resolves $client-system (and executes the __get on 
 $client) before resolving the arguments to the multiCall() method call.

Hi!

Can't you call the methods $client-methodOne() and
$client-methodTwo() before the call to $client-system-multiCall()?
That way, you could store they values in local variables, and then
pass them to the $client-system-multiCall(), assuring that those
methods are executed before the multiCall(). Something like:

$methodOne = $client-methodOne();
$methodTwo = $client-methodTwo();
$client-system-multiCall($methodOne, $methodTwo);

Cheers,
Bruno.


 Is this order something that is specified by PHP and so can be relied upon to 
 stay the same in the future or is it just how it currently works.

 If it cannot be relied upon to stay this way, I will have to rewrite the 
 multiCall method and API...

 regards,
 Auke van Slooten
 Muze

 --
 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] Execution order of PHP

2010-03-10 Thread Bruno Fajardo
2010/3/10 Auke van Slooten a...@muze.nl:
 Bruno Fajardo wrote:

 2010/3/10 Auke van Slooten a...@muze.nl

 Hi,

 In a hobby project I'm relying on the order in which the following piece
 of PHP code is executed:

 $client-system-multiCall(
  $client-methodOne(),
  $client-methodTwo()
 );

 Can't you call the methods $client-methodOne() and
 $client-methodTwo() before the call to $client-system-multiCall()?
 That way, you could store they values in local variables, and then
 pass them to the $client-system-multiCall(), assuring that those
 methods are executed before the multiCall(). Something like:

 $methodOne = $client-methodOne();
 $methodTwo = $client-methodTwo();
 $client-system-multiCall($methodOne, $methodTwo);

 Hi,

 This is not what I meant. I should perhaps mention that it's an xml-rpc
 client and the method calls are remote method calls. The multiCall method
 gathers multiple method calls into a single request.

 The trick I'm using now is to set a private property in the $client-__get()
 method when the property you're accessing is 'system'. From then untill you
 call the method 'multiCall', instead of calling the methods (in this case
 methodOne and methodTwo) the client creates a new object with the call
 information (method name and arguments) and returns that. In multiCall all
 arguments are therefor call information objects and multicall creates a
 single request based on that information.

Hmm, you cleared that to me now... If you need to first create the
property system and then call a method in that object system,
can't you do something like:

$client-system = null;
$client-system-multiCall(
$client-methodOne(),
$client-methodTwo()
);

I'm not testing these snippets of code, so sorry if I'm getting something wrong.

Cheers,
Bruno.


 So in your example the client would simply call methodOne and methodTwo and
 return the results. Then it would try to do a multiCall with whatever the
 previous methods have returned.

 regards,
 Auke van Slooten
 Muze


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



Re: [PHP] Execution order of PHP

2010-03-10 Thread Bruno Fajardo
2010/3/10 Andrew Ballard aball...@gmail.com:
 On Wed, Mar 10, 2010 at 9:54 AM, Bruno Fajardo bsfaja...@gmail.com wrote:
 [snip]
 2010/3/10 Auke van Slooten a...@muze.nl:
 This is not what I meant. I should perhaps mention that it's an xml-rpc
 client and the method calls are remote method calls. The multiCall method
 gathers multiple method calls into a single request.

 The trick I'm using now is to set a private property in the $client-__get()
 method when the property you're accessing is 'system'. From then untill you
 call the method 'multiCall', instead of calling the methods (in this case
 methodOne and methodTwo) the client creates a new object with the call
 information (method name and arguments) and returns that. In multiCall all
 arguments are therefor call information objects and multicall creates a
 single request based on that information.

 Hmm, you cleared that to me now... If you need to first create the
 property system and then call a method in that object system,
 can't you do something like:

 $client-system = null;
 $client-system-multiCall(
    $client-methodOne(),
    $client-methodTwo()
 );

 I'm not testing these snippets of code, so sorry if I'm getting something 
 wrong.

 Cheers,
 Bruno.

 [snip]

 I'm not sure you would want to assign null to $client-system. After
 all, __set() might not be defined.

Yes, you're right, Andrew. Setting the property to null is not the
best choice in this case.


 I agree with Rob here. If order is really crucial, then call the
 statements in the correct order:

 ?php

 /**
  * causes $client to call __get() in order to resolve
  * 'system'
  */
 $system = $client-system;


This was my point too, to create the object before the call to
multiCall(), I just messed my example with the null assignment... :-)
The code you suggested must solve the OP issue.

Cheers,
Bruno.


 /**
  * You should add some handling here to make sure that
  * $system is really an object that implements your
  * multiCall() method, and not something else (like null).
  */


 $system-multiCall(
    $client-methodOne(),
    $client-methodTwo()
 );

 ?



 Andrew


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



Re: [PHP] How to get the 'return type' of a function?

2010-02-23 Thread Bruno Fajardo
2010/2/23 Daniel Egeberg degeb...@php.net

 2010/2/23 Dasn d...@lavabit.com:
  Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a
  function.
  For example:
  ?php
 
  $rf = new ReflectionFunction('strstr');
  echo $rf;
  ?
  === output ==
 
  Function [ internal:standard function strstr ] {
 
   - Parameters [3] {
     Parameter #0 [ required $haystack ]
     Parameter #1 [ required $needle ]
     Parameter #2 [ optional $part ]
   }
  }
 
  The problem is there's no 'return type' (i.e. 'string' in this example)
  info about the function.
 
  Could you tell me how to retrieve the 'return type'?
  Thanks.
 
 
  --
  Dasn

 That's not possible. Consider this function:

 function foo()
 {
        switch (rand(0, 1)) {
                case 0: return 42;
                case 1: return 'bar';
        }
 }

 What should the return type be?

Mixed? 
http://www.php.net/manual/en/language.pseudo-types.php#language.types.mixed


 --
 Daniel Egeberg

 --
 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] Cookies sessions

2010-01-20 Thread Bruno Fajardo
2010/1/20  clanc...@cybec.com.au:
 When you are working with sessions, provided you start your program with 
 session_id(), you
 can then do anything you like with session variables at any point in your 
 program.

Hi,

You meant session_start() instead of session_id(), right? But yes,
once you started a session (before any output is sent to the browser,
that includes echo and print statements, empty space chars, etc) you
can do anything you like with the $_SESSION array, being able to read
the stored values in other requests / scripts of your app, as long as
the session is started.

 In my
 original question I asked if there was a cookie equivalent.

As far as I know, yes, there is. You set a cookie using the
setcookie() function. This function, in the same way as
session_start(), must be called before any output is sent to the
browser. Once a cookie is set in the client, you can read the $_COOKIE
array in any subsequent request of your client, in any point of your
app, just like session.


 Someone said there was, but the above is simply demonstrating that their 
 suggested
 solution doesn't work. It appears there is no solution, but that the 
 workaround is to turn
 on output buffering, at least until you finish setting cookies, so that you 
 can be certain
 that no output is generated before this point.

You don't need to use output buffering at all. You only need this
mechanism if your script needs to output stuff before the
session_start() or setcookie() functions get executed.

Well, I hope this information is helpful.

Cheers,
Bruno.


 --
 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] Cookies sessions

2010-01-19 Thread Bruno Fajardo
2010/1/19  clanc...@cybec.com.au:
 I am trying for the first time to use cookies. The manual contains the 
 statement Cookies
 are part of the HTTP header, so setcookie() must be called before any output 
 is sent to
 the browser.

 When I first started using sessions, I was alarmed to read a very similar 
 statement about
 sessions, but I soon found that if I started my program with the statement
 session_start(); I could then set up, access, modify or clear any session 
 variable at
 any time in my program. This is enormously useful, as I can put the session 
 handling at
 any convenient point in my program, and can precede them with diagnostics if 
 I need to.

 However I have almost immediately found that while I appear to be able to 
 read cookies at
 any time, I cannot set them when I would like to. Is there any similar trick 
 which will
 work with cookies?

The only trick is that you have to call setcookie() before any output
is sent to the browser, just like the session_start() behavior.

 If I really have to work out what they should be, and then set them up,
 before issuing any diagnostics, etc, it will make life decidely more 
 complicated. (I
 assume that I can set several cookies using successive calls to setcookie()?)

Yes, each one with a differente name.


 I was also somewhat surprised to find that a cookie is used to implement 
 sessions. Does
 this place any limitations on using both sessions and cookies in the same 
 program?


No. The cookie in PHP that implements session is by default called
PHPSESSID. As long as your other cookies are named differently, you
should be fine.


 --
 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] What's the best way to extract HTML out of $var?

2010-01-15 Thread Bruno Fajardo
2010/1/15 alexus ale...@gmail.com:
 What's the best way to extract HTML out of $var?

 example of $var

 $var = a href=http://http://stackoverflow.com/Stack Overflow/a
 I want

 $var2 = http://starckoverflow.com/;
 example: preg_match();

 what else?

Hi,
If you simply wants to remove all tags from the string, try using the
strip_tags function (http://php.net/strip_tags).


 --
 http://alexus.org/

 --
 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] header(Location:...) fails

2010-01-13 Thread Bruno Fajardo
2010/1/13 Richard S. Crawford rscrawf...@mossroot.com

 Here is a snippet of code that is going to be the death of me:

 
 //  Create a new project
 $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
 code

 //  Make sure the project code is unique
 if (!$existingproject = mysql_query(select * from pb_versions where
 projectcode like '.strtoupper($projectcode).')) {
    die (Could not check for existing project code!br /.mysql_error());
 }

 $numprojects = mysql_num_rows($existingproject);

 if ($numprojects  0) {
    $pid = mysql_result($existingproject,0,versionID);
    header(Location:managebudget.php?e=1pid=$pid);
 }
 

 Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
 executed. Strangely, a header(Location) command later on in the script
 *is* executed. I've output the value of $numprojects, so I know that it's
 greater than 0, so the command
 header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
 but it isn't. (Weirdly, if I put a die() command *after* this header()
 command, it works... but it seems pathologically inelegant to do so.)

There's nothing in wrong in putting a die command after the
header(Location). In fact, it is common. The header() command by
itself don't imply in the send of the request. You can have many
header() commands in sequence, and the header will be sent only in the
end of the process.

Cheers,
Bruno.


 Obviously, I'm missing something incredibly basic. Can anyone help me figure
 this out?


 --
 Richard S. Crawford (rscrawf...@mossroot.com)
 http://www.mossroot.com
 Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

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



Re: [PHP] SVG and PHP

2010-01-05 Thread Bruno Fajardo
2010/1/5 Alice Wei aj...@alumni.iu.edu


 Hi,

  Just went online and saw an SVG generated from Python, and wanted to do
 the similar thing by loading the SVG into an PHP script. Here is the script
 that I have:

 ?php

 #Load the Map
 $ourFileName= USA_Counties_with_FIPS_and_names.svg;
 $fh = fopen($ourFileName, r) or die(Can't open file);
 fclose($fh);

 ?

 The problem is that my screen appears as blank even though I could open up
 USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone
 know what I might have done wrong here?


Aren't you just opening the file? I think that you need to print it in some
way suitable to your application.
Try using fread() or other function to read the contents of the file.



 Thanks in advance.

 Alice

 _
 Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
 http://clk.atdmt.com/GBL/go/177141664/direct/01/


Re: [PHP] Dual PHP installation and session sharing

2009-07-20 Thread Bruno Fajardo
Hi, Zareef.

I have not tried storing session in a database, and I think it's not
an option in my case, since I'm working on a legacy software that uses
distributed databases across several servers.

Actually, I guess it would be easier to setup a new webserver, running
PHP 5 only, and discontinue the current one. But if there's a chance
to share session in the actual environment, I would certainly prefer
that.

Thanks for the reply!

2009/7/19 Zareef Ahmed zareef.ah...@gmail.com


 On Sat, Jul 18, 2009 at 1:34 AM, Bruno Fajardo bsfaja...@gmail.com wrote:

 Hi all,

 I'm using Apache/2.2.3 (Linux/SUSE), running PHP 4.4.7 in CGI mode, in a
 dual installation with PHP 5.1.2 running as an Apache module.
 Scripts with .php5 extension are executed by PHP 5, and those with .php are
 executed by PHP 4, and everything runs as expected.
 My question is: is it possible to share session data between .php and .php5
 scripts in this environment? All my tests failed.

 have you tried using database as session storage and setting session id 
 manually in your application.


 Thanks in advance!



 --
 Zareef Ahmed :: A PHP Developer in India ( Delhi )
 Homepage :: http://www.zareef.net

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



[PHP] Dual PHP installation and session sharing

2009-07-17 Thread Bruno Fajardo
Hi all,

I'm using Apache/2.2.3 (Linux/SUSE), running PHP 4.4.7 in CGI mode, in a
dual installation with PHP 5.1.2 running as an Apache module.
Scripts with .php5 extension are executed by PHP 5, and those with .php are
executed by PHP 4, and everything runs as expected.
My question is: is it possible to share session data between .php and .php5
scripts in this environment? All my tests failed.

Thanks in advance!


Re: [PHP] Best Encryption Algorithm

2009-06-03 Thread Bruno Fajardo
Hi there!

Try out AES.
http://en.wikipedia.org/wiki/Advanced_Encryption_Standard

Bruno.

2009/6/3 Hemant Patel hemant.develo...@gmail.com

 Hello Everyone,
                      Hope you all are doing great.
                      Now we are creating a application which has high level
 of security so its obvious that we will require a algorithm for
 encryption/decrytpion.So Can anybody suggest me the best algorithm for
 encryption(irrespective of any languageJust a Algorithm).


 With Regards,
 Hemant Patel

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



Re: [PHP] MYSQL 5 auto increment not working

2009-05-21 Thread Bruno Fajardo
2009/5/21 Leidago !Noabeb leid...@googlemail.com

 Hi All


 I know this is not strictly a PHP question, but i have a problem whenever i
 insert a record using PHP. Basically the auto increment field does not work
 at all. Here's the structure of the table that i'm using:

 CREATE TABLE `children` (
  `cid` int(4) NOT NULL auto_increment,
  `cname` char(50) default NULL,
  `csname` char(50) default NULL,
  PRIMARY KEY  (`cid`)
 ) ENGINE=InnoDB

 I use PHP 5.1 and MYSQL 5

 I'm pretty sure the code i use to insert the data is sound since i've
 tested
 it with older versions of MYSQL.

 Has anyone else had similar problems?


Did you left empty the field `cid` (PK) in your INSERT statement?


Re: [PHP] Variables not initialized. Is it possible to...

2009-05-18 Thread Bruno Fajardo
This kind of tip is raised in form of notices. So, to enable that, use the
following function on top of your scripts:

error_reporting(E_ALL | E_NOTICE);

Best regards,
Bruno.

2009/5/18 Paul M Foster pa...@quillandmouse.com

 On Mon, May 18, 2009 at 05:38:37PM +0200, Cesco wrote:

  Is it possible to set a parameter in PHP 5 to ask the interpreter to
  raise an error every time I try to use a variable that wasn't
  initialized before ?
 
  For example, I've write this piece of code in Python:
 
 
  print(DonaldDuck)
 
 
   I get this error:
 
  Traceback (most recent call last):
File /Users/Cesco/Desktop/prova.py, line 3, in module
  print(DonaldDuck);
  NameError: name 'DonaldDuck' is not defined
 
 
  Until now I've seen that when I write this PHP equivalent:
 
 
  echo($DonaldDuck);
 
 
  When I try to run it, the PHP writes a blank string, because the
  variable is not yet initialized and PHP assumes that its value is an
  empty string (I guess)
 
 
  I'd like to have the same behaviour of Python in PHP, do you think
  that it is possible?

 Set your error reporting higher:

 error_reporting(E_ALL);

 at the top of your script.

 Paul
 --
 Paul M. Foster

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




Re: [PHP] SQL Injection - Solution

2009-05-06 Thread Bruno Fajardo
Hi there!

2009/5/6 Igor Escobar titiolin...@gmail.com

 Hi folks,
 Someone know how i can improve this function to protect my envairounment
 vars of sql injection attacks.

 that is the function i use to do this, but, some people think is not enough:

  * @uses $_REQUEST= _antiSqlInjection($_REQUEST);
  * @uses $_POST = _antiSqlInjection($_POST);
  * @uses $_GET = _antiSqlInjection($_GET);
  *
  * @author Igor Escobar
  * @email blog [at] igorescobar [dot] com
  *
  */

 function _antiSqlInjection($Target){
        $sanitizeRules =
 array('OR','FROM,'SELECT','INSERT','DELETE','WHERE','DROP TABLE','SHOW
 TABLES','*','--','=');
        foreach($Target as $key = $value):
                if(is_array($value)): $arraSanitized[$key] = 
 _antiSqlInjection($value);
                else:
                        $arraSanitized[$key] =
 addslashes(strip_tags(trim(str_replace($sanitizeRules,,$value;
                endif;
        endforeach;
        return $arraSanitized;


 }

 You can help me to improve them?

What if someone posts, in any form of your app, a message containing
or, from or where? Those are very common words, and eliminate
them is not the best solution, IMO.
Use mysql_real_escape_string() like Shawn said, possibly something
like this would do the trick (from
http://br2.php.net/manual/en/function.mysql-query.php):

$query = sprintf(SELECT firstname, lastname, address, age FROM
friends WHERE firstname='%s' AND lastname='%s',
mysql_real_escape_string($firstname),
mysql_real_escape_string($lastname));

Cheers,
Bruno.




 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 --

 Personal Blog
 ~ blog.igorescobar.com
 Online Portifolio
 ~ www.igorescobar.com
 Twitter
 ~ @igorescobar

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



Re: [PHP] Re: SQL Injection - Solution

2009-05-06 Thread Bruno Fajardo
2009/5/6 Igor Escobar titiolin...@gmail.com:
 hun...by the way I forgot to mention, I am Brazilian and here in Brazil
 these words are not common ...

Igor,

I'm brazilian too, but that is not the point. Deny the use of *any*
word as input in your app is unnecessary. The problem that you're
trying to solve, has been solved a long time ago.

Bruno.


 That is a recursive function and i can use array_map becouse i some cases we
 obtain arrays of arrays and that will generate a error.


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 --

 Personal Blog
 ~ blog.igorescobar.com
 Online Portifolio
 ~ www.igorescobar.com
 Twitter
 ~ @igorescobar





 On Wed, May 6, 2009 at 2:36 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 Igor Escobar wrote:
  Hunnn...
 
  So, what do you think now?
 
  function _antiSqlInjection($Target){
      $sanitizeRules =
  array('OR','FROM','SELECT','INSERT','DELETE','WHERE','DROP
  TABLE','SHOW TABLES','*','--','=');
      foreach($Target as $key = $value):
          if(is_array($value)): $arraSanitized[$key] =
  _antiSqlInjection($value);
          else:
              $arraSanitized[$key] = (!get_magic_quotes_gpc()) ?
  addslashes(str_ireplace(trim($sanitizeRules,,$value))) :
  str_ireplace(trim($sanitizeRules,,$value));
          endif;
      endforeach;
      return $arraSanitized;
  }
 
 Stay on list please.  I don't like the ternary or the brace omissions
 (alternate syntax) :-) however

 My point was that in my opinion you don't need the replace at all.
 Also, do you really want to strip all 'or', * and = from all fields?
 These may be perfectly valid in your app.  Or is a very, very common
 word, so is from and come to think of it, where, select, insert and delete.

 For any of the SQL injections to work in your query, there will need to
 be quotes or the backtick ` in the user supplied content.  The quotes
 are escaped by mysql_real_escape_string().

 I don't see any way for a SQL injection without the user input
 containing quotes or the backtick to break out of your query or
 prematurely terminate an expression.  Some examples here, however they
 don't mention the backtick:
 http://us2.php.net/manual/en/security.database.sql-injection.php

 This might be more useful:

 ||function _antiSqlInjection($Target)
 {
    if(is_array($Target)) {
        $Value = array_map('_antiSqlInjection', $Target);
    } else {
         if(get_magic_quotes_gpc()) {
             $Target = stripslashes($Target);
        }
         // replace backtick with single quote or whatever
        $Target = str_replace(`, ', $Target);
        $Value = mysql_real_escape_string($Target);
    }
    return $Value;
 }

 Thanks!
 -Shawn





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



Re: [PHP] RE: AJAX with POST

2009-04-05 Thread Bruno Fajardo
Ajax is asynchronous. The option of asynchronous or synchronous can be set
in the XMLHTTPRequest object (used by Ajax), but a synchronous call is not
Ajax.

Cheers,
Bruno.

2009/4/5 Phpster phps...@gmail.com

 Ajax can be both async and sync. Itsbthe fourth param in the open call and
 I believe by default it's a sync call not async

 Bastien

 Sent from my iPod

 On Apr 4, 2009, at 21:33, Skip Evans s...@bigskypenguin.com wrote:

  But my function using GET does seem to wait.

 Granted I cobbled it together from various samples and didn't author it
 from my own deep understanding of the exact process, but here's the snippet
 that does the real work.

 req.open('GET', url, false);
 req.send(null);

 if(req.responseText) {
  if(req.responseText.substring(0,7) == 'debug!!') {
  alert(req.responseText.substring(7));
  }
 }

 return(req.responseText);

 It seems to wait until it has data to return, because it works perfectly.
 I can send it a URL from another function and get the data back from server
 to the function as expected.

 The only part of it I'm unsure of is this:

 req.send(null);

 What does that do? As I said, I cobbled this function from examples, got
 it working, and presto, was off and running.

 Skip


 Brad Broerman wrote:

 Well, as the A in Ajax is asynchronous, there's no real way to make it
 wait. What you would normally do is use a callback:
   function createXHRObject( )
   {
   if (typeof XMLHttpRequest != undefined)
   {
   return new XMLHttpRequest();
   }
   else if (typeof ActiveXObject != undefined)
   {
   return new ActiveXObject(Microsoft.XMLHTTP);
   }
   else
   {
   throw new Error(XMLHttpRequest not supported);
   }
   }
   function sendAjaxRequest( websvcurl , params, callbackFn )
   {
   var xhrObject = createXHRObject();
   xhrObject.open(POST, websvcurl, true);
   xhrObject.onreadystatechange = function()
   {
   if (xhrObject.readyState == 4)
   {
   if( xhrObject.responseXML != null )
   {
   callbackFn (xhrObject.responseXML);
   }
   }
   }
   xhrObject.setRequestHeader(Content-type,
 application/x-www-form-urlencoded);
   xhrObject.setRequestHeader(Content-length, params.length);
   xhrObject.setRequestHeader(Connection, close);
   xhrObject.send(params);

   }
 -Original Message-
 From: Skip Evans [mailto:s...@bigskypenguin.com]
 Sent: Saturday, April 04, 2009 5:30 PM
 To: php-general@lists.php.net
 Subject: AJAX with POST
 Hey all,
 At the risk of being told this is a PHP and not a JS list, but
 also knowing the discussions on this list, to the benefit of
 all I believe, very wildly, I'm posting this JS code snippet
 for some advice.
 As I posted earlier, my AJAX app that uses a GET to post to
 the server (and get a response), fails on IE with larger data,
 so I thought I'd take a shot at writing a POST function, but
 so far I can get it to get the data back, but the problem is
 by the time the data has come back the function has already
 returned null back to the calling function. What I need this
 function to do is wait for the data to come back and then send
 it back to caller. Here's the function. Any advice would be
 greatly appreciated. (The code to get the appropriate object
 per browser has been omitted.)
 http.open(POST, url, true);
 //Send the proper header information along with the request
 http.setRequestHeader(Content-type,
 application/x-www-form-urlencoded);
 http.setRequestHeader(Content-length, url.length);
 http.setRequestHeader(Connection, close);
 http.send(url);
 http.onreadystatechange = function() {//Call a function when
 the state changes.
 if(http.readyState == 4  http.status == 200) {
   alert('['+http.responseText+']');
   return (http.responseText);
   }
 }
 --
 
 Skip Evans
 Big Sky Penguin, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://bigskypenguin.com
 
 Those of you who believe in
 telekinesis, raise my hand.
  -- Kurt Vonnegut


 --
 
 Skip Evans
 Big Sky Penguin, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://bigskypenguin.com
 
 Those of you who believe in
 telekinesis, raise my hand.
 -- Kurt Vonnegut

 --
 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: Extract result from a https remote server response

2009-02-13 Thread Bruno Fajardo
Assigning the return of file_get_contents to a variable?
Didn't get your point...

2009/2/13 m a r k u s queribus2...@hotmail.com

 Shawn McKenzie wrote:

 Shawn McKenzie wrote:

 m a r k u s wrote:

 Hi all,

 Example : 
 https://www.moneybookers.com/app/email_check.pl?email=t...@toto.comcust_id=123546password=123
 The MB server response displayed is : Illegal operation.
 We would like to put the result below in a php variable and process it .
 An idea ?

 PS: The server is secured. The php functions like file(), 
 file_get_contents(), readfile(), fopen() has been tested.
 Regards

 --

 m a r  k u s


 allow_url_fopen = On


 We have no control of the MB remote server configuration.

 --
 m a r k u s

 --
 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] sprintf thousand separator.

2009-02-11 Thread Bruno Fajardo
Can you extend the JPGraph class, intercepting the desired method,
formatting the output the way you need?

2009/2/11 João Cândido de Souza Neto j...@consultorweb.cnt.br

 No, I can´t, because if I do it how can jpgrhph render without numeric data?
 hehehe

 Richard Heyes rich...@php.net escreveu na mensagem
 news:af8726440902110523x63ce5485p6534d10063eb4...@mail.gmail.com...
  Thanks for your answer, but my real problem is to get thousand separator
  in
  jpgraph class which uses sprintf to display almost everithing;
 
  Can you format it first, and then pass it to JPGraph ?
 
  --
  Richard Heyes
 
  HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
  http://www.rgraph.org (Updated January 31st)



 --
 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] php validate user password

2009-02-09 Thread Bruno Fajardo
tedd,

I think that the problem of the duplicated hashes in the database
(in the case of two users using the same password) persists with a
constant prefix in the passwords. Although the random salt portion get
stored in the database concatenated to the hash, the attacker don't
know the string length of the salt, making the attack very difficult.

Cheers

2009/2/9 tedd tedd.sperl...@gmail.com:
 At 2:02 PM + 2/9/09, Stuart wrote:

 2009/2/9 Michael Kubler mdk...@gmail.com:

  These days SHA should really be used instead of MD5, and you should be
  SALTing the password as well.
  Here's a great guide :
 http://phpsec.org/articles/2005/password-hashing.html

 Good advice. I would also advise against stripping and trimming
 anything from passwords. By removing characters you're significantly
 reducing the number of possible passwords.

 I read the article and didn't find any objection to it, but before we all
 jump on the SHA bus, why can't we do this:

 1. Allow the user to pick whatever password they want.

 2. After entry, add a token string to it, such as 'a14fmw9'.

 3. Do a M5() hash and store the hash the dB.

 When the user wants to log back in:

 1. They enter their password.

 2. We add the token string ('a14fmw9') to it.

 3. Then we M5() the string and compare that hash with what's stored. That
 will work.

 Furthermore, if the token string is stored in the script, or in a
 configuration file, and not in the database (as suggested by the author),
 then if someone obtains access to the database, all the dictionary and other
 such brute force attacks will be more difficult because the hashes are more
 complex than one would normally expect, right?

 If not so, then where am I wrong?

 Another scheme would be simply to use the user's password and generate a
 hash. Then reverse the users password and generate another hash. Then
 shuffle the two hashes, or take pairs, or quads, or any number of other
 techniques to obscure the hash. As long at the process can be reversed, it
 will work.

 From my limited view, a minor amount of work can throw a major monkey wrench
 in any method of trying to crack a hash -- am I wrong?

 Cheers,

 tedd

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

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



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



Re: [PHP] php validate user password

2009-02-09 Thread Bruno Fajardo
Or, like the article suggested, a random portion for the hash... I
agree with you, Micah. The hash collision is a problem, and must be
avoided.
Same password hashes for different users are very good candidates for
a dictionary attack. Probably, in most of this cases, users picked
easy passwords, like 1234 or admin.

Cheers

2009/2/9 Micah Gersten mi...@onshore.com

 onlist this time...

 tedd wrote:

   snip
  
   I think the MD5() hash is a pretty good way and if the weakness is the
   user's lack of uniqueness in determining their passwords, then we can
   focus on that problem instead of looking to another hash. And besides,
   the solution presented was to create a salt and use that -- that's
   just another step in the algorithm process not much different than
   what I propose.
  
   Cheers,
  
   tedd
  
 

 The MD5 hash IS the problem.  The problem isn't the uniqueness of the
 passwords, but rather the uniqueness of the hash. The solution is to use
 another hash that does not have the same collision issues.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com




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




--
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

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



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
In my opinion, you would achieve better results using a template
engine, like Smarty (http://www.smarty.net/). In addition, your code
would be entirely separated from presentation in a elegant way.

2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank



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





-- 
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

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



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
Well, Smarty's caching layer is very fast. Maybe not as fast as an
echo statement, but apparentely Frank was also interested in separate
logic from presentation, and a series of echo's is not the best
solution in my opinion. :-)
But the best solution depends of the context of the application, i agree.

2009/2/6 Eric Butera eric.but...@gmail.com:
 On Fri, Feb 6, 2009 at 12:15 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 In my opinion, you would achieve better results using a template
 engine, like Smarty (http://www.smarty.net/). In addition, your code
 would be entirely separated from presentation in a elegant way.

 2009/2/6 Frank Stanovcak blindspot...@comcast.net:
 I'm in the process of seperating logic from display in a section of code,
 and wanted to make sure I wasn't treading on a performance landmine here, so
 I ask you wizened masters of the dark arts this...

 is there a serious performance hit, or reason not to use long, ie more than
 30 - 40 lines, comma conjoined echo statments...

 echo 'blah', $var, 'blah', $var2,...ad nauseum

 ... to output mixed html and php var values?  If so could you refer me to a
 work around, or better way?

 Frank



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



 In a thread about performance you suggest Smarty?  Really?  :D

 --
 http://www.voom.me | EFnet: #voom


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



Re: [PHP] long echo statement performance question

2009-02-06 Thread Bruno Fajardo
I am so stick to Smarty that I never tried other solutions, like
Savant. Thanks for the tip, I'll try it right away.

Cheers.

2009/2/6 Eric Butera eric.but...@gmail.com:
 On Fri, Feb 6, 2009 at 1:43 PM, Bruno Fajardo bsfaja...@gmail.com wrote:
 Well, Smarty's caching layer is very fast. Maybe not as fast as an
 echo statement, but apparentely Frank was also interested in separate
 logic from presentation, and a series of echo's is not the best
 solution in my opinion. :-)
 But the best solution depends of the context of the application, i agree.

 Right on.  I was just playing anyways.  I'm a strong supporter of
 things like Savant  Zend_View.  Use PHP, but for read only type of
 things with no logic.

 --
 http://www.voom.me | EFnet: #voom




-- 
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

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



Re: [PHP] Blank page of hell..what to look for

2009-02-05 Thread Bruno Fajardo
Maybe X-Debug (http://www.xdebug.org/) could help you find bugs in
your code, and
for development environments it's recommended to use the most
sensitive level of messages
(turn on E_STRICT and E_NOTIVE, for example).

2009/2/5 Ashley Sheridan a...@ashleysheridan.co.uk

 On Thu, 2009-02-05 at 12:22 -0500, Paul M Foster wrote:
  On Thu, Feb 05, 2009 at 11:11:03AM -0600, Terion Miller wrote:
 
  
   Speaking of IDE, which do people on here prefer, I have been using
   Dreamweaver CS3 just because as originally a designer I was/am used to 
   it...
   I did finally find the problem but moving an echo(damnit); from line to
   line commenting out everything below it...Oi ...is this ever going to get
   easier for me I often wonder...
 
  Use Vim. ;-}
 
  Paul
  --
  Paul M. Foster
 
 Any editor with coloured syntax highlighting will help. Just scanning
 through the script visually should let you spot the obvious errors, and
 then breaking the script down into chunks with echo statements is the
 next step. You don't need to break it down line by line, that takes
 ages! Instead, put one halfway through your code, that will let you know
 if the error is in the top or bottom half, then just keep breaking it
 down half at a time and soon you'll have the part the error is in. It's
 just a typical trial-and-error algorithm.


 Ash
 www.ashleysheridan.co.uk


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


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



[PHP] Web app for betting on soccer WorldCup 2006

2006-05-03 Thread FAURE, Bruno (PCO TECHNOLOGIES)

Hi all,


I am looking for a web application that could be used for organizing informal 
intranet bets on soccer worldcup 2006.

I can not find such an application, neither in php nor in other languages. I 
had a look on sourceforge and many websites, but there is nothing
Do you know if such apps exist and where I could find one?


Thanks in advance,

Bruno
Worldcup fan



This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.

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



[PHP] Re: Get recursive array

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

Hi Jochem,

well, thanks for the code... it's working perfect, but it seams a  
little bit slow as it's using while... doesn't?


Now, abusing of you, how can I unset a variable the same recursive  
way? :D Maybe like this?



	/ 
***

* @function_name get_var
* @function_type Method
* @function_input None
* @function_description None
	 
***/

function get_var()
{   
$arguments = func_get_args();

if(empty($arguments))
{
return null;
}

$reference = $this-vars;

while($argument = array_shift($arguments))
{
if(!isset($reference[$argument]))
{
return null;
}
else
{
$reference = $reference[$argument];
}
}

unset($reference);
}


And I didn't double posted, I had to subscribe... and I didn't know  
if my message had been sent or not.


Thanks,
Bruno B B Magalhaes

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



[PHP] Imap, reading the email-body

2005-10-19 Thread Bruno Gola

Hi guys,

I need some help with the imap_body function and how to work with the 
string that this function returns...


Im working on a mailing list archive website and i'm using the imap_* 
functions to handle this, the header works fine (and other things too) 
but the Body of the message dont work as expected. It came as one-line 
string, the \n character (or br in html) is simple ignored. I dont 
know how to make the function translate the \n to br.



You can understand better what i'm saying looking:

http://www.brunogola.com.br/testeimap.php

Look the main page and try to read any message... I dont know what can i 
do to fix it...


Thanks for any help and sorry any mistakes about my english...

Bruno Gola

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

?php
/ 
 
***

*  @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] 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] PHP vs. ColdFusion

2005-07-04 Thread Stéphane Bruno
On Fri, 2005-07-01 at 19:01, Mark Charette wrote:
 It is always funny to read that one needs OO approches to do anything 
 useful. What one needs is a modular approach, re-factoring, and knowing 

I never said that you NEED OO approach to do anything. I found some
problems where an OO approach helped me better than a linear approach,
and the inverse is also true.

My point was that a language that gives you the choice of programming
style is interesting. Both CF and PHP give you the choice to use OOP or
not.

Today, everyone agrees that procedural languages are an evolution from
BASIC-style linear programming.

Also, one can agree that OOP is an evolution from procedural
programming. Now, one can choose to stick with linear programming,
procedural programming or OOP. This is a matter of personal taste,
trade-offs that have a different meaning from one individual to another.

You can achieve modularity with procedural coding. But, you need to do
it yourself, while modularity is at the heart of OOP. You may prefer
linear or procedural coding over OOP, but surely not for modularity.

Stéphane

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



Re: Re[2]: [PHP] PHP vs. ColdFusion

2005-07-01 Thread Stéphane Bruno
Hello,

I followed the discussions closely. I wanted to reply to some questions
I saw in the discussions.

I am using both PHP and Coldfusion, but both on Linux platforms. So, I
am not bound to Microsoft technologies, and CF runs faster on Linux/Unix
than on Windows.

Like PHP, there is no need for a dedicated IDE to code/script on CF. You
may use Macromedia software to build web pages only if you want, except
if you want to make Flash movies/animations.

You can edit files manually to configure CF (XML files) with a ssh
access on the server (at least the Linux version I am used to), or use a
web interface to manage it.

Both languages have pros and cons, and I cannot say that one is superior
to the other. It is a matter of taste. I know that someone coming from a
programming background will be more comfortable with PHP, while someone
coming from a web design background may be more comfortable with CF, but
even that is changing. Once you get to do very advanced things, you need
to code using Object Oriented approaches, modular programming, web
services, etc. which both products allow you to do.

It is true that Coldfusion offers a lot of functionality 'out of the
box', and sometimes you need to look around to find equivalent
functionality, extensions for PHP. These functionalities are more geared
towards displaying data, managing forms, etc. PHP also offers a lot of
functionalities out of the box also. For example, PHP is really flexible
about how you want to retrieve a query, in what format, etc. The
functionalities are more geared towards programming utilities.

You can extend Coldfusion functionalities easily by creating 'custom
tags' in Perl, C, C++ or Java without having to recompile the product.
You can also instantiate any classes in Java because Coldfusion is based
on Java since version 5.

So, it's really a matter of personal taste and the background of each
one. I personally take pleasure developing applications on both
Coldfusion and PHP.

Stéphane

On Fri, 2005-07-01 at 09:50, Richard Davey wrote:
 Hello Andrew,
 
 Friday, July 1, 2005, 3:06:49 PM, you wrote:
 
 AS You know for a php developer your really don't know your own product to
 AS well (blah blah blah)
 
 Isn't it time to run off and write another check to Adobe or
 something? Rather than personally attacking other list members.
 
 Best regards,
 
 Richard Davey
 -- 
  http://www.launchcode.co.uk - PHP Development Services
  I do not fear computers. I fear the lack of them. - Isaac Asimov

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



[PHP] _construct() problem

2005-06-09 Thread Stéphane Bruno
Hello,

I designed a player class with the following properties and constructor:

class player {
  private $properties = array('firstname' = NULL, 'lastname' = NULL);
  function _construct($first, $last) {
$this-properties['firstname'] = $first;
$this-properties['lastname'] = $last;
  }
}

Then I have other methods that allow me to set and get the properties.
However, when I issue a:

$myplayer = new player('Laurent', 'Blanc');

it seems that the constructor is not taken into account: the properties
are not initialized. I have to explicitly initialize them with the
setter methods in order for the initialization to take place.

What did I do wrong?

I am running PHP 5.0.4 with Apache 2.0.54.

Stphane

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



[PHP] _construct() problem

2005-06-09 Thread Stéphane Bruno
Hello,

I designed a player class with the following properties and
constructor:

class player {
  private $properties = array('firstname' = NULL, 'lastname' = NULL);

  function _construct($first, $last) {
$this-properties['firstname'] = $first;
$this-properties['lastname'] = $last;
  }
}

Then I have other methods that allow me to set and get the properties.
However, when I issue a:

$myplayer = new player('Laurent', 'Blanc');

it seems that the constructor is not taken into account: the properties
are not initialized. I have to explicitly initialize them with the
setter methods in order for the initialization to take place.

What did I do wrong?

I am running PHP 5.0.4 with Apache 2.0.54 on Fedora Core 1.

Stphane

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



Re: [PHP] _construct() problem

2005-06-09 Thread Stéphane Bruno
Thanks, Richard

It now works. It was not obvious in the book I was using. The author
should have put a side note stating it is two underscores instead of
one.

Stphane

On Thu, 2005-06-09 at 08:42, Richard Davey wrote:
 Hello Stphane,
 
 Wednesday, June 8, 2005, 10:23:22 PM, you wrote:
 
 SB   function _construct($first, $last) {
 
 SB What did I do wrong?
 
 It's __construct()
 
 Best regards,
 
 Richard Davey
 -- 
  http://www.launchcode.co.uk - PHP Development Services
  I do not fear computers. I fear the lack of them. - Isaac Asimov

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



[PHP] Re: SSL use

2005-04-23 Thread Bruno Wolff III
On Fri, Apr 22, 2005 at 16:38:29 -0400,
  ruel.cima [EMAIL PROTECTED] wrote:
  hi,
 
  im handling some important information that needs to be stored in my
  postgresql database via a php script. i´ve been reading the mails sent on
  this mailing list on SSL use. my postgresql server allows SSL connections
  but im not sure how to make use of this.id like to know more about ssl and
  how to take advantage of its security features. any references?
 
   from my php script, do i need to make a special connection to the database
  or is the same e.g pg_connect(host= localhost dbname=test user=p
  password=p)?

If postgres is running on the same machine as php there isn't much point
in using encryption of the connection. You are probably better off using
domain sockets instead of a network connection in this case.

-- 
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.
?php
/** 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');
?
?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-generalw=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=PHPsubmitform=Find+search+plugins
--
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


[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


[PHP] line feed

2005-03-04 Thread Bruno Santos
Hello.
How do i print a line return using the echo command, for when i see the 
page source,
i get the code line by line and not all in the same line.

using double quotes (  ), i can put \n at the end and i get the result 
i want,
but, using sinle quotes ( ' ), \n doesnt work.

if i use double quotes, in a simple html comand i need to use \  and i 
dont want that.

is any way i could use single quotes, and getting the line feed ??
example:
Double quotes:
   echo table border=\1\ width=\800px\\n;
single quotes:
   echo 'table border=1 width=800px';
cheers
Bruno Santos
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: PHP and Access

2005-02-26 Thread Bruno Santos
pete M wrote:
Check this out
http://adodb.sourceforge.net/
http://phplens.com/adodb/code.initialization.html#init
have fun
Pete
Bruno Santos wrote:
Hello.
I need to to an application in PHP with graphics creation.
The database where i need to go and fetch the values is access.
is possible for PHP to fecth values from an access database ??
cheers
Bruno Santos

Hello all. Thanks for all the answeres but i have a small problem.
Im using Linux, not windows... Ive heard about unixODBC, can i used it
to connect to a access database ??
cheers
--
[EMAIL PROTECTED]
www.feiticeir0.no-ip.org
--
[EMAIL PROTECTED]
www.hal.min-saude.pt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Communication protocol of PHP and Mysql

2005-02-25 Thread Bruno Santos
Hello all.
Im developing an application as my final school project and for the 
report (administration manual) i need to specifie the protocol of 
communication between PHP and Mysql when accessing the mysql database 
using the functions within PHP.

PHP communicates with Mysql throw TCP/IP or any other protocol ?
cheers !
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP and Access

2005-02-25 Thread Bruno Santos
Hello.
I need to to an application in PHP with graphics creation.
The database where i need to go and fetch the values is access.
is possible for PHP to fecth values from an access database ??
cheers
Bruno Santos
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] URL encode

2005-02-23 Thread Bruno Santos
Hello.
Im having some trouble when getting a query from a $_GET method
the problem is, when using $_GET, i get some charaters decoded as html 
entities.

if i submit the word %sara% (example), is ok
but, if i submi the word %carlos%, i get Êrlos, witch is the translation 
of html entity %ca

how can i can resolve it ??
ive tryed with htmlentities, urlencode, urldecode, etc...
help ?
cheers
Bruno Santos
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] cannot remove cookies

2005-02-22 Thread Bruno Santos
Hello.
I'm using 2 cookies to control some user environmente.
every time the user logs in, the cookie is set, but when i try to change 
the value of that cookie,
deleting it firts and then setting a new one with another value, when i 
print the value of that cookie
the value is never the new one, but always the firts.

im setting the cookie with:
setcookie (cookie_name,cookie_value,time()+time-to-expiration);
when deleting it, i do
setcookie (cookie_name);
or
setcookie (cookie_name,,time()-time-to-expiration);
but it never works
the browser im testing it is firefox (linux)
but in IE is not working either...
PHP version is PHP-5.0.3
Apache version is Apache-2.0.52
Cheers
Bruno Santos
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] memory error

2005-02-17 Thread Bruno Santos
Hello. I've developed a script to use in shell to resize several images, 
but, when i try to run it, i keep receiving this error:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to 
allocate 2048 bytes)

how can i solve it ?
PHP: 5.0.3
php.ini settings:
max_execution_time = 300
max_input_time = 60
memory_limit = 8M
by the way, is there any function that allows me to flush the memory ??
cheers
Bruno Santos
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Users logins in Linux machine

2005-02-12 Thread Bruno Santos
Hello all.
I've a linux server that runs a mailserver for several users. I want to 
build a page where users can change their email password, that's their 
accounts password.

how can i with PHP manage to compare the password they type in a web 
form with the one they have in the system ?? (/etc/passwd) ??

can it be with LDAP ? or PAM ? or any other method ?
cheers !
Bruno Santos
--
Say no to software patents
www.nosoftwarepatents.com/
--
[EMAIL PROTECTED]
--
Divisao de Informatica
[EMAIL PROTECTED]
Tel: +351 272 000 155
Fax: +351 272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: +351 272 000 272
Fax: +351 272 000 257
--
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] 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] 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


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 '/'BR\n;
}
else{
  echo It does NOT end in '/'BR\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] client information

2005-01-11 Thread Bruno Santos
Hello all.
   I have a problem that i hope to solve with php. i know that, using 
$_SERVER['xxx'] is possible to find some information about the client 
who is accessing the script.
what i need to know if its possible to find out more information about 
the client, like in linux the DISPLAY variable of the client ?
if i make a system call, i get the server information and thats not what 
i want ?
if not with php, is possible to do it with javascript ?

thanx in advance
Bruno Santos
--
Say no to Software patents
www.nosoftwarepatents.com
--
[EMAIL PROTECTED]
--
Divisão de Informática
[EMAIL PROTECTED]
Tel: +272 000 155
Fax: +272 000 257
--
Hospital Amato Lusitano
[EMAIL PROTECTED]
Tel: 272 000 272
Fax: 272 000 257
--
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. b encoded to [b]
When editing an article:
Database --- UBB Decode --- Edit form --- UBB Encode --- Database
  |
  Eg. [b] becomes b
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] 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] 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


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

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:

?php
  $parts = explode('/', $_SERVER['PATH_INFO'];
  $controller = $parts[0];
  $module = $parts[1];
  unset($parts[0]);
  unset($parts[1]);
  $categories = array();
  while (list(, $cat) = each($parts)){
if (!strstr($cat, '.html')){
  $categories[] = $cat;
}
  }
?
--
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] scripting with php

2004-12-14 Thread Bruno Santos
Hello all.
i'm working with php for about 3 years and i must say: i cant get tired 
of it !! :-)

since my first page, ive used php as a server side language, embebed in 
html pages. now, i need to develop a small script to run as stand alone. 
how can i do it ?

just like bourn shell, ive used #!/usr/bin/php -q, but it apears is not 
working ...

can someone tell me how to i use php stand alone ?
chears !!!
Bruno Santos
--
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] 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] 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']
?php echo $_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] 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


[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] 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 Magalhes
On Dec 8, 2004, at 8:34 PM, John Holmes wrote:
Bruno B B Magalhes 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] 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=mysqlie=UTF-8oe=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


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}
table width=100% border=0 cellspacing=0 cellpadding=0  
align=center id=administration_listing
tr
td class=administration_listing_head{#head_name#}/td
td class=administration_listing_head{#head_path#}/td
td class=administration_listing_head  
align=center{#head_level#}/td
td class=administration_listing_head  
align=center{#head_order#}/td
td class=administration_listing_head  
align=center{#head_visibility#}/td
td class=administration_listing_head  
align=center{#head_type#}/td
td class=administration_listing_head  
align=center{#head_status#}/td
td class=administration_listing_head align=center   
width=75{#head_actions#}/td
/tr
{section name=m loop=$modules}
tr
form action={#Address#}{$controllerPath}/{$modulePath}/updatemodule  
method=post
input type=hidden name=moduleId value={$modules[m].moduleId}
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} nowrap{$modules[m].moduleName}/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} nowrapa  
href={$serverPath}{$modules[m].moduleController}/ 
{$modules[m].modulePath}  
target=_blank{$serverPath}{$modules[m].moduleController}/ 
{$modules[m].modulePath}/a/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrapselect  
name=moduleLevel size=1 onchange=this.form.submit(){html_options  
options=$levelrange selected=$modules[m].moduleLevel}/select/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrapselect  
name=moduleOrder size=1 onchange=this.form.submit(){html_options  
options=$orderrange selected=$modules[m].moduleOrder}/select/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrapselect  
name=moduleVisibility size=1 onchange=this.form.submit()option  
value=0 {if $modules[m].moduleVisibility eq  
0}selected{/if}{$smarty.config.visibility_invisible}/optionoption  
value=1 {if $modules[m].moduleVisibility eq  
1}selected{/if}{$smarty.config.visibility_visible}/option/select/ 
td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrapselect  
name=moduleType size=1 onchange=this.form.submit()option  
value=none {if $modules[m].moduleType eq  
'none'}selected{/if}{$smarty.config.type_none}/optionoption  
value=alias {if $modules[m].moduleType eq  
'alias'}selected{/if}{$smarty.config.type_alias}/optionoption  
value=default {if $modules[m].moduleType eq  
'default'}selected{/if}{$smarty.config.type_default}/option/ 
select/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrapselect  
name=moduleStatus size=1 onchange=this.form.submit()option  
value=0 {if $modules[m].moduleStatus eq  
0}selected{/if}{$smarty.config.status_inactive}/optionoption  
value=1 {if $modules[m].moduleStatus eq  
1}selected{/if}{$smarty.config.status_active}/option/select/td
td class=administration_listing_row_{if $smarty.section.m.iteration  
is odd}one{else}two{/if} align=center nowrap  width=75a  
href={#Address#}{$controllerPath}/{$modulePath}/editmodule/ 
{$modules[m].moduleId}img src={#MediaAddress#}{#bEdit#}  
alt={#aEdit#} border=0/aimg src={#MediaAddress#}{#tPixel#}  
border=0 height=10 width=10{if $smarty.session.userlevel = 9}a  
href={#Address#}{$controllerPath}/{$modulePath}/deletemodule/ 
{$modules[m].moduleId}img src={#MediaAddress#}{#bDelete#}  
alt={#aDelete#} border=0/a{/if}/td
/form
/tr
{sectionelse}
trtd class=administration_listing_row_one colspan=8  
align=center nowrap{#message_no_modules#}/td/tr
{/section}
/table
{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] 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


[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] 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..
==
?php
/**
* Project: BBBM Framework
* File: authentication.class.php
*
* @desc Main Authentication 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.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='',$accesslevel=0)
{
$query = 'SELECT
users.userId,
groups.groupLevel
FROM
'.$this-database-table['users'].' AS users,
'.$this-database-table['usersgroups'].' AS 
groups
WHERE
users.userGroup=groups.groupId
AND
users.userName=\''.$username.'\'
AND
users.userSession

[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 .= 'td class=menuitem_active  
onmouseover=menuHover(\'mainmenu\', '.$m.', \'menuitem_active\')  
onmouseout=menuHover(\'mainmenu\', '.$m.', \'menuitem_active\')
			a  
href='.$framework-output- 
get_config_vars('Address').$modules[$i]['moduleController'].'/ 
'.$modules[$i]['modulePath'].'';
		}
		else
		{
			$output .= 'td class=menuitem_inactive  
onmouseover=menuHover(\'mainmenu\', '.$m.', \'menuitem_active\')  
onmouseout=menuHover(\'mainmenu\', '.$m.', \'menuitem_inactive\')
			a  
href='.$framework-output- 
get_config_vars('Address').$modules[$i]['moduleController'].'/ 
'.$modules[$i]['modulePath'].'';
		}
		
		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 .= '/a/td';
		
		if($i  $c)
		{
			$output .= 'td class=menuspacer|/td';
		}
		
		$m++;
		$m++;
	}

	$output .= '/tr/table';
	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)

?php
/**
* Project: BBBM Framework
* File: site
*
* @desc Site Controller
* @link 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'] != ''   
file_exists(FRAMEWORK_DIR.$framework- 
controller['controllerPath'].'.aliases/'.$framework-modules- 
module['moduleAliasPath'].'.func.php'))
		{
			include_once(FRAMEWORK_DIR.$framework- 
controller['controllerPath'].'.aliases/'.$framework-modules- 
module['moduleAliasPath'].'.func.php');
		}
		elseif(isset($framework-modules-module['modulePath'])   
$framework-modules-module['modulePath'] != ''   
file_exists(FRAMEWORK_DIR.$framework- 
controller['controllerPath'].'.aliases/'.$framework-modules- 
module['modulePath'].'.func.php'))
		{
			include_once(FRAMEWORK_DIR.$framework- 
controller['controllerPath'].'.aliases/'.$framework-modules- 
module['modulePath'].'.func.php');
		}
		else
		{
			echo '[MODULE INITIALIZATION] No module to load!';
		}
		exit;
	}
	
	/**
	* Including module
	*/
	$framework-benchmark-mark('framework','including_module');
	if(isset($framework-modules

Re: [PHP] Javascript and php

2004-11-07 Thread Bruno B B Magalhães
Reinhart,
?php
for($i = 0; $i  mysql_num_rows($result)-1; $i++)
{
$row = mysql_fetch_object($result);

echo ''.$row-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:

SCRIPT LANGUAGE=JavaScript
!-- 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;
...
/script
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


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],'spam 
class=highlighted'.$oddsyntax[$i].'/spam',$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 its more important, but how many occurrences is  
also important...
Does someone knows Googles 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 domnio 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 domnio  
de Torben Grael, bicampeao invicto da competicao.
 Radicado na Alemanha, Jablonski e comandante do sindicato italiano  
Toscana Challenge, que se prepara para a Americas Cup de 2007.  
Experiente, ele tem entre os seus maiores ttulos o da Admirals Cup de  
1993. No ranking mundial de match race, ele soma 10.060 pontos, contra  
10.468 do norte-americano Ed Baiard, lder 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 olmpico 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 olmpicas, 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 nvel 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] 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


  1   2   >