SitePoint Sponsor

User Tag List

Page 21 of 31 FirstFirst ... 11171819202122232425 ... LastLast
Results 501 to 525 of 767
  1. #501
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Watermark-ing

    In reply to a PM from an SP member i integrated the watermarking script into his code, that was pretty much original! Below is the code which should work with most people scripts. Note that you need to place it immediatly after you copy the image from the TMP dir to within your site.

    PHP Code:
    // Store the orignal file
    copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);
     
    // Watermark the original file
    //////////////////////////////// WATERMARK SCRIPT ////////////////////////////////////////
    ///////// Courtesy of Rob Guard (www.infizi.com // rob@infizi.com) and Sitepoint /////////
    // Requires GD Image Lib 1.8++ //
    $my_watermark "watermark.png"// Must be PNG-24 Format - Create in photoshop using a trasparent background - set the image layer trasparency to around 40%

    $margin 5// px margin around watermark
    $my_image $images_dir."/".$filename;

    // Get the watermark image, load it in to a variable and get its size.
    $watermark imagecreatefrompng($my_watermark);
    $w getimagesize($watermark_image);

    // Create the read and write functions for the new image
    $function_suffix $gd_function_suffix[$filetype];
    $Create 'ImageCreateFrom' $function_suffix;
    $Save 'Image' $function_suffix;

    // Load in Image to be watermarked
    $image $Create($my_image);
    $image_size getimagesize($my_image);

    // Total width - watermark width - margin gives co-ordinates for the watermark.
    $dest_x $size[0] - $w[0] - $margin;
    $dest_y $size[1] - $w[1] - $margin;

    // Merge the images
    imagecopy($image$watermark$dest_x$dest_y00$w[0], $w[1]);

    // Save $image to $my_image
    $Save($image$my_image);

    //Destroy TMP files
    imagedestroy($image);
    imagedestroy($watermark);

    ////////////////////////////////  END WATERMARK   //////////////////////////////////////// 
    New Design - PHP Slowly flowing in!

    Infizi Studio's

  2. #502
    SitePoint Guru hisham777's Avatar
    Join Date
    Dec 2005
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks infizi for the code
    Never be shy to ask silly Qs
    An answer is always better than none

  3. #503
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess I'm a tad bit stupid... I can't get the watermark to show... youre supposed to put the watermark file itself in the root where all the php files are, right? Cuz it aint showing....

  4. #504
    SitePoint Guru hisham777's Avatar
    Join Date
    Dec 2005
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by renikdelan
    I guess I'm a tad bit stupid... I can't get the watermark to show... youre supposed to put the watermark file itself in the root where all the php files are, right? Cuz it aint showing....
    am having problem make it work as well
    Never be shy to ask silly Qs
    An answer is always better than none

  5. #505
    SitePoint Member
    Join Date
    May 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What would be the best way to format the photo date to a month-year format? I've tried using substr but it didn't work, I feel like such a noob.

  6. #506
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sorvin
    What would be the best way to format the photo date to a month-year format? I've tried using substr but it didn't work, I feel like such a noob.
    is the date your using a php time stamp? ro is it already formatted? Please give us an example of the date you want to change!
    New Design - PHP Slowly flowing in!

    Infizi Studio's

  7. #507
    SitePoint Member
    Join Date
    May 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My bad, the date is in 0000-00-00 00:00:00 format gotten from the sql command now(). I would like it in 00-0000 format.

  8. #508
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, short of using mktime() to make a time stamp and then formatting that, i would do the following and use explode (not substr):

    PHP Code:
    <?
    $date_parts 
    explode("-"$date);
    $new_date $date_parts[1]."-".$date_parts[0];
    Quote Originally Posted by Sorvin
    My bad, the date is in 0000-00-00 00:00:00 format gotten from the sql command now(). I would like it in 00-0000 format.
    New Design - PHP Slowly flowing in!

    Infizi Studio's

  9. #509
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    you could always use inset the date.

    PHP Code:
      <?php
      
          $today 
    date("m-Y");
      
      
    ?>
    that will output "06-2006" (mm-yyyy).

    but if you need the time stamp aswell the above example will do.

  10. #510
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have to time to read the whole thread to ask if this has been quested/done before, so sorry if it has.

    Woudln't it be much easier to make it all into a class, so you can use it for other things, or use it to make an admin zone for it ?

    I'm wanting to make it into a class, but i don't have much exeircence with OOP, so any help or tips are welcome.

  11. #511
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I tried making it into a calss, and it does work, but you need a whole lot of front end code. This project is aimed at first time PHPers looking to extend their knowledge a little bit, hence giving them a class file and telling them what does what requires an intemediate level as they need to understand OOP. Quite like you actually. The idea is good, i added functions like $mygallery->getrandomimages(no of images[, categoryspecific]). Fantastic function that allowed me to add random images, and with a little tweaking creating functions like $mygallery->getlatestimages(noimages[,catspecific])

    Its all great, but unless you understand OOP enough to make it yourself, you wont understand another persons OOP implementation and you wont be able to create pages with it.

    I suggest if you really want this in OOP, sticking with that standard code, and slowly building a class by taking out repetative code etc etc an creating a class. Remember that your class will need to connect to the DB prior to any calls to it too!

    If i had time i would sit and write one and send it to you, but i dont, and you wouldnt understand it without a full explanation either!
    Quote Originally Posted by -_DarkRanger_-
    I don't have to time to read the whole thread to ask if this has been quested/done before, so sorry if it has.

    Woudln't it be much easier to make it all into a class, so you can use it for other things, or use it to make an admin zone for it ?

    I'm wanting to make it into a class, but i don't have much exeircence with OOP, so any help or tips are welcome.
    New Design - PHP Slowly flowing in!

    Infizi Studio's

  12. #512
    JuanM
    SitePoint Community Guest
    So I'm trying to add the delete function he has displayed. I want the user to click on the thumbnail and it deletes the pic. I'm having trouble excuting the delete function. Something like this would be ideal:

    <A HREF='delete_photo($PHOTO_ID)'><IMG THUMBNAIL></A>

    Any ideas?

  13. #513
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got a problem when trying to customize my design layout. Now, we all know the default design.inc.php looks like this:
    PHP Code:
    <?php

    $design_header
    = <<<__HTML_END

    <!-- Add your site header here -->
    HTML DESIGN-start
    __HTML_END;

    $design_footer= <<<__HTML_END

    <!-- Add your site footer here -->
    HTML DESIGN-end
    __HTML_END;
    ?>
    Now a few obstacles im running into is this: my gallery is in the /gallery directory off the root. But I have include files, scripts, and stylesheets in their respective directories, which are also off the root. Anyway, the majority of my header code is controlled by one line:
    <? include("includes/header.php") ?>
    However, I can't seem to add this on its own, even if I change it to have "../" before the path. I'm also running into the same thing with my footer file is well. To make things worse, when I use brute force and inject the contents of my header.php directly into the design.inc.php, it puts all the gallery below all my design code (when everything else on the site fits nicely within).

    Help!

  14. #514
    SitePoint Member
    Join Date
    May 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reply to renikdelan

    Basically if you write over the "<!-- Add your site header here -->
    HTML DESIGN-start" You will have no problems inserting your code. You have to use absolute addresses to include files in different directories (http://www.yourcode.cim/includes/yourcode.php). I thought that it was a faulty design until I tried to brute force it myself and saw where it ended up.

    I don't know if that will solve your header problem, but it should, all html and php will come after the header has already parsed.

  15. #515
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm actually seeing this when I do a view source...
    PHP Code:
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <TITLE>RenikDelan's Site</TITLE>
    <? include("http://www.renikdelan.com/includes/header.php"?>
    <div class="content">
    And when I try and add in the footer? That just bones the whole thing into an exception error...

    If anyone wants to give me a design.inc page with a header and footer that has a php include, itd be a HUGE help...
    Last edited by renikdelan; Jun 29, 2006 at 20:23.

  16. #516
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just want to say your gallery article is useful, therefore I don't use it.

  17. #517
    SitePoint Member
    Join Date
    May 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also renikdelan, the begining of your index.php file calls out to include(design.inc.php) twice, for some reason it will only work if this remains so. Make sure that you keep both of those lines.

    You have to place all of your <style> code within the <<<__HTML_END and __HTML_END; area.

  18. #518
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    U.S.
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem of displaying the screenshot at the page 2 of tutorial

    I have just copied whole code of page 2(preupload.php) of this tutorial, but didn't get the same look as screenshot right below the code on page 2 (preupload.php) of tutorial. Secondly don't understand what those codes meant "<<<__HTML_END"and"__HTML_END;", I have attached the code below, please let me know if I am wrong, this is the url of the tutorial :http://www.sitepoint.com/article/php...stem-minutes/2, thanks bunch!!
    PHP Code:
    <?php 
     
    include 'config.inc.php'

     
    // initialization 
     
    $photo_upload_fields ''
     
    $counter 1

     
    // If we want more fields, then use, preupload.php?number_of_fields=20 
     
    $number_of_fields = (isset($_GET['number_of_fields'])) ? 
       (int)(
    $_GET['number_of_fields']) : 5

     
    // Firstly Lets build the Category List 
     
    $result mysql_query('SELECT category_id,category_name FROM gallery_category'); 
     while(
    $row mysql_fetch_array($result)) { 
       
    $photo_category_list .= <<<__HTML_END 
    <option value="$row[0]">$row[1]</option>\
    __HTML_END

     } 
     
    mysql_free_result$result );   

     
    // Lets build the Image Uploading fields 
     
    while($counter <= $number_of_fields) { 
       
    $photo_upload_fields .= <<<__HTML_END 
    <tr><td
     
    Photo {$counter}: 
     <
    input name="photo_filename[]" 
    type="file" /> 
    </
    td></tr
    <
    tr><td
     
    Caption
     <
    textarea name="photo_caption[]" cols="30" 
       
    rows="1"></textarea
    </
    td></tr
    __HTML_END
       
    $counter++; 
     } 

     
    // Final Output 
     
    echo <<<__HTML_END 
    <html
    <
    head
    <
    title>Lets upload Photos</title
    </
    head
    <
    body
    <
    form enctype="multipart/form-data" 
     
    action="upload.php" method="post" 
     
    name="upload_form"
     <
    table width="90%" border="0" 
       
    align="center" style="width: 90%;"
       <
    tr><td
         
    Select Category 
         
    <select name="category"
         
    $photo_category_list 
         
    </select
       </
    td></tr
       <!
    —Insert the image fields here --> 
       
    $photo_upload_fields 
       
    <tr><td
         <
    input type="submit" name="submit" 
           
    value="Add Photos" /> 
       </
    td></tr
     </
    table
    </
    form
    </
    body
    </
    html
    __HTML_END
    ?>

  19. #519
    SitePoint Zealot maffp's Avatar
    Join Date
    Jun 2005
    Location
    UK
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Excellent tutorial: can somebody tell me though, how do I alter the code so that regardless of the uploaded file type (as long as it is GD version compatible), the sytem creates and resizes the original image into a jpeg and creates the thumbnail as a gif??

    Thanks.

  20. #520
    SitePoint Zealot maffp's Avatar
    Join Date
    Jun 2005
    Location
    UK
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    by the way... I'm referring to the tutorial at: http://www.sitepoint.com/article/php...system-minutes

  21. #521
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    U.S.
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    do you have the problem that I have?

    Quote Originally Posted by maffp
    Excellent tutorial: can somebody tell me though, how do I alter the code so that regardless of the uploaded file type (as long as it is GD version compatible), the sytem creates and resizes the original image into a jpeg and creates the thumbnail as a gif??

    Thanks.

    Do you have a trouble for showing the upload form as the same as screen shot in the tutorial(preupload.php) that I mentioned? If you don't, can you let me know how to understand the codes <<<__HTML_END"and"__HTML_END;". I don't understand them. Do I need to create a header.php and footer.php individually to be able to display preupload.php correctly?

    Thanks.

  22. #522
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    U.S.
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kilroy
    My preupload.php doesn't show any uploadfield whatsoever. Here's the code:

    PHP Code:
    <?php 
     
     
    // Include design
     
    include 'design.inc.php';
     
     
    // Include configuration file
     
    include 'config.inc.php'

     
    // Initialization 
     
    $photo_upload_fields ''
     
    $counter 1

    // If you want more fields, then the call to this page should be like, 
    // preupload.php?number_of_fields=20

        
    if( $_GET['number_of_fields'] )
        
    $number_of_fields = (int)($_GET['number_of_fields']);

        
    // Firstly Lets build the Category List

        
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
        while( 
    $row mysql_fetch_array$result ) )
        {
    $photo_category_list .=<<<__HTML_END
        <option value="$row[0]">$row[1]</option>\n
    __HTML_END;
        }
        
    mysql_free_result$result );    

    // Lets build the Photo Uploading fields
        
    while( $counter <= $number_of_fields )
        {
    $photo_upload_fields .=<<<__HTML_END
    <tr>
        <td>
             Photo 
    {$counter}:
            <input name=' photo_filename[]' type='file' />
        </td>
    </tr>
    <tr>
        <td>
             Caption:
            <textarea name='photo_caption[]' cols='30' rows='1'></textarea>
        </td>
    </tr>
    __HTML_END;
        
    $counter++;
        }

    // Final Output
    echo <<<__HTML_END
    $design_header

    <div class="content">
    <h1>Upload photos</h1>
    <form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
    <table width='90%' border='0' align='center' style='width: 90%;'>
    <tr>
        <td>
            Select Category
            <select name='category'>
                
    $photo_category_list
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <p>
    $photo_upload_fields</p>
        </td>
    </tr>

    <tr>
        <td>
                <input type='submit' name='submit' value='Add Photos' />
        </td>
    </tr>
    </table>
    </form>
    </div>
    $design_footer
    __HTML_END;
    ?>
    Does anyone know what's wrong with it? The script is located at http://hd-clan.2dhost.net/preupload.php

    Thanks,

    Kilroy
    I have the same problem and posted the question, so far no one answer our problem, well, all we need to do is that keep in faith in this forum.

  23. #523
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    U.S.
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have the same problem and posted the question, so far no one answer our problem, well, all we need to do is that keep in faith in this forum.

  24. #524
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Smile

    Quote Originally Posted by begeiste
    Do you have a trouble for showing the upload form as the same as screen shot in the tutorial(preupload.php) that I mentioned? If you don't, can you let me know how to understand the codes <<<__HTML_END"and"__HTML_END;". I don't understand them. Do I need to create a header.php and footer.php individually to be able to display preupload.php correctly?

    Thanks.
    sorry for not replying back sooner, we've all been busy.

    anyway, those tags "<<<__HTML_END"and"__HTML_END;" are another way of doing " or a '.

    still not clear?

    here's an example of the code changed to way i'm going on about:
    PHP Code:
      <?php 
        
    include 'config.inc.php'
       
        
    // initialization 
        
    $photo_upload_fields ''
        
    $counter 1
       
        
    // If we want more fields, then use, preupload.php?number_of_fields=20 
        
    $number_of_fields = (isset($_GET['number_of_fields'])) ? 
          (int)(
    $_GET['number_of_fields']) : 5
       
        
    // Firstly Lets build the Category List 
        
    $result mysql_query('SELECT category_id,category_name FROM gallery_category'); 
        while(
    $row mysql_fetch_array($result)) { 
          
    $photo_category_list .= '<option value="$row[0]">$row[1]</option>\n'
        } 
        
    mysql_free_result$result );   
       
        
    // Lets build the Image Uploading fields 
        
    while($counter <= $number_of_fields) { 
          
    $photo_upload_fields .= 
      <tr><td> 
        Photo {$counter}: 
        <input name="photo_filename[]" 
      type="file" /> 
      </td></tr> 
      <tr><td> 
        Caption: 
        <textarea name="photo_caption[]" cols="30" 
          rows="1"></textarea> 
      </td></tr>'

          
    $counter++; 
        } 
       
        
    // Final Output 
        
    echo '<html> 
      <head> 
      <title>Lets upload Photos</title> 
      </head> 
      <body> 
      <form enctype="multipart/form-data" 
        action="upload.php" method="post" 
        name="upload_form"> 
        <table width="90%" border="0" 
          align="center" style="width: 90%;"> 
          <tr><td> 
            Select Category 
            <select name="category"> 
            $photo_category_list 
            </select> 
          </td></tr> 
          <!—Insert the image fields here --> 
          $photo_upload_fields 
          <tr><td> 
            <input type="submit" name="submit" 
              value="Add Photos" /> 
          </td></tr> 
        </table> 
      </form> 
      </body> 
      </html>'

      
    ?>
    getting it now?

    here's a small snippet of the code:

    the orig:
    PHP Code:
      $photo_category_list .= <<<__HTML_END 
      
    <option value="$row[0]">$row[1]</option>\
      __HTML_END

    the changed example:
    PHP Code:
      $photo_category_list .= '<option value="$row[0]">$row[1]</option>\n'
    i personally prefer the changed example above, to me it makes it easy to understand and read. others will like the other method of using the html tags "<<<__HTML_END", etc...

    the problem with the method that i like using is you may have to do something like the code below to get the code to work, only if there's an error message appearing in the web browser:
    PHP Code:
     <option value="'.$row[0].'">'.$row[1].'</option
    as for the other question:
    Do I need to create a header.php and footer.php individually to be able to display preupload.php correctly?
    you will need to create a header.php and footer.php to display the top and bottom of each page.

    the preupload.php goes inbetween the header and footer then placed into the index page through the web browser.

    spence

  25. #525
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by maffp
    Excellent tutorial: can somebody tell me though, how do I alter the code so that regardless of the uploaded file type (as long as it is GD version compatible), the sytem creates and resizes the original image into a jpeg and creates the thumbnail as a gif??

    Thanks.
    could you post your code so we can view what you've done?

    ta!

    spence


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
  •