OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 1 May 2006 00:37:13 -0000 Issue 4102

php-general-digest-helplists.php.net
Date: Sun Apr 30 2006 - 19:37:13 CDT


php-general Digest 1 May 2006 00:37:13 -0000 Issue 4102

Topics (messages 235142 through 235171):

Re: problem with mktime
        235142 by: Ross
        235145 by: chris smith

Re: Undefined Variable
        235143 by: Stut
        235164 by: Smart Software
        235166 by: Smart Software
        235169 by: Smart Software
        235170 by: ray.hauge.americanstudentloan.com

Re: Session Array Disappears
        235144 by: Jochem Maas

php editor-close but not quite!
        235146 by: Ross

php pager-close but not no cigar!
        235147 by: Ross
        235148 by: Jochem Maas

OOP Static Functions vs. Objects
        235149 by: Edward Vermillion
        235150 by: Jochem Maas
        235151 by: Edward Vermillion
        235154 by: Jochem Maas
        235155 by: Edward Vermillion
        235157 by: Jochem Maas
        235159 by: Stut

trying to download birary data
        235152 by: Ross
        235153 by: Ross
        235158 by: Jochem Maas

Re: Removing special chars
        235156 by: Jochem Maas

Re: we are looking for experienced php programmers full time freelance...
        235160 by: tedd

Re: php login
        235161 by: tedd

Re: PHP Standard style of writing your code
        235162 by: tedd

c99shell
        235163 by: scot
        235165 by: scot
        235167 by: Stut
        235168 by: Dave Goodchild

Picture for Form Security
        235171 by: benc11.gmail.com

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


soted it ! Thanks.

R.
""Ross"" <rossaztechost.com> wrote in message
news:AA.28.18514.C82A4544pb1.pair.com...
>I am using this to compare todays date with dates retieved from a database.
>The problem is it seem to retrun the same value for the $then variable
>
> and can be seen ot working here....
>
> http://nationalservicesscotland.com/cms/time.php
>
>
> <?
>
> session_start();
> include ('../shared/connect.php');
>
> $query= "SELECT headline, id, expiry, link FROM events";
>
> $result= mysql_query($query);
>
>
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
>
>
> $compare= explode("/", $row['expiry']);
>
>
> $day = isset($compare[0]) ? $compare[0] : null;
> echo "day is $day<br>br><br>";
> $month = isset($compare[1]) ? $compare[1] : null;
> echo "month is $month<br>br><br>";
> $year = isset($compare[2]) ? $compare[2] : null;
> echo "year is $year<br>br><br>";
>
> $then = mktime(0,0,0,$month,$day, $year);
>
> $now = mktime (0,0,0,date("m"),date("d"),date("Y"));
>
>
> $diff = $now - $then;
>
> echo "today is $today<BR>";
> echo "expiry date is $ross<br>";
> echo "now mktime value is is $now<br>";
> echo "then mkvalue is $then<br><br>";
> if ($diff < 0 ) {
> /*$text = stripslashes ($row['headline']);
> $newtext = wordwrap($text, 12, "\n", 1);
> $link=$row['link'];
> echo $newtext."<a href=\"$link\">...read more</a>"."<br /><br />";*/
>
> }
> }
> ?>

attached mail follows:


On 4/30/06, Ross <rossaztechost.com> wrote:
> soted it ! Thanks.

please enlighten us in case someone else has the same sort of issue...

> ""Ross"" <rossaztechost.com> wrote in message
> news:AA.28.18514.C82A4544pb1.pair.com...
> >I am using this to compare todays date with dates retieved from a database.
> >The problem is it seem to retrun the same value for the $then variable
> >
> > and can be seen ot working here....
> >
> > http://nationalservicesscotland.com/cms/time.php
> >
> >
> > <?
> >
> > session_start();
> > include ('../shared/connect.php');
> >
> > $query= "SELECT headline, id, expiry, link FROM events";
> >
> > $result= mysql_query($query);
> >
> >
> > while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
> >
> >
> > $compare= explode("/", $row['expiry']);
> >
> >
> > $day = isset($compare[0]) ? $compare[0] : null;
> > echo "day is $day<br>br><br>";
> > $month = isset($compare[1]) ? $compare[1] : null;
> > echo "month is $month<br>br><br>";
> > $year = isset($compare[2]) ? $compare[2] : null;
> > echo "year is $year<br>br><br>";
> >
> > $then = mktime(0,0,0,$month,$day, $year);
> >
> > $now = mktime (0,0,0,date("m"),date("d"),date("Y"));
> >
> >
> > $diff = $now - $then;
> >
> > echo "today is $today<BR>";
> > echo "expiry date is $ross<br>";
> > echo "now mktime value is is $now<br>";
> > echo "then mkvalue is $then<br><br>";
> > if ($diff < 0 ) {
> > /*$text = stripslashes ($row['headline']);
> > $newtext = wordwrap($text, 12, "\n", 1);
> > $link=$row['link'];
> > echo $newtext."<a href=\"$link\">...read more</a>"."<br /><br />";*/
> >
> > }
> > }
> > ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

