[PHP] Re: some kind of library loader

2002-04-08 Thread Arpad Tamas

Hi Eric (and others who might help),

Actually I haven't tried the custom error handler for function or 
class definiton not found errors because I read in the manual that 
the processing is continued after the statement where the error 
raised. I also thought of a little hacking in php's source, but I 
haven't got too much experience in c.
Your idea looks fine to me, but I have one question. How do you 
determine in the precompiler that which functions or classes are 
really needed?
On our system it highly depends on the actual run. The template 
parser parses the template file, finds our special tags, and creates 
the appropriate objects to get the data for the tags from them. These 
tags and classes are nested in each other. Now while I'm writing this 
I have a new idea. I don't know if it will suit your needs (nor mine 
yet), just a quick thought.
Each template classes (which gives about 50% of the whole code) are 
derived from one main template class (it does the hard work).
The main problem is that there are many object creations in all over 
the code, and they depend on the actual class or template tag.
So I'm trying to find a common part of the code, where I can handle 
the missing class definition errors, or just start over some part of 
the processing when an error occurs.
a template example might help to understand it better:
table ...
xarticle
  trtd ...
xtitleb{xtext}b/xtitle
  /tr/td
/xarticle
/table
The tags starting with x are our template tags (x... and {x...}), 
and each container tag (x./x..) has it's own handler class. 
In xarticle's handler object xtitle's handler is created, which 
will raise an error if there's no class definition yet.
If catching the class not found errors would work I could set a 
class not found error signal in a global variable, load the needed 
class in the error handler. After the error handler finished, I could 
check if the error signal is set in the mentioned common code and if 
it is I could roll back all the processing of xtitle and start it 
over this time with the already included class definition.
I can relatively easily find this common code, because of the 
ancestor main template class, what all other template classes extend.

Because of the many roll backs this most likely wouldn't be faster 
than the original code was. To make things faster I could store some 
kind of cache for all the template files with the previously needed 
classes (I can get it with get_defined_classes()). This would work 
because the needed classes are mainly depend on the template in our 
system (especialy the template classes). Next time when a page is 
requested with the same template, I could just read the cache and 
include all the previously needed classes.

So the sollution in general: find a common code where you can roll 
back to some point where the line that caused the error can be 
executed again.
I know my example was a little complicated, but I hope you can 
understand it. Let me know if something isn't clear.

But now I checked if I can catch the Cannot instantiate non-existent 
class error, and unfortunatelly not :((

For the developers of php: Is it hard to make this feature to work? I 
would really appreciate it, and would be very very happy :))

