[PHP] Get recursive array
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
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
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
Re: [PHP] Re: How to read PHP variables.
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.
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
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
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
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
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
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
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
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] Re: class calling script
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
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
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] $GLOBALS, any probolems?
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.
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...
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
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] UBB Code correct use
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
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
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
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
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
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
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
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] Slow Zend Optimizer
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
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
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
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...
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.
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.
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)
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
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
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
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?
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
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
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
[PHP] Array unset
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!
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
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
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');
Re: [PHP] Javascript and php
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
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
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
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
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)
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
Igor, the problem on using a framework is that you have to learn it before you take advantage of its features, I mean you must consider the learning curve in your time schedule. There are pretty good frameworks out there, but each one with your pros and cons, and with your own goals, I mean, a strong and reliable framework doesn´t mean it is extensible or even template driven, or also even easy to learn. I developed my own framework, witch I am using on almost all my projects (course I won´t kill a fly with a hammer!) for one year and half, and still on version 0.5dev! :) Some of then: http://www.zope.org http://www.fusebox.org http://www.mojavi.org http://www.binarycloud.com http://www.eZpublish.com http://amb.sourceforge.net http://www.phpmvc.net http://phrame.itsd.ttu.edu http://www.horde.org Best Regards, Bruno B B Magalhães On Oct 23, 2004, at 4:04 PM, Igor wrote: I need to develop an PHP/MySql application (about 20 db tables and 70 screens). I was wandering if there is a solid framework out there that could help development. Also, I would appreciate any recommendations for books/docs on good development practices and php app. architecture. Thanks! Igor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] enterprise php application automated testing
Well, we call it pre-testing, the only way, and the better one, is doing it with the future users of your system! Regards, Bruno B B Magalhães On Oct 23, 2004, at 10:00 PM, blackwater dev wrote: Hello all, I know I can use simpletest to test my application at the class level but I need a tool to test it at a much higher level. I need something to enter data in forms, click links, etc. I have played some with simpletest's web tester without much luck. I am just curious how others are effectively testing their large php enterprise applications? Years ago I wrote Visual test scripts and it had a feature where I could record all my keystrokes as I entered, clicked, etc...I guess I am curious if there is anything like that..open source? Any suggestions are welcome. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mixing classes
Hi Tomy, I did the same thing! I´ve used a class called framework to encapsulate everything... here is what looks like: framework.inc.php ?php /** * Project: BBBM Framework * File: framework.inc.php * * @desc Main Framework Include * @link http://www.bbbm.com.br/ * @copyright 2004 Bruno B B Magalhaes * @author Bruno B B Magalhaes [EMAIL PROTECTED] * @package BBBM Framework * @version 0.5-dev */ session_start(); /** * Include Core Classes */ require_once(FRAMEWORK_DIR.'core/framework.class.php'); require_once(FRAMEWORK_DIR.'core/preferences.class.php'); require_once(FRAMEWORK_DIR.'core/languages.class.php'); require_once(FRAMEWORK_DIR.'core/database.class.php'); require_once(FRAMEWORK_DIR.'core/authentication.class.php'); require_once(FRAMEWORK_DIR.'core/input.class.php'); require_once(FRAMEWORK_DIR.'smarty/smarty.class.php'); require_once(FRAMEWORK_DIR.'core/output.class.php'); require_once(FRAMEWORK_DIR.'core/modules.class.php'); require_once(FRAMEWORK_DIR.'core/validation.class.php'); require_once(FRAMEWORK_DIR.'core/filters.class.php'); /** * Include Shared Classes */ include_once(FRAMEWORK_DIR.'shared/categories.class.php'); ? framework.class.php ?php /** * Project: BBBM Framework * File: framework.class.php * * @desc Main Framework Class * @link http://www.bbbm.com.br/ * @copyright 2004 Bruno B B Magalhaes * @author Bruno B B Magalhaes [EMAIL PROTECTED] * @package BBBM Framework * @version 0.5-dev */ class framework { var $preferences; var $database; var $authentication; var $input; var $output; var $modules; var $validation; var $filters; var $languages; var $controller; /** * PHP 4 Constructor */ function framework() { $this-preferences = new preferences();// Preferences Layer $this-languages = new languages(); // Language Layer $this-database = new database($this-preferences); // Database Layer $this-input = new input(); // Input Layer $this-modules = new modules($this-database); // Modules Layer $this-authentication = new authentication($this-database); // Authentication Layer $this-output = new output($this-preferences,$this-languages); // Ouput Layer $this-validation = new validation(); // Validation functions $this-filters = new filters(); // Filters Functions } function is_valid_controller($contoller='') { if($contoller != '') { $contoller = addslashes(strip_tags($contoller)); $this-database-build_table(array('controllers')); $query = 'SELECT controllerStatus FROM '.$this-database-table['controllers'].' WHERE controllerPath=\''.$contoller.'\' '; $this-database-query($query); if($this-database-num_rows() 0) { $this-database-fetch_array(); if($this-database-row['controllerStatus'] 0) { $this-controller = $contoller; return true; } else { $this-controller = false; return false; } } else { $this-controller = false; return false; } } else { return false; } } } ? Regards, Bruno B B Magalhães -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mixing classes
Hi Tomy, I did the same thing! I´ve used a class called framework to encapsulate everything... here is what looks like: framework.inc.php ?php /** * Project: BBBM Framework * File: framework.inc.php * * @desc Main Framework Include * @link http://www.bbbm.com.br/ * @copyright 2004 Bruno B B Magalhaes * @author Bruno B B Magalhaes [EMAIL PROTECTED] * @package BBBM Framework * @version 0.5-dev */ session_start(); /** * Include Core Classes */ require_once(FRAMEWORK_DIR.'core/framework.class.php'); require_once(FRAMEWORK_DIR.'core/preferences.class.php'); require_once(FRAMEWORK_DIR.'core/languages.class.php'); require_once(FRAMEWORK_DIR.'core/database.class.php'); require_once(FRAMEWORK_DIR.'core/authentication.class.php'); require_once(FRAMEWORK_DIR.'core/input.class.php'); require_once(FRAMEWORK_DIR.'smarty/smarty.class.php'); require_once(FRAMEWORK_DIR.'core/output.class.php'); require_once(FRAMEWORK_DIR.'core/modules.class.php'); require_once(FRAMEWORK_DIR.'core/validation.class.php'); require_once(FRAMEWORK_DIR.'core/filters.class.php'); /** * Include Shared Classes */ include_once(FRAMEWORK_DIR.'shared/categories.class.php'); ? framework.class.php ?php /** * Project: BBBM Framework * File: framework.class.php * * @desc Main Framework Class * @link http://www.bbbm.com.br/ * @copyright 2004 Bruno B B Magalhaes * @author Bruno B B Magalhaes [EMAIL PROTECTED] * @package BBBM Framework * @version 0.5-dev */ class framework { var $preferences; var $database; var $authentication; var $input; var $output; var $modules; var $validation; var $filters; var $languages; var $controller; /** * PHP 4 Constructor */ function framework() { $this-preferences = new preferences();// Preferences Layer $this-languages = new languages(); // Language Layer $this-database = new database($this-preferences); // Database Layer $this-input = new input(); // Input Layer $this-modules = new modules($this-database); // Modules Layer $this-authentication = new authentication($this-database); // Authentication Layer $this-output = new output($this-preferences,$this-languages); // Ouput Layer $this-validation = new validation(); // Validation functions $this-filters = new filters(); // Filters Functions } function is_valid_controller($contoller='') { if($contoller != '') { $contoller = addslashes(strip_tags($contoller)); $this-database-build_table(array('controllers')); $query = 'SELECT controllerStatus FROM '.$this-database-table['controllers'].' WHERE controllerPath=\''.$contoller.'\' '; $this-database-query($query); if($this-database-num_rows() 0) { $this-database-fetch_array(); if($this-database-row['controllerStatus'] 0) { $this-controller = $contoller; return true; } else { $this-controller = false; return false; } } else { $this-controller = false; return false; } } else { return false; } } } ? Regards, Bruno B B Magalhães -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reverse (or backward?) Infinity Loop
Hi guys, I have a normal categories table: catId catParentId catName catStatus But I want when a user enters on: http://hostname/site/products/catId1/catId7/catId13/../../contentId.html A listing should apear like that: Category 1 Category 7 Category 13 Category 2 Category 3 Category 4 Category 5 A reverse (or backward) loop! We need to get the last category and then follow the ParentId until the 0 ParentId. Have anybody made this before (I hope so)? Many Thanks, Bruno B B Magalhaes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php