php-general Digest 1 Jul 2008 12:51:07 -0000 Issue 5544

Topics (messages 276147 through 276163):

Re: unset in foreach breaks recrusion
        276147 by: David Sky

Re: exec() Error
        276148 by: zhiqi pan

ISO
        276149 by: òÅÁÌÉÚÁÃÉÑ ðÒÏÅËÔÁ

REALLY NEWB QUESTION - include issue
        276150 by: TS
        276151 by: TS
        276152 by: Thijs Lensselink
        276155 by: TS
        276156 by: Chris
        276157 by: Thijs Lensselink

Re: Simple array problem
        276153 by: Thijs Lensselink
        276154 by: Richard Heyes
        276162 by: tedd
        276163 by: Richard Heyes

Re: Encription
        276158 by: Stefano Esposito

Re: can you give me example of website using postgresql database?
        276159 by: paragasu

Re: Strategy to protect images
        276160 by: Stefano Esposito
        276161 by: Nitsan Bin-Nun

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 ---
Hey,

Can't use your example, as you check weather
$sorted is empty, if it is -> run the foreach and return,
but on next recursion when it's not empty - do nothing :)

Though I found how to cut a few seconds (on very big array),
removing the first if, and adding a $return=true to functions'
parameters, and in future calls set it to false:

function recur($array, &$sorted=array(), $pid=0, $level=0, $return=true)
{
                foreach($array as $id=>$parent)
                {
                        if($pid===$parent)
                        {       
                                $sorted[$id]= $level;
                                unset($array[$id]);
                                if(in_array($id,$array)){
                                        recur($array, &$sorted, $id, $level+1, 
false);
                                }
                        }
                }
                if($return){return $sorted;}
}


Well, I guess that's it, I'm sure I can think of
another way to cut execution time, but, well,
I don't have much time for it :)


Thanks all!

David.


