Re: AW: [PHP] image function

2002-08-13 Thread Nicholas Mercier

At 04:52 PM 8/13/2002 +0200, Sascha Braun wrote:
Okay... I've looked at that library and felt as if I was looking into the 
ark of the Covenant.

I'm really not that good at programing and looking at that script made my 
eyes bleed.

This is a script I've used to save an image and then dynamically resize it 
proportionately until it is within 200x180.  It also renames the file and 
creates a mysql database entry for the file so my image collection can 
later be searched.

";
 if(($temp_h*1.8) > ($temp_w*2))
 {
 $ratio = $temp_w/$temp_h;
 $dest_w = 200*$ratio;
 $dest_h = 200;
 }
 if(($temp_h*1.8) < ($temp_w*2))
 {
 $ratio = $temp_h/$temp_w;
 echo "Ratio - $ratio ";
 $dest_w = 180;
 $dest_h = 180*$ratio;
 }
 //On the off chance that the image is proportionate to 200x180 
already we just set the height and width.
 if(($temp_h*1.8) == ($temp_w*2))
 {
 $dest_w = 180;
 $dest_h = 200;
 }

 //Create the canvas.  To use imagecreatetruecolor you need 
php_gd2.dll listed as an extension
 $image_t = imagecreatetruecolor($dest_w, $dest_h);

 //Resize (technically resample) the image to the new canvas
 imagecopyresampled($image_t, $tempimage, 0, 0, 0, 0, $dest_w, 
$dest_h, $temp_w, $temp_h);

 //Save the Thumbnail
 if(!ImageJpeg($image_t, $image_root.$smallfilename))
 {
 echo "ERROR: Thumbnail Image unable to Upload!";
 exit;
 }
}
//Clean up
imagedestroy($tempimage);
imagedestroy($image_t);

//Insert File info into MySQL database
$imageUpdate = "insert into images (catID, caption, descr, systemID, 
genreID, game) values ('$f_imageCat', '$f_caption', '$f_descr', 
'$f_system', '$f_genre', '$f_game')";

if(!mysql_query($imageUpdate, $conn))
{
 echo "ERROR: Unable to Submit information to Database, try Upload 
later.";
 exit;
}
echo "Image Upload Successful! Image ID is: $newnum";
?>





I am running a windows system, so I know that the JPEG functions do work.
Gif functions will NOT WORK as the compression algorithm is now copyrighted.
If this script (once tweaked for your system needs) does not work and your 
php.ini file is included the proper extension I don't know what to say.

Nick

>I believe the jpeg funnktions don't work on a windows system. The Gifs don't
>do either because they aren't implemeted too.
>
>Please look at this Library. It's very nice but I don't get it working and
>the guy who made it don't know either, why it's not working on my system.
>Must be something about jpeg librarys and so on.
>
>Schura
>
>PS.: Examples at the end of the file.
>
>-Ursprüngliche Nachricht-
>Von: Nicholas Mercier [mailto:[EMAIL PROTECTED]]
>Gesendet: Dienstag, 13. August 2002 10:35
>An: [EMAIL PROTECTED]
>Betreff: Re: [PHP] image function


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




Re: [PHP] Variable naming standards???

2002-08-13 Thread Nicholas Mercier

My two cents,

I think if you are working on a personal product you use what works for 
you.  If working in a group find out or decide as a group what standards to 
use.  The hungarian standards are well designed, but I've seen others that 
work as well.

When posting data from a from to another script I've see F used... as in 
$f_username $f_userpass.
As well as many others.

The best advise I could give with my (VERY) limited experience, chose a 
constant method for yourself and stick to it.  That way it will become 
second nature to you.

Nick

At 09:52 AM 8/13/2002 -0400, Gerard Samuel wrote:
>A philosophical question
>Are there any standards to naming variables??
>I was told that one should include a letter or combination of letters to 
>describe a variable
>i.e.
>$sfoo = 'string';  // string
>$bfoo = true;  // bool
>$nfoo = 10;  // interger
>
>etc
>
>Thanks
>
>--
>Gerard Samuel


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




Re: [PHP] security login

2002-08-13 Thread Nicholas Mercier

At 04:12 PM 8/12/2002 +0100, Pag wrote:
Here is my humble, but relatively effective solution for a low security site.

Create a file called security.php and require it at the head of every 
secure page.  This is the one I use.

You are not logged in.  Please do so.";
 echo "Login Here";
 exit;
}
else
{
 echo "You are currently logged in as: $userinfo[name] ";
 echo "If you are not $userinfo[name] please Logout. Thank you.";
}
?>

All you need your log in script to do is check the user name and password 
against what is stored in the database and register a session.

