Re: [PHP] how to include a remote file and change relative links to non-relative

2001-07-17 Thread Aral Balkan

I've been working on Hans Anderson's Browser class and I've adapted it to do
what you're looking for. It's not complete but there should be a lot here
for you to go on. Again, I haven't had time to fine tune things at all so
it's a very rough hack right now. Hope it helps.

The dirty on how to use it:

?php

  require_once ('class_browser.php');

  // new browser
  $browser = new Browser();

  $file_array = $browser-get_url(array(
  url=$file,
  req_mthd='GET',
  protocol='HTTP/1.1',
  robot_rules=FALSE
 )
);

  if ($file_array[errcode] == 1) {
   $file_text = $file_array[content];

  // convert relative links to absolute
  $file_text = $browser-translate($file_text, $file);

?

class_browser.php:

class Browser {

 /*
Class Browser by Hans Anderson.
This code is released under the GPL license.
Modifications by Aral Balkan

  06.22.01 - Added two new methods:

 (1) $string = translate_links($string, $url);

  Translates all relative links in argument $string to
  absolute links using the full URL to the page being
  accessed in the $url argument. Returns the translated
  string.

 (2) $string = translate_images($string, $url);

  Translates all relative image links in argument $string to
  absolute links using the full URL to the page being
  accessed in the $url argument. Returns the translated
  string.

 Aral Balkan ([EMAIL PROTECTED])
 */

 function get_url($array) {

  /* defaults (there is no default for 'url' or 'content') */
  $robot_rules = TRUE; /* follow the robots.txt standard */
  $req_mthd = 'GET';
  $protocol = 'HTTP/1.0';
  $user_agent = 'PHP3 Browser';
  $time_out = 10;

  /* for each argument set in the array, overwrite default */
  while(list($k,$v) = each($array)) {
   $$k=$v;
  }

  /* set up the cookies.  If it exists, the straight variable
 will be written above ($$k=$v). */

  if(is_array($cookies)) {
   $cookies2send = '';
   while(list($k,$v) = each($cookies) ) {
$cookies2send .= Cookie: $k= . urlencode($v) . \n;
   }
  }

   if(!isset($url))
  return array(content=' ',headers=' ',errcode=-1,errmsg='Fatal
Error: No URL defined');

$parsed_url = parse_url($url);

  if($robot_rules) {

   $robots_url = $parsed_url[scheme] . :// . $parsed_url[host];
   if($parsed_url[port]) $robots_url .= : . $parsed_url[port];
   $robots_url .= /robots.txt;
   if(!$this-robot_rules($url,$robots_url,$user_agent))
 return array(content=' ',headers='
',errcode=0,errmsg=Non-fatal Error: Robot Rules do not permit this
browser to access $url);

  }

   $req_mthd = strtoupper($req_mthd); // 2068 rfc says it's case
sensitive.

  $host = $parsed_url[host];

  if(!$host || $host=='' || !isset($host))
  array(content=' ',headers=' ',errcode=-1,errmsg='Fatal Error:
No URL defined');

  $path = $parsed_url[path];
  if(!$path || $path=='' || !isset($path))
  $path = /;

  $query = $parsed_url[query];
  if($query!='')
  $path = $path?$query;

  if(!isset($parsed_url[port])) {
   $port = 80;
  } else {
   $port = $parsed_url[port];
  }

  $timeout = time() + $time_out;

  $fp = fsockopen($host,$port,$errno,$errstring,$time_out);

 if(!$fp) {
  return array(content=' ',headers='
',errcode=0,errmsg=Non-Fatal Error: Could not make connection to url
$url (not found in DNS or you are not connected to the Internet));
 } else {

   set_socket_blocking($fp,1); // aral: set to 1 for it to work on
Windows  Unix

   $REQUEST = $req_mthd $path $protocol\n;
   if(eregi(^HTTP\/1\.[1-9],$protocol)) $REQUEST .= Host: $host\n;
   $REQUEST .= User-Agent: $user_agent\n;
  if($referer) {
   $REQUEST .= Referer: $referer\n;
  }
   $REQUEST .= Connection: close\n;

  if($cookies) {
   $REQUEST .= $cookies2send;
  }

  if($req_mthd==POST) {
   $REQUEST .= Content-length:  . (strlen($content)) . \n;
   $REQUEST .= Content-type: application/x-www-form-urlencoded\n;
   $REQUEST .= \n$content\n;
  }
  fputs($fp,$REQUEST\n); // complete the request
#  print $REQUEST\n;

  if($timeouttime())
   return array(content=' ',headers='
',errcode=0,errmsg=Non-Fatal Error: Timed out while downloading
page);
  while (!feof($fp)  time()$timeout) {
  $output = fgets($fp,255);

  $view_output .= $output;

if(!isset($header)) {
   if($output==\n || $output == \r\n || $output == \n\l) {
  $header = $view_output;
 $view_output = '';
   }
}

  }


 }

fclose($fp);

if(time()$timeout)
 return
array(content=$content,headers=$headers,errcode=0,errmsg=No
n-Fatal Error: Timed out while downloading page);

return
array(content=$view_output,headers=$header,errcode=1,errmsg=
Success);

} // end function get_url

/* * */

function get_headers($h) {
  $array = explode(\n,$h);

   for($i=0;$icount($array);$i

Re: [PHP] I want to learn this!

2001-07-15 Thread Aral Balkan

If you're running Windows, try the .chm (windows helpfile?) version of the
manual -- IMHO it's much easier to navigate then the HTML version. I find it
indispensable.

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Finding Out Document That Included Another File

2001-07-12 Thread Aral Balkan

The way PHP works currently, $PHPSELF will point to your original file.

This is actually a problem, as it means that you cannot use relative
includes in the included file if its in a different directory. There's
currently discussion on the PHP-DEV list about changing this. Perhaps
there's going to a be a new include_local function or, ideally, I'd love it
if there was an environment variable set up that pointed to the included
page so the script could handle any relative includes (or HTML links, for
that matter) itself.

For your purposes though, $PHPSELF should work.

Hope this helps.

Aral :)

__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Credit Card script that really works...

2001-07-12 Thread Aral Balkan

You may also want to try Manuel Lemos' Form class -- it is very detailed and
well coded solution that handles all sorts of form validation, including
credit cards:

http://www.phpclasses.upperdesign.com/browse.html/package/1

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Speed of loding PHP pages

2001-07-11 Thread Aral Balkan

 Netscape is notoriously slug-like when it comes to loading large tables
(i.e. the output of phpinfo()).

A way around this is to break up large tables into numerous smaller ones (or
at least have one table at the top that displays something so that the user
doesn't think that things have gone awry).

Personally, I couldn't be happier that Netscape won't be making browsers
anymore and I wish that trouble-some bug of an excuse for a browser would
just go away :)

Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] session variable name into form

2001-07-09 Thread Aral Balkan

This might help - straight from the PHP manual:

* * *
If track_vars is enabled and register_globals is disabled, only members of
the global associative array $HTTP_SESSION_VARS can be registered as session
variables. The restored session variables will only be available in the
array $HTTP_SESSION_VARS.

If register_globals is enabled, then all global variables can be registered
as session variables and the session variables will be restored to
corresponding global variables.

If both track_vars and register_globals are enabled, then the globals
variables and the $HTTP_SESSION_VARS entries will reference the same value.
* * *

Hope this helps,
Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Losing the session with database session handler...

2001-07-08 Thread Aral Balkan

Has anyone run into this: I've got a custom session handler that saves
session info in a database but the sessionID gets lost as I go from one page
to another. It appears to be random as sometimes it's not lost!

I've got a link from one page to the other and each time a different session
ID is appended to it and new entries are made in the database. The following
in my PHP.ini:

session.use_trans_sid = 1
session.referer_check = 1
session.cookie_lifetime = 0
session.use_cookies = 1
session.save_handler = user

I'd appreciate any input you may have.

Thnx, Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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 prevent people from downloading images

2001-07-03 Thread Aral Balkan

I bought (it was something like $5-10) a java class called imageProtect from
Liquid Cool Research (their new page is http://www.liquidcoolresearch.com/)
a long time ago and I just checked on their site -- it doesn't seem to be on
sale any more. It worked for me (basically it was just java loading and
displaying the image but it did a bit more if I recall -- like the ability
to add watermarks, copyright info, etc.)

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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 prevent people from downloading images

2001-07-03 Thread Aral Balkan

 if that image is viewable on the computer monitor, it's impossible to
protect it if someone wants to steal it bad enough.

True, and I have friends who are professional photographers who actually
*don't* want to protect their images in this way. It is much more profitable
to be able to log who is stealing your images and then sue them. :)

Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] OO v. Functions Was: Re: [PHP] PHP Form (aka:Re: [PHP] Can any one spot the Parse error Here)

2001-07-02 Thread Aral Balkan

 Ive coded in both PHP and ASP and in both OO and function oriented.
Ultimately, i find functionally oriented PHP to be the best ... what do
other people think?

Having learnt how to program using Basic when I was 8, I had to unlearn a
lot of things as I moved from Basic to Pascal (what? I can't just Goto
wherever I want to?) then to C (a point-what?) and then a self-imposed exile
from programming only to rediscover it with Actionscripting (Flash) and
Lingo (Director) before trying out Python and finally loving PHP!

Why all this? Well it kinda charts my move from unplanned-write-as-you
top-down programming to function-based programming to object-oriented (which
is something I thought I had missed the boat on during the time I stopped
programming). Although it took a while for me to get my head around it my
favorite has to be Object Oriented. It's shocking to see my own
transformation from someone who would rather write hours of code then adapt
someone else's code to someone who'd rather scour the net looking for a
ready-made class that can then be extended.

Although PHP is not a real object oriented language, I still prefer using
the oo logic whenever possible. Although I guess there are times when you
can't use classes in PHP (has anyone been able to create a custom session
handler *class*, for example?.. how would you set up the
session_set_save_handler that takes strings to point to the various handler
functions from within a class?) I try to whenever I can. I think the words I
love most lately are abstract, modular, and portable and though it usually
takes lots more planning and perhaps a little bit more time spent conding at
first for those adjectives to apply to your code, I believe it's definitely
worth it!

OK, ok, I won't write to the list again first thing after I get up... I sure
can ramble!

__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Good intro to SQL reference Was: Re: [PHP] Get highest value of key most efficiently

2001-07-02 Thread Aral Balkan

You might also want to reference James Hoffman's excellent Introduction to
Structured Query Language (SQL Tutorial) page:
http://w3.one.net/~jhoffman/sqltut.htm

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] session handler class

2001-07-02 Thread Aral Balkan

Hi Scott,

I'd love to see the class you made but couldn't find a link in your email.
Could you let me know where to find it?

Thanks :)

Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] session handler class

2001-07-02 Thread Aral Balkan

It's strange -- I see that the message has an attachment in Outlook Express
but I'm not given the option to save it. I guess it got stripped off.

I'd really appreciate it if you could put up a link to it.

Thanks so much!.. Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Help with custom session handler

2001-06-30 Thread Aral Balkan

I'm writing a custom session handler that saves sessions using Manuel Lemos'
excellent Metabase library. The problem is, although I've got the
session_set_save_handler function pointing to the correct start, end, read,
write, destroy and garbage collection functions, when I call session_start
and session_register, the write function does not get called (the only
function that gets called is the read function.)

I read on a post at PHPBuilder that the write function cannot output to the
browser so just to make sure I logged my debug code to a global variable and
it really is not getting called.

I'd really appreciate any suggestions you might have -- it's got me stumped!

Thanks, Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] emalloc / erealloc problem (was: help with custom session handler)

2001-06-30 Thread Aral Balkan

ok, I found what's making Apache crash... my getting entries like:

FATAL:  emalloc():  Unable to allocate 1701082243 bytes
FATAL:  erealloc():  Unable to allocate 369098752 bytes

in the log. Somehow when I query the database it must be trying to
allocate -- unless my eyes deceive me -- ~1.6 GBs of memory in the first
entry and ~350 Megs in the second.

