php-general Digest 8 Dec 2003 04:56:54 -0000 Issue 2460
Topics (messages 172130 through 172138):
Re: getimagesize() & MySQL Image Storage (Running functions on contents of variables)
172130 by: Galen
Can I request ?
172131 by: playerfr
172132 by: Evan Nemerson
Re: Random Numbers..
172133 by: Evan Nemerson
172137 by: Luke
write failed
172134 by: Dan McCullough
Re: Check type of uploaded file
172135 by: Bob Hockney
172136 by: Bob Hockney
Re: Not able to execute Linux binary
172138 by: Karam Chand
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 ---
So you're saying there's no way to do what I want to do.
Anybody got any other ideas?
It seems so stupid to be unable to run functions that accept files on
variables, with so many people using databases and whatnot these days.
-Galen
On Dec 7, 2003, at 1:46 AM, Justin Patrin wrote:
Galen wrote:
I'm using a MySQL database to store images as BLOBs. I know how to
handle all the MySQL stuff, it's easy, and really makes keeping track
of files nice an clean. No permissions, no risk of getting things out
of sync, finding stuff is as easy as SQL.
My question is about handling stuff once you pull it out of the
database. When I store images in the database, I currently stash the
format and the resolution in the database, which works but is a bit
messy. I can't find any easy way to run getimagesize on the contents
of a variable, not a file. I could write the image to a file if I
needed to, but that can be slow and rather inelegant, I'd rather
store the values in the DB. Any ideas on how I could use getimagesize
or similar function to determine the format and resolution of the
image in a variable?
I have had a similar problem with ftp uploading. There was no way to
upload the contents of a variable, so I had to write everything to
the disk, kind of annoying when I have 1,000 files. The script wasn't
a very heavily used script nor could the public execute it, but it
bugged me to no end. I think there are some other functions that also
only operate on files and I've fought with them too.
Is there any kind of generic solution for this? Some kind of wrapper
I could use to make a variable act like a reference to a file but
actually be in memory only?
If this seems totally pointless, please tell me. But it seems like
there should be a way for almost any function that runs off a file to
run off the contents of a variable, it's just binary data.
Thanks,
Galen
If the programs read from a file descriptor, you could open a pipe,
write into it on your side, and have the command read from it. But
that's really messy... and won't work for the image size function.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
I am using a PHPBB to have forum and site in php and i need a little script
, can i request it here or do you know an otehr group where i can request
it.
Thnaks
--- End Message ---
--- Begin Message ---
On Sunday 07 December 2003 11:33 am, playerfr wrote:
> Hi,
>
> I am using a PHPBB to have forum and site in php and i need a little script
> , can i request it here or do you know an otehr group where i can request
> it.
Uh, you can request help writing the script here when you hit a wall, but it's
not really a good idea to ask someone to do it for you, unless you're going
to pay them. If you want to pay someone, this is a great place to find
experienced coders...
>
> Thnaks
--
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en
--
"I am indeed amazed when I consider how weak my mind is and how prone to
error. "
-Rene Descartes
--- End Message ---
--- Begin Message ---
On Saturday 06 December 2003 10:39 pm, TheHeadSage wrote:
> Hey,
>
> I've got a script which used to generate a random quote. It worked fine
> untill this problem occurred..
>
> Say we have 4 quotes with QuoteID's of 1 through to 4
> The script would grab a number of rows, and generate a random number
> between 1 and this value (being 4 in this case) This worked fine untill,
> one of the quotes was removed and another added, leaving 4 quotes once
> again, but the last one had an ID of 5. The problem is the Random number
> generated is between 1 and 4, so the final quote is never shown..
>
> I tried using the RAND() function in the MySQL statement it's self, but
> it's not random enough...
Perhaps something like
SELECT quote FROM quotes ORDER BY RAND('.mt_rand().') LIMIT 1
>
> Then I thought of doing this:
>
> Select all the Quote ID's from the DB.
> Store them in an Array.
> Generate a random number between 1 and the last ID.
> If the Random Number matches a Quote ID, then display the quote,
> otherwise Generate another
Wow, sounds complicated. How about
shuffle($quotes);
echo $quotes[0];
but much better speed-wise to do it from the DB.
>
> But I couldn't get the code to work. Any suggestions on either how to
> write the above, or made the MySQL RAND() function, more random?
um, yeah.
--
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en
--
"A popular government, without popular information, or the means of acquiring
it, is but a Prologue to a Farce or a Tragedy - or perhaps both. Knowledge
will forever govern ignorance, and a people who mean to be their own
Governors must arm themselves with the power which knowledge gives."
-James Madison
--- End Message ---
--- Begin Message ---
select all and
use
mysql_data_seek($result, rand(mysql_num_rows($result) - 1));
$row = mysql_fetch_assoc($result);
and there, your random row is returnd, that should be easy enough :) and it
should work
--
Luke
"Theheadsage" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey,
>
> I've got a script which used to generate a random quote. It worked fine
> untill this problem occurred..
>
> Say we have 4 quotes with QuoteID's of 1 through to 4
> The script would grab a number of rows, and generate a random number
> between 1 and this value (being 4 in this case) This worked fine untill,
> one of the quotes was removed and another added, leaving 4 quotes once
> again, but the last one had an ID of 5. The problem is the Random number
> generated is between 1 and 4, so the final quote is never shown..
>
> I tried using the RAND() function in the MySQL statement it's self, but
> it's not random enough...
>
> Then I thought of doing this:
>
> Select all the Quote ID's from the DB.
> Store them in an Array.
> Generate a random number between 1 and the last ID.
> If the Random Number matches a Quote ID, then display the quote,
> otherwise Generate another
>
> But I couldn't get the code to work. Any suggestions on either how to
> write the above, or made the MySQL RAND() function, more random?
--- End Message ---
--- Begin Message ---
Just wanted to see if this was correct. To me this is saying that /tmp
cannot be written to as there is no space left on device.
Warning: Unknown(): write failed: No space left on device (28) in Unknown on
line 0
Warning: Unknown(): Failed to write session data (files). Please verify that
the current setting of session.save_path is correct (/tmp) in Unknown on
line 0
--- End Message ---
--- Begin Message ---
Richard Davey wrote:
> BH> I want to test an uploaded file to see if it is a text file, but I don't want
> BH> to rely on the presence of an os command such as 'file.' Is there a
> BH> straightforward way to do this within PHP? Thanks in advance.
>
> Yes, check the $_FILES['userfile']['type'] after upload.
I tried this initially, but the problem is that it relies on the client's
interpretation of the file type. With the files I used for testing, Konqueror and
other reported the MIME type as text/plain, but Mozilla reported it as
application/octet-stream. What I am looking for is a way to test the file
depending only upon PHP. i.e., to be platform and client independent.
-Bob
--- End Message ---
--- Begin Message ---
Gerard Samuel wrote:
> On Saturday 06 December 2003 11:01 pm, Richard Davey wrote:
> > Yes, check the $_FILES['userfile']['type'] after upload.
> >
> That can be spoofed.
> There isn't really a way to determine file types...
I was thinking of trying something like ereg("[[:print:]]*", "$contents") on the
file. Not really what I want, but would reject obvious non-text files.
-Bob
--- End Message ---
--- Begin Message ---
Hello
I think there is some problem with the permission.
Even if I execute a command like -
echo ( "start" );
exec ( "pwd" );
echo ( "end" );
the output is - startend
shouldnt be pwd showing the present working directory
to me.
Karam
--- Jason Wong <[EMAIL PROTECTED]> wrote:
> On Saturday 06 December 2003 12:56, Karam Chand
> wrote:
>
> > looking at manuals and help and some help from
> you. i
> > wrote the attached code-
> >
> > error_reporting (E_ALL);
> > ini_set('display_errors', 1);
> >
> > $result = `./myapp`;
> > print_r ( $result );
> >
> > echo ( "2" );
> >
> > exec("./myapp",$result);
> > print_r($result);
> >
> > It is returning output
> >
> > 2Array ( )
> >
> > which means the array is empty !!!
> >
> > it should have outputted ErrorError
>
> I believe you mean to say that it should output:
> 2Error
>
> OK, does your "myapp" program dump its output to
> STDOUT?, Remember exec() only
> captures STDOUT.
>
> > Both the php and the binary exsits in
> > http://www.mydomain.com/mgmt/
>
> One way to satisfy yourself that exec() is working
> is to create a small test
> program, eg:
>
> ----8<-------------
> #!/bin/bash
> echo "test"
> ----8<-------------
>
> Then exec() it.
>
> > Can I send you the binary so that you can check it
> > out?
>
> No thank you.
>
> --
> Jason Wong -> Gremlins Associates ->
> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet
> Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> The girl who stoops to conquer usually wears a
> low-cut dress.
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
--- End Message ---