php-general Digest 29 Aug 2007 11:43:55 -0000 Issue 4988

Topics (messages 261431 through 261447):

Background Image
        261431 by: Jeff
        261433 by: Al
        261438 by: Per Jessen

Re: Adding text before last paragraph
        261432 by: Dotan Cohen

Re: Database includes
        261434 by: Larry Garfield
        261435 by: brian
        261436 by: Chris

Re: Problems with matrix
        261437 by: Felipe Alcacibar

How to show proper time to users from around the world
        261439 by: Hemanth
        261440 by: mike

Socket takes a long time to 'finish'
        261441 by: Alvar Saenz-Otero
        261443 by: Eddie Dunckley

How to run and terminate C++ program(*.exe) with PHP?
        261442 by: Aram Shatakhtsyan
        261447 by: shiplu

Heredocs
        261444 by: RodgerW
        261445 by: RodgerW

Re: Trying to understand sessions and using them to authenticate...
        261446 by: Ford, Mike

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 ---
<body background="../images/bkgrnds/shot04.JPG" link="#00FF00" 
vlink="#FFFF00" alink="#00FFFF">

is how I am displaying my background image. This is creating problems for 
different screen resolutions.

What would be the appropriate way to display this code so the image would 
not scroll, resize to the users current screen resolutions and just the page 
content would scroll?

TYIA! 

--- End Message ---
--- Begin Message ---
You are in the wrong newsgroup.  Try the HTML newsgroup

Jeff wrote:
<body background="../images/bkgrnds/shot04.JPG" link="#00FF00" vlink="#FFFF00" alink="#00FFFF">

is how I am displaying my background image. This is creating problems for different screen resolutions.

What would be the appropriate way to display this code so the image would not scroll, resize to the users current screen resolutions and just the page content would scroll?

TYIA!

--- End Message ---
--- Begin Message ---
Jeff wrote:

> What would be the appropriate way to display this code so the image
> would not scroll, resize to the users current screen resolutions and
> just the page content would scroll?

This list is about PHP, and probably not the best place to ask that
question, but you need to look at CSS and javascript. 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
On 28/08/07, Brian Rue <[EMAIL PROTECTED]> wrote:
> Sure, I'll break it apart a little:

Er, wow, thanks. Lots of material here...

> '{(?=<p(?:>|\s)(?!.*<p(?:>|\s)))}is'
>
> $regex = '{' .     // opening delimeter
>          '(?=' .   // positive lookahead: match the beginning of a position
>                    // that matches the following pattern:
>              '<p' .  // first part of an opening <p> tag
>                  '(?:' . // non-capturing parenthesis (same as normal
>                          // parenthesis, but a bit faster since we don't
>                          // need to capture what they match for use later
>                  '>|\s' . // match a closing > or a space
>                  ')' . // end capturing paranthesis
>                  '(?!' . // negative lookahead: the match will fail if the
> //following pattern matches from the current position
>                  '.*' .  // match until the end of the string
>                  '<p(?:>|\s)' . // same as above - look for another <p> tag
>                  ')' .  // end negative lookahead
>          ')' .      // end positive lookahead
>          '}is';   // ending delimeter, and use modifiers s and i

It was the negative lookahead that confused me, I see. The rest seems
pretty straightforward. Difficult, but straightforward.

>
> About the modifiers: i makes it case-insensitive, and s turns on
> dot-matches-all-mode (including newlines)--otherwise, the . would only match
> until the next newline.

Yes, this I know.

> The regex has two parts: matching a <p> tag, and then making sure there
> aren't any more <p> tags in the string following it. The positive lookahead
> is (hopefully) pretty straightforward. The negative lookahead works by using
> a greedy (regular) .*, which forces the regex engine to match all the way to
> the end of the haystack. Then it encounters the <p(?:>\s) part, forcing it
> to backtrack until it finds a <p> tag. If it doesn't find one before
> returning to the 'current' position (directly after the <p> tag we just
> matched), then we know we have found the last <p> tag.

Nice. Very nice.

> The positive and negative lookahead are 'zero-width' requirements, which
> means they don't advance the regex engine's pointer in the haystack string.
> Since the entire regex is zero-width, the replacement string gets inserted
> at the matched position.

