php-general Digest 24 Sep 2005 12:14:22 -0000 Issue 3700

Topics (messages 223111 through 223117):

Re: how to stream a movie file with fread [success] Now, how to do a fast 
encrypt ?
        223111 by: Graham Anderson

Re: Subtracting dates w/o database interaction (MySQL)
        223112 by: Stephen Leaf

Re: Is PHP the language for me???
        223113 by: Rory Browne

Re: basic user/input form questions... more validation!
        223114 by: Chris Shiflett

Re: selfreferencing script with output
        223115 by: Sabine
        223116 by: Sabine

php 4 script with php 5.
        223117 by: Dwayne Hottinger

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Ok, I got it :)


Is there a better way to do a very fast encryption of a file for a key that changes daily ?

The movie is loading and playing at the same time [progressive/rtsp], so the encrypt/decrypt needs to be pretty fast
I tried mcrypt but it seemed way to slow....
Maybe there is a better encryption method ? Or, are there better characters to search/replace ? Does not have to be ultra secure...just needs to be encryption that could last a day or so...as it will change daily.

When I run this, the movie plays, but shows a blank screen and plays no audio...which is exactly what I want :) I want to write a data handler on the user side that connects to a db and gets the $find and $replace keys to unlock the movie

many thanks in advance...and yes, I am experimenting

<?php

$fileSize = filesize($filepath);

header("ETag: ".md5(time()));
header("Accept-Ranges: bytes");
header ("Content-Length: ".$fileSize);
header('Content-Type: video/quicktime');

$find = array("{","ፀ","k","?");
$replace = array("q","m","g","&");

    if( $fd  = fopen($filepath, 'rb')){
     while(!feof($fd)) {
        echo str_replace($find,$replace,  fread($fd, 8192));
     }
     fclose ($fd);
     exit;
   }

?>
On Sep 23, 2005, at 4:07 PM, Graham Anderson wrote:

I am trying to stream a movie file with 'fread'
this my first step in trying to dynamically encrypt the file as it is being streamed from the server

do I need to fread the data in chunks?
If so, how?

$filename ="$path2file";
$file = fopen($filename,'r');
$fileSize = filesize($filename);
$ContentType = " video/quicktime";
header ("Content-type: $ContentType");
header ("Content-length: $fileSize");

while( $filedata_temp = fread($file, $fileSize) )
echo $filedata_temp;

<b>Fatal error</b>: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in <b>xxxxxxxx/fopenTest.php</b> on line <b>27</b><br />

BTW, I can get readfile to work just fine :)
AFAIK, readfile does not parameters to alter the file contents

many thanks :)

g

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


--- End Message ---
--- Begin Message ---
$date = mysql date field 2005-09-23 for example
$difference =ceil((strtotime($date) - time()) / 86400);

strtotime is far nicer than mktime when you already have a date field ready.

On Friday 23 September 2005 03:10 pm, Philip Thompson wrote:
> On Sep 23, 2005, at 11:16 AM, Chris W. Parker wrote:
> > Philip Thompson <mailto:[EMAIL PROTECTED]>
> >
> >     on Friday, September 23, 2005 9:12 AM said:
> >> I'm needing to find the number of days between two dates without
> >> using an database functions (DATE_SUB, etc)... only PHP. Is there an
> >> easy way to accomplish this? I have searched the PHP site, but have
> >> not been successful in finding anything that will assist me.
> >>
> >> Any help would be appreciated.
> >
> > There might be an easier way but... convert to timestamp, subtract
> > smaller number from bigger number, figure out how much time has
> > passed.
> > Chris.
>
> I actually discovered how to do this right after I made the post. I
> looked at some archives and worked this out.
>
> <code>
>
> // today - 9/23/05
> $start = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
>
> // the objective day - 3/15/06
> $end = mktime(0, 0, 0, 3, 15, 2006);
>
> // subtract today from the objective and divide by 24*60*60 to get days
> $difference = ceil(($end - $start) / (86400));
>
> </code>
>
> Thanks for your assistance.
> ~Philip

--- End Message ---
--- Begin Message ---
On 9/23/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> "Emily McCall" <[EMAIL PROTECTED]> wrote on 09/23/2005 03:07:39
> PM:
>
> > I am trying to figure out whether php will help me to set up a
> > website which is essentially just links to donwloadable material.
>
> Emily, you certainly came to the right place to get an endorsement of PHP
> ;)

Kirk:
While I agree with you to a certain extent, I think you should have a
little more faith in the professionalism(and honesty) of many of the
subscribers to this list. I've personally(I think), as have many
others, pointed out situations on this list, where another language
would be a better tool for the job than PHP.

This however is not one of those situations. This type of job is what
PHP was made for, and what PHP is extremely suitable for. This is the
type of job, for which I have no problem whatsoever endorsing PHP.

Emily:
I hope this goes some way towards answering your question. I cannot
answer it conclusively because this may be a one off project, and the
rest of your coding may be better suited to a different language. Look
into Perl and Python. I think you should still choose PHP, but would
hope that you do so on its merits, and not because it was the first
one you considered.



