php-general Digest 27 May 2008 17:58:39 -0000 Issue 5482

Topics (messages 274718 through 274748):

Re: Very simple session question
        274718 by: Chris
        274719 by: John Allsopp

Re: Downloading movies / forcing download
        274720 by: Iv Ray

Re: autoload issues
        274721 by: Joakim Ling

Periodically delete old records from mysql table
        274722 by: Stefano Esposito
        274723 by: Richard Heyes
        274725 by: tedd
        274727 by: Robin Vickery
        274728 by: Nate Tallman
        274735 by: Richard Heyes
        274737 by: Ted Wood

Re: Image modifications
        274724 by: zerof

Re: mail warning!!
        274726 by: Daniel Brown

Re: visibility + unserialization
        274729 by: Robert Cummings
        274730 by: Ted Wood
        274731 by: Robert Cummings
        274733 by: Robert Cummings

Re: scanned in & manipulate to a pdf
        274732 by: Christian Flickinger
        274739 by: Bastien Koert
        274747 by: Brady Mitchell

Header Redirect
        274734 by: Yui Hiroaki
        274736 by: Stut
        274738 by: Jim Lucas
        274741 by: Yui Hiroaki
        274742 by: Robert Cummings
        274743 by: Stut
        274744 by: Stut
        274748 by: elk dolk

mime_content_type() sees .swf flash file as text/plain
        274740 by: Bob

validating username
        274745 by: Sudhakar
        274746 by: Ted Wood

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 ---
Ted Wood wrote:
> 
> Using double-quotes instead of single-quotes in the code you provided
> should be *no* difference at all. I'm curious if there's something else
> going on for you. Can you provide more complete code?
> 
> Back to your original example, calling session_start() will restart a
> session, so only call that function once during a request, or make sure
> to write out the session using session_write() before calling it again.

Where did you hear that?

$ cat go.php
<?php
session_start();

echo 'sess id is ' . session_id() . "\n";

$_SESSION['abc'] = '12345';

print_r($_SESSION);

session_start();

echo 'sess id is ' . session_id() . "\n";

print_r($_SESSION);


$ php go.php
sess id is de0474e8080c0143b92ddb426c2c580d
Array
(
    [abc] => 12345
)
sess id is de0474e8080c0143b92ddb426c2c580d
Array
(
    [abc] => 12345
)


(Of course you'll get a different session id but nothing else will change).

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

--- End Message ---
--- Begin Message ---
Chris wrote:
Ted Wood wrote:
Using double-quotes instead of single-quotes in the code you provided
should be *no* difference at all. I'm curious if there's something else
going on for you. Can you provide more complete code?
Me too, but it appears to be working now. I'm testing it over the next few days so I'll post more code in a day or so if there's still a problem

Thanks
J

--- End Message ---
--- Begin Message ---
A successful download across all browsers requires proper headers.

I do not have time to fix your code, but here are some suggestions, which for me do successful downloads regardless the browser -

header("Content-type: $mime");

/*
 *
 * This fixed the download in IE 7
 *
 * EXPLANATION
 *
 *     Without this direct point to the URI
 *     leads to attempt to download index.php, which leads to nothing.
 *
 */
header("Cache-Control: post-check=0, pre-check=0");

/*
 *
 * RFC 2183
 *
 * Works on IE 7 and FF 1.5
 *
 */
header("Content-Disposition: attachment; filename=\"$file\"; size=$size");

/*
 *
 * RFC 2183
 *
 * No idea what it is good for.
 *
 */
header('Content-Description: download');

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

I'm using Ioncoder, the structure for the classes is that I have a "master"
library folder in every client root containing all classes, but
unfortunately the filename is not the same as the classname (some files are
but not all) so no luck matching classes with filenames.

The code I use to scan the files are:
$rows = file_get_contents($path);
if (preg_match('#^(?:abstract |final )?class (\S+) #m', $rows, $m)) {
        ...
}

The files just looks totally scrambled when they are encoded, so this is not
working at all obviously. 

regards

-----Original Message-----
From: Bojan Tesanovic [mailto:[EMAIL PROTECTED] 
Sent: 24 May 2008 01:33 PM
To: PHP General list
Subject: Re: [PHP] autoload issues

Can you be more specific,   the structure of directories what encoder  
did you use can you provide a sample
PHP encoded class/script ...

On May 23, 2008, at 5:27 PM, Joakim Ling wrote:

> Anyone have a solution for using autoload with encoded php files?

Bojan Tesanovic
http://www.carster.us/






--- End Message ---
--- Begin Message ---
Hi all,

i'm wandering if there's some intelligent way to delete old records
from a mysql table without using cronjobs (i can't), using PHP.
This table has a field which stores the value returned from time(), and
i want to do 

mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");

at periodical intervals (say every 15 hours). Thanks for any hint :)

Ciao,
Stefano
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Vasco è tornato! Sul tuo cellulare Il mondo che vorrei
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7749&d=27-5

--- End Message ---
--- Begin Message ---
i'm wandering if there's some intelligent way to delete old records
from a mysql table without using cronjobs (i can't), using PHP.
This table has a field which stores the value returned from time(), and
i want to do
mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");

You could have it triggered manually, or by your website say. Or you could (if you have it) use a cron job on another machine. You must of course be able to connect to MySQL remotely from this box if you choose that route. Depending on your MySQL version triggers may be able to do it too - but I've not used these so I couldn't say for sure.

--
              Richard Heyes

         In Cambridge? Employ me
        http://www.phpguru.org/cv

+----------------------------------------+
| Access SSH with a Windows mapped drive |
|    http://www.phpguru.org/sftpdrive    |
+----------------------------------------+

--- End Message ---
--- Begin Message ---
At 1:26 PM +0200 5/27/08, Stefano Esposito wrote:
Hi all,

i'm wandering if there's some intelligent way to delete old records
from a mysql table without using cronjobs (i can't), using PHP.
This table has a field which stores the value returned from time(), and
i want to do

mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");

at periodical intervals (say every 15 hours). Thanks for any hint :)

Ciao,
Stefano

Stefano:

I can't help your wandering around, but if you are wondering about how to periodically delete records from a dB without using a cron, then this will work.

Create and set a field for "last_deletion" to current time.

When users accesses the dB, then have the process check current time with "last_deletion" and if the "last_deletion" is greater than current time plus 15 hours, then run the "delete old records" routine and reset the "last_deletion" to current time.

That way, users accessing the dB will trigger the "delete old records" process.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
2008/5/27 Stefano Esposito <[EMAIL PROTECTED]>:
> Hi all,
>
> i'm wandering if there's some intelligent way to delete old records
> from a mysql table without using cronjobs (i can't), using PHP.
> This table has a field which stores the value returned from time(), and
> i want to do
>
> mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");
>
> at periodical intervals (say every 15 hours). Thanks for any hint :)

What version of MySQL? If it's >= 5.1.6, you can use the mysql event scheduler.

http://dev.mysql.com/tech-resources/articles/event-feature.html
http://dev.mysql.com/doc/refman/5.1/en/events.html

-robin

--- End Message ---
--- Begin Message ---
Depending on how many records you need to delete, having it triggered by
your website may not be the best option. I suppose you could fork a
different process though.


On Tue, May 27, 2008 at 8:35 AM, tedd <[EMAIL PROTECTED]> wrote:

> At 1:26 PM +0200 5/27/08, Stefano Esposito wrote:
>
>> Hi all,
>>
>> i'm wandering if there's some intelligent way to delete old records
>> from a mysql table without using cronjobs (i can't), using PHP.
>> This table has a field which stores the value returned from time(), and
>> i want to do
>>
>> mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");
>>
>> at periodical intervals (say every 15 hours). Thanks for any hint :)
>>
>> Ciao,
>> Stefano
>>
>
> Stefano:
>
> I can't help your wandering around, but if you are wondering about how to
> periodically delete records from a dB without using a cron, then this will
> work.
>
> Create and set a field for "last_deletion" to current time.
>
> When users accesses the dB, then have the process check current time with
> "last_deletion" and if the  "last_deletion" is greater than current time
> plus 15 hours, then run the "delete old records" routine and reset the
> "last_deletion" to current time.
>
> That way, users accessing the dB will trigger the "delete old records"
> process.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
> tedd wrote:
At 1:26 PM +0200 5/27/08, Stefano Esposito wrote:
Hi all,

i'm wandering if there's some intelligent way to delete old records
from a mysql table without using cronjobs (i can't), using PHP.
This table has a field which stores the value returned from time(), and
i want to do

mysql_query("DELETE FROM `table` WHERE `time`<='".(time()-86400)."'");

at periodical intervals (say every 15 hours). Thanks for any hint :)

Depending on how busy your website is, you might not need to alter you schema at all. ie Add a query to one page of your website that only runs when it's minute 1 of any (or a particular) hour. Depending on how busy your website is it may mean that the query runs too much or too little.

--
              Richard Heyes

         In Cambridge? Employ me
        http://www.phpguru.org/cv

+----------------------------------------+
| Access SSH with a Windows mapped drive |
|    http://www.phpguru.org/sftpdrive    |
+----------------------------------------+

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

Re: cron jobs... this is my recommended solution. They don't need to be set up on the same server as your website. They can be on any host, and can just use curl to call a particular url on your site at set intervals.

~Ted



On 27-May-08, at 9:06 AM, Richard Heyes wrote:

> tedd wrote:
At 1:26 PM +0200 5/27/08, Stefano Esposito wrote:
Hi all,

i'm wandering if there's some intelligent way to delete old records
from a mysql table without using cronjobs (i can't), using PHP.
This table has a field which stores the value returned from time(), and
i want to do

mysql_query("DELETE FROM `table` WHERE `time`<='". (time()-86400)."'");

at periodical intervals (say every 15 hours). Thanks for any hint :)

Depending on how busy your website is, you might not need to alter you schema at all. ie Add a query to one page of your website that only runs when it's minute 1 of any (or a particular) hour. Depending on how busy your website is it may mean that the query runs too much or too little.


--- End Message ---
--- Begin Message ---
Ronald Wiplinger escreveu:
I would like to find some samples to start with.

We want to upload a picture and the user may apply some "filters" or
"instructions" to create a new picture, based on the uploaded picture and
the available "filters" and "instructions".

The idea of it is not really mature, since we have no idea where to start
and what is possible to do.

bye

R.

-------
Some useful examples for the use of filters and other efects, here:
http://www.educar.pro.br/i_en/php/gd/

--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
Você deve, sempre, consultar uma segunda opinião!
----------------------------------------------------------
Deixe todos saberem se esta informação foi-lhe útil.
----------------------------------------------------------      
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------

--- End Message ---
--- Begin Message ---
On Mon, May 26, 2008 at 11:34 PM, Emiliano Boragina
<[EMAIL PROTECTED]> wrote:
> I dont understand.. in my server I can run the form perfectly… but in the
> client server not… appears this message:
>
>
>
> Warning: mail() [ <http://www.consultapsico.com.ar/demo/function.mail>
> function.mail]: "sendmail_from" not set in php.ini or custom "From:" header
> missing in D:\Service\Sites\Consultapsico\www\demo\form.php on line 10

    The answer and link that Ted gave you should help you out, but one
thing I'd suggest as to why it worked on your server and not your
client's is that your client is using a Windows server.  Chances are,
your server is running a *NIX flavor.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
On Tue, 2008-05-27 at 11:27 -0400, Robert Cummings wrote:
>
> You can use use an import technique to import the serialized data and
> resave it in the PHP5 format:
> 
> foo.php5 (Run via PHP5)
> ---------------------------------------------------------
> <?php
> 
> class Foo
> {
>     protected $aaa = 'aaa5';
>     protected $bbb = 'bbb5';
>     protected $ccc = 'ccc5';
> 
>     static function importFromPhp4( $serialized )
>     {
>         $array = (array)unserialize( $serialized );
>         $import = new Foo();
> 
>         $import->aaa = $array['aaa'];
>         $import->bbb = $array['bbb'];
>         $import->ccc = $array['ccc'];

A loop can be used in the above assignment code to assign the
properties. You just need to check if the key is prefixed by the null
byte:

<?php

class Foo
{
    protected $aaa = 'aaa5';
    protected $bbb = 'bbb5';
    protected $ccc = 'ccc5';

    static function importFromPhp4( $serialized )
    {
        $array = (array)unserialize( $serialized );
        $import = new Foo();

        foreach( $array as $key => $value )
        {
            if( $key[0] !== "\x00" )
            {
                $import->$key = $value;
            }
        }

        return $import;
    }
}

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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

Robert, thanks very much for your detailed explanation. This makes sense as I've wrapped my brain around protected and private property types.

I think I'll be leaving them as public members for performance reasons. Down the road, I may add special handling for certain members that should be private and protected. The __sleep() and __wake() function should come in handy for that.

Thanks again.

~Ted



On 27-May-08, at 8:27 AM, Robert Cummings wrote:


On Tue, 2008-05-27 at 11:00 +0530, Chetan Rane wrote:
Can you please example code because I simulated the similar thing and it works fine here

<?php
class A {
        protected $x = '12345';
        protected $y = '12345';
        function __construct() {
                
        }
        
        public function Hello(){
                echo Hello2;
        }
        
}
echo "<pre>";
$a = new A();
echo serialize($a);
print_r($a);
print_r(unserialize(serialize($a)));

?>

O/P :
O:1:"A":2:{s:4:"�*�x";s:5:"12345";s:4:"�*�y";s:5:"12345";}A Object
(
   [x:protected] => 12345
   [y:protected] => 12345
)
A Object
(
   [x:protected] => 12345
   [y:protected] => 12345
)

I think that’s perfectly fine.

You didn't read his problem correctly. Try the following:

foo.php4  (Run via PHP4)
---------------------------------------------------------
<?php

class Foo
{
   var $aaa = 'aaa4';
   var $bbb = 'bbb4';
   var $ccc = 'ccc4';
}

echo serialize( new Foo() );

?>

Now using the output from the above script paste it into the $foo4 var
in the following script (it should be as shown in my example below):

foo.php5 (Run via PHP5)
---------------------------------------------------------
<?php

class Foo
{
   protected $aaa = 'aaa5';
   protected $bbb = 'bbb5';
   protected $ccc = 'ccc5';
}

$foo4 =
'O:3:"foo":3:{s:3:"aaa";s:4:"aaa4";s:3:"bbb";s:4:"bbb4";s:3:"ccc";s: 4:"ccc4";}';
$foo4 = unserialize( $foo4 );

var_dump( $foo4 );

?>

The reason this happens is because serialize tracks the var type. In the PHP4 case, no var type is possible and so no var type is stored. As such the unserialize function does what PHP code does... it presumes public. However, at a low level within the PHP binary, there is no check to see
if the property exists in another form. For instance, to unserialize,
the unserialize code instantiates a new Foo object when it encounters
the Foo instance in the serialized data stream. When it is instantiated the protected members are initialized. But protected members are stored differently internally than public members, and so, I presume for speed,
PHP didn't bother testing for the existence of both, but rather gives
one precedence over the other when a property is requested. So happily, the different variable types are co-existing. Some pbrief testing shows
that private members are getting precedence. So this is obviously an
issue for all the old serialized data once you promote the var type to
protected.

So what CAN you do??

You can choose not to change the properties to protected.

You can use use an import technique to import the serialized data and
resave it in the PHP5 format:

foo.php5 (Run via PHP5)
---------------------------------------------------------
<?php

class Foo
{
   protected $aaa = 'aaa5';
   protected $bbb = 'bbb5';
   protected $ccc = 'ccc5';

   static function importFromPhp4( $serialized )
   {
       $array = (array)unserialize( $serialized );
       $import = new Foo();

       $import->aaa = $array['aaa'];
       $import->bbb = $array['bbb'];
       $import->ccc = $array['ccc'];

       return $import;
   }
}

$foo4 =
'O:3:"foo":3:{s:3:"aaa";s:4:"aaa4";s:3:"bbb";s:4:"bbb4";s:3:"ccc";s: 4:"ccc4";}';
$foo = Foo::importFromPhp4( $foo4 );

var_dump( $foo );

?>

That should solve the problem.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP



--- End Message ---
--- Begin Message ---
On Tue, 2008-05-27 at 08:40 -0700, Ted Wood wrote:
> Robert, thanks very much for your detailed explanation. This makes  
> sense as I've wrapped my brain around protected and private property  
> types.
>
> I think I'll be leaving them as public members for performance  
> reasons. Down the road, I may add special handling for certain
> members  
> that should be private and protected. The __sleep() and __wake()  
> function should come in handy for that.

If you're moving your entire system over to PHP5, then a one time pass
through the database may be optimal. A simple loop to grab each record,
import it, re-serialize and save it should do the trick. And from my
brief test where I found private members have precedence over public
members, it seems it might be the most efficient solution also... in the
long term.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Tue, 2008-05-27 at 11:00 +0530, Chetan Rane wrote:
> Can you please example code because I simulated the similar thing and it 
> works fine here
> 
> <?php
> class A {
>       protected $x = '12345';
>       protected $y = '12345';
>       function __construct() {
>               
>       }
>       
>       public function Hello(){
>               echo Hello2;
>       }
>       
> }
> echo "<pre>";
> $a = new A();
> echo serialize($a);
> print_r($a);
> print_r(unserialize(serialize($a)));
> 
> ?>
> 
> O/P :
> O:1:"A":2:{s:4:"�*�x";s:5:"12345";s:4:"�*�y";s:5:"12345";}A Object
> (
>     [x:protected] => 12345
>     [y:protected] => 12345
> )
> A Object
> (
>     [x:protected] => 12345
>     [y:protected] => 12345
> )
> 
> I think that’s perfectly fine.

You didn't read his problem correctly. Try the following:

foo.php4  (Run via PHP4)
---------------------------------------------------------
<?php

class Foo
{
    var $aaa = 'aaa4';
    var $bbb = 'bbb4';
    var $ccc = 'ccc4';
}

echo serialize( new Foo() );

?>

Now using the output from the above script paste it into the $foo4 var
in the following script (it should be as shown in my example below):

foo.php5 (Run via PHP5)
---------------------------------------------------------
<?php

class Foo
{
    protected $aaa = 'aaa5';
    protected $bbb = 'bbb5';
    protected $ccc = 'ccc5';
}

$foo4 =
'O:3:"foo":3:{s:3:"aaa";s:4:"aaa4";s:3:"bbb";s:4:"bbb4";s:3:"ccc";s:4:"ccc4";}';
$foo4 = unserialize( $foo4 );

var_dump( $foo4 );

?>

The reason this happens is because serialize tracks the var type. In the
PHP4 case, no var type is possible and so no var type is stored. As such
the unserialize function does what PHP code does... it presumes public.
However, at a low level within the PHP binary, there is no check to see
if the property exists in another form. For instance, to unserialize,
the unserialize code instantiates a new Foo object when it encounters
the Foo instance in the serialized data stream. When it is instantiated
the protected members are initialized. But protected members are stored
differently internally than public members, and so, I presume for speed,
PHP didn't bother testing for the existence of both, but rather gives
one precedence over the other when a property is requested. So happily,
the different variable types are co-existing. Some pbrief testing shows
that private members are getting precedence. So this is obviously an
issue for all the old serialized data once you promote the var type to
protected.

So what CAN you do??

You can choose not to change the properties to protected.

You can use use an import technique to import the serialized data and
resave it in the PHP5 format:

foo.php5 (Run via PHP5)
---------------------------------------------------------
<?php

class Foo
{
    protected $aaa = 'aaa5';
    protected $bbb = 'bbb5';
    protected $ccc = 'ccc5';

    static function importFromPhp4( $serialized )
    {
        $array = (array)unserialize( $serialized );
        $import = new Foo();

        $import->aaa = $array['aaa'];
        $import->bbb = $array['bbb'];
        $import->ccc = $array['ccc'];

        return $import;
    }
}

$foo4 =
'O:3:"foo":3:{s:3:"aaa";s:4:"aaa4";s:3:"bbb";s:4:"bbb4";s:3:"ccc";s:4:"ccc4";}';
$foo = Foo::importFromPhp4( $foo4 );

var_dump( $foo );

?>

That should solve the problem.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message --- It can certainly be done. It can easily be done using the Imagick extension (Image Magick extension for PHP), as I have just done something similar (taking multiple PDFs and combining into flattened multi-page PDFs)

Is PHP the best language for this? Depends on your knowledge and confort level with PHP. The best language is the language you know best and can easily accomodate your requirements.

- spoon

""Ronald Wiplinger"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
I got a Windows program, which can scan in a book by scanning in the pages
1,3,5, ....n  turn the book by 180 degrees and scan in from the back side
n-1,n-3, ... 2. Then the program made a pdf book of the scanned in pages.

I am not sure if a php program is the right way to do, but I thought to do
the same by scanning in the pages (p0001, p0002, p0003, .....) and then work on each page in a batch to turn p0001 by 180 degree and rename it to a0001,
rename p000(n-1) to a0002, turn p0002 by 180 degree and rename it to a0003
....
and add each page to a book.pdf

Is php right for that?

bye

Ronald



--- End Message ---
--- Begin Message ---
On Tue, May 27, 2008 at 11:46 AM, Christian Flickinger <[EMAIL PROTECTED]>
wrote:

> It can certainly be done. It can easily be done using the Imagick extension
> (Image Magick extension for PHP), as I have just done something similar
> (taking multiple PDFs and combining into flattened multi-page PDFs)
>
> Is PHP the best language for this? Depends on your knowledge and confort
> level with PHP. The best language is the language you know best and can
> easily accomodate your requirements.
>
> - spoon
>
>
Christian,

Interesting to know, however the OP's question was about using PHP to run
the scanner, not on the already present PDFs in the FS. Can your solution
handle the scanning? Could / Would you be willing to share you solution on
merging the PDFs? That is something that I am interested in...

Thanks,
-- 

Bastien

Cat, the other other white meat

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

On May 27, 2008, at 923AM, Bastien Koert wrote:
Interesting to know, however the OP's question was about using PHP to run
the scanner, not on the already present PDFs in the FS.

That's not how I read the question, but clearly I could be wrong...


Could / Would you be willing to share you solution on
merging the PDFs? That is something that I am interested in...

I've been meaning to suggest that the OP look at pdftk (http://www.accesspdf.com/pdftk/ ) - though it's not a PHP solution, it's a great tool for working with PDFs. It can make otherwise tedious, time consuming tasks with PDFs quick and easy.

Brady

--- End Message ---
--- Begin Message ---
HI!


I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

<?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
  header("HTTP/1.1 301 Moved Permanently");
  header("Location: http:///example.com/";);
  exit();
}
?>



Regards,
Yui

--- End Message ---
--- Begin Message ---
On 27 May 2008, at 17:06, Yui Hiroaki wrote:
I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

<?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: http:///example.com/";);
 exit();
}
?>

1) Why? Redirects should be avoided where possible for performance reasons.

2) If you have to then the code you have will work but you need to check $_SERVER['QUERY_STRING'] rather than REQUEST_URI.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Yui Hiroaki wrote:
HI!


I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

<?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
  header("HTTP/1.1 301 Moved Permanently");
  header("Location: http:///example.com/";);
  exit();
}
?>



