php-general Digest 25 Sep 2006 05:00:41 -0000 Issue 4366

Topics (messages 242169 through 242180):

Re: array_sum($result)=100
        242169 by: Penthexquadium
        242178 by: Google Kreme

Alternative to FCKeditor
        242170 by: John Taylor-Johnston
        242172 by: Al
        242175 by: Jon Anderson

Re: Object to array conversion oddity
        242171 by: Robert Cummings
        242173 by: Ray Hauge
        242174 by: Marcus Bointon
        242176 by: Robert Cummings

Apache - page fault in php5ss.dll in phpmyadmin?
        242177 by: Ralph Frost

Re: File Upload Security and chmod
        242179 by: Andy Hultgren

Download files outside DocumentRoot Dir
        242180 by: Ramiro

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 ---
On Sun, 24 Sep 2006 19:06:11 +0300, "Ahmad Al-Twaijiry" <[EMAIL PROTECTED]> 
wrote:

> Hi everyone
> 
> I have array of numbers and I want to get out of it a list of numbers
> that if I sum them it will be 100, here is my list (for example ) :
> 
> $list = array(10,20,10,10,30,50,33,110,381,338,20,11,200,100);
> 
> 
> I want the result to be :
> 
> $result = array( 10,20,10,10,50);
> 
> as you can see in the array $result , if we array_sum($result) the
> result will be 100.
> 
> is they any algorithm to do this ?

I think you can try to sort the array in reverse order, and then
calculate the sum of numbers in loops (end loop when the sum is larger
than target sum).

It seems there is no algorithm can do this quickly.

--- End Message ---
--- Begin Message ---
On 24 Sep 2006, at 10:41 , Penthexquadium wrote:
On Sun, 24 Sep 2006 19:06:11 +0300, "Ahmad Al-Twaijiry" <[EMAIL PROTECTED]> wrote:
I have array of numbers and I want to get out of it a list of numbers
that if I sum them it will be 100, here is my list (for example ) :

I think you can try to sort the array in reverse order, and then
calculate the sum of numbers in loops (end loop when the sum is larger
than target sum).

That seems like a very slow way to do it, I think.

First thing, sort the array, then scan the array backwards for the first number under the target sum (in this case, 50). Then look for another number that will add to make the target sum. So, if you find a 90, look for a 10. If you find it, you're done. If you don't find it, then search for the next smallest number (33) and add it. Then repeat. If you don't find a match at 83, then add the next smallest number, 20. But that puts you over your target, so you discard 33 and start over with 50 and the next lowest number, 20. Now you are only looking for numbers <=20.

This might be the perfect place to use a recursive function, as long as you are careful to limit it's iteration cycles.

No way is this going to be done quickly.

--
And, while it was regarded as pretty good evidence of criminality to be living in a slum, for some reason owning a whole street of them merely got you invited to the very best social occasions.
--- End Message ---
--- Begin Message ---
Anyone know of a good alternative to FCKeditor? Or a decent file uploader?
Even after paying for a little help, I get zip for FCK.
I need another solution, another editor with an active forum or support,
John

--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
Anyone know of a good alternative to FCKeditor? Or a decent file uploader?
Even after paying for a little help, I get zip for FCK.
I need another solution, another editor with an active forum or support,
John

Tell folks what to want to accomplish.

--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
Anyone know of a good alternative to FCKeditor? Or a decent file uploader?
Even after paying for a little help, I get zip for FCK.
I need another solution, another editor with an active forum or support,
John

TinyMCE...I don't know how good/bad TinyMCE is, but if you can't use FCK, you could try it.

http://tinymce.moxiecode.com/

jon

--- End Message ---
--- Begin Message ---
On Sun, 2006-09-24 at 10:53 +0100, Marcus Bointon wrote:
> On 24 Sep 2006, at 01:05, Robert Cummings wrote:
> 
> > Blah, blah, blah. The documentation is probably out of date and  
> > applied
> > to PHP4. Feel free to get off your arse and volunteer if you don't  
> > like
> > it >:) You don't get have your cake and eat it *PTHTHTHTHTTHTHTH*
> 
> How exactly am I not helping by pointing out there's a problem in the  
> first place? It's a lot more constructive than being rude.

Because you're pointing it out to the wrong people. See bugs.php.net.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Sunday 24 September 2006 15:00, Robert Cummings wrote:
> Because you're pointing it out to the wrong people. See bugs.php.net.

Maybe you missed it, but he did submit a bug report:

http://bugs.php.net/?id=38935

He just wanted to see if other people had run into a similar situation before 
submitting the bug... from my understanding.  I don't want to put words in 
Marcus' mouth

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

--- End Message ---
--- Begin Message ---
On 24 Sep 2006, at 22:07, Ray Hauge wrote:

Maybe you missed it, but he did submit a bug report:

http://bugs.php.net/?id=38935

He just wanted to see if other people had run into a similar situation before submitting the bug... from my understanding. I don't want to put words in
Marcus' mouth

Yup (and thanks), that was exactly my intention. Initially I wasn't sure that I was not doing something wrong, or seeing interference from XDebug etc. It's hard enough getting a PHP bug report accepted at all, so I try to make sure that it's very, very clear. I'm quite used to getting 'bogusbotted' by now - you seem to have to fight for every bug, in code or documentation. I appreciate that the maintainers have to deal with a lot of crap, and I make an effort not to waste their time (e.g. by reading docs, searching archives, posting on -users, as they suggest), but occasionally they just don't read the report - in this case I was referred to the documentation, which agrees 100% with my complaint!

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