>
> Yes. PHP will handle your task nicely, and IMHO, it is the easiest
> language to learn and use for dynamic web programming. Dig in and enjoy!
>
> Kirk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
bruce wrote:
my question was directed towards trying to understand if you were
meaning that an app should escape all output from the mysql db?

If you think about that for a moment, I think you'll see that it doesn't make a lot of sense. Data that you get from a remote source is input, not output. Data that you send to a remote source is output.

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
Thank you very much for your answer, Rory,

but I fear I don't understand the most important parts of it.
It would be very nice of you if you could give me a further hint, more explanation.

Rory Browne schrieb:

On 9/23/05, Sabine <[EMAIL PROTECTED]> wrote:
Hello to all,

I have 2 scripts ( preparing about 1000 mails for pear's mail-queue and
sending them) which shall be started by the user.
There are
- limitations of the provider  for the duration of the scripts
- no cronjobs

So I had the idea to write a selfreferencing script like that:

$begin= intval($_GET["begin"]);
$allMails = 1000;

//... prepare / send a portion of for example 50 mails

if (($begin+ 50) < $allMails) {
   header("Location: script.php?begin=".($begin+ 50));
} else {
  echo "Done!";
}

But I want to show the user some output like a statusbar (eventually
with pear's Html_Progress) or something like that so he knows the script
is still working.

instead of simply headering the location out, you could simply output
a html page, that has a meta tag to replace it.
What do you mean with that meta tag?

maybe something like

<html/head/meta tag here>
<body>
<?php
 $full_width = 200;
 $amt_sent = $_GET['begin'] + 50;
 $amt_to_send = 1000;
 $img_width = ceil($amt_sent * $full_width / $amt_to_send);
?>
<img src="pixel.php" height="20" width="<?php echo $img_width; ?>">

<?php
flush();
send_the_mails();

?>



Has anybody of you an idea, a tip for me how to do it?
I don't see how I can do it within the construct above.
Is there an alternative to it?

This doesn't necessarly need to be done using a self-referencing
script. You could have an ajax type system where each script is
accessed sequentially.

And what is an ajax type system? I'm not sure if I don't understand what you mean due to my lack of english speaking capabilities or if I don't know the concept. I assume the last. But additionaly I don't find the word "ajax" in my dictionaries or at leo's. Is it an abbreviation?

Kind regards
Sabine

--- End Message ---
--- Begin Message ---
Thanks for your answer, Gustav,

now I see I didn't explain good enough what my problem is.
My problem is not how to construct a status bar, but not it is possible to provide any output before the headering (*Warning*: Cannot modify header information - headers already sent by). Neither after it.

Best regards
Sabine

P.S.: I played around with PEARs HTML_Progress. It's really worth trying. The user doc on Laurent Lavilles page provides a lot of explanation and examples. (http://pear.laurent-laville.org/HTML_Progress/).


Gustav Wiberg schrieb:

----- Original Message ----- From: "Sabine" <[EMAIL PROTECTED]>
To: "PHP general" <php-general@lists.php.net>
Sent: Friday, September 23, 2005 6:14 PM
Subject: [PHP] selfreferencing script with output


Hello to all,

I have 2 scripts ( preparing about 1000 mails for pear's mail-queue and sending them) which shall be started by the user.
There are
- limitations of the provider  for the duration of the scripts
- no cronjobs

So I had the idea to write a selfreferencing script like that:

$begin= intval($_GET["begin"]);
$allMails = 1000;

//... prepare / send a portion of for example 50 mails

if (($begin+ 50) < $allMails) {
    header("Location: script.php?begin=".($begin+ 50));
} else {
   echo "Done!";
}

But I want to show the user some output like a statusbar (eventually with pear's Html_Progress) or something like that so he knows the script is still working.

Has anybody of you an idea, a tip for me how to do it?
I don't see how I can do it within the construct above.
Is there an alternative to it?

Thanks in advance for your answers
Sabine


Hi

I don't know if this works, but I think it ought to work:

Set a picture (a line) with width 1, next iteration set the line to width 2, next to width 3...

OR set a picture with width % off <count of mails>

Change picture with dhtml (or if you prefer Javascript and css ;-))

/G
http://www.varupiraten.se/








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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22






--- End Message ---
--- Begin Message ---
I am trying to transfer some databases and php scripts that populate them to a
new server.  Server is running Fedora core 4 with mysql 4.x and php 5.0.5.
Original scripts were writen with php 4.x and worked fine.  I get a PHP Notice:
 Undefined variable: return_array when running them on the new server and the
database doesnt get populated.  Mysql database and mysql user rights seem to be
correct.  Do I have to rewrite the script for php 5.x or should it work and I
need to dig for another problem?  Im quite new to php and dont know quite which
way to go for help. I hope I have posted this on the right list.

ddh


--
Dwayne Hottinger
Network Administrator
Harrisonburg City Public Schools

--- End Message ---

Reply via email to