Hmm.

> I hope that made at least a little bit of sense :) If you're doing a lot of
> regex work, I would strongly recommend reading the book Mastering Regular
> Expressions by Jeffrey Friedl... it's very well written and very helpful.

I don't do a lot, but it's a great tool to know when one needs it!
Thank you for the patient explanations.

Just a general note, both these addresses are 404 right now:
http://il.php.net/manual/en/pcre.pattern.modifiers.php
http://uk.php.net/manual/en/pcre.pattern.syntax.php

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

--- End Message ---
--- Begin Message ---
On Tuesday 28 August 2007, brian wrote:

> > If you have to modify anything other than a single config file in order
> > to move your site/app from one server to another, then you have a design
> > flaw. (I'd say that applies for moving the site to a subdirectory on a
> > server too, but that takes a bit more effort.)
>
> I'm with Larry on this. Include a constants file at the top of your
> scripts. In that file you can place a switch block that tests for the
> $_SERVER['HTTP_HOST']. For each case, place something like:

That's bad, too, if you have multiple developers on the project.  Just have a 
separate config file that contains *nothing* but the installation config, and 
every install has its own copy.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
Larry Garfield wrote:
On Tuesday 28 August 2007, brian wrote:


If you have to modify anything other than a single config file in order
to move your site/app from one server to another, then you have a design
flaw. (I'd say that applies for moving the site to a subdirectory on a
server too, but that takes a bit more effort.)

I'm with Larry on this. Include a constants file at the top of your
scripts. In that file you can place a switch block that tests for the
$_SERVER['HTTP_HOST']. For each case, place something like:


That's bad, too, if you have multiple developers on the project. Just have a separate config file that contains *nothing* but the installation config, and every install has its own copy.


How so? If, by multiple developers, you mean multiple *development domains*, then yes, that'd need tweaking. Otherwise, i fail to see the badness.
--- End Message ---
--- Begin Message ---
brian wrote:
Larry Garfield wrote:
On Tuesday 28 August 2007, brian wrote:


If you have to modify anything other than a single config file in order
to move your site/app from one server to another, then you have a design
flaw. (I'd say that applies for moving the site to a subdirectory on a
server too, but that takes a bit more effort.)

I'm with Larry on this. Include a constants file at the top of your
scripts. In that file you can place a switch block that tests for the
$_SERVER['HTTP_HOST']. For each case, place something like:


That's bad, too, if you have multiple developers on the project. Just have a separate config file that contains *nothing* but the installation config, and every install has its own copy.


How so? If, by multiple developers, you mean multiple *development domains*, then yes, that'd need tweaking. Otherwise, i fail to see the badness.

Multiple developers as in more than one person coding the application.

You'd be sharing the development environment (database, files etc) - not what you want.

Think if your app was in cvs/subversion and you had someone working on the same stuff at the desk next to you.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Andres Rojas wrote:
Hi all,

I'm new in PHP programming and I have a problem with this script. I need
to read a large file around 2Mb and several lines (28000). All start Ok,
but suddenly the script stop without message error.

<?php
        $fichero="62007lg.txt";
    $buffer = file($fichero);
    $lineas = count($buffer);

   foreach($buffer as $linea){
        
    list($day, $month, $year, $hour, $min, $temp, $hum, $dew, $baro,
$wind, $gust, $wdir, $rlastm, $rdai, $rmon, $ryear,
$heat)=sscanf($linea,"%d %d %d %d %d %f %d %f %f %d %d %d %f %f %f %f %f \n");

        $mday[]=$day;
        $mmonth[]=$month;
$myear[]=$year; $mhour[]=$hour;
        $mmin[]=$min;
        $mtemp[]=$temp;
        $mhum[]=$hum;
        $mdew[]=$dew;
        $mbaro[]=$baro;
        $mwind[]=$wind;
        $mgust[]=$gust;
        $mwdir[]=$wdir;
        $mrlastm[]=$rlastm;
        $mdai[]=$rdai;
        $mrmon[]=$rmon;
        $mryear[]=$ryear;
        $mheat[]=$heat;
        echo"$day $month $year $hour $min $temp $hum $dew $baro $wind $gust
$wdir $rlastm $rdai $rmon $ryear $heat <br>";
        }
