Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: Copyright Script?

  1. #21
    Join Date
    Nov 2011
    Posts
    196
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    There is a folder called UPLOADS
    The script generates 3 photos from the photo you upload.

    1,one photo is the origianl size that was selected to be used
    2,one photo is the resized output sized photo
    3,one photo is the resized output sized photo with a watermark

    I do not need 1 & 2 to be generated.
    If i knew how to write code or scripts i would but i dont some looking for some help.
    I can supply the text in the script file if that helps to look and edit for me ?
    Last edited by theremotedr; 09-10-2012 at 01:42 AM.

  2. #22
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    As I said, I'm too busy to put much time into this at the moment. If you post the code, I can take a quick look, but if I don't see what's wrong I won't be able to take the time to debug it.

    Either:
    1) The image is copied using move_uploaded_file(), just when it was uploaded in the first place.
    Or:
    2) The image is created using imagejpeg() or imagepng() or imagegif().

    Stopping it should be as simple as finding that line and commenting it out.


    Also, as I said above, if you use unlink(), you can delete the files after they're created. It's slightly less efficient than not creating them at all, but that should be very easy to do. See the php.net page for more information-- you'll just need to find the right path for the image and that's it.


    Another reason I don't want to put a lot of time into this is that if I were in your position, I'd just do it locally anyway. I think you're going to run into problems doing it this way, or at the very least put more time into setting this up than it would ever take you to just do it locally.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #23
    Join Date
    Nov 2011
    Posts
    196
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Here is the script thanks.
    Like i mentioned the script puts 3 photos in the uploads folder.
    1 the original size photo.
    2,the resized photo without watermark set to the size of the output file size.
    3,the resized photo with a watermark set to the size of the output file size.
    My output file size is set at 1024 x 768
    Once the photos are in the uploads folder i only have use for the photo with the watermark.
    The other two photos are deleted.
    This is why i would like a tweak in the script to not generate these two files or delete as soon as there are generated.

    PHP Code:
    <?php
    // Access the $_FILES global variable for this specific file being uploaded
    // and create local PHP variables from the $_FILES array of information
    $fileName $_FILES["uploaded_file"]["name"]; // The file name
    $fileTmpLoc $_FILES["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder
    $fileType $_FILES["uploaded_file"]["type"]; // The type of file it is
    $fileSize $_FILES["uploaded_file"]["size"]; // File size in bytes
    $fileErrorMsg $_FILES["uploaded_file"]["error"]; // 0 for false... and 1 for true
    $fileName preg_replace('#[^a-z.0-9]#i'''$fileName); // filter
    $kaboom explode("."$fileName); // Split file name into an array using the dot
    $fileExt end($kaboom); // Now target the last array element to get the file extension

    // START PHP Image Upload Error Handling -------------------------------
    if (!$fileTmpLoc) { // if file not chosen
        
    echo "ERROR: Please browse for a file before clicking the upload button.";
        exit();
    } else if(
    $fileSize 5242880) { // if file size is larger than 5 Megabytes
        
    echo "ERROR: Your file was larger than 5 Megabytes in size.";
        
    unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
        
    exit();
    } else if (!
    preg_match("/.(gif|jpg|png)$/i"$fileName) ) {
         
    // This condition is only if you wish to allow uploading of specific file types    
         
    echo "ERROR: Your image was not .gif, .jpg, or .png.";
         
    unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
         
    exit();
    } else if (
    $fileErrorMsg == 1) { // if file upload error key is equal to 1
        
    echo "ERROR: An error occured while processing the file. Try again.";
        exit();
    }
    // END PHP Image Upload Error Handling ---------------------------------
    // Place it into your "uploads" folder mow using the move_uploaded_file() function
    $moveResult move_uploaded_file($fileTmpLoc"uploads/$fileName");
    // Check to make sure the move result is true before continuing
    if ($moveResult != true) {
        echo 
    "ERROR: File not uploaded. Try again.";
        exit();
    }
    // Include the file that houses all of our custom image functions
    include_once("ak_php_img_lib_1.php");
    // ---------- Start Adams Universal Image Resizing Function --------
    $target_file "uploads/$fileName";
    $resized_file "uploads/resized_$fileName";
    $wmax 1024;
    $hmax 768;
    ak_img_resize($target_file$resized_file$wmax$hmax$fileExt);
    // ----------- End Adams Universal Image Resizing Function ----------
    // ---------- Start Adams Convert to JPG Function --------
    if (strtolower($fileExt) != "jpg") {
        
    $target_file "uploads/resized_$fileName";
        
    $new_jpg "uploads/resized_".$kaboom[0].".jpg";
        
    ak_img_convert_to_jpg($target_file$new_jpg$fileExt);
    }
    // ----------- End Adams Convert to JPG Function -----------
    // ---------- Start Adams Image Watermark Function --------
    $target_file "uploads/resized_".$kaboom[0].".jpg";
    $wtrmrk_file "watermark.png";
    $new_file "C:\Documents and Settings\IAN PARSONS\My Documents\MY WEB SITE STUFF\WEST COUNTRY PHOTOZONE\copyright photos/zcopyright_".$kaboom[0].".jpg";
    ak_img_watermark($target_file$wtrmrk_file$new_file);
    // ----------- End Adams Image Watermark Function -----------
    // Display things to the page so you can see what is happening for testing purposes
    echo "The file named <strong>$fileName</strong> uploaded successfuly.<br /><br />";
    echo 
    "It is <strong>$fileSize</strong> bytes in size.<br /><br />";
    echo 
    "It is an <strong>$fileType</strong> type of file.<br /><br />";
    echo 
    "The file extension is <strong>$fileExt</strong><br /><br />";
    echo 
    "The Error Message output for this upload is: $fileErrorMsg";
    ?>
    Last edited by jscheuer1; 09-10-2012 at 04:19 PM. Reason: Format

  4. #24
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    It would be possible to not generate the files, but that would require significantly rewriting the functions. As it is, it generates each then uses those files to generate the next. So if you turned that off in the script, you wouldn't have any file from which to generate the watermark photo.

    So the solution here, although it isn't the most elegant, is simply to delete those after they're done processing.

    At the end of the script, use the unlink() function with the right path, once for each extra image, to remove them.
    http://www.php.net/manual/en/function.unlink.php

    With the right paths, that should work immediately. However:
    1) Be careful with this-- you're deleting files on the server. If you aren't confident about it, then create a backup of the whole site first and don't use this on an active website. After some testing you should see that it works and you can rely on it.
    2) Use only paths generated by you. Don't rely on user input or a clever user might be able to delete other files on the system. This will also mean that you probably want to rename all of the photos rather than using the original names, or they could try to trick the system into deleting other files based on the name of the photo they upload. Of course this also applies to how the files are named in the first place-- they might find a way to overwrite a file that you wanted based on the name of the image-- so renaming all uploads is a good idea. Or filtering the filenames at least.
    3) The only possible technical problem will be if there's a permissions error on deleting (unlinking) the file. There shouldn't be, because it's generated by PHP. But if there is, just let us know.

    Let us know if you can't figure out the paths. Post your current unlink() code and we can try to help.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #25
    Join Date
    Nov 2011
    Posts
    196
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Adding the unlink () worked.

    Thanks

  6. #26
    Join Date
    Mar 2011
    Location
    N 11° 19' 0.0012 E 142° 15' 0
    Posts
    1,521
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    If this thread is finished, please set it to resolved.
    You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.

Similar Threads

  1. Copyright
    By H3llspwan in forum The lounge
    Replies: 4
    Last Post: 05-09-2011, 11:53 PM
  2. Does the web copyright is possible?
    By Theodoretheo in forum Looking for such a script or service
    Replies: 9
    Last Post: 02-05-2009, 06:12 AM
  3. Script in IFrame (Copyright)?
    By codeajax in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 11-14-2006, 09:30 PM
  4. Auto Copyright year script
    By dak in forum JavaScript
    Replies: 2
    Last Post: 10-05-2006, 08:05 PM
  5. copyright law
    By junde in forum The lounge
    Replies: 3
    Last Post: 06-30-2006, 09:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •