[PHP] Re: Catalog or cart

2005-03-01 Thread Anguz
Hi Ryan,
I've used osCommerce as a catalog before, but it's a bit of a pain to 
customize. ZenCart is supposed to be easier, but I haven't tried it yet. 
For the last project I did of this kind, I wrote my own catalog script 
and I feel a lot more comfortable with that.

I do realize that it'll require a bit more work to add a cart to a 
catalog like that in the future, though, unless you use something simple 
like the cart provided by PayPal, but it's PayPal only.

Cristian
Ryan A wrote:
Hey all,
I have a client who has a computer store, now he wants to put all his stuff
in one site.
He does not want to do any selling from his site, but just list all his
items.
After looking via google and the the usual script sites, agora cart looks
pretty good and easy to maintain, other choices X-Cart,oscommerce,phpcatalog
I dont really want to build this from scratch as I am sure a lot of very
very good solutions are already out there and i would rather use the time
instead to either tweak the software to his particular needs/requests
request
for example:
he wants a few lines and a picture(optional) of his product (eg: a HP
printer) and when clicked on it should pop up a window with that products
details.
/request
or cleaning up his design, digital snaps etc
I've never really worked on a site like this before so I would appreciate
any recommendations you have towards a cart or catalog system thats has
worked really well for you, or you heard is good or you helped develop etc
I would like a cart/catalog that is open source (does not have to be
free..but not expensive) so i can play with the code if need be.
The reason i was leaning towards a cart is, if he ever decides to sell
online, i dont want to build a whole extra piece of software to go with the
catalog.
Thanks in advance,
Ryan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] get_defined_vars in all scopes?

2005-02-27 Thread Anguz
Hi!
I'm using this at the end of a script
echo 'pre'; var_dump(get_defined_vars()); echo '/pre';
but it only returns what get_defined_vars gives, which is what's 
available in the current scope. Is there any way to get also the vars 
used in functions that weren't globalized?

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


Re: [PHP] get_defined_vars in all scopes?

2005-02-27 Thread Anguz
John Holmes wrote:
I'm using this at the end of a script
echo 'pre'; var_dump(get_defined_vars()); echo '/pre';
but it only returns what get_defined_vars gives, which is what's 
available in the current scope. Is there any way to get also the vars 
used in functions that weren't globalized?

No, not unless you call this in the functions, also. The variables don't exist after the function is completed. 

---John Holmes...
UCCASS - PHP Survey System
http://www.bigredspark.com/survey.html
I see. Thank you John.
Many functions may end at different places, they not alway reach the 
end, so I guess I could do it globalizing every var/arr, at least the 
ones I'm most interested in.

Is there some program I can use that'll monitor the vars when executing 
the script? I think Xdebug [http://xdebug.org/] does that with 
functions, but am not sure if it'll work with vars.

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


[PHP] Re: Something like strip_tags?

2004-07-05 Thread Anguz
Jason Paschal wrote:
i'd like to be able to strip only one type of HTML tag from a web 
document (a), but to do that with strip_tags(), i'd have to predict 
every possible HTML tag that might be used, except for the one i want to 
strip, and put those in the allowable tags parameter.

That's why I was hoping someone knew of a better way to accomplish 
this.  Any suggestions are welcome.

Thanks in advance,
~j
I'd probably do this:
$str = preg_replace('~a.+?/a~is', '', $str);
If you wanted to keep the anchored text and URLs, then something like:
$str = preg_replace('~a href=(.+?).*?(.+?)/a~is', '$2 [$1]', $str);
HIH,
Cristian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Determine whether $_GET has a value

2004-06-24 Thread Anguz
Terence wrote:
Hi,
Say you have a querystring - index.php?myname=joe
To determine whether myname has a value I have come to the following 
conclusions / shortcomings when using one of the following:

ISSET = as long as the variable myname exists it's set, but there's no 
guarantee of a value

!EMPTY = if your name = 0 (zero) then it's considered empty, for all 
else it seems to work

STRLEN = I have found this to be the only sure way to know.
Is there any other way, or should we always use a combination of ISSET 
and STRLEN?
Wouldn't this work?
  if(isset($_GET['var'])  !empty($_GET['var'])){
 // do something...
  }
Cristian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Benchmarking a script

2004-06-23 Thread Anguz
Hello,
I have a script I am optimizing and want to compare the before and after 
in speed. So I wrote a few lines to loop this script but I have a 
problem. In the script I'm optimizing there's some function definitions 
and when the script starts the second iteration it throws an error 
because the function already exists. How can I modify my benchmark code 
to make it work? This is what I have:

?php
$bench_n = 1000;
for($bench_i=$bench_n; --$bench_i=0; ){
ob_start();
$bench_time1 = array_sum(explode(' ', microtime()));
// script start 
// script...
	// script end **
	$bench_time0 += array_sum(explode(' ', microtime())) - $bench_time1;
	while(@ob_end_clean());
}
echo 'preTot Time: ' , $bench_time0 , 'br /Loops:' , $bench_n , 
'br /Avg Time: ' , ($bench_time0 / $bench_n) , '/pre';
?

Thank you very much in advance.
Cristian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Benchmarking a script

2004-06-23 Thread Anguz
Jason Barnett wrote:
Well you could put all of your function definitions into a separate 
file.  Then, just include the function file before you loop through the 
code that uses the functions.  Or as an alternative you could also do:

?php
if (!function_exists('name_of_function')) {
  function name_of_function() {
 // do something
  }
}
?
But this really isn't a good idea.  Try to put the function definitions 
into a separate file if that's feasible.

Jason

Thank you Jason. The problem I'm having is that part of what I'm 
benchmarking is having to define the functions compared to having not 
to. Basically part of the speed improvement is taking big parts of the 
code out of functions, so I need the definitions there :/

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


[PHP] Re: protecting web page

2004-05-08 Thread Anguz
[EMAIL PROTECTED] wrote:

Hi,

i'm designing a web application and i want to protect my web page from
printing and if possible want to protect source code too.
Do you know any solution that can help me. I've find an application named
HTML guard but it only work for static html pages. I need more a class or
function to prevent for printing.
Thanks for your help,

Marc
For the HTML source, I've used this in a client's page once and works 
very well:

http://cleverscripts.com/index.php?a=cleversource

Dunno about the printing though.

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


[PHP] Re: reversing an IF statement

2004-05-01 Thread Anguz
Kim Steinhaug wrote:

Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.
Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}
Wouldn't it then be like this?

