473,473 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need help modifying this PHP script

I was wondering if someone here could help me with modifying this PHP
template so that it does something very specific for me. My knowledge
of PHP is very limited (I'm more of a Cold Fusion developer), which is
why I'm inquiring here.

Anyways, first I'll show you the PHP code, and then I'll explain what
kind of modification I need to have applied:

------------------------------------------------------------------------------
<?
include ("config.php");
include("imgprocess.php");

//create a php code that will be evaluated later, each time displaying
the image...

$imgdata =
"\$points=\"$points\";\$colors=\"$colors\";\$penci lwidths=\"$pencilwidths\";";

//...pack it in a compressed archive...

$newgzfile = gzopen($newid.".gz", "w9");
gzwrite($newgzfile, $imgdata);
gzclose($newgzfile);

//...and free some memory.

unset ($imgdata);

//create virtualy the image from the flash compression algorythm;

$image=makeimg();

//create physically the thumbnail from our gd virtual image.

$image2 = ImageCreate($thumbsize,$thumbsize);
imagecopyresized ( $image2 , $image , 0 , 0 , 0 , 0 , $thumbsize
,$thumbsize, 450 ,450 ) ;
if($thumbformat == "jpg"){
Imagejpeg($image2,"temp".$newid.".jpg",$thumbquali ty);
}else{
Imagepng($image2,"temp".$newid.".png");
}
//now lets tell flash every thing is ok

echo "everything=okaisayhellotoyourmama";

?>
------------------------------------------------------------------------------

This PHP file, as best as I can tell, writes a file named "temp.jpg" to
a specific directory on the server (defined in the config.php file).
What I need is to have the template modified so that it "waits" to
make sure that the file named "temp.jpg" DOES NOT EXIST at that
location before attempting to write the file. I've written some Cold
Fusion routines which promptly rename the temp.jpg files and moves them
to a different location, but since this will be used in a multi-user
environment, I have to make sure that temp.jpg never gets overwritten.
I'm not sure if this is even possible to accomplish or not, but I thank
you in advance for whatever assistance you can offer.

Cheers,
- yvan

Aug 6 '05 #1
2 1630
yv**@atzilut.com wrote:
: I was wondering if someone here could help me with modifying this PHP
: template so that it does something very specific for me. My knowledge
: of PHP is very limited (I'm more of a Cold Fusion developer), which is
: why I'm inquiring here.

: Anyways, first I'll show you the PHP code, and then I'll explain what
: kind of modification I need to have applied:

: ------------------------------------------------------------------------------
: <?
: include ("config.php");
: include("imgprocess.php");

: //create a php code that will be evaluated later, each time displaying
: the image...

: $imgdata =
: "\$points=\"$points\";\$colors=\"$colors\";\$penci lwidths=\"$pencilwidths\";";

: //...pack it in a compressed archive...

: $newgzfile = gzopen($newid.".gz", "w9");
: gzwrite($newgzfile, $imgdata);
: gzclose($newgzfile);

: //...and free some memory.

: unset ($imgdata);

: //create virtualy the image from the flash compression algorythm;

: $image=makeimg();

: //create physically the thumbnail from our gd virtual image.

: $image2 = ImageCreate($thumbsize,$thumbsize);
: imagecopyresized ( $image2 , $image , 0 , 0 , 0 , 0 , $thumbsize
: ,$thumbsize, 450 ,450 ) ;
: if($thumbformat == "jpg"){
: Imagejpeg($image2,"temp".$newid.".jpg",$thumbquali ty);
: }else{
: Imagepng($image2,"temp".$newid.".png");
: }
: //now lets tell flash every thing is ok

: echo "everything=okaisayhellotoyourmama";

: ?>
: ------------------------------------------------------------------------------

: This PHP file, as best as I can tell, writes a file named "temp.jpg" to
: a specific directory on the server (defined in the config.php file).
: What I need is to have the template modified so that it "waits" to
: make sure that the file named "temp.jpg" DOES NOT EXIST at that
: location before attempting to write the file. I've written some Cold
: Fusion routines which promptly rename the temp.jpg files and moves them
: to a different location, but since this will be used in a multi-user
: environment, I have to make sure that temp.jpg never gets overwritten.
: I'm not sure if this is even possible to accomplish or not, but I thank
: you in advance for whatever assistance you can offer.

: Cheers,
: - yvan

Make the various instances of the script cooperate by using a unique name
each time for the temporary file.

The "uniqid" function may be appropriate for this task.

At the top of the code you create a string that is the unique name, then
later on the script uses that name. Each instance will have a different
name.

I can't show you exactly because the code you show does not seem to
include all the accesses to the file being created.
--

This space not for rent.
Aug 7 '05 #2
Thanks for your reply Malcom, but I thought I'd let you know that
someone just emailed me a modified version of the template which does
exactly what I need it to. The code he sent me is as follows:

---------------------------------------------------------------------------------------

if($thumbformat == "jpg"){
while (file_exists("temp".$newid.".jpg")) {
sleep(1);
}
Imagejpeg($image2,"temp".$newid.".jpg",$thumbquali ty);
}else{
while (file_exists("temp".$newid.".png")) {
sleep(1);
}
Imagepng($image2,"temp".$newid.".png");
}

--------------------------------------------------------------------------------

But liek I said, -- thanks anyways. I'm always grateful for the time
folks invest in helping me trying to work out these programming
riddles. I appreciate your efforts!

Cheers,
- yvan

Aug 7 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: pancho | last post by:
Greetings, I need help configuring/building PHP3 with MySQL as a DSO on a Solaris 8 box - this module is needed to host some existing sites I will be migrating Note. I built PHP4 from source and...
4
by: VA | last post by:
I am using a JS library of functions that I include in my web page using the usual <script type="text/javascript" src=...> method Is there a way to automatically call one of my own functions...
2
by: chuck | last post by:
Hi, I am modifying some code from here http://www.quirksmode.org/dom/domform.html I have a div 'readroot' that I clone. I change the change the id and name of the childnodes of 'readroot' to...
2
by: P2P | last post by:
Hi I am wondering if someone can help me here with the "perfect" marquee vertical scrolling script I've found. This marquee is great for me as it will call an external html page. This allow...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
11
Haitashi
by: Haitashi | last post by:
I found this awesome help bubble script. I haven't been able to do one thing. What instantiates the bubble is an icon. I need to use both an icon and text. For instance I want to have a small letter...
1
by: bn4 | last post by:
I have been trying to modify a script that i had working in the past but have lost.. ORIGINAL URL: http://www.thescripts.com/forum/thread147097.html STEPS: I want it to do the following:...
6
by: John [H2O] | last post by:
I would like to write a function to write variables to a file and modify a few 'counters'. This is to replace multiple instances of identical code in a module I am writing. This is my approach:...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.