What could be causing this???

As I mentioned earlier, I have a custom session handler set up that uses
Manuel Lemos' Metabase library to save the session to a database (of the
supported ones, I'm using mySQL.)

I hope this message makes it to the list in a day or so (I really don't
understand why the list is so slow...) because this is driving me crazy!

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] emalloc / erealloc problem (was: help with custom session handler)

2001-06-30 Thread Aral Balkan

Rasmus,

When I try it with the MySQL handler you provided everything goes well -- no
errors. I guess I was hoping that the problem was with some php.ini setting
or something and not with Metabase as I'm dreading going into all code but
alas, I guess I must.

Do you have any idea what sort of database query could cause a memory leak
like that? Could it have anything to do with the serialized data being
written to the database having a '|' character and that character somehow
being interpretted as a concatenation character in a Metabase function?

I'm going to look into this and let you know if I find a solution (I really
hope I do as my thesis pretty much depends on it!)

Thanks again for all your help,

Aral :)

__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] emalloc / erealloc problem (was: help with custom session handler)

2001-06-30 Thread Aral Balkan

Well finally I am 99.9% sure that the problem is with Metabase. I've managed
to bring the code down to the absolute minimum to simplify things and I can
now state the bug clearly:

On Pentium III 500Mhz running WinMe, Apache 1.3.19 and PHP 4.0.5, use of
Metabase calls in custom session handler to update a MySQL database randomly
crash Apache with (again, randomly) errors in either PHP4TS.DLL or
MSVCRT.DLL.