--- End Message ---
--- Begin Message ---
On Sun, 2006-09-24 at 22:26 +0100, Marcus Bointon wrote:
> On 24 Sep 2006, at 22:07, Ray Hauge wrote:
> 
> > Maybe you missed it, but he did submit a bug report:
> >
> > http://bugs.php.net/?id=38935
> >
> > He just wanted to see if other people had run into a similar  
> > situation before
> > submitting the bug... from my understanding.  I don't want to put  
> > words in
> > Marcus' mouth
> 
> Yup (and thanks), that was exactly my intention. Initially I wasn't  
> sure that I was not doing something wrong, or seeing interference  
> from XDebug etc. It's hard enough getting a PHP bug report accepted  
> at all, so I try to make sure that it's very, very clear. I'm quite  
> used to getting 'bogusbotted' by now - you seem to have to fight for  
> every bug, in code or documentation. I appreciate that the  
> maintainers have to deal with a lot of crap, and I make an effort not  
> to waste their time (e.g. by reading docs, searching archives,  
> posting on -users, as they suggest), but occasionally they just don't  
> read the report - in this case I was referred to the documentation,  
> which agrees 100% with my complaint!

I did miss the bug report. My apologies :)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message --- I have been running Apache 1.3.19, php511 with mySQL 4.1.5 server on win98 and using phpmyadmin264.

A few weeks ago everything was working. Recently, when I press the BROWSE button in phpmyadmin version 2.64 I get an "Apache" error "Program has performed an illegal operation and will now be shut down...."

The details say: "APACHE caused an invalid page fault in
module PHP5TS.DLL at 017f:00d7634c...."

I upgraded to php 5.1.6 and tried phpmyadmin 2.90 but continue to get the same unfortunate result.

I see now that when I try "INSERT" in phpmyadmin EVERY OTHER text field will accept only one character.

The Apache error.log does not report anything related to php5ts.dll or phpmyadmin. It did reflect the following: <b>Warning</b>: PHP Startup: Unable to load dynamic library 'c:\php511\ext\php_mcrypt.dll' - One of the library files needed to run this application cannot be found.
 in <b>Unknown</b> on line <b>0</b><br />

after I enabled php_mcrypt.dll in php.ini per phpmyadmin 2.90 instructions.


extension_dir in php.ini is  set to c:\php516\ext


I'm aware I ought to be upgrading OS, but when Googling for help on this, I see other references from folks with XP, etc. I also have questions into the phpmyadmin forum but have not heard back yet.

Thanks in advance for any thoughts or suggestions for resolving this sort of behavior or uncovering the flaw I am overlooking.

Best regards,
Ralph Frost

  

--- End Message ---
--- Begin Message ---
Hi Tedd,

Yes, when I browse to www.myDomain.com I get the index.html file, and so I
have been leaving the .public_html/ directory alone since it is not my
root.  I'm curious, what you described is exactly what I'm trying to do -
what permissions do you set the parent folder at when you are finished
uploading/saving/downloading/etc.?  I have my "uploaded_images/"
directory set at chmod 0100 and I can still browse to an uploaded image from
my file upload page...  Thanks for your response,

Andy


On 9/23/06, tedd <[EMAIL PROTECTED]> wrote:

At 7:19 PM -0600 9/22/06, Andy Hultgren wrote:
>For whatever reason when I ftp in using WinFtp I don't see public_html
>(it's hidden, don't know why; if I make a directory called
>".public_html" it gets created and then disappears), but I can see my
>file structure from my host's website and so I know that when I ftp in
>to myDomain.com this is what is "there":
>
>index.htm
>page1.htm
>page2.htm
>.public_html/
>images/
>etc. etc.

Andy:

Sorry, I didn't catch all of the thread, but this is my drift.

When you access your site (http://yourdomain.com) via a browser, do
you see the above index.htm?

If so, and you want to stay with that host, then leave the
.public_html/ folder alone, and build your site using WinFTP, or
whatever.

If you want to change permissions for a file from within a php
script, then ftp into your site (using ftp_login), change the parent
folder permissions, do your file thing (upload, delete, save, etc.),
and then change the parent folder permissions back and it's done.

At least that's the way I do it working on a shared host and it works for
me.

tedd

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


--- End Message ---
--- Begin Message ---
Hi,
i'm trying to find a good solution to this problem. I want download files 
from a directory outside DocumentRoot.

This files cannot be downloaded through direct url like 
http://site/test.zip. It must be downloaded after user login.

I know i can do that using some functions like fread() + fopen() or 
readfile(), than i would echo file buffer to browser with correct headers. 
But, reading then dumping file to browser is a big problem to server.

I've made one test that shows me i will "eat" 1.8% of RAM (i've used "ps 
aux" at Linux, in a server with 2Gb of RAM) to download a 30Mb file at 
60kb/s speed. So, imagine what a dump-php-script can do with 50 to 100 
concurrently downloads. Probably i will need 1 TeraByte of RAM to provide 
downloads ;)

Theres my question now. Is there other way to protect files against direct 
downloading? (Obligating users to login and denying direct-url's).

I also know i can check referer by using Mod_Rewrite at Apache. But it isn't 
secure, since referer cannot be sent or be fake.

Please, help me ;)

Thank you !
--------
Script i used to test:
<?
$url = "test.tar.gz";

header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=\"".basename($url)."\";");
header('Content-Length: ' . filesize($url));
@readfile($url) OR die();
?> 

--- End Message ---

Reply via email to