attached mail follows:


Smart Software wrote:
> while(query )//here the query is opened
> {
> <table ">
> <tr>
> <td ><?php query->name ?> </td> // record from database
> <td > Please fill in your age:</td> //text
> <td "><input name="age" type="text" </td> //textbox,
> <td ><a href="<? echo
> "otherform.php?age=PLACE_HERE_THE_VALUE_FROM_QUANTITY_TEXTBOX&name=query->name";
> ?> "</td>
> </tr>
> </table>
> }

Actually a Javascript question, but I seem to be in a rare good mood
today, so you're in luck. In the snippet below I've also fixed some
syntax issues that tell me you really don't know what you're doing. On
the other hand it could just be what you wrote in the email and not what
you are actually trying to run. Either way I suggest you Google for a
beginners tutorial on PHP to learn some basics.

<?php
$counter = 0;
while(query) //here the query is opened [Stut: If you say so!]
{
?>
     <table>
       <tr>
         <td><?php $query->name ?></td> // record from database
         <td>Please fill in your age:</td> //text
         <td><input id="age<?=$counter?>" name="age" type="text"</td>
//textbox,
         <td><a href="#" onclick="location.href = 'otherform.php?age=' +
document.getElementById('age<?=$counter?>').value +
'&name=<?=urlencode($query->name)?>'; return false;">Save Age</a></td>
      </tr>
     </table>
<?php
     $counter++;
}
?>

What this is doing is assigning an ID to each age textbox, that allows
the onclick handler for the link (which you had not closed properly or
given some text to display) to get the value and add it to the URL it
links to.

I suggest you run this and compare the source file and the output to see
what is server-side and what is client-side, because I don't think you
understand the difference yet.

Enjoy.

-Stut

attached mail follows:


isset always returns 0

i create dynamic textbox called quantity0, textbox1, textbox3.......

then i a, trying to get the content of the textbox but it is always 0.

as you can see, i tried the suggestions but it still dont work.

is there something iam doing wroing? why is the textbox always 0?