Thanks and greetings,
Arpi

 I have had a similar idea.  I also tried the custom error handler
 aproach and it didn't work here either.  I have set the project
 aside that I was thinking about it for but I do have some ideas
 that would help and may be able to contribute.  I wasn't even able
 to get php to call my custom error handler for function not found
 errors.  How did you do that?  Was there anything useful in the
 context argument?  My guess is that to get this aproach to work
 would require hacking the code to php itself but the hack wouldn't
 be very major.  However I do have an alternate plan that has been
 waiting for me to get around to building it is a simple parser that
 will read a php file and get the required functions and classes and
 then pre build a library file for just that page.  The parsing
 shouldn't be that dificult as all function calls begin with 'func('
 and for classes checking for 'new classname' or 'classname::' would
 give me a list of all items that need to be checked for.  Then
 simply build (from the source) a list of all builtin php functions
 and allow those and check for declarations of inline functions and
 classes while parsing and remove those.  That would leave a list of
 functions and classes that are external.  Then build a database of
 classes and functions either as a real database or simple an index
 of the files that contain each resource.  I don't think it would be
 too hard.  The next step would be to make a publicly available
 archive of functions and classes that fit into this index.  Or to
 build it into pear.

 Please keep in touch with me on this issue.  Feel free to email me
 off list if you want.

 Eric

-- 
PHP General Mailing List 

Re: [PHP] Re: some kind of library loader - Thanks

2002-04-04 Thread Arpad Tamas


Ok, Thank you for your help Miguel and Maxim, I'm trying to do it by 
the help of your suggestions.

Arpi

  Also, you can find out if a class was defined by calling
  'class_exists()'. In this way you might save something.
  The best way thought is what Miguel was saying: load the files
  conditionally with a logic.
 
  That's what I'm trying to do, but still searching for the logic.
  But as I see, there's no better way of doing this other than
  checking if the needed classes are defined before every
  instantiation.

 Perhaps you can conjure up some sort of namespace scheme, and then
 use a global array to track which class files have been loaded, or
 which classes have been instantiated, or whatever it is you need to
 keep track of.

 In your file with a dependency:

   global $LOAD_STATUS;
   if (!$LOAD_STATUS['classes-db-queryops'])
  include 'lib/classes/db/queryops.php';

 In lib/classes/db/queryops.php:

   global $LOAD_STATUS;
   $LOAD_STATUS['class-db-queryops'] = 1;

 Seems fairly cheap to do.

 miguel

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




[PHP] some kind of library loader

2002-04-03 Thread Arpad Tamas

Hi Everyone!

I have an idea, but I don't know how to realise it, if it can be at 
all.
We have a relatively big system, with 52k lines of php code without 
much html, and many classes (1138) that depend on each other.
And I think I don't need to say that php parses the code somewhat 
slow. That's what I'm trying to solve. I know there are code caches, 
but none of them suits all of our customers or our needs (price, 
effectiveness).
Of course not all classes are needed on every page request, so I'm 
trying to separate them, and require them when they are really 
needed, but that's not easy with 1100 classes.

So I thought I'd write a custom error handler, and when an unloaded 
class is created or it's static method is accessed an error would 
be triggered and I'd require it in the error handler. The only 
problem is, that after the error handler finished the main code is 
executed *after* the statement that triggered the error, so I can't 
tell php to give one more try for the previously faulty code.

Is there any chance for this to work with some trick, or do you know 
of a better sollution for the problem?

Thanks for your help,

Arpi

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




Re: [PHP] register_shutdown_function vs require (with pseudocode example)

2002-02-20 Thread Arpad Tamas

Hi,
No one has any idea on this topic? Or the question wasn't clear?
Thanks,
Arpi

 Hi again,
 I read my email back and found a little hard to understand :)), so
 I thought a code exmplae might help.
 It's just pseudo code for explaining how my cache works:

 //simplified main code
 if page is in cache {
   deliver the old one
   register_shutdown_function(regenerate)
 } else {
   regenerate()
   deliver
 }

 //registered shutdown function
 function regenerate() {
   if it's locked by another process {
   return
   } else {
   lock
   require_once(...);
   require_once(...);
   require_once(...);
   require_once(...);
   require_once(...);
   creation of many classes
   calling of many methods (the code is approx 1,6Megs)
   store
   unlock
   }
 }
 The main code delivers the page and reigsters the regenerate()
 function, and that's all what it should do. It takes about 0.04s,
 but this time unfortunately depends on what the regenerate()
 function does. If the page is locked then it finishes quickly (the
 overall time is 0.04s again), but when it can be regenerated it
 takes 0.25s. By the way the whole page regeneration takes 1.1s,
 that's why I really don't understand the 0.25s.
 I hope it was clearer with the two mails :)), and someone has an
 idea of whats happening here.

 Thanks for your help,
   Arpi

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




[PHP] register_shutdown_function vs require

2002-02-19 Thread Arpad Tamas