On Mon, Jun 30, 2008 at 8:24 AM, Roberto Costumero Moreno
<[EMAIL PROTECTED]> wrote:
> Hi David,
>
> That's good work ;-)
>
> You are right that my example would only return one entry for each parent.
> Didn't realized of that.
>
> I know the local copies you create in the recursive calls is not the best
> solution in efficiency, but lots of times it is better to have local copies
> of the array (in time of execution of the foreach) that the reference to it,
> and the loss is not so big.
>
> I think i would not be able to improve that function a lot, but if I come up
> a solution I will tell you.
>
> One little advice, you can get the same functionality saving a little bit of
> code, and having one variable less, so the function should look like this
> (avoiding the use of $return variable and makes the code clearer for later
> revisions):
>
> /**
>  * Recursion
>  * @array as ( id => parent )
>  * return array as ( id => level ) maintaining arrays' initial order
>  */
> function recur($array, &$sorted=array(), $pid=0, $level=0)
> {
>        if(empty($sorted)){
>           foreach($array as $id=>$parent)
>           {
>                if($pid===$parent)
>                {
>                        $sorted[$id]= $level;
>                        unset($array[$id]);
>                        if(in_array($id,$array)){
>                                recur($array, &$sorted, $id, $level+1);
>                        }
>                }
>           }
>           return $sorted;
>        }
> }
>
> Note that return $sorted is inside the if so as to avoid returning an empty
> array. If you don't mind returning an empty array put it down the bracket.
>
> And thanks to you. I signed up to the mailing list only two days ago
> (although I've been working with PHP for at least 3 years), and you are the
> first person I help successfully (or almost). Don't ever regret of asking
> problems in the mailing list and always wait about 24 hours for someone to
> answer ;-)
>
> There are lots of people from all over the world so if the one helping your
> case is in the opposite part of the world and is asleep... it takes time ;-)
>
> Cheers,
>
> Roberto
>
>
>
>
> On Mon, Jun 30, 2008 at 17:38, David Sky <[EMAIL PROTECTED]> wrote:
>>
>> Hey Robero,
>>
>> Thanks for the answer, the none recursion function is a good idea,
>> although as provided in your example if would only return one
>> entry from each parent it can get to and it only can get to few,
>> depends on how the array is sorted.
>>
>> Basically you can make it work if you would sort the array from
>> small to high by parent value, but in my case I will get this array
>> pre-sorted by date, so I can't change the order.
>>
>> Now, about your other suggestion, yes, it will work without the reference.
>> I used the reference to avoid creating "local" copies of the array.
>>
>> I solved the problem by removing the reference just as you said, but then
>> there would be to many recursions, so I ended up with this function:
>>
>> /**
>>  * Recursion
>>  * @array as ( id => parent )
>>  * return array as ( id => level ) maintaining arrays' initial order
>>  */
>> function recur($array, &$sorted=array(), $pid=0, $level=0)
>> {
>>        if(empty($sorted)){$return=true;}else{$return=false;}
>>        foreach($array as $id=>$parent)
>>        {
>>                if($pid===$parent)
>>                {
>>                        $sorted[$id]= $level;
>>                        unset($array[$id]);
>>                        if(in_array($id,$array)){
>>                                recur($array, &$sorted, $id, $level+1);
>>                        }
>>                }
>>        }
>>        if($return){return $sorted;}
>> }
>>
>> Checking with in_array if parent exist in array to make
>> less runs and saving micro seconds on return... haha.
>>
>> I couldn't make it any faster, but if anybody can,
>> please, let me know, I would be happy to know how to.
>>
>>
>> Thanks Robero, this is first time I'm looking for help in mailing list,
>> and I was starting to regret writing here, but your reply changed it :)
>>
>> Thanks!
>>
>> David.
>>
>>
>>
>> On Mon, Jun 30, 2008 at 6:36 AM, Roberto Costumero Moreno
>> <[EMAIL PROTECTED]> wrote:
>> > That's not the problem. Look that the function is called with &$return,
>> > so
>> > there is a reference to the variable in which the function returns the
>> > value
>> > (if not there would not be an answer...).
>> >
>> > Otherwise, i think the problem is in the recursive call inside the
>> > function.
>> > Once you make the unset, you make a recursive call to the function like:
>> >
>> > recrusion(&$array, &$return, $id, $level+1);
>> >
>> > while I think the problem will be solved if you make the call just like:
>> >
>> > recrusion($array, &$return, $id, $level+1);
>> >
>> >
>> > Notice that the $array variable has not & symbol, so is the variable
>> > itself
>> > and not a reference of it.
>> >
>> > Although there is a better and simple solution for that problem (or I
>> > think
>> > something like this should work well):
>> >
>> >
>> > <?php
>> > function recrusion($array, $return, $pid=0, $level=0){
>> >       foreach($array as $id=>$parent){
>> >               if( $parent===$pid ){
>> >                       $return[$id]= $level;
>> >                       unset($array[$id]); /* remove this to get correct
>> > results */
>> >
>> >                       $level++;
>> >                         $pid = $id;
>> >               }
>> >       }
>> > }
>> > $return= array();
>> > $array= array(1=>0,2=>1,3=>2,4=>3,5=>2,6=>2,7=>6,8=>6,9=>0,10=>0);
>> > recrusion($array, &$return);
>> >
>> > var_dump( $return );
>> > ?>
>> >
>> > So you don't make any recursive call, you don't lose too much efficiency
>> > and
>> > it should work well for the whole array.
>> >
>> > Try the two solutions above and see whether if any is up to your
>> > problem.
>> >
>> >
>> > Cheers,
>> >
>> > Roberto
>> >
>> >
>> > On Mon, Jun 30, 2008 at 14:27, Jason Norwood-Young
>> > <[EMAIL PROTECTED]> wrote:
>> >>
>> >> On Sun, 2008-06-29 at 18:25 -0800, David Sky wrote:
>> >> > Hello everyone!
>> >> >
>> >> > A couple of days ago I submitted a bug to PHP
>> >> > http://bugs.php.net/bug.php?id=45385
>> >> > But I was mistaken, apparently it's not a bug.
>> >> > And I was "sent" here to get help.
>> >>
>> >> I think you might be forgetting to return $return.
>> >>
>> >> J
>> >>
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >
>> >
>
>

--- End Message ---
--- Begin Message ---
use wget
exec("wget http://www.mysite.com/calculate.php";);
Only execute the php programe from "web"
exec("/usr/bin/php /.../calculate.php")



2008/6/27 Boyd, Todd M. <[EMAIL PROTECTED]>:

> > -----Original Message-----
> > From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, June 26, 2008 7:50 AM
> > To: Boyd, Todd M.; [EMAIL PROTECTED]
> > Subject: RE: Re: [PHP] exec() Error
> >
> > Hi, Todd:
> >
> >    It looks like I have some other errors in my Perl code, and I got
> it
> > fixed, switched the permission to 755, and made attempts to call it
> > using cURL through my working PHP script.
> >
> >    Here is the code:
> >
> > // create a new cURL resource
> > $ch = curl_init();
> >
> > // set URL and other appropriate options
> > curl_setopt($ch, CURLOPT_URL, "http://192.168.10.63/total.cgi";);
> > curl_setopt($ch, CURLOPT_HEADER, false);
> >
> > // grab URL and pass it to the browser
> > curl_exec($ch);
> >
> > // close cURL resource, and free up system resources
> > curl_close($ch);
> >
> > This time, I do not get the "script" output from the script in
> > total.cgi, but I got
> >
> > Forbidden
> > You don't have permission to access /total.cgi on this server.
> >
> > I have switched the permission to both scripts at both servers. Is
> > there something wrong I have done here?
>
> Alice,
>
> I do not program in Perl, nor do I use CGI often enough to help you much
> here. However, it looks to me like it's a webserver issue, and has
> nothing to do with your code itself. Whatever CGI module is being used
> must probably be told that total.cgi needs granular permissions.
>
> Your web administrator will be able to help you much more than I can at
> this point.
>
> HTH,
>
>
> Todd Boyd
> Web Programmer
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
潘治岐
手机: 13621265301
Email: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
  
Бизнес-процессы: проект по описанию и оптимизации
Семинар 10-11 июля, Москва 


В программе:
  Когда и кому   нужно описание бизнес-процессов  Основные   методы описания 
&#8211; какой выбрать?  Анализ орг.структуры   и процессов компании  Система 
показателей   бизнес-процессов  ПО для формализации   процессов  Реализация   
проекта: рабочая группа, последовательность   действий, аудит  Оптимизация   
бизнес-процессов    
        Каждая тема сопровождается разбором практики 

Для получения дополнительной информации пишите [EMAIL PROTECTED]
Или звоните
        
508-62-45&nbsp;&nbsp; и&nbsp;&nbsp;&nbsp;       8-915-362-78-61


--- End Message ---
--- Begin Message ---
Trying to "include()" a script from another domain on my server and it won't
let me do it.

I'm getting this error.

open_basedir restriction in effect. Operation not permitted etc...

Please help and stop laughing at me.

Thanks ahead, T


--- End Message ---
--- Begin Message ---
>Code segment?
>Exact error message? (Is there more context?)

Include (/file);

Function.include</a>]: open_basedir restriction in effect.
File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed
path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in
/var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line 151

It's my server and it makes perfect security sense because the package I'm
using allows me to resell but, I don't care about that particular security
issue since I'm not reselling. I'm assuming it's something in php.ini. It's
a linux machine. I'm not sure what else there is to tell. 

Thanks, T





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 01, 2008 1:08 AM
To: TS
Subject: RE: [PHP] REALLY NEWB QUESTION - include issue

Code segment?
Exact error message? (Is there more context?)

I probably don't have the answer to answer you, but make like a little
easier
for those who might by giving them some information to work with.

David

>-- Original Message --
>From: "TS" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Date: Tue, 1 Jul 2008 00:50:50 -0600
>Subject: [PHP] REALLY NEWB QUESTION - include issue
>
>
>Trying to "include()" a script from another domain on my server and it
won't
>let me do it.
>
>I'm getting this error.
>
>open_basedir restriction in effect. Operation not permitted etc...
>
>Please help and stop laughing at me.
>
>Thanks ahead, T
>
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>


--- End Message ---
--- Begin Message ---
Quoting TS <[EMAIL PROTECTED]>:

Code segment?
Exact error message? (Is there more context?)

Include (/file);

Function.include</a>]: open_basedir restriction in effect.
File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed
path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in
/var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line 151

It's my server and it makes perfect security sense because the package I'm
using allows me to resell but, I don't care about that particular security
issue since I'm not reselling. I'm assuming it's something in php.ini. It's
a linux machine. I'm not sure what else there is to tell.

Thanks, T





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2008 1:08 AM
To: TS
Subject: RE: [PHP] REALLY NEWB QUESTION - include issue