When Apache does not crash, the code does work (I tested this with a simple
variable increment).

When the Metabase session handler is replaced with one using MySQL calls,
the problem goes away.

Entries noticed in Apache's error.log that may be related are:
FATAL:  emalloc():  Unable to allocate 1701082243 bytes
FATAL:  erealloc():  Unable to allocate 369098752 bytes

I've already written to Manuel about this and I'm sure he'll have the
problem figured out in no time but in the meanwhile, I'm posting my code
here so that this post may benefit others trying to do this in the future
(and with the hope that maybe someone can discover something that *I'm*
doing wrong that could be causing all this!)

?php
/*
 metabase sesssions library

 error: makes Apache crash randomly with errors in PHP4TS.DLL and MSVCRT.DLL
 running on WinMe with Apache 1.3.19 and PHP 4.0.5

 based on the code of Sterling Hughes (PHP Developer's Cookbook,
 pgs. 222 - 224) and Ying Zhang (PHPBuilder, Custom Session
 Handlers in PHP4,
http://www.phpbuilder.com/columns/ying2602.php3?page=1)

 metabase by Manuel Lemos ([EMAIL PROTECTED],
 http://www.phpclasses.upperdesign.com/)

 copyright (c) 2001, aral balkan ([EMAIL PROTECTED])
  http://www.aralbalkan.com
*/

// metabase database abstraction layer
require_once metabase/metabase_parser.php;
require_once metabase/metabase_manager.php;
require_once metabase/metabase_database.php;
require_once metabase/metabase_interface.php;

$SESS_LIFE = get_cfg_var('session.gc_maxlifetime');

// default life of session to an hour
if ($SESS_LIFE == '') { $SESS_LIFE = 3600; }

function on_session_start ($save_path, $session_name)
{
 global $database;

 /*  db_init.php holds the values for
  $db_type, $db_user, $db_pass, $db_host
 */
 require_once('db_init.php');

 $metabase_init = array(
 Type=$db_type,
 User=$db_user,
 Password=$db_pass,
 Host=$db_host,
 IncludePath=metabase/,
 Persistent=TRUE
 );

 $metabase_error = MetabaseSetupDatabase($metabase_init, $database);

 if ($metabase_error != '') {
  die('Database setup error: '.$metabase_error);
  return false; // failure
 }

 // select database
 $previous_database_name = MetabaseSetDatabase($database, $db_name);
 return true;
}

function on_session_end()
{
 // Nothing needs to be done in this function
 // since we used a persistent connection
 return true;
}

