php-general Digest 20 Oct 2007 18:43:29 -0000 Issue 5082

Topics (messages 263437 through 263451):

Re: Rename does not work
        263437 by: Sascha Braun | CEO . BRAUN Networks

Re: problem calling functions
        263438 by: Robin Vickery

Re: This, then that.
        263439 by: tedd
        263440 by: tedd
        263441 by: tedd
        263442 by: tedd
        263447 by: Robert Cummings
        263448 by: tedd
        263449 by: tedd

Re: This, then that. [solved?]
        263443 by: tedd
        263444 by: tedd

Adding Categories using Google's PHP API
        263445 by: Ali, Saqib

Re: Reference return buggy notice?
        263446 by: tedd
        263450 by: Stut

PEAR::Log & mdb2
        263451 by: Irimia, Suleapa

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 ---
Both versions are PHP 5.2.4_p20070914-r2

I backchecked the rights a couple of times. There to problem
does not appear.

I cant really understand what is happening. On the server
eaccelerator and memcache is performing its work. I believe
that when I restart the apache and as well the memcache all
classes I am writing to the memcache and i guess to the e-
accelerator are deleted, or?

The problem first occured since I was writing a function to
read an xml files storing image names as values in its para-
meters, and rewriting these values each time, the xml docu-
ment is stored again, by simply renaming the images.

Now I left the function out, because its not really needed
to rewrite the picuture names over and over. But the problem
remains.

Maybe I am doing something wrong with eaccelerator, so its
keeping an old version of the class in mind?

How do I empty eaccelerator, because a memcache restart does
not make a fix.

Thank you for your help.

Sascha

Am Freitag, den 19.10.2007, 12:55 +0100 schrieb Richard Heyes:
> Sascha Braun | CEO @ BRAUN Networks wrote:
> > I am using the rename function on my local development
> > system fine. But as soon as I upload the script, the
> > rename function does not work anymore.
> > 
> > Is there a specific compiler flag needed, to make rename
> > work on both plattforms?
> 
> You're using different platforms for developing and your live version? 
> Mistake number one. As for the rename issue, first guess is permissions. 
> As in, you don't have them.
> 
> -- 
> Richard Heyes
> +44 (0)800 0213 172
> http://www.websupportsolutions.co.uk
> 
> Knowledge Base and HelpDesk software
> that can cut the cost of online support
> 

--- End Message ---
--- Begin Message ---
On 19/10/2007, afan pasalic <[EMAIL PROTECTED]> wrote:
>
>
> Robin Vickery wrote:
> > On 19/10/2007, afan pasalic <[EMAIL PROTECTED]> wrote:
> >
> >> hi
> >> I have a problem with calling functions:
> >>
> >> <?php
> >> function solution1($var1)    {
> >>     // some code
> >> }
> >>
> >> function solution2($var2)    {
> >>     // some code
> >> }
> >>
> >> function solution3($var3)    {
> >>     // some code
> >> }
> >>
> >> if ($function == 'solution1' or $function == 'solution2' or $function ==
> >> 'solution3')
> >> {
> >>     $my_solution = $function($var); # this supposed to call one of
> >> "solution" functions, right?
> >> }
> >> ?>
> >>
> >> suggestions?
> >>
> >
> > suggestions for what?
> >
> > What is your problem? If you set $function to 'solution1' and run your
> > code, it will indeed execute solution1().
> >
> > -robin
> >
>
> the problem is that this code doesn't work. and I was asking where is
> the problem, or can I do it this way at all.

Firstly, the code you posted does indeed work fine.

Secondly,  you need to learn to ask questions properly: What do you
expect the code to do? What is it actually doing? Are there any error
messages, if so what are they?

-robin

--- End Message ---
--- Begin Message ---
At 6:23 PM +0200 10/19/07, Zoltán Németh wrote:
2007. 10. 19, péntek keltezéssel 12.07-kor tedd ezt írta:
 At 8:19 PM -0400 10/18/07, TG wrote:
 >Describe the process a little more.

 Ok, here's what I want to do.

 I want to prohibit an image from being shown to anyone who is not
 permitted (i.e., logged in).

 The way I want to do this is to:

 1. Set the image permissions to 0640. That way no one can get to the image.

 2. Then my application (part 1) will show the images to whomever is
 approved by changing the permission and then loading the image. Of
 course, the image can be taken at that point, but only by the person
 who was approved.

 3. After the application (part 1) runs, I want another application
 (part 2) to come along and change the permissions of the image back
 to 0640.

 Now, I have no problems with anything other than getting part 2 to
 run after part 1 runs. So, that's the problem.

 As to any server questions, I would like the answer to be generic or
 a way to determine which server type it is and make adjustments
 accordingly.