Regards,
Yui


Well, in your example code, you have 3 forward slashes...

What that a typo in your example, or is that cut/paste from your script?

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
I try it following your adivice;



Code***************************************
<?php
$uuu=$_SERVER["QUERY_STRING"];

if ($_SERVER['REQUEST_URI'] == '/index.php'."?"."$uuu") {
  header("HTTP/1.1 301 Moved Permanently");
  header("Location: http://example.com/";);
  exit();
}
?>

But I still need toconfigure below;
http://example/index.php?123233 and http://example/index.php/?123233



Can you help me?


Regards,
Yui
2008/5/28 Stut <[EMAIL PROTECTED]>:
> On 27 May 2008, at 17:06, Yui Hiroaki wrote:
>>
>> I would like to have some question.
>>
>> For example,
>> I am in http://example.com/?12324242
>>
>> I would like to REDIRECT from  http://example.com/?1312323232
>> to  http://example.com/
>>
>> I can REDIRECT from http://example.com/index.php to http://example.com
>>
>>
>> Please do tell me how I can redirect!
>>
>>
>> This is the sample what I test below!
>>
>> <?php
>> if ($_SERVER['REQUEST_URI'] == '/index.php') {
>>  header("HTTP/1.1 301 Moved Permanently");
>>  header("Location: http:///example.com/";);
>>  exit();
>> }
>> ?>
>
> 1) Why? Redirects should be avoided where possible for performance reasons.
>
> 2) If you have to then the code you have will work but you need to check
> $_SERVER['QUERY_STRING'] rather than REQUEST_URI.
>
> -Stut
>
> --
> http://stut.net/
>