<table width="700">
<? $query1 = mysql_query("SELECT * FROM products where product_group='$cat'
order by position");
 $counter = 0;
 while ($rowType = mysql_fetch_array($query1))
 {
  $textbox="quantity";
  $textbox= "$textbox$counter"; //variable is set to quantity0, quantity1,
quantity2 etc
?>
  <td width="30%">New row number: <? echo $counter; ?></td>
  <td width="30%">name of textbox: <? echo $textbox; ?></td>
  <? //below the textbox will be created?>
  <td width="10%"><input id="<? $textbox ?>" name="<? $textbox ?>"
type="text" value="1" size="1" maxlength="3"></td>
<?
  //get content of textbox
  $q = isset($_REQUEST['$textbox']) ? $_REQUEST['$textbox'] : 0;
?>
  <td width="10%"> <a href=" <? echo "products.php?quantity=$q"; ?>"
</a>TEST</td>
  <td width="20%"> <? echo "content of textbox: $q"; ?> </td>
  </tr>
<?
  $counter++;
 }
?>
 </table>

""Richard Lynch"" <ceol-i-e.com> schreef in bericht
news:53414.67.184.121.112.1146346993.squirrelwww.l-i-e.com...
> On Sat, April 29, 2006 5:42 am, Smart Software wrote:
>> code below shows all records from products table with an textbox and
>> an
>> order button for each record
>
>> How can i add the content of the textbox?
>> i tried this:
>> <td width="40%"> <a href="<? echo
>> "products.php?cat=$cat&quantity=$quantity&toevoegen=1&id=$rowType[7]";
>> ?>"><img src="images/bestel1.gif" border="0"></a></td>
>>
>> but all i get is an error telling me there is a undefined varable
>
> You probably are following some kind of tutorial that assumes
> "register_globals" is "on" -- or you are simply used to that
> environment.
>
> So when you try to use $quantity, it's not defined.
>
> The value you want is in $_REQUEST['quantity'];
>
> You should do something like this:
>
> <?php
> //Get data from REQUEST:
> $quantity = isset($_REQUEST['quantity']) ? $_REQUEST['quantity'] : 0;
> //Force valid data:
> $quantity = (int) $quantity;
> //rest of script here.
> ?>
>
> --
> Like Music?
> http://l-i-e.com/artists.htm

attached mail follows:


isset always returns 0

i create dynamic textbox called quantity0, textbox1, textbox3.......

then i a, trying to get the content of the textbox but it is always 0.

as you can see, i tried the suggestions but it still dont work.

is there something iam doing wroing? why is the textbox always 0?

<table width="700">
<? $query1 = mysql_query("SELECT * FROM products where product_group='$cat'
order by position");
 $counter = 0;
 while ($rowType = mysql_fetch_array($query1))
 {
  $textbox="quantity";
  $textbox= "$textbox$counter"; //variable is set to quantity0, quantity1,
quantity2 etc
?>
  <td width="30%">New row number: <? echo $counter; ?></td>
  <td width="30%">name of textbox: <? echo $textbox; ?></td>
  <? //below the textbox will be created?>
  <td width="10%"><input id="<? $textbox ?>" name="<? $textbox ?>"
type="text" value="1" size="1" maxlength="3"></td>
<?
  //get content of textbox
  $q = isset($_REQUEST['$textbox']) ? $_REQUEST['$textbox'] : 0;
?>
  <td width="10%"> <a href=" <? echo "products.php?quantity=$q"; ?>"
</a>TEST</td>
  <td width="20%"> <? echo "content of textbox: $q"; ?> </td>
  </tr>
<?
  $counter++;
 }
?>
 </table>

attached mail follows:


isset always returns 0

i create dynamic textbox called quantity0, textbox1, textbox3.......

then i a, trying to get the content of the textbox but it is always 0.

as you can see, i tried the suggestions but it still dont work.

is there something iam doing wroing? why is the textbox always 0?

<table width="700">
<? $query1 = mysql_query("SELECT * FROM products where product_group='$cat'
order by position");
 $counter = 0;
 while ($rowType = mysql_fetch_array($query1))
 {
  $textbox="quantity";
  $textbox= "$textbox$counter"; //variable is set to quantity0, quantity1,
quantity2 etc
?>
  <td width="30%">New row number: <? echo $counter; ?></td>
  <td width="30%">name of textbox: <? echo $textbox; ?></td>
  <? //below the textbox will be created?>
  <td width="10%"><input id="<? $textbox ?>" name="<? $textbox ?>"
type="text" value="1" size="1" maxlength="3"></td>
<?
  //get content of textbox
  $q = isset($_REQUEST['$textbox']) ? $_REQUEST['$textbox'] : 0;
?>
  <td width="10%"> <a href=" <? echo "products.php?quantity=$q"; ?>"
</a>TEST</td>
  <td width="20%"> <? echo "content of textbox: $q"; ?> </td>
  </tr>
<?
  $counter++;
 }
?>
 </table>

attached mail follows:


> -------- Original Message --------
> Subject: [PHP] re: undefined variable
> From: "Smart Software" <infosmart-software.org>
> Date: Sun, April 30, 2006 1:50 pm
> To: php-generallists.php.net
>
> //get content of textbox
> $q = isset($_REQUEST['$textbox']) ? $_REQUEST['$textbox'] : 0;

You should use $_REQUEST[$textbox] or $_REQUEST["$textbox"]. Variables
are not converted within a single-quoted string.

HTH,
Ray

attached mail follows:


Richard Lynch wrote:
...

>
> Your basic Human Interface principle, which is apparently going to be
> called Web 2.0 now. :-)
>

lol, that sums it up perfectly.

...

attached mail follows:


http://scottishsocialnetworks.org/editor2.php

attached mail follows:


I have almost got my pager working here (just hit submit to return the full
db)

http://scottishsocialnetworks.org/editor2.php

http://scottishsocialnetworks.org/editor2.phps

The pager works fine until you hit any of the other links at the bottom then
I get a blank page. Any ideas?

Ross

attached mail follows:


Ross wrote:
> I have almost got my pager working here (just hit submit to return the full
> db)
>
>
> http://scottishsocialnetworks.org/editor2.php
>
> http://scottishsocialnetworks.org/editor2.phps
>
> The pager works fine until you hit any of the other links at the bottom then
> I get a blank page.

I get a login page because the pages links refer to editor.php.

Any ideas?

1. your using $_GET['page'] and $_POST['pageNum'] - that might be related to the problem.
2. check your error log and/or turn on display_errors.
3. getting a blank page often happens if a 'require' statement fails.
4. (not part of the problem:) put your class(es) and function(s) in
seperate files and try to layout your code so that your not intermingling
php and html too much - it saves on headaches down the road.

>
>
> Ross
>

attached mail follows:


I'm still trying to get my head around all the OOP stuff and was
wondering if there is any basic difference between calling a static
function as opposed to creating an object, in situations where both
methods will do the same thing for you. Is there any overhead to
creating an object from a class that might impact time/memory
consumption(efficiency), or does PHP treat these two methods the
same? I'm currently working with PHP4 but am also curious as to how
it works in PHP5.

I.E.:

<pseudoCode>
class Foo {
        
        var $_vars = array();

        function &setVar1($var) {
                static $localVars = array();
                if (!empty($localVars[$var])) {
                        return $localVars[$var];
                } else {
                        $localVars[$var] =& new $var();
                        return $localVars[$var];
                }
        }

        function &setVar2($var) {
                if (!empty($this->_vars[$var])) {
                        return $this->_vars[$var];
                } else {
                        $this->_vars[$var] =& new $var();
                        return $this->_vars[$var];
                }
        }
}

$result1 =& Foo::setVar1('something');

$bar = new Foo();
$result2 =& $bar->setVar2('something');
</pseudoCode>

Right now I'm working on an object controller type of class, but I
can see where I might run into this situation in other areas where
storing a value in a static function variable or a class variable
would accomplish much the same thing as far as the calling code is
concerned.

Any thoughts?

Ed

attached mail follows:


Edward Vermillion wrote:
> I'm still trying to get my head around all the OOP stuff and was
> wondering if there is any basic difference between calling a static
> function as opposed to creating an object, in situations where both
> methods will do the same thing for you. Is there any overhead to
> creating an object from a class that might impact time/memory
> consumption(efficiency), or does PHP treat these two methods the same?
> I'm currently working with PHP4 but am also curious as to how it works
> in PHP5.
>

creating an object is a lot of overhead, after the object is created the
difference in calling the method on the object and calling the other method
statically is neglegible/non-existant.

don't even try to compare objects in php4 and php5 on anything other than
a superficial level - php5 has so much more OO functionality that it's
jsut not funny. :-P
for instance all those '&'s you are using - php5 doesn't
need it (throws E_STRICT errors at you actually if you use them) because
objects are always references (unless you specifically clone them)

I recommend going to php5 if your currently developing new php OO code, this
might not be possible due to production env. restriction but it doesn't stop
you installing a copy locally and getting your hands dirty :-)

have fun.

> I.E.:
>
> <pseudoCode>
> class Foo {
>
> var $_vars = array();
>
> function &setVar1($var) {
> static $localVars = array();
> if (!empty($localVars[$var])) {
> return $localVars[$var];
> } else {
> $localVars[$var] =& new $var();
> return $localVars[$var];
> }
> }
>
> function &setVar2($var) {
> if (!empty($this->_vars[$var])) {
> return $this->_vars[$var];
> } else {
> $this->_vars[$var] =& new $var();
> return $this->_vars[$var];
> }
> }
> }
>
> $result1 =& Foo::setVar1('something');
>
> $bar = new Foo();
> $result2 =& $bar->setVar2('something');
> </pseudoCode>
>
> Right now I'm working on an object controller type of class, but I can
> see where I might run into this situation in other areas where storing
> a value in a static function variable or a class variable would
> accomplish much the same thing as far as the calling code is concerned.
>
> Any thoughts?
>
> Ed
>

attached mail follows:


On Apr 30, 2006, at 10:10 AM, Jochem Maas wrote:

> Edward Vermillion wrote:
>> I'm still trying to get my head around all the OOP stuff and was
>> wondering if there is any basic difference between calling a
>> static function as opposed to creating an object, in situations
>> where both methods will do the same thing for you. Is there any
>> overhead to creating an object from a class that might impact
>> time/memory consumption(efficiency), or does PHP treat these two
>> methods the same? I'm currently working with PHP4 but am also
>> curious as to how it works in PHP5.
>
> creating an object is a lot of overhead,

That's what I was thinking, but wasn't sure. I'm looking for a 'best
practice' really, I've just 'discovered' the static keyword in PHP4,
and have a very superficial knowledge of it in PHP5.

> don't even try to compare objects in php4 and php5 on anything
> other than
> a superficial level - php5 has so much more OO functionality that it's
> jsut not funny. :-P
> for instance all those '&'s you are using - php5 doesn't
> need it (throws E_STRICT errors at you actually if you use them)
> because
> objects are always references (unless you specifically clone them)
>
> I recommend going to php5 if your currently developing new php OO
> code, this
> might not be possible due to production env. restriction but it
> doesn't stop
> you installing a copy locally and getting your hands dirty :-)
>
> have fun.

