php-general Digest 16 Apr 2012 14:20:40 -0000 Issue 7777

Topics (messages 317563 through 317572):

Re: Customized Session Handler can not work for PHP 5.1.6 and CentOS5.5
        317563 by: Mingda
        317564 by: Mingda
        317565 by: Tommy Pham
        317566 by: Alain Williams
        317567 by: Mingda
        317568 by: Mingda
        317569 by: Mingda
        317570 by: Mingda

Re: tempnam() not working as expected...
        317571 by: marco.behnke.biz

Re: php in windows
        317572 by: Steven Staples

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Sorry, wrong stackoverflow link. Here is the correct one:

http://stackoverflow.com/questions/10150296/cant-make-custom-session-save-handler-workno-registered-method-called-in-cent#comment13018050_10150327


And here is the code for session:

<?php
class session
{
  public static function init()
  {
session_set_save_handler('session::open', 'session::close', 'session::read', 'session::write', 'session::destroy', 'session::gc');
  }

  public static function open($save_path, $session_name)
  {
     if (!is_dir($save_path)) {
            mkdir($save_path, 0777);
     }
    return true;
  }

  public static function close()
  {
    return true;
  }

  public static function read($sid)
  {
    global $db, $user;
    register_shutdown_function('session_write_close');
    if (!isset($_COOKIE[session_name()])) {
      $user = anonymousUser($sid);
      return '';
    }
$result = $db->query('SELECT s.data as session_data, s.* , u.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = "' . $db->escape($sid) . '" AND timestamp >= ' . $db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
    $user = $result->row();

    if ($user) {
      $data = $user->session_data;
      unset($user->passwd, $user->session_data);
      if ($user->uid > 0 && $user->status == 1) {
        $userInstance = User_Model::getInstance();
        $user->roles = $userInstance->getUserRoles($user->uid);
        $user->roles[] = User_Model::ROLE_AUTHENTICATED_USER;
        $user->permissions = array();
$user->data = (isset($user->data) && $user->data) ? unserialize($user->data) : array();
        foreach ($user->roles as $rid) {
$user->permissions = array_merge($user->permissions, $userInstance->getRolePermissions($rid));
        }
        $user->permissions = array_unique($user->permissions);
      } else {
        $user = anonymousUser($sid);
      }
      return $data;
    } else {
      $user = anonymousUser($sid);
      return '';
    }
  }

  public static function write($sid, $data)
  {
    global $db, $user;
if (!isset($user) || ($user->uid == 0 && empty($_COOKIE[session_name()]) && empty($data))) {
      return true;
    }
    $uri = '/' . Bl_Core::getUri();
$db->exec('UPDATE sessions SET uid = ' . $db->escape($user->uid) . ', ip = "' . $db->escape(ipAddress()) . '", uri = "' . $db->escape($uri) . '", data = "' . $db->escape($data) . '", timestamp = ' .
      $db->escape(TIMESTAMP) . ' WHERE sid = "' . $db->escape($sid) . '"');
    if (!$db->affected()) {
$db->exec('INSERT IGNORE INTO sessions (sid, uid, ip, uri, data, timestamp) VALUES ("' . $db->escape($sid) . '", ' . $db->escape($user->uid) . ', "' . $db->escape(ipAddress()) . '", "' . $db->escape($uri) . '", "' .
        $db->escape($data) . '", ' . $db->escape(TIMESTAMP) . ')');
    }
    return true;
  }

  public static function destroy($sid)
  {
    global $db;
$db->exec('DELETE FROM sessions WHERE sid = "' . $db->escape($sid) . '"');
    return true;
  }

  public static function gc($lifetime)
  {
    global $db;
$db->exec('DELETE FROM sessions WHERE timestamp < ' . $db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
    return true;
  }

  public static function count($timestamp = 0, $hasAnonymous = true)
  {
    global $db;
    if (!$hasAnonymous) {
      $cond = ' AND uid > 0';
    } else {
      $cond = '';
    }
$result = $db->query('SELECT COUNT(0) FROM sessions WHERE timestamp > ' . $timestamp . $cond);
    return $result->one();
  }
}



On 2012/4/15 14:53, Mingda wrote:
Hi, All,

I can't see the post I sent several hours ago, if repeated, please reply
to this one. Thanks!

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID


And the bottom are the code for the session handler. I first called
ob_start(), and after calling session::init(), I called session_start().
Then the fatal error happen. It did not trigger any function in the
"session" class.

I tried change the php.ini from session.save_handler = user, but the
error remains. And I found no matter what session.save_handler type is,
after calling session_set_save_handler(), the session.save_handler will
always automatically changed to 'user', that's why the Fatal error info
shows user (path: /tmp).

Can anybody help me out for such error? I was stuck by this issue for
more than 2 days, but still haven't get any clue!

You can view more details from stackoverflow if you want. Here is the link:
http://stackoverflow.com/questions/8845924/session-set-save-handler-class-for-database-not-working



--- End Message ---
--- Begin Message ---
Sorry, wrong stackoverflow link. Here is the correct one:

http://stackoverflow.com/questions/10150296/cant-make-custom-session-save-handler-workno-registered-method-called-in-cent#comment13018050_10150327


And here is the code for session:

<?php
class session
{
  public static function init()
  {
session_set_save_handler('session::open', 'session::close', 'session::read', 'session::write', 'session::destroy', 'session::gc');
  }

  public static function open($save_path, $session_name)
  {
     if (!is_dir($save_path)) {
            mkdir($save_path, 0777);
     }
    return true;
  }

  public static function close()
  {
    return true;
  }

  public static function read($sid)
  {
    global $db, $user;
    register_shutdown_function('session_write_close');
    if (!isset($_COOKIE[session_name()])) {
      $user = anonymousUser($sid);
      return '';
    }
$result = $db->query('SELECT s.data as session_data, s.* , u.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = "' . $db->escape($sid) . '" AND timestamp >= ' . $db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
    $user = $result->row();

    if ($user) {
      $data = $user->session_data;
      unset($user->passwd, $user->session_data);
      if ($user->uid > 0 && $user->status == 1) {
        $userInstance = User_Model::getInstance();
        $user->roles = $userInstance->getUserRoles($user->uid);
        $user->roles[] = User_Model::ROLE_AUTHENTICATED_USER;
        $user->permissions = array();
$user->data = (isset($user->data) && $user->data) ? unserialize($user->data) : array();
        foreach ($user->roles as $rid) {
$user->permissions = array_merge($user->permissions, $userInstance->getRolePermissions($rid));
        }
        $user->permissions = array_unique($user->permissions);
      } else {
        $user = anonymousUser($sid);
      }
      return $data;
    } else {
      $user = anonymousUser($sid);
      return '';
    }
  }

  public static function write($sid, $data)
  {
    global $db, $user;
if (!isset($user) || ($user->uid == 0 && empty($_COOKIE[session_name()]) && empty($data))) {
      return true;
    }
    $uri = '/' . Bl_Core::getUri();
$db->exec('UPDATE sessions SET uid = ' . $db->escape($user->uid) . ', ip = "' . $db->escape(ipAddress()) . '", uri = "' . $db->escape($uri) . '", data = "' . $db->escape($data) . '", timestamp = ' .
      $db->escape(TIMESTAMP) . ' WHERE sid = "' . $db->escape($sid) . '"');
    if (!$db->affected()) {
$db->exec('INSERT IGNORE INTO sessions (sid, uid, ip, uri, data, timestamp) VALUES ("' . $db->escape($sid) . '", ' . $db->escape($user->uid) . ', "' . $db->escape(ipAddress()) . '", "' . $db->escape($uri) . '", "' .
        $db->escape($data) . '", ' . $db->escape(TIMESTAMP) . ')');
    }
    return true;
  }

  public static function destroy($sid)
  {
    global $db;
$db->exec('DELETE FROM sessions WHERE sid = "' . $db->escape($sid) . '"');
    return true;
  }

  public static function gc($lifetime)
  {
    global $db;
$db->exec('DELETE FROM sessions WHERE timestamp < ' . $db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
    return true;
  }

  public static function count($timestamp = 0, $hasAnonymous = true)
  {
    global $db;
    if (!$hasAnonymous) {
      $cond = ' AND uid > 0';
    } else {
      $cond = '';
    }
$result = $db->query('SELECT COUNT(0) FROM sessions WHERE timestamp > ' . $timestamp . $cond);
    return $result->one();
  }
}



On 2012/4/15 14:53, Mingda wrote:
Hi, All,

I can't see the post I sent several hours ago, if repeated, please reply
to this one. Thanks!

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID


And the bottom are the code for the session handler. I first called
ob_start(), and after calling session::init(), I called session_start().
Then the fatal error happen. It did not trigger any function in the
"session" class.

I tried change the php.ini from session.save_handler = user, but the
error remains. And I found no matter what session.save_handler type is,
after calling session_set_save_handler(), the session.save_handler will
always automatically changed to 'user', that's why the Fatal error info
shows user (path: /tmp).

Can anybody help me out for such error? I was stuck by this issue for
more than 2 days, but still haven't get any clue!

You can view more details from stackoverflow if you want. Here is the link:
http://stackoverflow.com/questions/8845924/session-set-save-handler-class-for-database-not-working



--- End Message ---
--- Begin Message ---
On Sat, Apr 14, 2012 at 9:27 AM, Mingda <mingda...@gmail.com> wrote:
> Hi, All,
>
> System: CentOS 5.5; PHP version is 5.1.6.
>
> I met a strange problem associate with session_save_handler in current
> environment(The same code can work well in my local windows platform and
> ubuntu system).
>

This is your clue on how to fix.  What version of PHP are on Windows
and Ubuntu?  If different, perhaps upgrade your CentOS' PHP?  If the
same exact version on all 3 OSes, then consult CentOS :).

HTH,
Tommy

--- End Message ---
--- Begin Message ---
On Sun, Apr 15, 2012 at 12:27:00AM +0800, Mingda wrote:
> Hi, All,
> 
> System: CentOS 5.5; PHP version is 5.1.6.
> 
> I met a strange problem associate with session_save_handler in current 
> environment(The same code can work well in my local windows platform and 
> ubuntu system).
> 
> I just want to use a customized session save handler to be triggered, so 
> that I can call my own logic to handling the session. The testing in 
> local is pretty great but when migration to the VPS, it bring me the 
> following error:
> 
> Fatal error: session_start() [<a 
> href='function.session-start'>function.session-start</a>]: Failed to 
> initialize storage module: user (path: /tmp)
> 
> 
> The default value for session save handler and session save path in 
> php.ini are:
> 
> session.save_handler = files
> session.save_path = "/tmp"
> session.name = PHPSESSID

Try changing the path to /var/lib/php/session

Are you being caught by selinux - try
        setenforce off
and see if that makes it work.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>

--- End Message ---
--- Begin Message --- Hi, Thanks, it's originally is /var/lib/php/session, I double it's privilege problem, so changed to /tmp.

And I Followed your advice for setenforce off, but can't make it work.

Mingda

On 2012/4/16 14:13, Alain Williams wrote:
On Sun, Apr 15, 2012 at 12:27:00AM +0800, Mingda wrote:
Hi, All,

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID

Try changing the path to /var/lib/php/session

Are you being caught by selinux - try
        setenforce off
and see if that makes it work.



--- End Message ---
--- Begin Message --- Hi, Thanks, it's originally is /var/lib/php/session, I double it's privilege problem, so changed to /tmp.

And I Followed your advice for setenforce off, but can't make it work.

Mingda

On 2012/4/16 14:13, Alain Williams wrote:
On Sun, Apr 15, 2012 at 12:27:00AM +0800, Mingda wrote:
Hi, All,

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID

Try changing the path to /var/lib/php/session

Are you being caught by selinux - try
        setenforce off
and see if that makes it work.



--- End Message ---
--- Begin Message ---
Sorry, wrong link provided, correct link is:

http://stackoverflow.com/questions/10150296/cant-make-custom-session-save-handler-workno-registered-method-called-in-cent#comment13018050_10150327




On 2012/4/15 0:27, Mingda wrote:
Hi, All,

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID


And the bottom are the code for the session handler. I first called
ob_start(), and after calling session::init(), I called session_start().
Then the fatal error happen. It did not trigger any function in the
"session" class.

I tried change the php.ini from session.save_handler = user, but the
error remains. And I found no matter what session.save_handler type is,
after calling session_set_save_handler(), the session.save_handler will
always automatically changed to 'user', that's why the Fatal error info
shows user (path: /tmp).

Can anybody help me out for such error? I was stuck by this issue for
more than 2 days, but still haven't get any clue!

You can view more details from stackoverflow if you want. Here is the link:
http://stackoverflow.com/questions/8845924/session-set-save-handler-class-for-database-not-working



<?php
class session
{
public static function init()
{
session_set_save_handler('session::open', 'session::close',
'session::read', 'session::write', 'session::destroy', 'session::gc');
}

public static function open($save_path, $session_name)
{
if (!is_dir($save_path)) {
mkdir($save_path, 0777);
}
return true;
}

public static function close()
{
return true;
}

public static function read($sid)
{
global $db, $user;
register_shutdown_function('session_write_close');
if (!isset($_COOKIE[session_name()])) {
$user = anonymousUser($sid);
return '';
}
$result = $db->query('SELECT s.data as session_data, s.* , u.* FROM
users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = "' .
$db->escape($sid) .
'" AND timestamp >= ' . $db->escape(TIMESTAMP -
Bl_Config::get('session.lifetime', 10800)));
$user = $result->row();

if ($user) {
$data = $user->session_data;
unset($user->passwd, $user->session_data);
if ($user->uid > 0 && $user->status == 1) {
$userInstance = User_Model::getInstance();
$user->roles = $userInstance->getUserRoles($user->uid);
$user->roles[] = User_Model::ROLE_AUTHENTICATED_USER;
$user->permissions = array();
$user->data = (isset($user->data) && $user->data) ?
unserialize($user->data) : array();
foreach ($user->roles as $rid) {
$user->permissions = array_merge($user->permissions,
$userInstance->getRolePermissions($rid));
}
$user->permissions = array_unique($user->permissions);
} else {
$user = anonymousUser($sid);
}
return $data;
} else {
$user = anonymousUser($sid);
return '';
}
}

public static function write($sid, $data)
{
global $db, $user;
if (!isset($user) || ($user->uid == 0 && empty($_COOKIE[session_name()])
&& empty($data))) {
return true;
}
$uri = '/' . Bl_Core::getUri();
$db->exec('UPDATE sessions SET uid = ' . $db->escape($user->uid) . ', ip
= "' . $db->escape(ipAddress()) .
'", uri = "' . $db->escape($uri) . '", data = "' . $db->escape($data) .
'", timestamp = ' .
$db->escape(TIMESTAMP) . ' WHERE sid = "' . $db->escape($sid) . '"');
if (!$db->affected()) {
$db->exec('INSERT IGNORE INTO sessions (sid, uid, ip, uri, data,
timestamp) VALUES ("' . $db->escape($sid) .
'", ' . $db->escape($user->uid) . ', "' . $db->escape(ipAddress()) . '",
"' . $db->escape($uri) . '", "' .
$db->escape($data) . '", ' . $db->escape(TIMESTAMP) . ')');
}
return true;
}

public static function destroy($sid)
{
global $db;
$db->exec('DELETE FROM sessions WHERE sid = "' . $db->escape($sid) .. '"');
return true;
}

public static function gc($lifetime)
{
global $db;
$db->exec('DELETE FROM sessions WHERE timestamp < ' .
$db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
return true;
}

public static function count($timestamp = 0, $hasAnonymous = true)
{
global $db;
if (!$hasAnonymous) {
$cond = ' AND uid > 0';
} else {
$cond = '';
}
$result = $db->query('SELECT COUNT(0) FROM sessions WHERE timestamp > '
. $timestamp . $cond);
return $result->one();
}
}






--- End Message ---
--- Begin Message ---
Sorry, wrong link provided, correct link is:

http://stackoverflow.com/questions/10150296/cant-make-custom-session-save-handler-workno-registered-method-called-in-cent#comment13018050_10150327




On 2012/4/15 0:27, Mingda wrote:
Hi, All,

System: CentOS 5.5; PHP version is 5.1.6.

I met a strange problem associate with session_save_handler in current
environment(The same code can work well in my local windows platform and
ubuntu system).

I just want to use a customized session save handler to be triggered, so
that I can call my own logic to handling the session. The testing in
local is pretty great but when migration to the VPS, it bring me the
following error:

Fatal error: session_start() [<a
href='function.session-start'>function.session-start</a>]: Failed to
initialize storage module: user (path: /tmp)


The default value for session save handler and session save path in
php.ini are:

session.save_handler = files
session.save_path = "/tmp"
session.name = PHPSESSID


And the bottom are the code for the session handler. I first called
ob_start(), and after calling session::init(), I called session_start().
Then the fatal error happen. It did not trigger any function in the
"session" class.

I tried change the php.ini from session.save_handler = user, but the
error remains. And I found no matter what session.save_handler type is,
after calling session_set_save_handler(), the session.save_handler will
always automatically changed to 'user', that's why the Fatal error info
shows user (path: /tmp).

Can anybody help me out for such error? I was stuck by this issue for
more than 2 days, but still haven't get any clue!

You can view more details from stackoverflow if you want. Here is the link:
http://stackoverflow.com/questions/8845924/session-set-save-handler-class-for-database-not-working



<?php
class session
{
public static function init()
{
session_set_save_handler('session::open', 'session::close',
'session::read', 'session::write', 'session::destroy', 'session::gc');
}

public static function open($save_path, $session_name)
{
if (!is_dir($save_path)) {
mkdir($save_path, 0777);
}
return true;
}

public static function close()
{
return true;
}

public static function read($sid)
{
global $db, $user;
register_shutdown_function('session_write_close');
if (!isset($_COOKIE[session_name()])) {
$user = anonymousUser($sid);
return '';
}
$result = $db->query('SELECT s.data as session_data, s.* , u.* FROM
users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = "' .
$db->escape($sid) .
'" AND timestamp >= ' . $db->escape(TIMESTAMP -
Bl_Config::get('session.lifetime', 10800)));
$user = $result->row();

if ($user) {
$data = $user->session_data;
unset($user->passwd, $user->session_data);
if ($user->uid > 0 && $user->status == 1) {
$userInstance = User_Model::getInstance();
$user->roles = $userInstance->getUserRoles($user->uid);
$user->roles[] = User_Model::ROLE_AUTHENTICATED_USER;
$user->permissions = array();
$user->data = (isset($user->data) && $user->data) ?
unserialize($user->data) : array();
foreach ($user->roles as $rid) {
$user->permissions = array_merge($user->permissions,
$userInstance->getRolePermissions($rid));
}
$user->permissions = array_unique($user->permissions);
} else {
$user = anonymousUser($sid);
}
return $data;
} else {
$user = anonymousUser($sid);
return '';
}
}

public static function write($sid, $data)
{
global $db, $user;
if (!isset($user) || ($user->uid == 0 && empty($_COOKIE[session_name()])
&& empty($data))) {
return true;
}
$uri = '/' . Bl_Core::getUri();
$db->exec('UPDATE sessions SET uid = ' . $db->escape($user->uid) . ', ip
= "' . $db->escape(ipAddress()) .
'", uri = "' . $db->escape($uri) . '", data = "' . $db->escape($data) .
'", timestamp = ' .
$db->escape(TIMESTAMP) . ' WHERE sid = "' . $db->escape($sid) . '"');
if (!$db->affected()) {
$db->exec('INSERT IGNORE INTO sessions (sid, uid, ip, uri, data,
timestamp) VALUES ("' . $db->escape($sid) .
'", ' . $db->escape($user->uid) . ', "' . $db->escape(ipAddress()) . '",
"' . $db->escape($uri) . '", "' .
$db->escape($data) . '", ' . $db->escape(TIMESTAMP) . ')');
}
return true;
}

public static function destroy($sid)
{
global $db;
$db->exec('DELETE FROM sessions WHERE sid = "' . $db->escape($sid) .. '"');
return true;
}

public static function gc($lifetime)
{
global $db;
$db->exec('DELETE FROM sessions WHERE timestamp < ' .
$db->escape(TIMESTAMP - Bl_Config::get('session.lifetime', 10800)));
return true;
}

public static function count($timestamp = 0, $hasAnonymous = true)
{
global $db;
if (!$hasAnonymous) {
$cond = ' AND uid > 0';
} else {
$cond = '';
}
$result = $db->query('SELECT COUNT(0) FROM sessions WHERE timestamp > '
. $timestamp . $cond);
return $result->one();
}
}






--- End Message ---
--- Begin Message ---

tamouse mailing lists <tamouse.li...@gmail.com> hat am 14. April 2012 um
00:05 geschrieben:

> Can someone explain the following to me:
>
>
> <?php
> $d=tempnam(".","dir");                 /* create a temp named file *

> unlink($d);                         /* unlink it because we're going to
make it a directory */
> mkdir($d,777,true);                /* make the directory */
> echo "$d is ". (is_dir($d)?'':'NOT')." a directory\n";
>
>
> $f=tempnam($d,"file");                /* using the first directory,
create a new
> temp named file */
> unlink($f);                        /* unlink it as we're going to make it
a directory */
> mkdir($f,777,true);                /* make the directory */
> echo "$f is ". (is_dir($f)?'':'NOT')." a directory\n";
> ?>
>
> /Users/tamara/Sites/gallery/lib/common/t/dirGuWOLW is  a directory
> /private/var/folders/pI/pIx-p0mhH5eEQ64yAiDQmE+++TI/-Tmp-/fileC7Rnzg
> is  a directory

Could you do an "ls -la" for both files and send the output?
Try using "mkdir($d, 0777, true);"


>
> Why isn't the second tempnam using the directory path I pass to it?
>
> The strange thing I notice is that if I pass in a directory path to
> tempnam that was NOT created initially by tempnam, it works:
>
> miishka:t tamara$ mkdir a
> miishka:t tamara$ php -r 'echo
> tempnam("/Users/tamara/Sites/gallery/lib/common/t/a","file").PHP_EOL;'
> /Users/tamara/Sites/gallery/lib/common/t/a/filepSwRzF
> miishka:t tamara$
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Kirk Bailey [mailto:kbai...@howlermonkey.net]
> Sent: April 11, 2012 10:11 PM
> To: php-gene...@lists.php.net
> Subject: Re: [PHP] Re: php in windows
> 
> Steve, THERE IS NO SUCH FILE in tinyweb. It turns to the operating system
> asspciations to determine what to use to process the cgi, then captures
the
> returned stdio output and feeds THAT back as part of the data stream back
> down the stack. Therefore, it is not interfacing with the windows
operating
> system properly, and as I do not speak delphi, I am not sure how to go
> through the sourcecode and rectify this.
> If you like, I cna provide a link to the installer that adds it to a
> windows computer so you can take a look- if you or anyone else is
> interested. Oddly enough, it appears to handle python fine, and is
reported
> by others to also handle perl.
> > Kirk,
> >
> > You have to tell your "tinyweb" what to do with the .php extensions...
> > in the config of the webserver, you will have to add a line saying
> > where the php binary is, or uncomment it (as it probably already
> > exists) and restart the webserver.
> >
> >
> > As it appears to me, since you can have some "code" on the screen,
> > your server does not know how to deal with it, so it will treat it like
a
> text
> > file, and just spew the code out.   Once you have it pointing to the php
> > binary, it will work.
> >
> > Good luck!
> >
> > Steve Staples.
> >
> >

Sorry, I have been out of the office for the last few days... have you
gotten this to work?

As a suggestion, is PHP in the windows path?   If not, then this may be the
issue... Python may have been installed, and put the exe in the PATH
variable, where PHP may not have done it (not sure, I personally use XAMPP
on my windows box for quick development)

Check the PATH from the dos prompt, and if it is not in there, then you will
have to add it (I am just guessing here)

Just in case you're not sure where it is, on my XP machine, I just right
click on "My Computer", click "Properties" and then on the "Advanced" tab,
there is a button labelled "Environment Variables" and then add the path to
the PHP exe...

Hope that this helps!

 
Steven Staples


--- End Message ---

Reply via email to