--- End Message ---
--- Begin Message ---
On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
> On 27 May 2008, at 17:06, Yui Hiroaki wrote:
> > I would like to have some question.
> >
> > For example,
> > I am in http://example.com/?12324242
> >
> > I would like to REDIRECT from  http://example.com/?1312323232
> > to  http://example.com/
> >
> > I can REDIRECT from http://example.com/index.php to http://example.com
> >
> >
> > Please do tell me how I can redirect!
> >
> >
> > This is the sample what I test below!
> >
> > <?php
> > if ($_SERVER['REQUEST_URI'] == '/index.php') {
> >  header("HTTP/1.1 301 Moved Permanently");
> >  header("Location: http:///example.com/";);
> >  exit();
> > }
> > ?>
> 
> 1) Why? Redirects should be avoided where possible for performance  
> reasons.

Didn't this topic get covered several months back. I always do redirects
so as not to bugger browser history, titles, indexing, etc. If someone
requests a page and they need to be logged in, I redirect to the login
page, I never just present the login page... that's just incorrect from
a hierarchical and semantic point of view. Similarly, if I'm doing 404
handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On 27 May 2008, at 17:45, Yui Hiroaki wrote:
I try it following your adivice;



Code***************************************
<?php
$uuu=$_SERVER["QUERY_STRING"];