That's what I'm doing now. I've got 5.1.2(?) loaded up on my main dev
server and am getting my feet wet with the OOP stuff. The only
'problem' I'm facing at the moment is that a lot of the work I do is
for clients on shared hosts, and you know what that means as far as
being able to do a total migration to PHP5.

Right now I'm looking at getting the PHP4 code I have into a state
that resembles as much as possible what it will look like in PHP5,
just to keep the different versions I'm going to end up with as close
as possible.

Thanks!
Ed

attached mail follows:


Edward Vermillion wrote:
>
> On Apr 30, 2006, at 10:10 AM, Jochem Maas wrote:
>
>> Edward Vermillion wrote:
>>
>>> I'm still trying to get my head around all the OOP stuff and was
>>> wondering if there is any basic difference between calling a static
>>> function as opposed to creating an object, in situations where both
>>> methods will do the same thing for you. Is there any overhead to
>>> creating an object from a class that might impact time/memory
>>> consumption(efficiency), or does PHP treat these two methods the
>>> same? I'm currently working with PHP4 but am also curious as to how
>>> it works in PHP5.
>>
>>
>> creating an object is a lot of overhead,
>
>
> That's what I was thinking, but wasn't sure. I'm looking for a 'best
> practice' really, I've just 'discovered' the static keyword in PHP4,
> and have a very superficial knowledge of it in PHP5.

