php-windows Digest 27 Apr 2004 08:17:08 -0000 Issue 2227

Topics (messages 23544 through 23558):

modifying a substring
        23544 by: John Yu
        23546 by: William CANDILLON
        23547 by: William CANDILLON
        23553 by: Jason Barnett
        23557 by: Jason Barnett

Re PEAR
        23545 by: sudar
        23554 by: Jason Barnett

using filemtime
        23548 by: Harpreet
        23550 by: William CANDILLON

most latest file
        23549 by: Harpreet
        23556 by: Jason Barnett

PHP and Authentication
        23551 by: Kc2LTO - Andrew Ragone
        23555 by: Jason Barnett

Order By........
        23552 by: Will
        23558 by: De Greef S�bastien

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi guys
 
I want to do some fancy syntax highlighting so I added <code> </code> to my
input text.
 
Is there a way to take the entire input text, but only take the substring
between those tags, do something to the substring and put it back into the
original text?
 
Thanks in advance
 
John 

--- End Message ---
--- Begin Message ---
Use xml_parse_into_struct () :

<?
$string = Ur_contents
$ xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $string, $ vals, $ index);
xml_parser_free($xml_parser);
highlight_string($vals['0']['value']);
?>

To show the code out the <code></code> :

<?
$string = Ur_contents
$i = 1;
$fp = fread($string, $i);
While (eregi("<code>", $fp)== false) {
++$i
$fp = fread($string, $i);
}
$txt = substr ($fp, -6);
Echo ($txt);
?>


-----Message d'origine-----
De�: John Yu [mailto:[EMAIL PROTECTED] 
Envoy�: lundi 26 avril 2004 18:44
��: [EMAIL PROTECTED]
Objet�: [PHP-WIN] modifying a substring

Hi guys
 
I want to do some fancy syntax highlighting so I added <code> </code> to my
input text.
 
Is there a way to take the entire input text, but only take the substring
between those tags, do something to the substring and put it back into the
original text?
 
Thanks in advance
 
John 

--- End Message ---
--- Begin Message ---
Or:

<?
$string = Ur_contents;
$text = implode ('<code>', $string);
Echo ($text[0]);
?>
 
-----Message d'origine-----
De�: William CANDILLON [mailto:[EMAIL PROTECTED] 
Envoy�: lundi 26 avril 2004 21:16
��: [EMAIL PROTECTED]
Objet�: RE: [PHP-WIN] modifying a substring


Use xml_parse_into_struct () :

<?
$string = Ur_contents
$ xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $string, $ vals, $ index);
xml_parser_free($xml_parser);
highlight_string($vals['0']['value']);
?>

To show the code out the <code></code> :

<?
$string = Ur_contents
$i = 1;
$fp = fread($string, $i);
While (eregi("<code>", $fp)== false) {
++$i
$fp = fread($string, $i);
}
$txt = substr ($fp, -6);
Echo ($txt);
?>


-----Message d'origine-----
De�: John Yu [mailto:[EMAIL PROTECTED] 
Envoy�: lundi 26 avril 2004 18:44
��: [EMAIL PROTECTED]
Objet�: [PHP-WIN] modifying a substring

Hi guys
 
I want to do some fancy syntax highlighting so I added <code> </code> to my
input text.
 
Is there a way to take the entire input text, but only take the substring
between those tags, do something to the substring and put it back into the
original text?
 
Thanks in advance
 
John 

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

--- End Message ---
--- Begin Message --- John Yu wrote:
Hi guys
I want to do some fancy syntax highlighting so I added <code> </code> to my
input text.
Is there a way to take the entire input text, but only take the substring
between those tags, do something to the substring and put it back into the
original text?
Thanks in advance
John



PHP has a built in syntax-highlighting function, so you could use that along with preg_replace to highlight the code. You could also use ini_set() to change the color values if you don't have access to php.ini directly.


http://www.php.net/highlight_string

Even if you don't want to use the built-in function, preg_replace is probably the best way to do what you want to do.
--- End Message ---
--- Begin Message ---
William Candillon wrote:

Use xml_parse_into_struct () :

<?
$string = Ur_contents
$ xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $string, $ vals, $ index);
xml_parser_free($xml_parser);
highlight_string($vals['0']['value']);
?>

I was going to suggest preg_replace, but I kind of like xml_parse_into_struct(). But, won't they have a problem if there's no root tags wrapping the entire string?



To show the code out the <code></code> :

<?
$string = Ur_contents
$i = 1;
$fp = fread($string, $i);
While (eregi("<code>", $fp)== false) {
++$i
$fp = fread($string, $i);
}
$txt = substr ($fp, -6);
Echo ($txt);
?>

--- End Message ---
--- Begin Message ---
Hai Janson

Thanks for responding. The problem with me is that,
right now I don't
have access to the server. I have just got a virtual
directory in which
I have to upload my files and execute. And recently I
heard about PEAR
and how it simplies the job, but I cannot explain this
to my Sys Admin
as he will not allow me to access the server or change
any
configuration.

In this situation will PEAR will be of any help to me
? and also I
cannot predict my Production Server. What I can ask
for is only a PHP
installation with default configuration.

So can I use PEAR without configuring anything In the
server, with
default PHP installation.

Thnks in advance for any help

With regards
Sudar




        
                
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25�
http://photos.yahoo.com/ph/print_splash

--- End Message ---
--- Begin Message ---
Sudar wrote:

Hai Janson

Thanks for responding. The problem with me is that,
right now I don't
have access to the server. I have just got a virtual
directory in which
I have to upload my files and execute. And recently I

PEAR files could be put under your document root, you don't *have* to have access to the server and put them elsewhere. It's just that if your sysadmin wanted to offer PEAR to a lot of people then he could save all of you from having redundant / non-updated PEAR installations.


heard about PEAR
and how it simplies the job, but I cannot explain this
to my Sys Admin
as he will not allow me to access the server or change
any
configuration.

In this situation will PEAR will be of any help to me
? and also I
cannot predict my Production Server. What I can ask
for is only a PHP
installation with default configuration.

So can I use PEAR without configuring anything In the
server, with
default PHP installation.

Yes, you can use a default PHP installation and use PEAR. It uses its own configuration file to manage the system and once you get PEAR set up adding new packages is easy, almost tooo easy :) There is also a web interface to install and maintain PEAR packages, so you don't need to have access to the shell. The web interface is nice, it makes it easy to see what's going on (what version of a package you have and the most recent version are displayed).