if ($_SERVER['REQUEST_URI'] == '/index.php'."?"."$uuu") {
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: http://example.com/";);
 exit();
}
?>

But I still need toconfigure below;
http://example/index.php?123233 and http://example/index.php/?123233



Can you help me?

<?php
  if (strlen($_SERVER['QUERY_STRING']) > 0)
  {
    // The third parameter of the header function can be
    // used to set the response code.
    header('Location: http://example.com/', true, 301);

    // You really should output something here so that in
    // the unlikely event the client doesn't auto-follow
    // the redirect the user is not left in the lurch.
    echo 'Moved <a href="http://example.com/";>here</a>';

    exit;
  }
?>

Rocket science it ain't!

But I repeat... this seems to be a completely pointless redirect. The user is already requesting the index page, so why redirect them back to the index page?

-Stut

--
http://stut.net/

2008/5/28 Stut <[EMAIL PROTECTED]>:
On 27 May 2008, at 17:06, Yui Hiroaki wrote:

I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

<?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http:///example.com/";);
exit();
}
?>

1) Why? Redirects should be avoided where possible for performance reasons.

2) If you have to then the code you have will work but you need to check
$_SERVER['QUERY_STRING'] rather than REQUEST_URI.

-Stut

--
http://stut.net/



--- End Message ---
--- Begin Message ---
On 27 May 2008, at 17:54, Robert Cummings wrote:
On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
On 27 May 2008, at 17:06, Yui Hiroaki wrote:
I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