in php5 you can mark class variables and function as static ontop of the
ability to declare variables inside functions as static (as you can in php4)

I remember 'discovering' the static keyword - what an eye opener is was :-)

>> don't even try to compare objects in php4 and php5 on anything other
>> than
>> a superficial level - php5 has so much more OO functionality that it's
>> jsut not funny. :-P
>> for instance all those '&'s you are using - php5 doesn't
>> need it (throws E_STRICT errors at you actually if you use them) because
>> objects are always references (unless you specifically clone them)
>>
>> I recommend going to php5 if your currently developing new php OO
>> code, this
>> might not be possible due to production env. restriction but it
>> doesn't stop
>> you installing a copy locally and getting your hands dirty :-)
>>
>> have fun.
>
>
> That's what I'm doing now. I've got 5.1.2(?) loaded up on my main dev

5.1.2 is a good release to start with (for one it up2date ;-) because
you miss out on all the 5beta3 -> 5.0.1 -> 5.0.5 -> 5.1 migration hoops
that some of us had to jump through - I feel that at this stage the functionality
and behaviour of the engine is really settling down nicely (php6 will
bring it's own set of migration issues though - not much you can do about it -
software evolves right :-P)

> server and am getting my feet wet with the OOP stuff. The only
> 'problem' I'm facing at the moment is that a lot of the work I do is
> for clients on shared hosts, and you know what that means as far as
> being able to do a total migration to PHP5.

I have the luxury of running my own server(s) so I can do what I want
(obviously client code runs on my servers :-) most of the time, sometimes
I have to use php4 (almost inescapable given that just about all shared-hosting
is still php4) - writing 'proper' php5 code is impossible if you have to be
able to run it on php4 machines - so that is indeed a big drawback.

>
> Right now I'm looking at getting the PHP4 code I have into a state that

refactoring (cleaning up ;-) is always a good idea - if the code is neat and
well designed it won't be too hard to move it to php5-only when you are able ...
it does mean you can't use any

> resembles as much as possible what it will look like in PHP5, just to
> keep the different versions I'm going to end up with as close as possible.

CVS or subversion (and 3 weeks intensive study of what branches are) might
be of help to you - not for the faint-hearted though!

> Thanks!
> Ed

attached mail follows:


On Apr 30, 2006, at 10:45 AM, Jochem Maas wrote:

>
> CVS or subversion (and 3 weeks intensive study of what branches
> are) might
> be of help to you - not for the faint-hearted though!
>

Been reading the subversion manual for the past three days... ;)