Code segment?
Exact error message? (Is there more context?)

I probably don't have the answer to answer you, but make like a little
easier
for those who might by giving them some information to work with.

David

-- Original Message --
From: "TS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Tue, 1 Jul 2008 00:50:50 -0600
Subject: [PHP] REALLY NEWB QUESTION - include issue


Trying to "include()" a script from another domain on my server and it
won't
let me do it.

I'm getting this error.

open_basedir restriction in effect. Operation not permitted etc...

Please help and stop laughing at me.

Thanks ahead, T



Looks like your hosting is blocking files included outside of the webroot. If you have root access you could change this. If you wanted to. But security is not a bad thing :)

To allow opening of remote url's you can enable 'allow_url_fopen' in php.ini.


--- End Message ---
--- Begin Message ---
> To allow opening of remote url's you can enable 'allow_url_fopen' in
php.ini.

This isn't a remote url though. It's a local path.

Looking for something similar to crossdomain.xml file for Flash if anyone is
familiar with that.

Thanks, T


-----Original Message-----
From: Thijs Lensselink [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 01, 2008 1:58 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] REALLY NEWB QUESTION - include issue

Quoting TS <[EMAIL PROTECTED]>:

>> Code segment?
>> Exact error message? (Is there more context?)
>
> Include (/file);
>
> Function.include</a>]: open_basedir restriction in effect.
> File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed
> path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in
> /var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line
151
>
> It's my server and it makes perfect security sense because the package I'm
> using allows me to resell but, I don't care about that particular security
> issue since I'm not reselling. I'm assuming it's something in php.ini.
It's
> a linux machine. I'm not sure what else there is to tell.
>
> Thanks, T
>
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 01, 2008 1:08 AM
> To: TS
> Subject: RE: [PHP] REALLY NEWB QUESTION - include issue
>
> Code segment?
> Exact error message? (Is there more context?)
>
> I probably don't have the answer to answer you, but make like a little
> easier
> for those who might by giving them some information to work with.
>
> David
>
>> -- Original Message --
>> From: "TS" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Date: Tue, 1 Jul 2008 00:50:50 -0600
>> Subject: [PHP] REALLY NEWB QUESTION - include issue
>>
>>
>> Trying to "include()" a script from another domain on my server and it
> won't
>> let me do it.
>>
>> I'm getting this error.
>>
>> open_basedir restriction in effect. Operation not permitted etc...
>>
>> Please help and stop laughing at me.
>>
>> Thanks ahead, T
>>
>>

Looks like your hosting is blocking files included outside of the  
webroot. If you have root access you could change this. If you wanted  
to. But security is not a bad thing :)

To allow opening of remote url's you can enable 'allow_url_fopen' in
php.ini.


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


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Thijs Lensselink [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 01, 2008 1:58 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] REALLY NEWB QUESTION - include issue
> 
> Quoting TS <[EMAIL PROTECTED]>:
> 
>>> Code segment?
>>> Exact error message? (Is there more context?)
>> Include (/file);
>>
>> Function.include</a>]: open_basedir restriction in effect.
>> File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed
>> path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in
>> /var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line
> 151


/var/www/vhosts/domain/httpdocs/file.php is not in the paths you allowed:

/var/www/vhosts/differentdomain/httpdocs

or

/tmp

So you'll need to adjust it through your apache config or you can
disable it just for that domain as well.

See
http://www.php.net/manual/en/configuration.changes.php#configuration.changes.apache


and

http://www.php.net/manual/en/features.safe-mode.php#ini.open-basedir


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

--- End Message ---
--- Begin Message ---
Quoting TS <[EMAIL PROTECTED]>:

To allow opening of remote url's you can enable 'allow_url_fopen' in
php.ini.

This isn't a remote url though. It's a local path.

Looking for something similar to crossdomain.xml file for Flash if anyone is
familiar with that.

Thanks, T


-----Original Message-----
From: Thijs Lensselink [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2008 1:58 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] REALLY NEWB QUESTION - include issue

Quoting TS <[EMAIL PROTECTED]>:

Code segment?
Exact error message? (Is there more context?)

Include (/file);

Function.include</a>]: open_basedir restriction in effect.
File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed
path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in
/var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line
151