?>

If only I print the variable $buffer all it's ok, but when I try to fill
all the matrix the script doesn't work. If I reduce the number of matrix
only a 3 o 4 it's Ok, but If I increase number of this matrix the script
crash again.

Perhaps it's a problem of memory of server, but my  service provider say
me that this is not the problem.


Thank you very much

Andres:

The info is too poor to see what is wrong, maybe you need to review a error_reporting() php function, o error_reporting php.ini variable i send you some code:

<?php
   error_reporting(E_ALL);

    $fichero="62007lg.txt";
    $buffer = file($fichero);
    $lineas = count($buffer);

   foreach($buffer as $linea){

            $data = preg_split("/\s+/", trim($linea));
// trim removes all white spaces at the end and the beginning of the string.
            $k = 0;
            foreach(array(
                                'mday', 'mmonth',
                                'myear', 'mhour',
                                'mtemp',  'mhum',
                                'mdew', 'mbaro',
                                'mwind', 'mgust',
                                'mwdir',  'mrlastm',
                                'mrdai', 'mrmon',
                                'mryear', 'mheat' ) as $var )
            {
                if(!isset($$var)) $$var = array();
                array_push($$var, $data[$k]);
                echo $var." => ".$data[$k];
                $k++;
            }   

   }
?>
                
cheers!!

Felipe Alcacibar

--- End Message ---
--- Begin Message ---
Hi friends,

Is there a solution to showing the proper time and date at user
browsers
and also recording proper USER times in the database operations in
mysql

Hemanth

-- 
www.ValueAds.biz    so easy....
FREE India Classifieds
Jobs, Matrimony, Property and more....
A Bangalore, India Venture.

--- End Message ---
--- Begin Message ---
On 8/29/07, Hemanth <[EMAIL PROTECTED]> wrote:
> Hi friends,
>
> Is there a solution to showing the proper time and date at user
> browsers
> and also recording proper USER times in the database operations in
> mysql

if you have the opportunity to have them input the time, you can then use

putenv("TZ=America/Los_Angeles") before any time operations and they
will be localized. it will accept any of the timezone library
definitions (or what you select for instance on unix libraries)

there's also a new date extension available as of one of the latest
php versions i believe that makes it even easier.

http://us3.php.net/manual/en/ref.datetime.php has the info.

for mysql data exchange you can use FROM_UNIXTIME and
UNIX_TIMESTAMP(NOW()) for example; if you dig it out from the database
and use the PHP functions it will localize it properly still. i don't
even fuss with this stuff anymore, i have a date formatting function
which takes $visitor['timezone'] (which is pre-populated with a
default, and overridden if the user has defined a different one) and
uses putenv("TZ=$foo") before i do the actual date/function calls -
it's been working flawlessly for years. i could probably update it now
to use the new extension too, natively maybe it would work slightly
faster than environment setting.

trying to detect the timezone offset from the browser i do not think
can be done consistently. i don't think i've seen anything that is
considered foolproof for that. maybe just DST checks...

--- End Message ---
--- Begin Message ---
Hello,

I have a small but somewhat annoying issue.

Whenever I open a socket to another server, the file is read very quickly, but it takes the up to 30 seconds or so to close the connection...

Here is what I do:
  $sever = "server.mit.edu";
  $url = "/link";
  $port = 80;
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
  $server_protocol = $_SERVER['SERVER_PROTOCOL'];

  $valsencoded = "";
  while (list($key,$value) = each ($content))
     $valsencoded .= urlencode($key) . "=" . urlencode($value) ."&";
  $valsencoded = substr($urlencoded,0,-1);

  $content_length = strlen($valsencoded);

  $headers = "POST $url $server_protocol
Content-Type: application/x-www-form-urlencoded
Host: $server
Content-Length: $content_length