(I'm a slow reader)

Ed

attached mail follows:


Edward Vermillion wrote:
>
> On Apr 30, 2006, at 10:45 AM, Jochem Maas wrote:
>
>>
>> CVS or subversion (and 3 weeks intensive study of what branches are)
>> might
>> be of help to you - not for the faint-hearted though!
>>
>
> Been reading the subversion manual for the past three days... ;)
>
> (I'm a slow reader)

me I'm just slow - I still on 'how the f*** do I use branches in CVS'
after using it for 18 months+; and I haven't even begun to look at subversion
yet :-P

>
> Ed

attached mail follows:


Jochem Maas wrote:
> me I'm just slow - I still on 'how the f*** do I use branches in CVS'
> after using it for 18 months+; and I haven't even begun to look at
> subversion
> yet :-P

I strongly suggest you skip branches in CVS and go straight to
subversion. I've been using CVS for years and have attempted to use the
branching facilities a couple of times with no great success. I've now
switched to subversion and it just makes sense - none of the confusion I
had with CVS. Give it a look.

-Stut

attached mail follows:


On this page
http://www.nationalservicesscotland.com/publications/a-z.php

I use the following code to donwload binary data. It is jsut gibberish. I
think the offending line is echo "<a class=\"pdflinks\"
href=\"$link\"</a>$name</span>";

How do I recompile the binaryy data into docs and pdfs?

         <?
    $letter="a";
$query= "SELECT * FROM publications WHERE alphabet='$letter'";

 $result= mysql_query($query);
   while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){

    $row['pdf_size'] = $row['pdf_size']/ 1024;
 $row['pdf_size']= number_format($row['pdf_size'], 0);
 $size= $row['pdf_size'];
$name = str_replace("_", " ", $row['pdf_name']);
$name = str_replace(".pdf", "", $name);
$link= $row['content'];

echo "<a class=\"pdflinks\" href=\"$link\"</a>$name</span>";
echo "&nbsp;&nbsp;";
echo "<span class=\"sizes\">($size kb)</span>";
?><a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>

<?
}

attached mail follows:


On this page
http://www.nationalservicesscotland.com/publications/a-z.php

I use the following code to donwload binary data. It is jsut gibberish. I
think the offending line is echo "<a class=\"pdflinks\"
href=\"$link\"</a>$name</span>";

How do I recompile the binaryy data into docs and pdfs?

         <?
    $letter="a";
$query= "SELECT * FROM publications WHERE alphabet='$letter'";

 $result= mysql_query($query);
   while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){

    $row['pdf_size'] = $row['pdf_size']/ 1024;
 $row['pdf_size']= number_format($row['pdf_size'], 0);
 $size= $row['pdf_size'];
$name = str_replace("_", " ", $row['pdf_name']);
$name = str_replace(".pdf", "", $name);
$link= $row['content'];

echo "<a class=\"pdflinks\" href=\"$link\"</a>$name</span>";
echo "&nbsp;&nbsp;";
echo "<span class=\"sizes\">($size kb)</span>";
?><a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>

<?
}

attached mail follows:


Ross wrote:
> On this page
> http://www.nationalservicesscotland.com/publications/a-z.php
>
> I use the following code to donwload binary data. It is jsut gibberish. I
> think the offending line is echo "<a class=\"pdflinks\"
> href=\"$link\"</a>$name</span>";
>
> How do I recompile the binaryy data into docs and pdfs?
>
>
> <?
> $letter="a";
> $query= "SELECT * FROM publications WHERE alphabet='$letter'";
>
> $result= mysql_query($query);
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
>
> $row['pdf_size'] = $row['pdf_size']/ 1024;
> $row['pdf_size']= number_format($row['pdf_size'], 0);
> $size= $row['pdf_size'];
> $name = str_replace("_", " ", $row['pdf_name']);
> $name = str_replace(".pdf", "", $name);
> $link= $row['content'];
>
> echo "<a class=\"pdflinks\" href=\"$link\"</a>$name</span>";

$link should a link to a download script rather than the actual
file data! something *like*:

        /dl.php?file_id=1

and your dl.php script should take the id select the content from
your publications table and output that directly *without* any html
being output... you will mostly like need to also output some suitable
headers to tell the browser what it is/needs to do. - search this list
for more info on suvh headers (or the web), similar questions have been
answered repeatedly (so you should find something pretty quickly)

> echo "&nbsp;&nbsp;";
> echo "<span class=\"sizes\">($size kb)</span>";
> ?><a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>
>
>
> <?
> }
>

attached mail follows:


Gerry Danen wrote:
> I would like to replace all chars in a string that are not a-z or 0-9
> with a space. I can use a series of str_replace functions, but there
> has to be a faster way.
>
> I know there is a solution but my chemo-brain is slowing me down today. Sorry...

$output = preg_replace('#[^a-z0-9]#i', '', $input);

I always forget what the 'special' 'shortcut' tokens are for specifing
alphanumeric chars, etc in regexps so I mostly end up writing it the long way
round (as above).