<?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http:///example.com/";);
exit();
}
?>

1) Why? Redirects should be avoided where possible for performance
reasons.

Didn't this topic get covered several months back. I always do redirects
so as not to bugger browser history, titles, indexing, etc. If someone
requests a page and they need to be logged in, I redirect to the login
page, I never just present the login page... that's just incorrect from

Personally I tend to only use redirects when a form handler has done it's job to avoid evil messages when the user hits back. However, I have used both redirected and non-redirected login workflows in the past for various reasons, and I don't believe there is a "standard" way to do it. It depends on how the site will be used and by whom.

a hierarchical and semantic point of view. Similarly, if I'm doing 404
handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.

The correct response to a 404 page is 404. No arguments. If you redirect missing pages then your site effectively contains an infinite number of pages. By all means display a useful page when you return your 404 but not marking it as a missing page does little if anything for your SEO rank and absolutely nothing for your users.

IMHO if you're going to use a semantic argument to defend one point you need to carry that attitude throughout.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
What about using .htaccess for redirection for example, to redirect a single 
page:

Redirect 301  /oldpage.html  http://www.example.com/newpage.html



Stut <[EMAIL PROTECTED]> wrote: CC: PHP General List <[EMAIL PROTECTED]>
From: Stut <[EMAIL PROTECTED]>
To: Robert Cummings <[EMAIL PROTECTED]>
Date: Tue, 27 May 2008 18:04:02 +0100
Subject: Re: [PHP] Header Redirect

 On 27 May 2008, at 17:54, Robert Cummings wrote:
> On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
>> On 27 May 2008, at 17:06, Yui Hiroaki wrote:
>>> I would like to have some question.
>>>
>>> For example,
>>> I am in http://example.com/?12324242
>>>
>>> I would like to REDIRECT from  http://example.com/?1312323232
>>> to  http://example.com/
>>>
>>> I can REDIRECT from http://example.com/index.php to http://example.com
>>>
>>>
>>> Please do tell me how I can redirect!
>>>
>>>
>>> This is the sample what I test below!
>>>
>>> >>> if ($_SERVER['REQUEST_URI'] == '/index.php') {
>>> header("HTTP/1.1 301 Moved Permanently");
>>> header("Location: http:///example.com/";);
>>> exit();
>>> }
>>> ?>
>>
>> 1) Why? Redirects should be avoided where possible for performance
>> reasons.
>
> Didn't this topic get covered several months back. I always do  
> redirects
> so as not to bugger browser history, titles, indexing, etc. If someone
> requests a page and they need to be logged in, I redirect to the login
> page, I never just present the login page... that's just incorrect  
> from

Personally I tend to only use redirects when a form handler has done  
it's job to avoid evil messages when the user hits back. However, I  
have used both redirected and non-redirected login workflows in the  
past for various reasons, and I don't believe there is a "standard"  
way to do it. It depends on how the site will be used and by whom.

> a hierarchical and semantic point of view. Similarly, if I'm doing 404
> handling with fuzzy request sniffing to determine what was actually
> requested, I again perform a redirect once I've ascertained what was
> probably desired. If you don't, then Google and other search engines
> will index these malformed URLs instead of the correct URL.