if($_GET['id']!=1  $_GET['mode']!='home'  (isset($_GET['item'])  
$_GET['mode']!='news'))
   // Do stuff.

I may be wrong though. Note that I used AND instead of OR for the 
conditions, because you want them all true at the same time. But then 
again, you'd have to test it, with so many conditions it becomes a bit 
difficult to picture it in my head :P

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


Re: [PHP] Re: Separating spaces from the rest

2004-05-01 Thread Anguz
Curt Zirzow wrote:
You forgot the pattern deliminator:
  
 print_r(preg_split('/(\s+)/',word1 word2 word3., -1, PREG_SPLIT_DELIM_CAPTURE));

Curt
You're right, that fixed the space capturing.

Justin Patrin wrote:
 ...I wonder why you're doing this, but here's an answer for you.

 BTW, if you use var_dump or var_export, you can see the whitespace :-).

 $arr = preg_split('/(^\s+)/',word1 word2 word3., -1,
   PREG_SPLIT_DELIM_CAPTURE);

 The ^ means beginning of string.

 This will still give you an empty string in $arr[0], so do something 
like:

 unset($arr[0]);
 $arr = array_values($arr);

 Or just write your code to expect the extra entry. ;-)

The ^ did the trick, thanks! I noticed the empty [0].

I'm doing this to display code in an indented way and to keep the indent 
if the line wraps, instead of going back all the way to the left. So I'm 
putting the spaces in a td and the code line in another td, with a 
table for each line. I tested it and looks very well, now I'm writting 
the code to generate it.

Thank you all for your help! :)

Anguz

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


[PHP] Separating spaces from the rest

2004-04-30 Thread Anguz
I have an array with many strings, of which most have spaces or tabs at 
the beginning, but no fixed number of them. Example:

$arr[0] = 'Hello.';

How can I separate them into two strings? Like:

Array
(
[0] = Array
(
[0] =   //I added the quotes to notice the space.
[1] = Hello.
)
)
TIA!
Anguz
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Separating spaces from the rest

2004-04-30 Thread Anguz
Thanks! I was just reading that function in the manual when I got your 
reply. I tested it but I still have a couple of problems with it.

print_r(preg_split('(\s+)',word1 word2 word3., -1, 
PREG_SPLIT_DELIM_CAPTURE));

I get this:

Array
(
[0] =
[1] = word1
[2] = word2
[3] = word3.
)
In [0] the spaces aren't there and it's splitting the other spaces too, 
where I need to only split the leading spaces. How should I write it?

TIA,
Anguz
Kemper, Helmut wrote:
 Hi,

 See preg_explite and use /(\s+)/ for explode string into array.

 Tanks,
 Kemper


 
 -
 Helmut Kemper
 [EMAIL PROTECTED]
 Celular (Mobile): 55 81 99268744


 On 30/04/2004, at 20:22, Anguz wrote:

 I have an array with many strings, of which most have spaces or tabs
 at the beginning, but no fixed number of them. Example:

 $arr[0] = 'Hello.';

 How can I separate them into two strings? Like:

 Array
 (
 [0] = Array
 (
 [0] =   //I added the quotes to notice the space.
 [1] = Hello.
 )
 )

 TIA!
 Anguz

 --
 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: $PATH_INFO not working

2004-04-24 Thread Anguz
Noel Da Costa wrote:
Hi,