It's my server and it makes perfect security sense because the package I'm
using allows me to resell but, I don't care about that particular security
issue since I'm not reselling. I'm assuming it's something in php.ini.
It's
a linux machine. I'm not sure what else there is to tell.

Thanks, T





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2008 1:08 AM
To: TS
Subject: RE: [PHP] REALLY NEWB QUESTION - include issue

Code segment?
Exact error message? (Is there more context?)

I probably don't have the answer to answer you, but make like a little
easier
for those who might by giving them some information to work with.

David

-- Original Message --
From: "TS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Tue, 1 Jul 2008 00:50:50 -0600
Subject: [PHP] REALLY NEWB QUESTION - include issue


Trying to "include()" a script from another domain on my server and it
won't
let me do it.

I'm getting this error.

open_basedir restriction in effect. Operation not permitted etc...

Please help and stop laughing at me.

Thanks ahead, T



Looks like your hosting is blocking files included outside of the
webroot. If you have root access you could change this. If you wanted
to. But security is not a bad thing :)

To allow opening of remote url's you can enable 'allow_url_fopen' in
php.ini.



In your first post you mentioned something about a remote domain. So i assumed you were including a remote page. But Chris already answered your question. Just add the paths so they are accessible.


--- End Message ---
--- Begin Message ---
Quoting Brian Dunning <[EMAIL PROTECTED]>:

I'm trying to add a number to a value in an array. Pretend I have this:

$new_value = array('orange', 2);
$arr = array(
        array('blue', 4),
        array('orange', 5),
        array('green', 6));

I want to add the new value to the existing matching array element, so
I end up with this:

$arr = array(
        array('blue', 4),
        array('orange', 7),
        array('green', 6));

Seems like it should be really simple but all the ways I can figure out
to do it are too kludgey.




Just loop through the array to update. And use in_array to check if the key to update exists. Then you can do $array[$key][1] = $newValue.

Something like this maybe:

function updateArray(&$array, $update)
{
    list($updateKey, $updateValue) = $update;
    foreach ($array as $key => $subArray) {
        if (in_array($updateKey, $subArray)) {
            $array[$key][1] = $updateValue;
        }
    }
}

updateArray($arr, $new_value);
var_dump($arr);

--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
I'm trying to add a number to a value in an array. Pretend I have this:

$new_value = array('orange', 2);
$arr = array(
    array('blue', 4),
    array('orange', 5),
    array('green', 6));

I want to add the new value to the existing matching array element, so I end up with this:

$arr = array(
    array('blue', 4),
    array('orange', 7),
    array('green', 6));

Seems like it should be really simple but all the ways I can figure out to do it are too kludgey.

It's rather easy:

for ($i=0; $i<count($arr); $i++) {
    if ($arr[$i][0] == $new_array[0]) {
        $arr[$i][1] += $new_array[1];
        break; // Optional - means the first "orange" found will be
               // updated only
    }
}

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

--- End Message ---
--- Begin Message ---
At 9:35 AM +0100 7/1/08, Richard Heyes wrote:
Brian Dunning wrote:
Seems like it should be really simple but all the ways I can figure out to do it are too kludgey.

It's rather easy:

for ($i=0; $i<count($arr); $i++) {
    if ($arr[$i][0] == $new_array[0]) {
        $arr[$i][1] += $new_array[1];
        break; // Optional - means the first "orange" found will be
               // updated only
    }
}

--
Richard Heyes

Small correction:

for ($i=0; $i<count($arr); $i++)
   {
    if ($arr[$i][0] == $new_value [0])
      {
        $arr[$i][1] += $new_value [1];
        break; // Optional - means the first "orange" found will be
               // updated only
       }
   }

See here:

http://www.webbytedd.com/b1/array/

But, I'm not sure as to why you (Brian) would want to do that anyway.

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

--- End Message ---
--- Begin Message ---
Small correction:

Which is...?

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

--- End Message ---
--- Begin Message ---
On Mon, 30 Jun 2008 14:39:04 -0500
"Will Fitch" <[EMAIL PROTECTED]> wrote:

> Have you considered mcrypt then base64?

Thanks, i was completely forgetting mcrypt... that's what i need :)
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 VOGLIA DI VACANZA ?
* Prenota la tua vacanza in un Costa Hotels!
* Hotels e Agriturismo nella Riviera Romagnola.
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8032&d=1-7