and as someone else mentioned str_replace (and preg_replace) can take
arrays of strings for the find and replace args which save you doing multiple calls -
although to what extent this is true is, I believe, dependant on your php version
(check the docs for the specifics)

> Any suggestions?
>
> TIA
>
> Gerry
>

attached mail follows:


At 12:33 PM -0700 4/29/06, Paul Novitski wrote:
>At 10:46 AM 4/29/2006, tedd wrote:
>...
>>"I have found" it is simply a waste of my time to try to find
>>profitable common ground. They are concerned with one thing, and
>>one thing only, and that is how cheap can they get it -- and they
>>seldom have a clue as to what "it" is -- but, contrary to their
>>lip-service, it certainly isn't quality.
>...
>
>Whoa! "They" "they" "they"... Tedd, there are stupid, venal people
>everywhere in the world, and smart and honorable ones besides.
>Speaking from personal experience I know that there are cultural
>divides so wide that what's honorable on one side appears
>dishonorable from the other; truth appears as lies; respect appears
>as disrespect; discretion as conspiracy; elegance as boorishness.
>To judge individuals despite these fundamental differences and then
>to paint an entire nation of people based on one's experiences with
>a few seems lacking in sense, respect, rationality, and honor
>(speaking from this side of your and my cultural divide!). You're
>free to form your own prejudices based on your experiences, of
>course, but I'm astonished that you would voice them publicly. I'm
>embarrassed by your comments.
>
>Paul

Paul and Dave:

Do not confuse prejudices with racialism or think that an "open mind"
also has blinders to obvious differences because neither are true.

Paul, you have nothing to be embarrassed about -- you didn't voice my
opinion. Unless you think I represent your group, which I certainly
do not, nor do you mine.

The "they" remark was taken out of context -- I used the term for
Indian companies and for the group that I dealt with who wasted
several million dollars to save a few thousand in an oil deal -- no
matter how you cut that, that was stupid!

My experiences are simply seeds that were planted and now have come
to harvest. Who's responsible for that?

There's nothing wrong with prejudices, we all have them, and form
them, everyday -- all races, all creeds and all nationalities. This
is not a one-sided phenomena, and in fact, it is an instinct of
survival.

It is in the application of prejudices that good and evil may come.
But, to not speak of prejudices publicly because of the current
"political correctness" environment is certainly not doing anything
to lessen problems, is it? Or is it one of those "We can think it,
but let's not speak publicly about it." things, which are more
poisonous than to what you elude Dave.

If I am wrong, then show me. I'm a reasonable person who is slow to
judge -- but my life experiences have led me to what I now believe is
true. However, I am willing to change my beliefs if I have reason to
do so. Give me reason.

I know that I am not alone in my experiences, and as such, speaking
outright may cause others to better understand my position, which is
shared by many. After all, isn't awareness of a problem one of the
steps in correcting it?

This current climate is certainly one of "We should understand other
cultures." but that sword cuts both ways. If one culture wants us to
understand them, then isn't the reverse true as well?

It is in a manner of open communication I speak my mind and not
behind the backs of others.

If you believe that I do not understand the adverse and unjust
effects of false prejudices, then walk a mile in my shoes -- for
being disabled, I can't.

This topic has wandered far off the main theme of this list and this
will be my last post to this thread. If I have offended anyone
personally, please accept my most sincere apology -- that was not my
intent.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

attached mail follows:


At 9:32 PM +0200 4/29/06, Schalk wrote:
>Greetings All,
>
>Where can I find a good tutorial on creating a login protected area
>using php? I did a Google search and found a couple but, I would
>like to get suggestions from the list. Thanks!
>
>--
>Kind Regards
>Schalk Neethling

Schalk:

Not that you said you needed one, but if you are interested in a
short and sweet password example, check out:

http://www.weberdev.com/get_example-4374.html

hth's

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

attached mail follows:


>Beautiful code often contains fewer bugs.
>
>Dante

I agree -- but, if nothing else, they're at least prettier bugs. :-)

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

attached mail follows:


Hi there,
 Not sure if this is proper place to post but here it goes. We got nailed by
someone using c99shell today. They were able to upload and overwrite a bunch
of index files. I am working on discovering how they were able to get it on
our server. Here's some basic info. I am by no means a php expert. Should
things be different? Is there a good paper out there somewhere in regards to
windows / iis5 / php security?

php 4.4.1
Safe Mode: OFF
Open basedir: none
Display Errors: ON
Short Open Tags: ON
File Uploads: ON
Magic Quotes: ON
Register Globals: ON
Output Buffering: OFF
Session save path: e:\PHP\sessiondata
Session auto start: 0
XML enabled: Yes
Zlib enabled: Yes
Disabled Functions: none