Thnks in advance for any help

With regards
Sudar




__________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25� http://photos.yahoo.com/ph/print_splash

--- End Message ---
--- Begin Message ---
The filemtime works for the following but the minute i use a server name as
my direcotry path it gives me an error Warning: filemtime(): Stat failed for
\\servername\c (errno=2 - No such file or directory) in

Like this works
$dir='c:\backups';
echo date("m-d-y H:i:s",filemtime($dir));

if i change the $dir to
$dir='\\servername\c\backups';
echo date("m-d-y H:i:s",filemtime($dir));

it fails

help is appreciated

Thanks

Regards,
Harpreet Kaur

--- End Message ---
--- Begin Message ---
If the code which execute the code is at c:\ : $dir = '/backups' 

-----Message d'origine-----
De�: Harpreet [mailto:[EMAIL PROTECTED] 
Envoy�: lundi 26 avril 2004 22:29
��: [EMAIL PROTECTED]
Objet�: [PHP-WIN] using filemtime

The filemtime works for the following but the minute i use a server name as
my direcotry path it gives me an error Warning: filemtime(): Stat failed for
\\servername\c (errno=2 - No such file or directory) in

Like this works
$dir='c:\backups';
echo date("m-d-y H:i:s",filemtime($dir));

if i change the $dir to
$dir='\\servername\c\backups';
echo date("m-d-y H:i:s",filemtime($dir));

it fails

help is appreciated

Thanks

Regards,
Harpreet Kaur

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

--- End Message ---
--- Begin Message ---
Actually I have a backups folder that gets once a day backups of the
database automaticcaly. I want to be able to know the name fo the the latest
file to do the restore. The name of the files have the time stamp and plus
file has a time last mdified date attached to it.

How can I know which file got restored last using php and also the file
name.

Thanks

--- End Message ---
--- Begin Message ---
Harpreet wrote:

Actually I have a backups folder that gets once a day backups of the
database automaticcaly. I want to be able to know the name fo the the latest
file to do the restore. The name of the files have the time stamp and plus
file has a time last mdified date attached to it.

How can I know which file got restored last using php and also the file
name.

Thanks

<?php

$directory = 'path/to/backups/directory';

$handle = opendir($directory) {
while (false !== ($file = readdir($handle))) {
  if ($file != "." && $file != ".." && fileatime($file) > $time) {
    $time = fileatime($file);
    $lastModifiedFile = $file;
  }
}

closedir($handle);
echo $lastModifiedFile;

?>

http://www.php.net/readdir
http://www.php.net/manual/en/function.fileatime.php

or, to check file creation times:

http://www.php.net/manual/en/function.filectime.php
--- End Message ---
--- Begin Message ---
Hello, one of the servers I am working on is being switched from UNIX to
Windows. There is nothing I can do about this but I am wondering how to get
the former USER_AUTH and such variables to work with IIS through a popup
login window. I noticed that it still works with PhpMyAdmin.

 

Thanks

______________

Andrew Ragone

Kc2LTO

www.lifeonedge.com

201.406.0298

 

 


--- End Message ---
--- Begin Message ---
Kc2lto - Andrew Ragone wrote:

Hello, one of the servers I am working on is being switched from UNIX to
Windows. There is nothing I can do about this but I am wondering how to get
the former USER_AUTH and such variables to work with IIS through a popup
login window. I noticed that it still works with PhpMyAdmin.

Well, did you read the manual? http://www.php.net/features.http-auth

If you wanted to, you could just define the constants yourself and leave the rest of the script alone. For example with the ISAPI modules:

if (!defined (PHP_AUTH_PW) && !defined (PHP_AUTH_USER)) {
list($user, $pw) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
define ('PHP_AUTH_PW', $pw);
define ('PHP_AUTH_USER', $user);
}





Thanks

______________

Andrew Ragone

Kc2LTO

www.lifeonedge.com

201.406.0298







--- End Message ---
--- Begin Message ---
Hello All,
I have a question regarding the order by:

Here is my code:
$get_post = "select * from $table_name2 where cat_id =
'$_POST[cat_id]' ORDER BY posted";

It is not taking the last post and putting it first. I
think there is something else I have to put there but
I cannot figure it out. Can someone help.


        
                
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

--- End Message ---
--- Begin Message ---
you must add the Order like ASC for upwards and DESC for descending order
"select * from $table_name2 where cat_id =
> '$_POST[cat_id]' ORDER BY posted DESC";

DESC will show from the last to the fiirst post from today to last week....
Regards


"Will" <[EMAIL PROTECTED]> a �crit dans le message news:
[EMAIL PROTECTED]
> Hello All,
> I have a question regarding the order by:
>
> Here is my code:
> $get_post = "select * from $table_name2 where cat_id =
> '$_POST[cat_id]' ORDER BY posted";
>
> It is not taking the last post and putting it first. I
> think there is something else I have to put there but
> I cannot figure it out. Can someone help.
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover


--- End Message ---

Reply via email to