Changeset 10 for trunk/upload.php


Ignore:
Timestamp:
May 17, 2003, 12:49:14 PM (22 years ago)
Author:
z0rglub
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upload.php

    r2 r10  
    11<?php
    22/***************************************************************************
    3  *             upload.php is a part of PhpWebGallery                       *
     3 *                                 upload.php                              *
    44 *                            -------------------                          *
    5  *   last update          : Sunday, October 27, 2002                       *
    6  *   email                : pierrick@z0rglub.com                           *
     5 *   application          : PhpWebGallery 1.3                              *
     6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
    77 *                                                                         *
    88 ***************************************************************************/
     
    1515 *                                                                         *
    1616 ***************************************************************************/
    17 function get_extension( $filename )
    18 {
    19   return substr ( strrchr( $filename, "." ), 1, strlen ( $filename ) );
    20 }
     17
     18//------------------------------------------------------------------- functions
     19
    2120// The validate_upload function checks if the image of the given path is valid.
    2221// A picture is valid when :
     
    3837  //echo $_FILES['picture']['name']."<br />".$temp_name;
    3938  $extension = get_extension( $_FILES['picture']['name'] );
    40   if ( $extension != 'gif' && $extension != 'jpg' && $extension != 'png' )
     39  if ( $extension != 'gif' and $extension != 'jpg' and $extension != 'png' )
    4140  {
    4241    $result['error'][$i++] = $lang['upload_advise_filetype'];
     
    5049  else if ( $_FILES['picture']['size'] > $my_max_file_size * 1024 )
    5150  {
    52     $result['error'][$i++] = $lang['upload_advise_width'].$my_max_file_size." KB";
     51    $result['error'][$i++] =
     52      $lang['upload_advise_width'].$my_max_file_size.' KB';
    5353  }
    5454  else
     
    6464      $size = getimagesize( $temp_name );
    6565      if ( isset( $image_max_width )
    66            && $image_max_width != ""
    67            && $size[0] > $image_max_width )
     66           and $image_max_width != ""
     67           and $size[0] > $image_max_width )
    6868      {
    69         $result['error'][$i++] = $lang['upload_advise_width'].$image_max_width." px";
     69        $result['error'][$i++] =
     70          $lang['upload_advise_width'].$image_max_width." px";
    7071      }
    7172      if ( isset( $image_max_height )
    72            && $image_max_height != ""
    73            && $size[1] > $image_max_height )
     73           and $image_max_height != ""
     74           and $size[1] > $image_max_height )
    7475      {
    75         $result['error'][$i++] = $lang['upload_advise_height'].$image_max_height." px";
     76        $result['error'][$i++] =
     77          $lang['upload_advise_height'].$image_max_height." px";
    7678      }
    7779      // $size[2] == 1 means GIF
    7880      // $size[2] == 2 means JPG
    7981      // $size[2] == 3 means PNG
    80       if ( $size[2] != 1 && $size[2] != 2 && $size[2] != 3 )
     82      if ( $size[2] != 1 and $size[2] != 2 and $size[2] != 3 )
    8183      {
    8284        $result['error'][$i++] = $lang['upload_advise_filetype'];
     
    8789        {
    8890        case 1 :
    89         {
    90           $result['type'] = 'gif';
    91           break;
    92         }
     91          $result['type'] = 'gif'; break;
    9392        case 2 :
    94         {
    95           $result['type'] = 'jpg';
    96           break;
    97         }
     93          $result['type'] = 'jpg'; break;
    9894        case 3 :
    99         {
    100           $result['type'] = 'png';
    101           break;
    102         }
     95          $result['type'] = 'png'; break;
    10396        }
    10497      }
     
    117110check_login_authorization();
    118111check_cat_id( $_GET['cat'] );
    119 if ( isset( $page['cat'] ) && is_numeric( $page['cat'] ) )
     112if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
    120113{
    121114  check_restrictions( $page['cat'] );
     
    130123}
    131124if ( $access_forbidden == true
    132      || $page['cat_site_id'] != 1
    133      || $conf['upload_available'] == 'false' )
    134 {
    135   echo"<div style=\"text-align:center;\">".$lang['upload_forbidden']."<br />";
    136   echo "<a href=\"".add_session_id_to_url( "./diapo.php" )."\">".$lang['thumbnails']."</a></div>";
     125     or $page['cat_site_id'] != 1
     126     or $conf['upload_available'] == 'false' )
     127{
     128  echo '<div style="text-align:center;">'.$lang['upload_forbidden'].'<br />';
     129  echo '<a href="'.add_session_id_to_url( './diapo.php' ).'">';
     130  echo $lang['thumbnails'].'</a></div>';
    137131  exit();
    138132}
    139133//----------------------------------------------------- template initialization
    140134$vtp = new VTemplate;
    141 $handle = $vtp->Open( './template/default/upload.vtp' );
    142 // language
    143 $vtp->setGlobalVar( $handle, 'upload_page_title',$lang['upload_title'] );
    144 $vtp->setGlobalVar( $handle, 'upload_title',     $lang['upload_title'] );
    145 $vtp->setGlobalVar( $handle, 'upload_username',  $lang['upload_username'] );
    146 $vtp->setGlobalVar( $handle, 'reg_mail_address', $lang['reg_mail_address'] );
    147 $vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
    148 $vtp->setGlobalVar( $handle, 'upload_successful',$lang['upload_successful'] );
    149 $vtp->setGlobalVar( $handle, 'search_return_main_page',
    150                     $lang['search_return_main_page'] );
     135$handle = $vtp->Open( './template/'.$user['template'].'/upload.vtp' );
     136initialize_template();
     137
     138$tpl = array( 'upload_title', 'upload_username', 'mail_address', 'submit',
     139              'upload_successful', 'search_return_main_page' );
     140templatize_array( $tpl, 'lang', $sub );
    151141// user
    152 $vtp->setGlobalVar( $handle, 'page_style',       $user['style'] );
    153 $vtp->setGlobalVar( $handle, 'user_login',       $user['pseudo'] );
     142$vtp->setGlobalVar( $handle, 'style',            $user['style'] );
     143$vtp->setGlobalVar( $handle, 'user_login',       $user['username'] );
    154144$vtp->setGlobalVar( $handle, 'user_mail_address',$user['mail_address'] );
    155 // structure
    156 $vtp->setGlobalVar( $handle, 'frame_start',      get_frame_start() );
    157 $vtp->setGlobalVar( $handle, 'frame_begin',      get_frame_begin() );
    158 $vtp->setGlobalVar( $handle, 'frame_end',        get_frame_end() );
    159145
    160146$error = array();
     
    167153//-------------------------------------------------------------- picture upload
    168154// vérification de la présence et de la validité des champs.
    169 if ( isset( $_POST['submit'] ) && !isset( $_GET['waiting_id'] ) )
     155if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
    170156{
    171157  $path = $page['cat_dir'].$_FILES['picture']['name'];
     
    203189  if ( sizeof( $error ) == 0 )
    204190  {
    205     $query = 'insert into '.$prefixeTable.'waiting';
     191    $query = 'insert into '.PREFIX_TABLE.'waiting';
    206192    $query.= ' (cat_id,file,username,mail_address,date) values';
    207193    $query.= " (".$page['cat'].",'".$_FILES['picture']['name']."'";
     
    214200}
    215201//------------------------------------------------------------ thumbnail upload
    216 if ( isset( $_POST['submit'] ) && isset( $_GET['waiting_id'] ) )
     202if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) )
    217203{
    218204  // upload of the thumbnail
    219205  $query = 'select file';
    220   $query.= ' from '.$prefixeTable.'waiting';
     206  $query.= ' from '.PREFIX_TABLE.'waiting';
    221207  $query.= ' where id = '.$_GET['waiting_id'];
    222208  $query.= ';';
     
    237223  if ( sizeof( $error ) == 0 )
    238224  {
    239     $query = 'update '.$prefixeTable.'waiting';
     225    $query = 'update '.PREFIX_TABLE.'waiting';
    240226    $query.= " set tn_ext = '".$extension."'";
    241227    $query.= ' where id = '.$_GET['waiting_id'];
Note: See TracChangeset for help on using the changeset viewer.