--- End Message ---
--- Begin Message ---
paragasu wrote:
>> I develop a relatively
>> large, in-house application using PostgreSQL that I can't wait to convert to
>> MySQL.
>
> well, you should give me a reason why you want to do this.
>
>> What exactly scares you about Sun/MySQL?
> personally, it is not about i am scared. i am still continue to use
> mysql for several
> project i did few years ago and continue support and upgrade it.
>
> for the moment, after making internet survey for few month i found out
> it might be
> worth my time trying to explore the concept of trigger etc.
>
> don't get me wrong. it is not about mysql vs postgresql. it is just
> something i believe
> worth to explore..

opps...

--- End Message ---
--- Begin Message ---
On Sun, 15 Jun 2008 13:48:28 +0200
Stefano Esposito <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> i have to forbid users of my site to view images directly (i.e.
> writing the image URL in the address bar) but they'd be able viewing
> them from the pages of the site. What's the best way of doing it, or
> something similar? Is there a common strategy using PHP? Thank you for
> any hint :-)
> 
> Ciao,
> Stefano

Thanks for all of your hints :)
Here's my solution:

1) disable contextmenu on the images to protect using javascript (just
to discourage less determined people)

2) for other purposes, the page containing images to protect, is
brought to users through an ajax request, so they can't so-easily
look at the source (not with browser's normal 'view source'
anyway... they would need something like firebug).

3) use a script to get image data (as someone on the list suggested),
checking for the right $_SERVER['HTTP_REFERER'] (i know... it's not so
trustworthy... if anyone has a better idea, i'll be glad to listen
to :))

4) encrypt the relative path of the image on the fly, using mcrypt with
a key generated on the login and then pass it encoded whit
base64_encode (with a little workaround for '+', '/' and '=' chars) to
the image-reading script. So, even if someone can get to the source,
they'll end up whit an encrypted id of which they don't know neither
the key nor the encryption method nor even what it's supposed to
represent (if some database id or a path).

I think that's a good way to prevent image theft... well, unless the
thief uses the print screen key...

What's your point of view?

Ciao,
Stefano
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Caschi, abbigliamento e accessori per la moto a prezzi convenienti, solo su 
Motostorm.it
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7850&d=1-7

--- End Message ---
--- Begin Message ---
Umm have you ever thought about watermark-ing it? (In case its not a part of
your website or something..)

On 01/07/2008, Stefano Esposito <[EMAIL PROTECTED]> wrote:
>
> On Sun, 15 Jun 2008 13:48:28 +0200
>
> Stefano Esposito <[EMAIL PROTECTED]> wrote:
>
>
> > Hi all,
> >
> > i have to forbid users of my site to view images directly (i.e.
> > writing the image URL in the address bar) but they'd be able viewing
> > them from the pages of the site. What's the best way of doing it, or
> > something similar? Is there a common strategy using PHP? Thank you for
> > any hint :-)
> >
> > Ciao,
> > Stefano
>
>
> Thanks for all of your hints :)
> Here's my solution:
>
> 1) disable contextmenu on the images to protect using javascript (just
> to discourage less determined people)
>
> 2) for other purposes, the page containing images to protect, is
> brought to users through an ajax request, so they can't so-easily
> look at the source (not with browser's normal 'view source'
> anyway... they would need something like firebug).
>
> 3) use a script to get image data (as someone on the list suggested),
> checking for the right $_SERVER['HTTP_REFERER'] (i know... it's not so
> trustworthy... if anyone has a better idea, i'll be glad to listen
> to :))
>
> 4) encrypt the relative path of the image on the fly, using mcrypt with
> a key generated on the login and then pass it encoded whit
> base64_encode (with a little workaround for '+', '/' and '=' chars) to
> the image-reading script. So, even if someone can get to the source,
> they'll end up whit an encrypted id of which they don't know neither
> the key nor the encryption method nor even what it's supposed to
> represent (if some database id or a path).
>
> I think that's a good way to prevent image theft... well, unless the
> thief uses the print screen key...
>
> What's your point of view?
>
>
> Ciao,
> Stefano
>
>
>   --
>   Email.it, the professional e-mail, gratis per te: http://www.email.it/f
>
>   Sponsor:
>
> Caschi, abbigliamento e accessori per la moto a prezzi convenienti, solo su
> Motostorm.it
>   Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7850&d=1-7
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to