why not put the image outside of the webroot? I don't think anyone can
access it there, if not using your imageserving php which authenticates
the user.

greets
Zoltán Németh

Safe mode is on which prohibits me from doing that.

Cheers,

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

--- End Message ---
--- Begin Message ---
At 1:09 PM -0400 10/19/07, Wolf wrote:
actually, you could run it by

1.  making the page
2. flushing the output buffer (which puts it in the screen)
3. run the 2nd script

Nope, tried it.

Whatever is done in a script is done before any output to the browser.

Cheers,

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

--- End Message ---
--- Begin Message ---
At 1:31 PM -0700 10/19/07, Instruct ICC wrote:
 > I want to prohibit an image from being shown to anyone who is not
 permitted (i.e., logged in).

 The way I want to do this is to:

 > 1. Set [file] permissions...



What if 2 or more users access the application at the same time?

Set the permissions so only the PHP application can access it.
Have the PHP application decide if this present user running this instance should see the image.
If approved, display image.

That's exactly the way I have it.

I'm not sure as to why the permissions got out-of-sync and you were able to view the image.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
At 4:59 PM -0400 10/19/07, Robert Cummings wrote:
On Fri, 2007-10-19 at 13:31 -0700, Instruct ICC wrote:
 > I want to prohibit an image from being shown to anyone who is not
 > permitted (i.e., logged in).
 >
 > The way I want to do this is to:
 >
 > 1. Set [file] permissions...



 What if 2 or more users access the application at the same time?

 Set the permissions so only the PHP application can access it.
Have the PHP application decide if this present user running this instance should see the image.
 If approved, display image.

One idea that has always been REALLY popular around here... stuff your
image in a database. *MUHAWHAWHAWHAWHAW* *Ducks from the flying rocks*.

Cheers,
Rob.
--

Rob:

That's really not a bad idea, but in this experiment I'm using images as a stand-in for larger files (CD's, Videos, etc).

Side note to everyone else (Rob knows this) Storing images in a dB has some advantages, but the concept has been beat to death on this list and no need to repeat it -- everything that could be said pro/con has been said -- just review the archives.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
On Sat, 2007-10-20 at 09:59 -0400, tedd wrote:
> At 4:59 PM -0400 10/19/07, Robert Cummings wrote:
> >On Fri, 2007-10-19 at 13:31 -0700, Instruct ICC wrote:
> >>  > I want to prohibit an image from being shown to anyone who is not
> >>  > permitted (i.e., logged in).
> >>  >
> >>  > The way I want to do this is to:
> >>  >
> >>  > 1. Set [file] permissions...
> >>
> >>
> >>
> >>  What if 2 or more users access the application at the same time?
> >>
> >>  Set the permissions so only the PHP application can access it.
> >>  Have the PHP application decide if this present user running this 
> >>instance should see the image.
> >>  If approved, display image.
> >
> >One idea that has always been REALLY popular around here... stuff your
> >image in a database. *MUHAWHAWHAWHAWHAW* *Ducks from the flying rocks*.
> >
> >Cheers,
> >Rob.
> >--
> 
> Rob:
> 
> That's really not a bad idea, but in this experiment I'm using images 
> as a stand-in for larger files (CD's, Videos, etc).
> 
> Side note to everyone else (Rob knows this) Storing images in a dB 
> has some advantages, but the concept has been beat to death on this 
> list and no need to repeat it -- everything that could be said 
> pro/con has been said -- just review the archives.

I use the db for images sometimes. I don't really care what some people
think since I've thought it out for myself and like th epros versus the
cons sometimes. At any rate, y our problem appears to be related to
safe_mode for not putting images outside the web tree. Most likely
though, you have access to .htaccess and so you could create a locked
images directory that exists within the web tree but which can't be
accessed by a browser. This would give you what you need to be within
the confines of safe mode.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
Hi gang:

Does this work any better at keeping the image safe?

http://www.webbytedd.com/bbb/image-test2/


Cheers,

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

--- End Message ---
--- Begin Message ---
At 11:58 AM -0400 10/20/07, Robert Cummings wrote:
 Most likely
though, you have access to .htaccess and so you could create a locked
images directory that exists within the web tree but which can't be
accessed by a browser. This would give you what you need to be within
the confines of safe mode.

Cheers,
Rob.

Ahhh, the old telephone in the shoe trick (I'm dating myself).

I had not considered that -- thanks.

Cheers,

tedd


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

--- End Message ---
--- Begin Message ---
At 1:57 PM -0700 10/19/07, Instruct ICC wrote:
 > but in the img tag, try src="display_image.php?id=anId"
and in display_image.php, test if the user is authorized before displaying the image. Then a direct call to display_image.php?id=anId would still have a chance to authenticate the user.

Forgot to reiterate:
Keep the images where only PHP can read them.
If you have the images in a file or a database, use header, and echo or fpassthru on the data.

That I would like to see an example of.

Something like "jan at anh dot sk"
http://php.he.net/image

I can create the image on the fly, but that gave me an idea.

I'll be back.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
At 1:45 PM -0700 10/19/07, Instruct ICC wrote:
 > Hi gang:

 I think I found a solution.

 Here's the url:

 http://www.webbytedd.com/bbb/image-test1/

 The point is that the image is only accessible via this script, is
 this correct?

I can access it without a script:
http://www.webbytedd.com/bbb/image-test1/images/a.jpg

I think what you were seeing was a cached image.

It may be difficult to guess a.jpg even if I can guess /images
but in the img tag, try src="display_image.php?id=anId"
and in display_image.php, test if the user is authorized before displaying the image. Then a direct call to display_image.php?id=anId would still have a chance to authenticate the user.

The script (in production) would check to see if the user was logged in, so that's not a problem.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
I am trying to use the Google's PHP API (ZendGdata) to add Categories
(labels/tags) to the posts for a blog.

I know how to define Category, but I am at a loss when it comes to
adding that Category to a entry (post). Any ideas how this can be
done? Any examples will be highly appreciated.


$category = new Zend_Gdata_App_Extension_Category();
$category->setScheme(".....");
$category->setTerm("mylabel");

Thanks
saqib

--- End Message ---
--- Begin Message ---
At 8:37 AM -0500 10/19/07, Philip Thompson wrote:
I know we went over references (C) in first semester programming. Excuse me
if this is too trivial, but why would you want to use a reference? I thought
in PHP, specifically, that it is unnecessary to use references.

A lil' embarrassed,
~Philip

~Philip:

No need to be embarrassed -- function by reference is not often needed.

Here's an example an example I ran into.

Tiger Geographical data (the stuff of Street Atlas, Google Maps, et al) is a collection of text files that contains long strings (thousands of records) of different record types (255 to be exact) and each record provides data in numerous formats (i.e., byte, unsigned integer, signed integer, short integer, long integer, FP, string, and the list goes on and on). Each record requires a different function to decipher and display the data.

Now, one could just travel down the long string each time determining what data goes to what function and then send the results to the screen along the way. However, that is very time consuming.

The way I solved it was to create a linked list that contained the memory addresses of the data and the memory addresses of the functions that were needed to work together. That way, the list of "what to do" was done only once and stored in a linked list. Please note that the linked list didn't require any decision making.

After that, when the list was initiated (a single call), then a cascade of data matched by functions was done ALL by reference. It was a series of "Here's your data, here's your function, now do your deed" and move on to the next record in the link. That was much quicker than having the program figure it out on the fly.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
Martin Marques wrote:
Stut escribió:

Say you have a function that builds a fairly large array and then returns it. If you just return it as usual PHP will make a copy of that array and therefore use twice the amount of memory than it needs to.

References also provide a way to return more than one variable from a function, but I doubt many PHP developers come across the need to do that.

How can that be done with references?

http://dev.stut.net/php/returnreference.php

-Stut

--
http://stut.net/

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

Can someone tell me what is wrong here please?

--
   define('BASE_PEAR_DSN','mysql://root:[EMAIL PROTECTED]/db');

   if(is_includeable('Log.php')) {
       require_once('Log.php');
$logConfig = array('dsn' => BASE_PEAR_DSN); $logger = &Log::singleton('mdb2', 'log_table', 'System', $logConfig);
       if (PEAR::isError($logger)) {
           die($logger->getMessage());
       }
       $logger->log('logging an event' . PEAR_LOG_DEBUG);
   }
--

I can't see anything in log_table and i don't know what is wrong here.
Many thanks,

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


--- End Message ---

Reply via email to