The correct response to a 404 page is 404. No arguments. If you  
redirect missing pages then your site effectively contains an infinite  
number of pages. By all means display a useful page when you return  
your 404 but not marking it as a missing page does little if anything  
for your SEO rank and absolutely nothing for your users.

IMHO if you're going to use a semantic argument to defend one point  
you need to carry that attitude throughout.

-Stut

-- 
http://stut.net/

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



       

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

I am querying uploaded files using the php function
mime_content_type($file), passing the absolute path to the file in the $file
var.

The result I get back is "text/plain" which clearly isn't what I expected -
or hoped for.

Is this php related or could it be Apache's config missing something like
"AddType application/x-Shockwave-Flash .swf" ?

I have no access to Apache's config as the server is managed but I really
would like to filter files based on mime type as opposed to file extensions
- and also get to the bottom of it.

Thanks,

Bob





--- End Message ---
--- Begin Message ---
my question is about validation using php. i am validating a username
which a user would enter and clicks on a image to find

if that username is available. example if a user enters abc#123 php
file is reading this value as abc ONLY which i do not

want instead the php file should read as abc#123. follow is the
sequence of pages. please advice the solution.

first page = register.php here a user enters a username and clicks on
an image to find out if the username is available or

not. using a javascript function of onclick i am reading the value
entered in the form in javascript as
=============================================
var useri = document.registrationform.username
var valueofuseri = document.registrationform.username.value

var recui = /^\s{1,}$/g;

if ((useri.value==null) || (useri.value=="") || (useri.length=="") ||
(useri.value.search(recui))> -1)
{
alert("Please Enter a User Name")
return false
}

window.open("checkusernamei.php?theusernameis="+valueofuseri,
"titleforavailabilityi", "width=680,  height=275, status=1,

scrollbars=1, resizeable=yes");

============================================

second page = checkusernamei.php = this file uses GET to read what was
entered in the form.
============================================
$username = $_GET["theusernameis"];

if( $username == "" ||  !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i",
$username) )
{
echo "username is blank or has special characters";
}
============================================
the # sign is being ignored only if the image is clicked in order to
check the username, if the user enters abc#123 and

clicks the submit button without clicking on the checkuser image
button then my php validation for username shows an error

message.

==============================================================
if( $username == "" ||  !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i",
$username) )
{ echo "display error message for username"; }
==============================================================
now the problem is with clicking the image only and passing using GET
method how can i fix this problem.

please advice.

thanks.

--- End Message ---
--- Begin Message ---
You need to encode the # mark. It is a special character in URLs.

Example (not a real url):
www.php.net/documentation.php#help

That #help points to an anchor in that page.

Try using the javascript escape() function.
http://www.javascripter.net/faq/escape.htm

~Ted



On 27-May-08, at 10:14 AM, Sudhakar wrote:

my question is about validation using php. i am validating a username
which a user would enter and clicks on a image to find

if that username is available. example if a user enters abc#123 php
file is reading this value as abc ONLY which i do not

want instead the php file should read as abc#123. follow is the
sequence of pages. please advice the solution.

first page = register.php here a user enters a username and clicks on
an image to find out if the username is available or

not. using a javascript function of onclick i am reading the value
entered in the form in javascript as
=============================================
var useri = document.registrationform.username
var valueofuseri = document.registrationform.username.value

var recui = /^\s{1,}$/g;

if ((useri.value==null) || (useri.value=="") || (useri.length=="") ||
(useri.value.search(recui))> -1)
{
alert("Please Enter a User Name")
return false
}

window.open("checkusernamei.php?theusernameis="+valueofuseri,
"titleforavailabilityi", "width=680,  height=275, status=1,

scrollbars=1, resizeable=yes");

============================================

second page = checkusernamei.php = this file uses GET to read what was
entered in the form.
============================================
$username = $_GET["theusernameis"];

if( $username == "" ||  !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i",
$username) )
{
echo "username is blank or has special characters";
}
============================================
the # sign is being ignored only if the image is clicked in order to
check the username, if the user enters abc#123 and

clicks the submit button without clicking on the checkuser image
button then my php validation for username shows an error

message.

==============================================================
if( $username == "" ||  !preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i",
$username) )
{ echo "display error message for username"; }
==============================================================
now the problem is with clicking the image only and passing using GET
method how can i fix this problem.

please advice.

thanks.

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



--- End Message ---

Reply via email to