function on_session_read ($key)
{
 global $database;

 $key = MetabaseGetTextFieldValue($database, $key);

 $stmt = SELECT sessionData FROM sessions;
 $stmt .=  WHERE sessionID = $key;
 $stmt .=  AND sessionExpire  . time();

 if (!($result = MetabaseQuery($database, $stmt))) {
   // query failed
   echo ' Main query (sql) failed.'.$e;
   echo ' Error: '.MetabaseError($database).$e;
   die();
 }

 $stmt_rows = MetabaseNumberOfRows($database, $result);

 if ($stmt_rows) {
  $sessionData = MetabaseFetchResult($database, $result, 0, 'sessionData');;
  return($sessionData);
 } else {
  return false;
 }
}

function on_session_write ($key, $val)
{
 global $session_db, $SESS_LIFE;
 global $database;

 // convert the text value to a format suitable for use in current database
 $expiry = time() + $SESS_LIFE;
 $key = MetabaseGetTextFieldValue($database, $key);
 $val = MetabaseGetTextFieldValue($database, $val);

 $replace_stmt = REPLACE INTO sessions (sessionID, sessionData,
sessionExpire)
 . values($key, $val, $expiry);

 $success = MetabaseQuery($database, $replace_stmt);

 return $success;
}

function on_session_destroy ($key)
{
 global $database;

 $key = MetabaseGetTextFieldValue($database, $key);
 $stmt = DELETE FROM sessions WHERE sessionID = $key;
 $success = MetabaseQuery($database, $stmt);
 return $success;
}

function on_session_gc ($max_lifetime)
{
 global $database;

 $stmt = delete from sessions where sessionExpire   . time();
 $success = MetabaseQuery($database, $stmt);
 return $success;
}

// Set the save handlers
session_set_save_handler(on_session_start, on_session_end,
   on_session_read, on_session_write,
   on_session_destroy, on_session_gc);

?

Thanks,
Aral :)

__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Time out Errors?

2001-06-30 Thread Aral Balkan

I've been having the same problem with Apache 1.3.19 / PHP 4.0.5 running on
WinMe -- and not just with my scripts either: phpMyAdmin does it sometimes
too. So, I reckon that the problem is with the configuration.

Has anyone experienced this on Win2000? (I'm in the process of moving my
files to a Win2000 box so I'll you know when I do if the problem repeats.)

Aral :)

__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Fatal Execution Error

2001-06-30 Thread Aral Balkan

Are you doing a database query by chance or anything with sessions? I'm
getting the same errors logged in the Apache logs for something I'm working
on (see my previous posts for details.)

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Filtering out \ when a ' is user entered?

2001-06-28 Thread Aral Balkan

I sent a reply to this earlier but for some reason some of my posts never
make it to the list, so here it is again (hopefully it will post this time,
and only once:)

 The way I do it is to use a function to check if magic quotes are on
(because if they're on the conversion is done automatically for you) and if
they're not, use the AddSlashes function before writing to the database and
use StripSlashes after reading from the database. You can use these two
functions:

function myAddSlashes($st) {
  if (get_magic_quotes_gpc()==1) {
return $st;
  } else {
return AddSlashes($st);
  }
}

function myStripSlashes($st) {
  if (get_magic_quotes_gpc()==1) {
return $st;
  } else {
return StripSlashes($st);
  }
}

Hope this helps,


__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Filtering out \ when a ' is user entered?

2001-06-27 Thread Aral Balkan

The way I do it is to use a function to check if magic quotes are on
(because if they're on the conversion is done automatically for you) and if
they're not, use the AddSlashes function before writing to the database and
use StripSlashes after reading from the database. You can use these two
functions:

function myAddSlashes($st) {
  if (get_magic_quotes_gpc()==1) {
return $st;
  } else {
return AddSlashes($st);
  }
}

function myStripSlashes($st) {
  if (get_magic_quotes_gpc()==1) {
return $st;
  } else {
return StripSlashes($st);
  }
}

Hope this helps,

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] PHP crashing IIS 5 on Wnidows 2K

2001-06-27 Thread Aral Balkan

I would agree, I had PHP 4 installed on IIS running on Win2000 and it was
very unstable. Since switching to Apache, I've had no problems whatsoever --
it's rock solid!

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] search for a better php source code viewer