Here is also a snip of log (altered IP's and URL) of what I think is the
hack of the site. (I could be wrong)

2006-04-29 23:47:46 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 958 105 172
HTTP/1.0 www.blah.com Wget/1.9.1 - -
2006-04-29 23:49:32 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 953 122 297
HTTP/1.1 www.blah.com libwww-perl/5.805 - -

Thanks,
 Scot

attached mail follows:


Hi there,
 Not sure if this is proper place to post but here it goes. We got nailed by
someone using c99shell today. They were able to upload and overwrite a bunch
of index files. I am working on discovering how they were able to get it on
our server. Here's some basic info. I am by no means a php expert. Should
things be different? Is there a good paper out there somewhere in regards to
windows / iis5 / php security?

php 4.4.1
Safe Mode: OFF
Open basedir: none
Display Errors: ON
Short Open Tags: ON
File Uploads: ON
Magic Quotes: ON
Register Globals: ON
Output Buffering: OFF
Session save path: e:\PHP\sessiondata
Session auto start: 0
XML enabled: Yes
Zlib enabled: Yes
Disabled Functions: none

Here is also a snip of log (altered IP's and URL) of what I think is the
hack of the site. (I could be wrong)

2006-04-29 23:47:46 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 958 105 172
HTTP/1.0 www.blah.com Wget/1.9.1 - -
2006-04-29 23:49:32 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 953 122 297
HTTP/1.1 www.blah.com libwww-perl/5.805 - -

Thanks,
 Scot

attached mail follows:


scot wrote:
> Hi there,
> Not sure if this is proper place to post but here it goes. We got nailed by
> someone using c99shell today. They were able to upload and overwrite a bunch
> of index files. I am working on discovering how they were able to get it on
> our server. Here's some basic info. I am by no means a php expert. Should
> things be different? Is there a good paper out there somewhere in regards to
> windows / iis5 / php security?
<snip>

Chances are the problem is one of the scripts written in PHP rather than
PHP itself. A good site to check out is http://phpsec.org/ - it has lots
of info and links to more info about PHP security.

> Here is also a snip of log (altered IP's and URL) of what I think is the
> hack of the site. (I could be wrong)
>
> 2006-04-29 23:47:46 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 958 105 172
> HTTP/1.0 www.blah.com Wget/1.9.1 - -
> 2006-04-29 23:49:32 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 953 122 297
> HTTP/1.1 www.blah.com libwww-perl/5.805 - -

Neither of these look particularly suspicious. Key things to look into
is who has access to your server, who writes the scripts, and whether
there are any scripts that write files to the server based on content
uploaded from users.

Hope that helps.

-Stut

attached mail follows:


Hey. That is not a good php.ini configuration.

1. display_errors should be disabled in production as it may output path
info to the browser.
2. register_globals should be disabled (default in php5) as it allows
scripts to be polluted with tainted data.
3. I would also disabled short_open_tags - not a security issue but more for
portability as you cannot guarantee this setting will be enabled on another
server.

On 30/04/06, scot <scotochotmail.com> wrote:
>
> Hi there,
> Not sure if this is proper place to post but here it goes. We got nailed
> by
> someone using c99shell today. They were able to upload and overwrite a
> bunch
> of index files. I am working on discovering how they were able to get it
> on
> our server. Here's some basic info. I am by no means a php expert. Should
> things be different? Is there a good paper out there somewhere in regards
> to
> windows / iis5 / php security?
>
> php 4.4.1
> Safe Mode: OFF
> Open basedir: none
> Display Errors: ON
> Short Open Tags: ON
> File Uploads: ON
> Magic Quotes: ON
> Register Globals: ON
> Output Buffering: OFF
> Session save path: e:\PHP\sessiondata
> Session auto start: 0
> XML enabled: Yes
> Zlib enabled: Yes
> Disabled Functions: none
>
> Here is also a snip of log (altered IP's and URL) of what I think is the
> hack of the site. (I could be wrong)
>
> 2006-04-29 23:47:46 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 958 105
> 172
> HTTP/1.0 www.blah.com Wget/1.9.1 - -
> 2006-04-29 23:49:32 x.x.x.x - x.x.x.x 80 GET /index.html - 200 0 953 122
> 297
> HTTP/1.1 www.blah.com libwww-perl/5.805 - -
>
> Thanks,
> Scot
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!

attached mail follows:


Does anyone know of a good script for form security, where someone goes to
login and then they have to type a number, disabling automated scripts from
logging in versus a physical user. It is widely used by domain registrars
who protect the identity of a domain name.