You can store lots of useful information in the session as well.  I find it 
useful if you want to give different users different permission 
levels.  That way you can late check the session data to see if they have 
permission to update the news, or publish an article.

Nick


> Well, first off sory for a very basic question, but i really dont 
> know where else to look for the answer. Heres my dilemma:
>
> I need to code a backend for this site i am building, the backend 
> will manage the news for the front page. The database stuff is pretty 
> straight forward (so far!), but i need to validate who does the managing, 
> i mean, some sort of login for only a few people. I am thinking of using 
> username/pass from a table and all that but the thing is, how do i do the 
> validating itself? Sure i know how to check for valid user/pass, but then 
> what happens for the rest of the pages inside the backend, how do i keep 
> the user validated and make sure only he can browse inside that "secure" 
> mini site?
> Dont know if i am explaining things right, hmm, ok, any of you 
> guys are familiar with gryematter? It validates the user at the start and 
> then we can do whatever we want inside. I want to prevent users from 
> skipping the login and just typing the other page url and go on from there.
> I use sessions, cookies? what? can you provide me with some urls 
> for my research, or at least what to look for?
> Thanks a lot, really appreciate all the help.
>
> Pag
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




Re: AW: [PHP] image function

2002-08-13 Thread Nicholas Mercier

At 03:37 AM 8/13/2002 +0200, you wrote:
Hey there,

I created a set of scripts that did basically what you are looking to do.

THINGS TO CHECK:
1.   You may have a problem if you uncommented both DLL files.  Apache will 
complain when it tries to load two libraries with the same functions in them.

2.Make sure that the dll file is in the correct place.  It should match 
the extension directory listed in your php.ini file.

3.Additionally you may want to copy the DLL to your WINNT/SYSTEM 
directory (don't know why, but I've been told this helps.)

4.Stop and restart Apache

5. When uploading an image to be resized realize that the data may type 
image/pjpeg (progressive jpeg) and not image/jpeg (This caused my scripts 
to choke on me when checking image types for filtering purposes)

If PHP 4.2.2 doesn't support Jpeg then that is odd since I'm working with 
version 4.1.1 and I have no problems with my image scripts.

Feel free to reply if you'd like to show me your scripts or ask for 
additional clarification.

Nick

>Hello,
>
>I got the same Problem right yet. I´m using an create thumbnail library on
>my website, but the class don't work on my computer and either not on my
>webspace where i tested it too.
>
>On my Computer there is installed Win2K with apache 2.0.35 and PHP 4.2.2. I
>used both GDLibs wich came along with my PHP Package, but they both didn't
>have support for Jpeg Images.
>
>I'm running ill while I work on this shit. 'Cause I need to create to create
>Thumbs from very large images, they're about 2.5 MB each. And right yet I
>don't know some about performance and if it will work ever. Later the hole
>site will run on an dedicated Linux machine. But I'm not the super pro on
>installing and compiling packages on a linux systems. And it would be nice
>if i could test the scripts on my WinNT 5 machine.
>
>Please tell me what you found out yet! - I got a very nice image creation
>library, wich is under GPL. I'm going to send it soon to ya if you want it.
>
>Thanks
>
>Schura
>
>-Ursprüngliche Nachricht-
>Von: NoWhErEMan [mailto:[EMAIL PROTECTED]]
>Gesendet: Montag, 12. August 2002 15:50
>An: [EMAIL PROTECTED]
>Betreff: Re: [PHP] image function
>
>
>Thank you Jay, Yup my apache is on Windows : )
>Let's me try first.
>"Jay Blanchard" <[EMAIL PROTECTED]> ¼¶¼g©ó¶l¥ó·s»D
>:002301c24201$b28caf00$[EMAIL PROTECTED]
> > [snip]
> > I known i need to install a lot of staffs to get all the functions
>works(GD
> > Lib, FreeType Lib, libjpeg, libpng, zlibetc etc).
> > But i only need a few of them, so if i just load the php_gd.dll, what
> > functions included?? I canr found any information about that.
> > And one more, does php_gd2.dll also a GD lib?
> > [/snip]
> >
> > The DLL is a Windows library AFAIR, and contains the GD functions when
> > included on a Windows server. You do not have to enable this extension on
>an
> > Apache server (unless it is Apache on Windows). You just have to make sure
> > that PHP is compiled with all of the proper libraries for your use of GD.
> >
> > As for the second DLL, I am not sure. I haven't done a lot of Windows GD
> > installations, it does not look familiar.
> >
> > HTH!
> >
> > Jay
> >
> >
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


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




Re: [PHP] image function

2002-08-13 Thread Nicholas Mercier

At 09:50 PM 8/12/2002 +0800, you wrote:
Jay,

I would recommend uncommenting the php_gd2.dll extension.