2001-06-27 Thread Aral Balkan

I second that, EditPlus rules!

It's also very easy to create your own custom syntax highlighting rules,
templates and auto-completes so it can highlight custom libraries, etc. that
you use. For example, if anyone's using Manuel's excellent Metabase database
abstraction class, I've uploaded syntax files, etc. for the XML tags it uses
to describe the database schemas.

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Installation problems with MySQL

2001-06-26 Thread Aral Balkan

Have you tried FoxServ? I think it's a godsent if you're running on
Windows -- installs Apache, PHP and MySQL without a hitch (at least it did
for me!)

-- http://sourceforge.net/projects/foxserv/

Hope this helps.

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Help with simple regular expression

2001-06-26 Thread Aral Balkan

 Yes, Perl is greedy

I was actually using ereg which I believe is POSIX, so POSIX must be greedy
too!

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Help with simple regular expression

2001-06-24 Thread Aral Balkan

Hi all,

I'm trying to match the body tag in an HTML file (eg. body
bgcolor=gg) with the following regular expression and eregi:

body.*

Unfortunately it matches everything from the body tag onwards and doesn't
stop at the greater-than sign. It should be simple thing but I'm stumped! To
me the regex reads match string that begins with body followed by zero or
more of anything and ending with a greater-than sign.

Any help would be greatly appreciated! :)

Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Help with simple regular expression

2001-06-24 Thread Aral Balkan

 (eg. body bgcolor=gg)

Lol... by the way gg must be an interesting color :)

Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] set_magic_quotes_runtime()

2001-06-24 Thread Aral Balkan

Despite what it says (and as far as I know) you *can't* change the state of
magic quotes from within a script. You can, however use a function like
this:

function myAddSlashes($st) {
  if (get_magic_quotes_gpc()==1) {
return $st;
} else {
   return AddSlashes($st);
}
}

Hope this helps,

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] Help with simple regular expression

2001-06-24 Thread Aral Balkan

body[^\]* worked... thanks Kristian...

As I get it -- match body then any number of characters that aren't greater
than signs then a greater than sign -- Is that right? (I'm really trying to
get my head around this regex thing.)

Thanks,

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯



-- 
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] REG_EMPTY error

2001-06-23 Thread Aral Balkan

Hi all,

I'm getting the following error when I try to load complex web pages with a
version of Hans Anderson's class.browser that I've modified to translate
relative links to absolute links (as well as images, flash object / embed
links). It's going to be part of a larger templating class (I'm going to
merge it into Stefan Bocskai Quicktemplate.)

In any case, here's the error I'm getting:

Warning: REG_EMPTY:?empty (sub)expression in
c:\foxserv\www\browser.class\class.browser.php on line 388

On line 388, I'm doing an eregi_replace:
$absolute_links[] = eregi_replace($r[1], $this_url, $array[$i]);

I'd appreciate some help if anyone's run into this problem before.

Thanks, Aral :)



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

2001-06-23 Thread Aral Balkan

As I understand it in PHP the constructor of the parent class is not called
when a child class is initiated.

You can call it manually. Eg., using your example:

class one
{
function one()
{
echo one ;
 }
}

class two extends one
{
function two()
{
one::one();
echo two ;
}
}

class three extends two
{
function three()
{
two::two();
echo three;
}
}

$foo = new three();

$foo should now equal 'one two three'. (:: lets you access functions from
within a class without explicitly declaring a new object).

Hope this helps (PS. The PHP Developer's Cookbook by Sterling Hughes has a
short but good chapter on classes).

Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
??



-- 
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] MySQL Dump In PHP

2001-06-22 Thread Aral Balkan

I use the mysqldump command line utility to do this and I don't know how to
interface that from PHP. However:

I just checked how phpMyAdmin does it and apparently it has functions that
re-create the dump using queries. You might want to download it
(http://www.phpwizard.net/projects/phpMyAdmin/) and check out the files
db_dump.php, tbl_dump.php and db_readdump.php.

Hope this helps!

Aral :)



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