473,597 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ 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("imgpro cess.php");

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

$imgdata =
"\$points=\"$po ints\";\$colors =\"$colors\";\$ pencilwidths=\" $pencilwidths\" ;";

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

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

//...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($th umbsize,$thumbs ize);
imagecopyresize d ( $image2 , $image , 0 , 0 , 0 , 0 , $thumbsize
,$thumbsize, 450 ,450 ) ;
if($thumbformat == "jpg"){
Imagejpeg($imag e2,"temp".$newi d.".jpg",$thumb quality);
}else{
Imagepng($image 2,"temp".$newid .".png");
}
//now lets tell flash every thing is ok

echo "everything=oka isayhellotoyour mama";

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

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 1647
yv**@atzilut.co m 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("imgpro cess.php");

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

: $imgdata =
: "\$points=\"$po ints\";\$colors =\"$colors\";\$ pencilwidths=\" $pencilwidths\" ;";

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

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

: //...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($th umbsize,$thumbs ize);
: imagecopyresize d ( $image2 , $image , 0 , 0 , 0 , 0 , $thumbsize
: ,$thumbsize, 450 ,450 ) ;
: if($thumbformat == "jpg"){
: Imagejpeg($imag e2,"temp".$newi d.".jpg",$thumb quality);
: }else{
: Imagepng($image 2,"temp".$newid .".png");
: }
: //now lets tell flash every thing is ok

: echo "everything=oka isayhellotoyour mama";

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

: 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("t emp".$newid.".j pg")) {
sleep(1);
}
Imagejpeg($imag e2,"temp".$newi d.".jpg",$thumb quality);
}else{
while (file_exists("t emp".$newid.".p ng")) {
sleep(1);
}
Imagepng($image 2,"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
2562
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 it loads without an error. When I try t run "apachectl configtest" I get the following error: -- Cannot load /usr/local/apache/libexec/libphp3.so into server: ld.so.1: /usr/local/apache/bin/httpd: fatal: relocation error: file...
4
2201
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 when function foo(...) (from the library) is called? In other words, when foo() is executed, check to see if there is an "execute me also" type of function (associated with foo) defined and if
2
2561
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 the original name plus a number(counter). The problem is I have i have a div 'serials' inside 'readroot' and the childnodes of
2
4268
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 me to design a html page and update just that page without having to muck around on coding with the main page. There is one thing I like to have this marquee script able to do for me.
11
3000
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. It works perfectly (assigning the correct images and the correct onclick events to the correct <atags):
11
1378
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 image next to the word "Email" and of you click on any of them you get the bubble. Any help will be greatly appreciated!!! Here's how you call it: <script type="text/javascript"> hb1 = new HelpBalloon({ icon:...
1
1965
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: 1-Load a Random Image each time page loads or is refreshed / script starts (with corresponding url link when clicked) 2-Images change by blend/fade into one another, on an adjustable time delay 3-Next image loaded also loads new corresponding url/link
6
1777
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: def write_vars(D): """ pass D=locals() to this function... """ for key in D.keys(): exec("%s = %s" % (key,D))
0
7977
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8276
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8261
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6705
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3936
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1496
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.