Gd2 contains some functions that GD lacks and is over all better in my opinion.
However, they are correct that you do NOT need to recompile when running 
PHP on a Windows Platform.  Simply change php.ini to include the added 
extension and then restart your apache server.

Nick


>Thank you Jay, Yup my apache is on Windows : )
>Let's me try first.
>"Jay Blanchard" <[EMAIL PROTECTED]> ¼¶¼g©ó¶l¥ó·s»D
>:002301c24201$b28caf00$[EMAIL PROTECTED]
> > [snip]
> > I known i need to install a lot of staffs to get all the functions
>works(GD
> > Lib, FreeType Lib, libjpeg, libpng, zlibetc etc).
> > But i only need a few of them, so if i just load the php_gd.dll, what
> > functions included?? I canr found any information about that.
> > And one more, does php_gd2.dll also a GD lib?
> > [/snip]
> >
> > The DLL is a Windows library AFAIR, and contains the GD functions when
> > included on a Windows server. You do not have to enable this extension on
>an
> > Apache server (unless it is Apache on Windows). You just have to make sure
> > that PHP is compiled with all of the proper libraries for your use of GD.
> >
> > As for the second DLL, I am not sure. I haven't done a lot of Windows GD
> > installations, it does not look familiar.
> >
> > HTH!
> >
> > Jay
> >
> >
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


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




[PHP] Follow Up

2002-07-25 Thread Nicholas Mercier

Okay, I somehow fixed it.  But to make sure I am clear on this ImageSY Will 
give the vertical height of an image and ImageSX will give the width?

Sorry to spam with such a stupid mistake...

Me.


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




[PHP] Image Resizing

2002-07-25 Thread Nicholas Mercier

Okay.  Unless I failed a math course in high school (which is possible) I 
think my formulas are sound.  However I'm having issues with this code.

The Intended result:  Take any image larger then 180x200 (WxH) and resize 
it proportionally so it fits within 200x180.
What I'm getting, exactly what I want, except images come back deformed or 
miscreated.  I've attached 2 jpegs that are produced by this script.  If 
anyone can help out it would be greatly appreciated

$lastnumQry = "SELECT imageID FROM images ORDER BY imageID DESC";
$lastnumRslt = mysql_query($lastnumQry, $conn);
$lastnum = mysql_fetch_array($lastnumRslt);
$newnum = $lastnum['imageID']+1;

//Set image dir
$image_root = $DOCUMENT_ROOT.'/images/';

//Create a temp image file from uploaded jpeg
$tempimage = imagecreatefromjpeg("$f_image");
$temp_h = ImageSX($tempimage);
$temp_w = ImageSY($tempimage);

//Checks that the image is not too small
if($temp_h < 50 && $temp_w <50)
{
echo "ERROR: Image is less then 50x50.";
exit;
}
//set file name

$filename = $newnum.'.jpg';

//save image
if(!ImageJpeg($tempimage, $image_root.$filename))
{
echo "ERROR: Image unable to upload!";
exit;
}
$smallfilename = $newnum.'_t.jpg';

if($temp_h < 200 && $temp_w <180)
{
//Save thumbnail
if(!ImageJpeg($tempimage, $image_root.$smallfilename))
{
echo "ERROR: Thumbnail Image unable to upload!";
exit;
}
}
else
{
echo "Resize beginning.";
if(($temp_h*1.8) > ($temp_w*2))
{
$ratio = $temp_h/$temp_w;
$dest_w = 200*$ratio;
$dest_h = 200;
echo "ONE - $dest_w - $dest_h";
}
if(($temp_h*1.8) < ($temp_w*2))
{
$ratio = $temp_w/$temp_h;
echo "Ratio - $ratio ";
$dest_w = 180;
$dest_h = 180*$ratio;
echo "TWO - $dest_w - $dest_h";
}
if(($temp_h*1.8) == ($temp_w*2))
{
$dest_w = 180;
$dest_h = 200;
}
$image_t = imagecreatetruecolor($dest_w, $dest_h);
imagecopyresampled($image_t, $tempimage, 0, 0, 0, 0, $dest_w, $dest_h, 
$temp_w, $temp_h);
if(!ImageJpeg($image_t, $image_root.$smallfilename))
{
echo "ERROR: Thumbnail Image unable to Upload!";
exit;
}
}


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


[PHP] Quick Question

2002-07-24 Thread Nicholas Mercier

I'm currently developing a Remote CMS for a site.

I'm working on the image upload and want to create a smaller thumbnail type 
image (thought >200x>180 instead of >50x>50)
I know I'm going to need either imagecopyresize() or imagecopyresample(). I 
don't know which would be better for this purpose or what the main 
difference is in terms of quality and run time. Any comments or assistance 
is gladly welcome.

Thank you in advance for your time,

Nicholas D. Mercier


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