Hi,
I'm trying to make some kind of caching system that first delivers 
the old page, and then regenerate the new one in the background. I 
achieved this with register_shutdown_function(). The registered 
function starts the real work, the normal php script just delivers 
the old page (of course if it were generated into the cahce before).
In the normal part of the program I required only the needed files to 
make the cache faster. It worked fine in older releases of php (maybe 
4.0.4, 4.0.5 I don't remember), but now 4.0.6 seems to include the 
files even if they aren't needed, and it slows down my cache. Without 
the requires (I commented out them) it delivers a page in avg 
0.04sec, but with the requires it's only 0.25 and it's too much for a 
cache.
The requires are called in the registered function, so they shouldn't 
affect the normal code. What is more interesting that it depends on 
the flow of the registered php code. For example if the page that 
should be regenarated is locked by another process and it can't be 
regenerated in the backround the cache delivers the page fast 
(0.04s), but if it's not locked (it can be regenerated) the cache 
becomes slow again (0.25s).
So what I don't understand: why the flow of the php code that is 
registered with register_shutdown_function affects the normal code's 
run? In theory it runs only when the normal code finished and the 
connection is released, and doesn't have anything to do with the 
normal script (that's why I started to use this method of caching).

(4.1.x is worse in this case because of bug #15209, it doesn't 
release the connection while the registered function is running)

Thanks for your help,
Arpi

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




Re: [PHP] session data vs cookie data

2002-01-30 Thread Arpad Tamas

  Do you null the user if the IP changes?  IPs can change
  during a user's
  session, so I wouldn't base the validity of the session
  solely based on IP.
 When that happens a user has to relogin. No data will be lost.

Relogin? Huh, I'd never visit a site where I have to login on every 
twice click.
For some reason our company share 5 ip adresses for it's employees 
with NAT. We don't ever know what is our *current* request's ip, it's 
always changes by chance. It could be that I use one ip while I'm 
visiting a site (it's not likely), but it could be that my 5 requests 
get to the site sitting on 5 different ips.
So I don't recommend using the visitors ip address for anything.
Arpi


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




Re: [PHP] configure problem: --with-mysql=/what exactly?

2001-11-20 Thread Arpad Tamas

Hi,
Do you have msyql-dev (or similar) package installed?
Arpi

 I have tried the following, each time removing config.cache
 beforehand:

 --with-mysql=/usr
 --with-mysql=/usr/include
 --with-mysql=/usr/include/mysql
 --with-mysql=/usr/lib

 According to a friend with mysql Debs installed it should be the
 first, yet PHP tells me each time it's using the bundled MySQL
 version and to be careful of running it with other mysql-using
 modules.

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




Re: [PHP] disable_functions not working in httpd.conf

2001-10-25 Thread Arpad Tamas

On Thursday 25 October 2001 09:47, Joseph Blythe wrote:
Hi,
bad news
disable_functions doesn't work for me either in apache's config file
I tried it with php_value, and php_admin_value, also in .htaccess 
with php_value without any luck

php4.0.5, Apache/1.3.14

bye,
Arpi

 Hey All,

 Was just trying the following and disable_functions is not working?
 Although safe mode and open_basedir are! What is really strange
 that when phpinfo is called the disable_functions value is phpinfo,
 can't seem to disable echo either, I don't want to put these in
 php.ini as I still want to be able to have a fully fledged php
 running from the main document root.

 VirtualHost *
 ServerAdmin [EMAIL PROTECTED]
 DocumentRoot /home/test/public_html
 ServerName test.foo.bar.com.au
 ErrorLog logs/test.foo.bar.com.au-error_log
 CustomLog logs/test.foo.bar.com.au-access_log common
   Directory /home/test/public_html
 AddType application/x-httpd-php .php
 AddType application/x-httpd-php-source .phps
 php_admin_value open_basedir /home/test/public_html
 php_admin_value user_dir /home/test/public_html
 php_admin_value disable_functions phpinfo
 php_admin_flag safe_mode On
 php_admin_value safe_mode_allowed_env_vars PHP_
 php_admin_value safe_mode_protected_env_vars LD_LIBRARY_PATH
 php_admin_value sendmail_from [EMAIL PROTECTED]
   /Directory
 /VirtualHost

 What am I doing wrong, any suggestions welcome on the above conf
 too :)

 Thanks in advance,

 Joseph

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




Re: [PHP] How to protect MySQL password

2001-10-24 Thread Arpad Tamas

On Wednesday 24 October 2001 16:42, Kurt Lieber wrote:
 On Wednesday 24 October 2001 00:30, you wrote:
  What we
  really need is an expert here to give us the low-down on the best
  way to accomplish the best security given regular tools.

 There isn't a way to solve it within the constraints you've
 mentioned (shared server at a hosting provider, apache,
 php-as-a-module)  If apache has read access on a file, which it has
 to have in order to serve it, someone else can get to that file via
 a PHP/Perl/C/whatever script/program.  Yes, you can use a server
 that has php safe_mode enabled, but that doesn't mean your scripts
 are safe -- it just means they're safe from being exploited by
 other php scripts.
If open_basedir is set properly for each user (and safe_mode is on), 
they can't reach each others' files at least from php. Of course if 
one can write and run programs with apache's user in another 
languages (perl, c, whatever) this doesn't help much (unless they can 
be configured in a similar way).


 What about encryption?
I think the encryption just makes someone's (who wants to steal 
something) work a little harder. In order to use the encrypted data, 
you have to decrypt it in php, so your code will contain the 
enc/decription algorithm and the keys that used.