Anyone know what might stop the $PATH_INFO variable from working?  I
developed a nav system using this which works on the test server, but not on
the live server. I'm guessing this is something to do with the way PHP
(4.2.2)  and Apache (2.0) were compiled on the live server (I've posted that
question on php.install), but what I'm wondering is...
Is there perhaps a code fix/work-around I could apply in my scripts to
replace the $PATH_INFO with something that achieves the same effect, without
having to redisign my entire nav system.
Thanks,
Noel
I think you have to enable accept path info in Apache 2, it's on in 1 by 
default. I'm not sure exactly what the command is, but you can search 
based on that. It's probably AcceptPathInfo ON.

Anguz

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


[PHP] Conditional Functions

2004-04-22 Thread Anguz
Hello,

I was wondering if using conditional functions would save resources. The 
thing is that there's many functions in the code I'm using, but most 
aren't used in each case. I was thinking that maybe, even if the 
functions are in the included files, I could not define them making them 
conditional. Would this benefit the script? How? TIA.

Anguz

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


Re: [PHP] Conditional Functions

2004-04-22 Thread Anguz
[snip]
Maybe you could group them by purpose and put them into different include
files. Then you just include the file containing the functions you need at
this point in the script.
Regards,
Torsten Roehr
[/snip]

The functions are already grouped in different files, but even then, not 
all the functions included are used every time. The thing is, that 
there's too many different values for $action and each has it's own set 
of functions used. So creating an include file tailor-made for each one 
is a bit difficult, specially since many functions are used in more than 
one action.

So I thought that maybe I could only define the needed ones in each 
case, although there's more in the include file. Example:

if ($in_array('Hello', $functionArray))
{
function Hello()
{
echo 'Hello';
}
}
I understand that the whole php file will be parsed, or does the parser 
skip the whole block inside the if when the condition is not met? But 
even if it is parsed, if the condition is not met, I believe that the 
function won't be defined, so I assume this would at least save RAM or 
something, right? Or not at all?

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


Re: [PHP] Conditional Functions

2004-04-22 Thread Anguz
[snip]
how do you not define a function but put it in an include file at the
same time and still have it be useable?
chris.
[/snip]

Look at example 12-2 here:
http://www.php.net/manual/en/language.functions.php
If I don't define them, I don't expect them to be usable, that's the 
point. I don't want to define functions I won't use, so I'd like to know 
if it actually helps performance-wise to bother doing it this way ;)

Anguz

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


Re: [PHP] Conditional Functions

2004-04-22 Thread Anguz
[snip]
Jay Blanchard wrote:
It might, have you experimented with any code? 
[/snip]

Haven't yet, although I plan to. I wanted to check with more knowledged 
people than I first in case this was an already known thing :)

Anguz

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


[PHP] Weird replacing

2003-09-25 Thread Anguz Web Design
Hi,

I wrote a code to change the urls in my forum, to a new format. I
did it with output buffering and inside it, I used
preg_replace_callback, which worked great for me. But I shared
this code with the forum program community and there's a person
that can't make it work. He says his Apache gets caught up in a
loop or something. So I looked for an alternative to
preg_replace_callback. The way I did it is with preg_match_all
and then changed each element in the array and saved the changed
elements in a new array, then I just str_replace using the arrays
as find/replace. This solutions worked fine, almost. I use two
functions to do changes to the urls, one to make them relative
and the other to change symbols in the query, to something more
friendly to search-engine spiders. The function to make them
relative works great with the new method, as it did with
preg_replace_callback, but the other function, the one to replace
symbols in the query, is acting in an odd way.

Here's function

?php
   function spider_url($match){
  if(!strstr($match['2'], 'action') || strstr($match['2'],
'display') || strstr($match['2'], 'messageindex'))
 return $match['1'] . '/' . str_replace(array(=, ;,
), array(-, _, _), $match['2']);
  return $match['0'];
   }
?

if I call it with this

?php
   /// $scripturl is the var that has the url to the forum
script, like http://example.com/bbs/index.php
   $buffer = preg_replace_callback('/(' . preg_quote($scripturl,
'/') . ')\?([\w;=~+%]+)/i', 'spider_url', $buffer);
?

it works great and the url

http://example.com/bbs/index.php?board=1;action=display;thread=12
3;start=1

changes to

http://example.com/bbs/index.php/board-1_action-display_thread-12
3_start-1

but if I do it with this

?php
   preg_match_all('/(' . preg_quote($scripturl, '/') .
')\?([\w;=~+%]+)/i', $buffer, $match_spider, PREG_SET_ORDER);
   for($i = 0; $i  count($match_spider); $i++){
  $arr1_spider[$i] = $match_spider[$i]['0'];
  $arr2_spider[$i] = spider_url($match_spider[$i]);
   }
   $buffer = str_replace($arr1_spider, $arr2_spider, $buffer);
?

then the url comes out like this

http://example.com/bbs/index.php/board-1;action=display;thread=12
3;start=1

It changes just the first part, up to the semicolon... I did
other tests and there was one where changed everything up to the
semicolon right before 'star'

I can't understand what's going on, so if someone has a clue,
please tell me. Thank you very much in advance for taking your
time reading this.

Cristian

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