Re: [PHP] Need help with regular expression

2008-07-10 Thread Maxim Antonov

Hello.

But I need no td and tr inside regular expression
It is a part of my templater.


In real code it looks like:
  if(strlen($item[$key])1){
return 
preg_replace('#\{%%%.*?\{%'.$key.'%\}.*?%%%\}#is','',$tpl);

}

if one of $key inside  {%%%  %%%} points to empty array item - all 
section between {%%% %%%} must be deleted.




Daniel Brown :

On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov [EMAIL PROTECTED] wrote:

Hi, all!

I try to use folowing regular expression:
$out =
preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);


[snip!]

I need result as:

trtdNAME:/tdtdinput type=text name=name value=
size=80//td/tr
 trtdFoto:/tdtdinput type=file name=foto value={%foto%} /
 {%%%br/img alt={%name%} src={%foto%}/%%%}
 /td/tr
==REPLACEMENT==

[snip!]

To get it *exactly* as you've mentioned here, use this instead:

?php
$out = 
preg_replace('/trtdBig.*\{%%%.*\{%bigfoto%\}.*%%%\}.*\/tr/Uis','==REPLACEMENT==',$str);
?



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



[PHP] Re: mount

2008-07-09 Thread Maxim Antonov

Hello, Mário

You may use function system!

system('mount -t vfat -o rw /dev/hdb1 /home/www/upload',$err);

if($err){
   echo We have error with number {$err};
}


Mário Gamito :

Hi,

I need to perform a mount and a umount from PHP.

I've searched the manual, but didn't find anything useful.

Any ideas ?

Any help would be appreciated.

Warm Regards,
Mário Gamito



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



Re: [PHP] checking if URL's exist

2008-07-09 Thread Maxim Antonov

You need

$s= fsockopen('host.com',80);

fwrite($s,GET .$URL. HTTP/1.1 \r\n);
fwrite($s,Host: host.com \r\n\r\n);

and you must read first string - if url exists string begining with 200 
or 304

if url not exists string begin - is 404




Børge Holen пишет:

On Wednesday 09 July 2008 12:18:27 [EMAIL PROTECTED] wrote:

Hi All,

I have a Directory table with hundreds of URL's to sites
and want to check periodically if all the URL's still exist.
Does anyone know of a utility to check this ?
Or a pointer to a piece of code ...

TIA, Cor


ping whois traceroute ... and a lot more




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



Re: [PHP] Running mount from PHP

2008-07-09 Thread Maxim Antonov

Try to do folowing
write shell script
#!/bin/sh
mount /dev/hdb /home/mountpoint

then write C code

int main(){
  system (mount.sh);
  return 0;
}

then compile C code
gcc main.c -o wrapper

then chmod  :

# chmod a+s wrapper

and do from php:

system ('wrapper');




Per Jessen пишет:

Mário Gamito wrote:


Hi,

I'm trying to run /bin/mount and /sbin/mount.cifs from a PHP page.

So, I´ve added this to /etc/sudoers:

-
Cmnd_AliasCMD_MOUNT = /bin/mount
Cmnd_AliasCMD_CIFS ) = /sbin/mount.cifs

nobody   ALL = NOPASSWD: CMD_MOUNT
nobody   ALL = NOPASSWD: CMD_CIFS
-

Problem is that I need to run it from PHP and in this way, it doesn't
mount.

I'm using PHP's exec function:
exec(sudo mount -t cifs ...)

I have the ownership and permissions of the mount point set correctly.

As it is a dynamic application, the mount point always changes
(/mnt/user1, /mnt/user2, etc.), so, /etc/fstab is not an option :(

Any ideas ?


Which user are you running your script with?  wwwrun? 



/Per Jessen, Zürich




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



[PHP] strange behavior, when converting float to int

2008-05-06 Thread Maxim Antonov

Hi, all!

Is this a bug?

[EMAIL PROTECTED]:~$ /usr/bin/php 1.php
45
45
float(46)


[EMAIL PROTECTED]:~$ /usr/bin/php -v
PHP 5.3.0-dev (cli) (built: Apr  4 2008 11:37:33)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies


[EMAIL PROTECTED]:~$ cat 1.php
?php
$i = 10.35 + 20.76 + 5.80 + 5.80 + 3.29;
echo (int)$i;
echo \n;
echo intval($i);
echo \n;
var_dump($i);

[EMAIL PROTECTED]:~$


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