Jump to content

Mouse

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Posts posted by Mouse

  1. <?php

    /**

    * $Id: buymeabeer.module,v 1.1 2007/05/27 15:34:58 yaph Exp $

    *

    * @file

    * Author: Ramiro Gómez - http://www.ramiro.org

    * A Drupal module that allows donations via Paypal to buy beer.

    */

     

    define('BMAB_ANCHOR_TEXT', t('If you liked this post, buy me a beer.'));

    define('BMAB_LINK_TITLE_TEXT', t('Donate a beer or two via Paypal.'));

     

    /**

    * Implementation of hook_menu().

    */

    function buymeabeer_menu($may_cache) {

      $items = array();

      $items[] = array(

        'path' => 'admin/settings/buymeabeer',

        'title' => t('Buy Me a Beer'),

        'description' => t('Enable the node types to display the buy me a beer link,

          set the paypal e-mail and the anchor text for the link.'),

        'callback' => 'drupal_get_form',

        'callback arguments' => array('buymeabeer_admin_settings'),

        'access' => user_access('administer site configuration'),

        'type' => MENU_NORMAL_ITEM

      );

      return $items;

    }

     

    /**

    * admin settings for the buymeabeer module

    */

    function buymeabeer_admin_settings() {

      $form = array();

      $form['buymeabeer'] = array(

        '#type' => 'fieldset',

        '#title' => 'Buy Me a Beer ' . t('settings'),

        '#collapsible' => TRUE,

        '#collapsed' => FALSE

      );

     

      $form['buymeabeer']['buymeabeer_paypal_mail'] = array(

        '#type' => 'textfield',

        '#title' => t('Paypal E-mail Addrees'),

        '#default_value' => variable_get('buymeabeer_paypal_mail', ''),

        '#size' => 60,

        '#maxlength' => 60,

        '#required' => TRUE,

        '#description' => t('Enter an e-mail address that is enabled to receive paypal payments.')

      );

     

      $form['buymeabeer']['buymeabeer_anchor_text'] = array(

        '#type' => 'textfield',

        '#title' => t('Anchor Text'),

        '#default_value' => variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT),

        '#size' => 60,

        '#maxlength' => 60,

        '#description' => t('Enter the anchor text for the link.')

      );

     

      $form['buymeabeer']['buymeabeer_link_title_text'] = array(

        '#type' => 'textfield',

        '#title' => t('Link Title Text'),

        '#default_value' => variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT),

        '#size' => 60,

        '#maxlength' => 60,

        '#description' => t('Enter the title text for the link. This is what is displayed as

          a tooltip when the cursor is moved over the link. This text is also used as the paypal

          donation identifier')

      );

     

      $form['buymeabeer']['buymeabeer_teaser_full_view'] = array(

        '#type' => 'select',

        '#title' => t('Display in teaser and/or full view'),

        '#default_value' => variable_get('buymeabeer_teaser_full_view', 0),

        '#options' => array(0 => t('Full view'), 1 => t('Teaser'), 2 => t('Teasers and full view')),

        '#description' => t('When to display the link.'),

      );

     

      $form['buymeabeer']['buymeabeer_node_types'] = array(

        '#type' => 'checkboxes',

        '#title' => t('Node Types'),

        '#default_value' => variable_get('buymeabeer_node_types', array()),

        '#options' => node_get_types('names'),

        '#description' => t('Enable the node types to display the link for.')

      );

     

      $form['buymeabeer']['buymeabeer_weight'] = array(

        '#type' => 'select',

        '#title' => t('Weight'),

        '#default_value' => variable_get('buymeabeer_weight', 20),

        '#options' => drupal_map_assoc(range(-20,20)),

        '#description' => t('Specifies the position of the link.

          A low weight, e.g. <strong>-20</strong> will display the link above the content

          and a high weight, e.g. <strong>20</strong> below the content.')

      );

     

        return system_settings_form($form);

    }

    /**

    * Implementation of hook_nodeapi().

    */

    function buymeabeer_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

      if ($op == 'view') {

        //Check our node is one of the checked types

        if(in_array($node->type, variable_get('buymeabeer_node_types', array()), TRUE)) {

          $display_link = FALSE;

          switch (variable_get('buymeabeer_teaser_full_view', 0)) {

            // display in full view only

            case 0:

              if (!$a3) {

                $display_link = TRUE;

              }

              break;

            // display in teaser only

            case 1:

              if ($a3) {

                $display_link = TRUE;

              }

              break;

            // display in full view and teaser

            case 2:

              $display_link = TRUE;

              break;

          }

          if($display_link) {

            $node->content['buymeabeer_ad'] = array(

              '#value' => theme('buymeabeer_link'),

              '#weight' => variable_get('buymeabeer_weight', 20)

            );

          }

        }

      }

    }

     

    function buymeabeer_paypal_link() {

      $paypal_mail = variable_get('buymeabeer_paypal_mail', '');

      $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT);

      $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT);

      $href = "https://www.paypal.com/cgi-bin/webscr";

      $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text";

      return l("<span>".$anchor_text."</span>", $href, array('class' => 'buymeabeer-link', 'title' => $title_text),

        $query, NULL, TRUE, FALSE);

    }

     

    /**

    * theme function for link display

    */

    function theme_buymeabeer_link() {

      $link = buymeabeer_paypal_link();

      return '<div class="buymeabeer"><span>'. $link .'</span></div>';

    }

     

    ?>

  2. This code is for a Drupal module i am playing with. i need to get span tags around the <strong>$anchor_text</strong>

    I have tried every thing i can think of to do it but i have run out of ideas! could someone help me put here?

    return '<div class="buymeabeer"><span>'. $link .'</span></div>';

    almost works but it puts the taggs arround everything and my CSS just wont play nice like that!

     

    <?php
    function buymeabeer_paypal_link() {
      $paypal_mail = variable_get('buymeabeer_paypal_mail', '');
      $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT);
      $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT);
      $href = "https://www.paypal.com/cgi-bin/webscr";
      $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text";
      return l($anchor_text, $href, array('class' => 'buymeabeer-link', 'title' => $title_text),
        $query, NULL, TRUE, FALSE);
    }
    
    /**
    * theme function for link display
    */
    function theme_buymeabeer_link() {
      $link = buymeabeer_paypal_link();
      return '<div class="buymeabeer">'. $link .'</div>';
    }
    
    ?>
    

  3. maybe somthing like...?

    <?php
    
    /* images named 1.jpg, 2.jpg etc. */ 
    
    // total number of images in the folder
    $total = "11";
    
    $file_type = ".jpg";
    
    // location of the folder containing the images
    $image_folder = "images/random";
    
    
    $start = "1";
    
    $random = mt_rand($start, $total);
    
    switch ($url) { 
        case 1: 
             echo "http://flickr.com/photos/account_123"; 
             break; 
        case 2: 
             echo "http://flickr.com/photos/account_246"; 
             break; 
        default: 
             echo "http://flickr.com/"; 
    }
    
    $image_name = $random . $file_type;
    
    echo "<a href=\"$url\"><img src=\"$image_folder/$image_name\" alt=\"$image_name\" /></a>";
    
    ?>
    

  4. For a while now I have been using the following “Random Image” code to display an image into the index page of my site http://afterthemouse.com but now I need to extend it’s scope a little. I need to add a link back to the photographers Flickr account to each photo. How do I structure the array?

     

    The thumbnails will be stored locally and serve as a link to the full size Flickr image

     

    Many thanks

     

    <?php
    
    /* images named 1.jpg, 2.jpg etc. */ 
    
    // total number of images in the folder
    $total = "11";
    
    $file_type = ".jpg";
    
    // location of the folder containing the images
    $image_folder = "images/random";
    
    $start = "1";
    
    $random = mt_rand($start, $total);
    
    $image_name = $random . $file_type;
    
    echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />";
    
    ?>
    

     

  5. Drupal help needed… PHP / CSS

     

    Friends, I need a little help tweaking a Drupal based site to make it all the more wonderful.

     

    My problem is I am still a relative N00bie to both PHP and Drupal and need a little help. I can’t pay much / anything at all but I am more than willing to give credit where it is due and help by return in and way I can (“Nigerian Cash” spammers need not apply for this).

     

    Here’s what I am working on and what I need help with…

    The site is http://afterthemouse.com

     

    And the bit’s I want to tweak are…

    Wim Leers’ Hierarchical Select module: [http://drupal.org/project/hierarchical_select] to make multiple selections easier to add and edit.

     

    Avatars – using Lullabot’s method [http://www.lullabot.com/articles/imagecache_example_user_profile_pictures] to make images a little more “friendly”

     

    A little custom coding on a use for Thickbox to “enlarge” user avatars

     

    Making the CSS play nice with IE

     

    Any help would be appreciated and I hope to hear from you soon

  6. Hi, I am using the GD Image library to make an image that I want to include in a page. But I cannot just include the GD script into the page as it just prints meaningless code… and I don’t really want to send my users to a page with only the raw image on it so can I redirect the browser back to the previous page but only when the image is created

     

    <?php
    
    // test vars
    $firstname = "testing";
    $uid = "11";
    //////////////////////////
       
       $point = 20; // good for up to around 16 places
       
       $text = $firstname;
       $text = mb_convert_case($text, MB_CASE_UPPER, "UTF-8");
       
       $size = imagettfbbox($point, 0, "nametag.ttf", $text);
       $xsize = abs($size[0]) + abs($size[2]);
       $ysize = abs($size[5]) + abs($size[1]);
    
       $image = imagecreatefrompng("sml_nm_tg.png");
       $imagesize = getimagesize("sml_nm_tg.png");
       $textleftpos = round(($imagesize[0] - $xsize) / 2);
       $texttoppos = round(($imagesize[1] + $ysize) / 2) + 10;
    
       $red = imagecolorclosest($image, 255, 51, 0);
       imagettftext($image, $point, 0, $textleftpos, $texttoppos, $red, "nametag.ttf", $text);
    
       header("content-type: image/png");
       imagepng($image, "badge_" . $firstname . ".png");
       imagedestroy($image);
    ;?>
    

  7. Ken, using the function imagecolorclosest() instead of imagecolorallocat() has done the trick, many thanks.

     

    The reason you're getting "gibberish" online is that you're getting warning messages about not being able to find the font you want.

     

    how can i rectify this, is there a way to find out which fonts are on the server (i assume) or can i put one in there?

     

    Many thanks

     

    Mouse

  8. Well I have had a little play with this and I am not clear on a couple of bits…

    <?php
       $point = 18;
       $text = "Bekky"; // to be users name here
    
       $size = imagettfbbox($point, 0, "ARIAL", $text);
       $xsize = abs($size[0]) + abs($size[2]);
       $ysize = abs($size[5]) + abs($size[1]);
    
       $image = imagecreatefrompng("images/badge/sml_nm_tg.png");
       $imagesize = getimagesize("images/badge/sml_nm_tg.png");
       $textleftpos = round(($imagesize[0] - $xsize) / 2);
       $texttoppos = round(($imagesize[1] + $ysize) / 2) + 10;
    
       $red = ImageColorAllocate($image, 255, 51, 0);
       $grey = ImageColorAllocate($image, 102, 153, 153);
    
       imagettftext($image, $point, 0, $textleftpos + 1, $texttoppos + 1, $grey, "ARIAL", $text);
       imagettftext($image, $point, 0, $textleftpos, $texttoppos, $red, "ARIAL", $text);
    
       header("content-type: image/png");
       imagepng($image);
       imagedestroy($image);
    ?>
    

     

    as you can see there is meant to be red writing with a grey drop shadow but as you can see from this local test screen print…

    <img src="http://mouse.nodstrum.com/images/badge/demo.jpg" />

    it just isn’t doing the colours thing… even worse <a href="http://mouse.nodstrum.com/nametag.php">when I try this online I get gibberish</a> any ideas? PLEASE????

  9. if (!file_exists($mempic)) {
    $mempic = "<img src='images/mugs/mug.'_'.$u_uid.'.jpg' class='picborder' width='47px' height='53px' align='left'>";
    } else {
    $mempic = "<img src='images/mugs/MugDefault.jpg' alt='No image on file' class='picborder' width='47px' height='53px' align='left'>";
          		} 
    

     

    jesirose, as i understand it the Full code should now be as above... with youe extra "!" in the first line... but this has killed all the images... am i getting your inference right?

  10. PT2: PHP, Head, Brick Wall, Bang... Bang, Bang!!!!

    The modified Cropper_include script.
    [code]
    <?php

    // handle requests for temporary low-res image:
    if(isset($_GET['showimg']))
    {
    header("Content-Type: image/jpeg");
    echo $_SESSION[$unique_session_key]['lowres'];
    die();
    }

    // handle photo uploads:
    $photoerr = false;
    if(isset($_FILES['photo']))
    {
    $img = imagecreatefromjpeg($_FILES['photo']['tmp_name']);
    if($img=="")
    {
    // bad image uploaded
    $photoerr = true;
    }
    else
    {
    $sizedata = getimagesize($_FILES['photo']['tmp_name']);
    // original dimensions:
    $orig_w = $sizedata[0];
    $orig_h = $sizedata[1];
    // low-res image dimensions:
    $full_w = min($default_max_width, $orig_w);
    $full_h = round(($full_w/$orig_w)*$orig_h);
    if($full_h > $default_max_height)
    {
    $full_h = $default_max_height;
    $full_w = round(($full_h/$orig_h)*$orig_w);
    }
    // create resized image:
    $full = imagecreatetruecolor($full_w, $full_h);
    imagecopyresized($full, $img, 0, 0, 0, 0, $full_w, $full_h, $orig_w, $orig_h);
    // store in Session:
    $_SESSION[$unique_session_key]['full'] = imgdata($img);
    $_SESSION[$unique_session_key]['lowres'] = imgdata($full);
    }
    }

    // handle crop requests:
    if(isset($_POST['top']) && isset($_POST['left']) && isset($_POST['width']) && isset($_POST['height']))
    {
    do { $tempfile = rand(1,10000); } while(file_exists(TEMP_DIR.$tempfile));
    $fp = fopen(TEMP_DIR.$tempfile, 'wb');
    fwrite($fp, $_SESSION[$unique_session_key]['full']);
    fclose($fp);
    $sizedata = getimagesize(TEMP_DIR.$tempfile);
    $orig_w = $sizedata[0];
    $orig_h = $sizedata[1];
    $img = imagecreatefromjpeg(TEMP_DIR.$tempfile);
    $full_w = intval($_POST['width']);
    $full_h = intval($_POST['height']);
    $full = imagecreatetruecolor($full_w, $full_h);
    imagecopyresized($full, $img, 0, 0, 0, 0, $full_w, $full_h, $orig_w, $orig_h);
    $final = imagecreatetruecolor($cropped_width, $cropped_height);
    imagecopy($final, $full, 0, 0, -1*(intval($_POST['left'])-250), -1*(intval($_POST['top'])-160), $cropped_width, $cropped_height);
    storeImage($final);
    unlink(TEMP_DIR.$tempfile);
    header("Location: $redirect_after_crop");
    }

    if(!isset($_SESSION[$unique_session_key]['full']))
    {
    $_SESSION[$unique_session_key]['full'] = file_get_contents($default_image);
    $_SESSION[$unique_session_key]['lowres'] = file_get_contents($default_image);
    }

    function imgdata($imgid)
    {
    do{ $filename = TEMP_DIR.rand(1,10000); } while(file_exists($filename));
    imagejpeg($imgid, $filename);
    $data = file_get_contents($filename);
    unlink($filename);
    return $data;
    }
    ?>
    CSS Removed
    JavaScript Removed
    <!--added next line TJ 14/01/07 Grrrr -->
    <?php echo "name here " .$_SESSION['imageName'] ;?>

    <?php if($photoerr) echo "<b>Error: The photo you attempted to upload was not a valid JPEG file.</b>"; ?>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
    <br />
    <span class="intro">Add your photo to your profile page:</span><br />
    <input type="file" name="photo" />
    <input type="submit" value="Upload your photo" />
    </form>
    </div>
    <div class="ontop" id="saveform">
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="hidden" id="top" name="top" value="-1" />
    <input type="hidden" id="left" name="left" value="-1" />
    <input type="hidden" id="width" name="width" value="-1" />
    <input type="hidden" id="height" name="height" value="-1" />
    <input type="submit" value="Click HERE to crop and save your photo" />
    </form>
    </div>
    <div id="fadebox1" class="fadebox"></div>
    <div id="fadebox2" class="fadebox"></div>
    <div id="fadebox3" class="fadebox"></div>
    <div id="fadebox4" class="fadebox"></div>
    <img src="<?php echo $_SERVER['PHP_SELF']; ?>?showimg=1" id="dragimg" />

    </body>
    </html>
    [/code]
    The offending page!
    http://mouse.nodstrum.com/form3.php
  11. APOLOGIES! this is a biggy!
    Well here goes again, I thought I’d got this one squared away but alas no. I found and modified the primary functions on this script which uploads and crops member photos for my site and it does these things well. But when it comes to saving the images in the file on my server it all goes pear shaped. Any help would be most welcome.

    Code: Setting Session variables in the main sign up page of my site Form1.php.
    [code]
    // Set the first name and family name in a session to pick them up after.
    $_SESSION['firstname'] = $s_firstname;
    $_SESSION['familyname'] = $s_familyname;
    [/code]
    Code: triggering the JavaScript pop up for the image uploader, including the session variables in the URL.
    [code]
    <?php
    $userNAME = trim($_SESSION['firstname'])."_".trim($_SESSION['familyname']);
    $userNAME = strtolower($userNAME);

    $cropHREF = "\"javascript:void(window.open('http://mouse.nodstrum.com/img_up/cropper.php?imageNAME=".$userNAME."', 'uploader', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=640,height=580'));\""
    ?>

    <B TITLE='header=[Photo Upload] body=[Choose a good clear head and shoulders photo of yourself preferably in your Disney days… The photos will be checked so nothing too outlandish please.]'><a href=<?php echo $cropHREF ;?><strong>Click here to upload your photo</strong></a> <font color="#3399FF"<i> (?)</i></b>
    <!-- IMG_UP test ends here -->
    The modified Cropper.php script.

    <?php
    // This script stores temporary image data in the user's session
    session_start();
    // print_r($_GET);
    // Names section added by MS 14-Jan-2007
    if (isset($_GET['imageNAME'])) {
    $_SESSION['imageName'] = $_GET['imageName'];
    }
    // print_r($_GET);

    // end of Names section added by MS 14-Jan-2007

    // The dimensions the uploaded image is resized to.
    // (The aspect ratio is maintained and no quality is lost during the final crop no matter how
    // small you set these values)
    $default_max_width = 640;
    $default_max_height = 480;

    // The size of the image the user will create:
    $cropped_width = 140;
    $cropped_height = 160;

    // A name for the session variable the script will use (must be unique for your domain)
    $unique_session_key = 'imgcropper';

    // A directory that the webserver can create files in, read from and delete files from
    // (the trailing slash is required)
    define('TEMP_DIR','temp/');

    // Before the user uploads their own image they get to play with this one:
    $default_image = 'default.jpg';

    // A semi transparent gif used to create the darkened effect around the edge of the page.
    $border_background = 'screen.gif';


    /* // After the user has chosen the area to crop, the cropped image is passed to the following
    // function that you must write your own code for:
    function storeImage($img_id)
    {
    // $img_id is a GD image reference, if you want the actual JPEG data pass it to imgdata (as below)
    $_SESSION['imgcropper']['cropped'] = imgdata($img_id);
    }
    */
    // NEW FROM HERE!
    // After the user has chosen the area to crop, the cropped
    // image is passed to the following function that you must
    // write your own code for:
    function storeImage($img_id)
    {
    // $img_id is a GD image reference, if you want the actual
    // JPEG data pass it to imgdata (as below)
    $fp = fopen('/images/mugs/'.$_SESSION['imageName'].'.jpg','wb');
    fwrite($fp, imgdata($img_id));
    fclose($fp);
    }

    // ...then the user is redirected to this page:
    $redirect_after_crop = 'done.php';

    // All of the code:
    include("cropper-include.php");

    ?>
    [/code]
  12. i recently found a great script that allows users on my site to upload and crop their member photo, i have modified the GREAT script which i found at http://da.vidnicholson.com/2006/10/php-image-uploader-and-manipulator.html
    BUT image manipulation in PHP is not really my area, so i have a question. Can i adapt this script to add a boarder to the finished image in a permanent way as i could with CSS in a temporary way?
    i.e. can i use PHP to do the same as this bit of CSS
    [code]
    .frame {
      float:left;
      border:solid 1px silver;
      padding:5px;
      margin-right:10px;
      }
    [/code]
    and here is the full JS / PHP /HTML file
    [code]
    <?php

    // handle requests for temporary low-res image:
    if(isset($_GET['showimg']))
    {
    header("Content-Type: image/jpeg");
    echo $_SESSION[$unique_session_key]['lowres'];
    die();
    }

    // handle photo uploads:
    $photoerr = false;
    if(isset($_FILES['photo']))
    {
    $img = imagecreatefromjpeg($_FILES['photo']['tmp_name']);
    if($img=="")
    {
    // bad image uploaded
    $photoerr = true;
    }
    else
    {
    $sizedata = getimagesize($_FILES['photo']['tmp_name']);
    // original dimensions:
    $orig_w = $sizedata[0];
    $orig_h = $sizedata[1];
    // low-res image dimensions:
    $full_w = min($default_max_width, $orig_w);
    $full_h = round(($full_w/$orig_w)*$orig_h);
    if($full_h > $default_max_height)
    {
    $full_h = $default_max_height;
    $full_w = round(($full_h/$orig_h)*$orig_w);
    }
    // create resized image:
    $full = imagecreatetruecolor($full_w, $full_h);
    imagecopyresized($full, $img, 0, 0, 0, 0, $full_w, $full_h, $orig_w, $orig_h);
    // store in Session:
    $_SESSION[$unique_session_key]['full'] = imgdata($img);
    $_SESSION[$unique_session_key]['lowres'] = imgdata($full);
    }
    }

    // handle crop requests:
    if(isset($_POST['top']) && isset($_POST['left']) && isset($_POST['width']) && isset($_POST['height']))
    {
    do { $tempfile = rand(1,10000); } while(file_exists(TEMP_DIR.$tempfile));
    $fp = fopen(TEMP_DIR.$tempfile, 'wb');
    fwrite($fp, $_SESSION[$unique_session_key]['full']);
    fclose($fp);
    $sizedata = getimagesize(TEMP_DIR.$tempfile);
    $orig_w = $sizedata[0];
    $orig_h = $sizedata[1];
    $img = imagecreatefromjpeg(TEMP_DIR.$tempfile);
    $full_w = intval($_POST['width']);
    $full_h = intval($_POST['height']);
    $full = imagecreatetruecolor($full_w, $full_h);
    imagecopyresized($full, $img, 0, 0, 0, 0, $full_w, $full_h, $orig_w, $orig_h);
    $final = imagecreatetruecolor($cropped_width, $cropped_height);
    imagecopy($final, $full, 0, 0, -1*(intval($_POST['left'])-250), -1*(intval($_POST['top'])-160), $cropped_width, $cropped_height);
    storeImage($final);
    unlink(TEMP_DIR.$tempfile);
    header("Location: $redirect_after_crop");
    }

    if(!isset($_SESSION[$unique_session_key]['full']))
    {
    $_SESSION[$unique_session_key]['full'] = file_get_contents($default_image);
    $_SESSION[$unique_session_key]['lowres'] = file_get_contents($default_image);
    }

    function imgdata($imgid)
    {
    do{ $filename = TEMP_DIR.rand(1,10000); } while(file_exists($filename));
    imagejpeg($imgid, $filename);
    $data = file_get_contents($filename);
    unlink($filename);
    return $data;
    }
    ?>
    <html>
    <head>
    <title>Photo Uploader</title>
    <style type="text/css">
    div.fadebox { background: transparent url(<?php echo $border_background; ?>) center repeat;
    position: absolute; z-index: 2; }
    div.ontop { background: #a0d9ff; position: absolute; z-index: 3; }

    div#fadebox1 { left: 0px; top: 0px; width: 250px; height: <?php echo $cropped_height+320; ?>px; }
    div#fadebox2 { left: 249px; top: 0px; width: <?php echo $cropped_width; ?>px; height: 160px; }
    div#fadebox3 { left: <?php echo $cropped_width+248; ?>px; top: 0px; width: 251px; height: <?php echo $cropped_height+320; ?>px; }
    div#fadebox4 { left: 249px; top: <?php echo $cropped_height+160; ?>px; width: <?php echo $cropped_width; ?>px; height: 160px; }

    div#udlr { left: 10px; top: 10px; text-align: center; background: transparent; }

    div#form { left: 0px; top: <?php echo $cropped_height+320; ?>px; height: 150px;
    width: <?php echo $cropped_width+500; ?>px; text-align: center; }

    div#saveform { left: <?php echo $cropped_width+50; ?>px; top: 430px; background: transparent; }

    img#dragimg { cursor: move; position: absolute; z-index: 1; top: 0px; left: 0px; }

    .intro { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
            </style>
    <script language="JavaScript">
    //<!--

    var dragging = false;
    var x,y,dx,dy;
    var theImg;
    var aspectRatio = -1;
    var top = 0;
    var left = 0;

    document.onmousemove = function(e)
    {
    if(aspectRatio==-1) init();
    if(dragging)
    {
    theE = e ? e : window.event;
    left = theE.clientX - dx;
    top = theE.clientY - dy;
    theImg.style.left = left + "px";
    theImg.style.top = top + "px";
    document.getElementById("top").value = top;
    document.getElementById("left").value = left;
    }
    return false;
    }
    //document.onmousemove = window.onmousemove;
    function mouseUp(e)
    {
    //alert("up");
    if(aspectRatio==-1) init();
    dragging = false;
    }
    function init()
    {
    theImg = document.getElementById("dragimg");
    document.getElementById("top").value = top;
    document.getElementById("left").value = left;
    document.getElementById("width").value = theImg.width;
    document.getElementById("height").value = theImg.height;
    aspectRatio = (theImg.height*1000) / theImg.width;
    theImg.onmousedown = function(e)
    {
    theE = e ? e : window.event;
    dragging = true;
    dx = theE.clientX - left;
    dy = theE.clientY - top;
    return false;
    }
    }
    function shrink()
    {
    if(aspectRatio==-1) init();
    theImg.width = theImg.width * 0.9;
    theImg.height = (theImg.width * aspectRatio) / 1000;
    document.getElementById("width").value = theImg.width;
    document.getElementById("height").value = theImg.height;
    }
    function grow()
    {
    if(aspectRatio==-1) init();
    theImg.width = theImg.width * 1.1;
    theImg.height = (theImg.width * aspectRatio) / 1000;
    document.getElementById("width").value = theImg.width;
    document.getElementById("height").value = theImg.height;
    }
    function up()
    {
    if(aspectRatio==-1) init();
    top -= 10; theImg.style.top = top+"px";
    document.getElementById("top").value = top;
    }
    function down()
    {
    if(aspectRatio==-1) init();
    top += 10; theImg.style.top = top+"px";
    document.getElementById("top").value = top;
    }
    function mleft()
    {
    if(aspectRatio==-1) init();
    left -= 10; theImg.style.left = left+"px";
    document.getElementById("left").value = left;
    }
    function right()
    {
    if(aspectRatio==-1) init();
    left += 10; theImg.style.left = left+"px";
    document.getElementById("left").value = left;
    }
    //-->
    </script>
    </head>
    <body bgcolor="#000" onmouseup="mouseUp()">
    <div class="ontop" id="udlr">
    <a href="javascript:up();"><img src="header_up.jpg" alt="Up" border="0" /></a><br />
    <a href="javascript:mleft();"><img src="header_left.jpg" alt="Left" border="0" /></a>
    <a href="javascript:right();"><img src="header_right.jpg" alt="Right" border="0" /></a><br />
    <a href="javascript:down();"><img src="header_down.jpg" alt="Down" border="0" /></a><br />
    <a href="javascript:shrink();"><img src="header_shrink.jpg" alt="Shrink" border="0" /></a>
    <a href="javascript:grow();"><img src="header_grow.jpg" alt="Grow" border="0" /></a>
    </div>
    <div class="ontop" id="form">
    <?php if($photoerr) echo "<b>Error: The photo you attempted to upload was not a valid JPEG file.</b>"; ?>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
    <br />
    <span class="intro">Add your photo to your profile page:</span><br />
                    <input type="file" name="photo" />
                  <input type="submit" value="Upload your photo" />
    </form>
    </div>
    <div class="ontop" id="saveform">
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="hidden" id="top" name="top" value="-1" />
    <input type="hidden" id="left" name="left" value="-1" />
    <input type="hidden" id="width" name="width" value="-1" />
    <input type="hidden" id="height" name="height" value="-1" />
    <input type="submit" value="Click HERE to crop and save your photo" />
    </form>
    </div>
    <div id="fadebox1" class="fadebox"></div>
    <div id="fadebox2" class="fadebox"></div>
    <div id="fadebox3" class="fadebox"></div>
    <div id="fadebox4" class="fadebox"></div>
    <img src="<?php echo $_SERVER['PHP_SELF']; ?>?showimg=1" id="dragimg" />

    </body>
    </html>

    [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.