";

  // open socket
  $socket = fsockopen($server, $port, $errno, $errstr, 60.0);
  if (!$socket) {
    $error = "ERROR: cannot contact Mailman server";
    return array(false,$error,$error); }

  if ($errstr) {
    $error = "ERROR: fSockOpen Error ($errno): $errstr";
    return array(false,$error,$error); }

  fputs($socket, $headers);  // send headers
  fputs($socket, $urlencoded);  // send post data

  // "tried stream_set_timeout($socket,3)" here

  // get the returned page
  while (!feof($socket))
  {
    $buf = @fgets($socket, 2048);
    $htmlreturned .= $buf;
  }
  fclose($socket);

If I put a debug 'echo "BUF: $buf\n" inside the while loop, I see the returned html from the post show up pretty much immediately, within about a second, maybe less.

However, the process 'stalls' after that for between 15-30 seconds, and then ends correctly.

I have tried to use timeouts, but they did not have any effects (did not really expect them to, but just in case).

My setup is Debian 4.0, php 5.2.0-8+etch7. Unfortunately I don't know the other server OS's/applications.

I found similar questions in posts from 2002 and 2003, but there were no replies (2002-04-30 guido.d.berger and 2003-11-25 thomas weber).

Any ideas greatly appreciated,

Alvar

--- End Message ---
--- Begin Message ---
On Wed 29 Aug 07, Alvar Saenz-Otero wrote:
> Hello,
> I have a small but somewhat annoying issue.
> Whenever I open a socket to another server, the file is read very
> quickly, but it takes the up to 30 seconds or so to close the
> connection...
>
> Here is what I do:
>    $sever = "server.mit.edu";
>    $url = "/link";
>    $port = 80;
>    $user_agent = $_SERVER['HTTP_USER_AGENT'];
>    $server_protocol = $_SERVER['SERVER_PROTOCOL'];

just a wild guess, but try to use perhaps http1.0 instead of 1.1, and
try to add into the header that you prepare and send a 
Connection: close\r\n


-- 
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections 
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23"S 18deg37'57.87"E Cape Town Bellville Oakdale ZA
         "I used to have a handle on life, but it broke."

--- End Message ---
--- Begin Message ---
How to run C++ program(*.exe) with PHP, and then terminate it.

--- End Message ---
--- Begin Message ---
On 8/29/07, Aram Shatakhtsyan <[EMAIL PROTECTED]> wrote:
>
> How to run C++ program(*.exe) with PHP, and then terminate it.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
PHP can do anything. But the matter is where the host permits to do such.

// See the following algorithm
function exec_php($host){
if (its $host that runs php as a module) {
  then it depends on the rights of $host
   if ($host is in the group of root){
      $host can do any thing.
   } else {
      $host will do those tasks that its been permitted.
   }
}
}

If (you are root and running php as a CLI){
   you can do anything (whatever you wish)
}.
if (you are normal user and running php as a CLI){
   you cant do some specific task like killing process.
}

// see the function definition above.
exec_php(apache);
exec_php(IIS);

I think you got it.
sorry for the approach. But it makes clear logic. :)

Thanks.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time

--- End Message ---
--- Begin Message ---
Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and double quotes work.

                <p>
                <h6>string init method 3: heredocs</h6>
                <?php
                        print <<< END
                                Test
                        END;            
                ?>
                </p>

--- End Message ---
--- Begin Message ---
Are heredocs supported by PHP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and double quotes work.

                <p>
                <h6>string init method 3: heredocs</h6>
                <?php
                        print <<< END
                                Test
                        END;            
                ?>
                </p>

--- End Message ---
--- Begin Message ---
On 28 August 2007 15:56, Stut wrote:

> Jason Pruim wrote:
> > One other question, to logout, can I just call a file that has
> > session_destroy() and a header("Location: ???"); in it? Or should I
> > do something else for logging out?
> 
> foreach (array_keys($_SESSION) as $key)
>      unset($_SESSION[$key];
> session_destroy();

        $_SESSION = array();
        session_destroy();
        session_commit();
        setcookie(session_name(), "",
                                        ini_get('session.cookie_lifetime'),
                                        ini_get('session.cookie_path'),
                                        ini_get('session.cookie_domain'));


Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730          Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---

Reply via email to