Arpi

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




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Arpad Tamas

On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:

The default value for $image parameter was missing:

 function top ($image=defaultvalue) {
  if ($image==defaultvalue) echo blah blah blah;
  else echo blah blah $image blah;
 }

Arpi

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




Re: [PHP] Delivering NAMED pdf files

2001-10-19 Thread Arpad Tamas

On Friday 19 October 2001 11:52, George Pitcher wrote:
 Hi all,

 I am delivering my PDF files from a non-internet directory. The
 file gets delivered but the filename is always changed to the name
 of the php script.

 Can anyone tell me how to get the file delivered so that the name
 stays as it was on the server?
It works this way for me on many browsers (included ie):

header(Content-Type: application/octectstream);
header(Content-Disposition: filename=$name);
header(Pragma: no-cache);
header(Expires: 0);

Don't forget to double-check every capital letter, because it matters 
in http and for most browsers too (for example your Content-Type's 
capitals are wrong below).
Arpi

 ==
 ?php
 $fp1 = D:\\Pdf\\ . $fp;
 $len = filesize($fp1);
 header(Content-type: application/pdf);
 header(Content-Disposition: inline; filename=$fp1);
 header(Content-Length: $len);
 readfile($fp1);
 ?
 =

 Regards

 George Pitcher, Edinburgh


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com

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




Re: [PHP] domxml

2001-10-18 Thread Arpad Tamas

On Wednesday 17 October 2001 19:47, php wrote:
 Hello,

 Warning:  Unknown list entry type in request shutdown (0) in
 Unknown on line 0
 appears on the bottom of every script I call that uses domxml.
 I have no idea was causes it... Any tips?
try to use (and compile php with) another version of libxml library
I used to get many warning messages like yours, and changing of 
libxml solved the problem.

Arpi


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




Re: [PHP] Should I convert special characters before writing them to a table?

2001-10-04 Thread Arpad Tamas

 Try addslashes() before executing the query and stripslashes() when
 retrieving data from the db.  See the online manual for more
 details.

I think stripslashes() isn't needed when retrieving data from the db, 
it is needed only in the query string to protect special chars from 
interpretting them as sql.

 Arpi

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




[PHP] Can I rely on session.gc_maxlifetime?

2001-09-25 Thread Arpad Tamas

Hi,
I don't know if I understand right the manual at the 
session.gc_maxlifetime setting.
As I read, php won't use sessions that are older than that time.
It means that when a user logs in, and does his/her work for more 
than (for example) 15 minutes, than he/she will be kicked off 
immediately, because the gc_maxlifetime is set to 900??
Is this right, or I missunderstoud something?

Thanks for your help,
Arpi

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




Re: [PHP] Sessions just don't work on my machine. (Trying this ag ain)

2001-09-24 Thread Arpad Tamas


 Then I will reload the first page again by erasing index2.php and
 hitting enter and it will display a new sess id number and show the
 first page, as normal but that sessid number is equal t the new
 session created on the server and the value of it is:

 var3; var1; var2

 This is stranger than strange.
This isn't so strange. The session id is stored in a cookie.

But.. I turned off cookies (debuging can be done much easier), and 
played a little.
I found that the session is created properly on the first page and 
the 2 variables are registered too.
But on the second page they aren't set on the first view (that's 
stange!).
If I reload the page (of course the same sid is in the url), the 2 
variables this time are set, with their value that were given on the 
first page (that's why I told above they were registered, and their 
values are stored properly, so it's not a problem of rights, session 
save paths, etc..)
So that's what I've found, but I have to go home now sorry.
On the other hand the 2 source file you've sent me worked fine on my 
computer, without any problems (and warnings). 

Arpi

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