Ignore:
Timestamp:
10/02/07 22:27:18 (5 years ago)
Author:
hverton
Message:

Added an image upload function to the Wiki module
Optimized the speed of the download panels
Fixed a crash due to "attachment to big" in M2F

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/common/wiki/php-files/modules/wiki/index.php

    r836 r862  
    88require_once dirname(__FILE__)."/../../includes/core_functions.php"; 
    99require_once PATH_ROOT."/includes/theme_functions.php"; 
    10  
    11 /*---------------------------------------------------+ 
    12 | Image uploads - handling and preparation           | 
    13 +----------------------------------------------------*/ 
    14 $variables[] = array(); 
    15  
    16 // load the locale for this module 
    17 include PATH_LOCALE.LOCALESET."admin/image_uploads.php"; 
    18  
    19 $variables['image_cats'][] = array('folder' => "wiki", 'name' => 'Wiki', 'path' => PATH_IMAGES."wiki/", 'selected' => true); 
    20 $ufolder = IMAGES."wiki/"; 
    21 $afolder = PATH_IMAGES."wiki/"; 
    22  
    23 if (isset($status)) { 
    24     if ($status == "upn") { 
    25         $title = $locale['420']; 
    26         $variables['message'] = $locale['425']; 
    27     } elseif ($status == "upy") { 
    28         $title = $locale['420']; 
    29         $variables['message'] = "<img src='".$ufolder.$img."' alt='$img' /><br /><br />".$locale['426']; 
    30     } 
    31     // define the message panel variables 
    32     $variables['bold'] = true; 
    33     $template_panels[] = array('type' => 'body', 'name' => 'wiki.upload.status', 'title' => $title, 'template' => '_message_table_panel.tpl'); 
    34     $template_variables['wiki.upload.status'] = $variables; 
    35     $variables = array(); 
    36 } 
    37  
    38 // if a file is uploaded, process it 
    39 if (isset($_POST['uploadimage'])) { 
    40     $error = ""; 
    41     $image_types = array( 
    42         ".gif", 
    43         ".GIF", 
    44         ".jpeg", 
    45         ".JPEG", 
    46         ".jpg", 
    47         ".JPG", 
    48         ".png", 
    49         ".PNG" 
    50     ); 
    51     $imgext = strrchr($_FILES['myfile']['name'], "."); 
    52     $imgname = $_FILES['myfile']['name']; 
    53     $imgsize = $_FILES['myfile']['size']; 
    54     $imgtemp = $_FILES['myfile']['tmp_name']; 
    55     if (!in_array($imgext, $image_types)) { 
    56         redirect(FUSION_REQUEST); 
    57     } elseif (is_uploaded_file($imgtemp)){ 
    58         include PATH_INCLUDES."photo_functions_include.php"; 
    59         $imgname = image_exists($afolder, substr("000000".$userdata['user_id'],-6).'_'.$imgname); 
    60         move_uploaded_file($imgtemp, $afolder.$imgname); 
    61         chmod($afolder.$imgname,0644); 
    62         redirect(FUSION_REQUEST); 
    63     } 
    64 } 
    65  
    66 /*---------------------------------------------------+ 
    67 | Locale definition for this installation module     | 
    68 +----------------------------------------------------*/ 
    69  
    70 if (file_exists(PATH_MODULES."wiki/locale/".$settings['locale'].".php")) { 
    71     include PATH_MODULES."wiki/locale/".$settings['locale'].".php"; 
    72 } else { 
    73     include PATH_MODULES."wiki/locale/English.php"; 
    74 } 
    7510 
    7611/** 
     
    437372    $template_panels[] = array('type' => 'body', 'title' => $wakkaConfig['wakka_name'], 'name' => 'wiki', 'template' => '_custom_html.tpl'); 
    438373    $template_variables['wiki'] = $variables; 
    439  
    440     // in edit mode? Allow image uploads 
    441     if (iMEMBER && $method == "edit") { 
    442         $variables['ifolder'] = $ifolder; 
    443         $variables['view'] = isset($view) ? $view : ""; 
    444  
    445         if (isset($view)) { 
    446             $image_ext = strrchr($afolder.$view,"."); 
    447             if (in_array($image_ext, array(".gif",".GIF",".jpg",".JPG",".jpeg",".JPEG",".png",".PNG"))) { 
    448                 $variables['view_image'] = $ufolder.$view; 
    449             } else { 
    450                 $variables['view_image'] = ""; 
    451             } 
    452         } else { 
    453             $variables['image_list'] = makefilelist($afolder, ".|..|imagelist.js|index.php", true); 
    454         } 
    455         $template_panels[] = array('type' => 'body', 'name' => 'modules.wiki.upload', 'template' => 'modules.wiki.upload.tpl', 'locale' => PATH_LOCALE.LOCALESET."admin/image_uploads.php"); 
    456         $template_variables['modules.wiki.upload'] = $variables; 
    457     } 
    458      
     374         
    459375    require_once PATH_THEME."/theme.php"; 
    460376} 
Note: See TracChangeset for help on using the changeset viewer.