Changeset 862 in ExiteCMS


Ignore:
Timestamp:
10/02/07 22:27:18 (4 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

Location:
modules/common
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • modules/common/download_statistics_panel/php-files/modules/download_statistics_panel/dls_process.php

    r836 r862  
    157157    } 
    158158} 
     159// set the ds_onmap marker 
     160$result = dbquery("UPDATE ".$db_prefix."dls_statistics SET ds_onmap = '1' WHERE ds_processed = '0' AND ds_file LIKE '%software.ver'"); 
     161 
    159162// mark all newly imported statistics records as processed 
    160163$result = dbquery("UPDATE ".$db_prefix."dls_statistics SET ds_processed = '1' WHERE ds_processed = '0'"); 
  • modules/common/download_statistics_panel/php-files/modules/download_statistics_panel/download_statistics_panel.php

    r844 r862  
    3535// first panel: statistics overview 
    3636 
    37 $data = dbarray(dbquery("SELECT MIN(ds_timestamp) AS timestamp FROM ".$db_prefix."dls_statistics")); 
    38 if (!is_array($data)) $data = array("timestamp" => time()); 
    39 $variables['date_first'] = $data['timestamp']; 
    40  
    41 $data = dbarray(dbquery("SELECT MAX(ds_timestamp) AS timestamp FROM ".$db_prefix."dls_statistics")); 
    42 if (!is_array($data)) $data = array("timestamp" => time()); 
    43 $variables['date_last'] = $data['timestamp']; 
    44  
    45 $data = dbarray(dbquery("SELECT COUNT(*) AS count FROM ".$db_prefix."dls_statistics")); 
    46 if (!is_array($data)) $data = array("count" => 0); 
    47 $variables['stats_count'] = $data['count']; 
    48  
    49 $data = dbarray(dbquery("SELECT COUNT(DISTINCT ds_url) AS count FROM ".$db_prefix."dls_statistics")); 
    50 if (!is_array($data)) $data = array("count" => 0); 
    51 $variables['stats_files'] = $data['count']; 
     37if (isset($_POST['date_first'])) { 
     38    $variables['date_first'] = $_POST['date_first']; 
     39} else { 
     40    $data = dbarray(dbquery("SELECT MIN(ds_timestamp) AS timestamp FROM ".$db_prefix."dls_statistics")); 
     41    if (!is_array($data)) $data = array("timestamp" => time()); 
     42    $variables['date_first'] = $data['timestamp']; 
     43} 
     44 
     45if (isset($_POST['date_last'])) { 
     46    $variables['date_last'] = $_POST['date_last']; 
     47} else { 
     48    $data = dbarray(dbquery("SELECT MAX(ds_timestamp) AS timestamp FROM ".$db_prefix."dls_statistics")); 
     49    if (!is_array($data)) $data = array("timestamp" => time()); 
     50    $variables['date_last'] = $data['timestamp']; 
     51} 
     52 
     53if (isset($_POST['stats_count'])) { 
     54    $variables['stats_count'] = $_POST['stats_count']; 
     55} else { 
     56    $data = dbarray(dbquery("SELECT COUNT(*) AS count FROM ".$db_prefix."dls_statistics")); 
     57    if (!is_array($data)) $data = array("count" => 0); 
     58    $variables['stats_count'] = $data['count']; 
     59} 
     60 
     61if (isset($_POST['stats_files'])) { 
     62    $variables['stats_files'] = $_POST['stats_files']; 
     63} else { 
     64    $result = dbquery("SELECT COUNT(ds_url) AS count FROM ".$db_prefix."dls_statistics GROUP BY ds_url"); 
     65    $variables['stats_files'] = dbrows($result); 
     66} 
    5267 
    5368// second panels: statistics per download mirror 
  • modules/common/download_statistics_panel/php-files/modules/download_statistics_panel/geomapping.php

    r836 r862  
    301301 
    302302    // consolidate the IP statistics per country 
    303     $result = dbquery("SELECT DISTINCT ds_ip, ds_cc FROM ".$db_prefix."dls_statistics WHERE ds_file LIKE '%software.ver'"); 
     303    $result = dbquery("SELECT DISTINCT ds_ip, ds_cc FROM ".$db_prefix."dls_statistics WHERE ds_onmap = '1'"); 
    304304    // and add them to the country table 
    305305    while ($data = dbarray($result)) { 
  • modules/common/download_statistics_panel/php-files/modules/download_statistics_panel/templates/modules.download_statistics_panel.tpl

    r844 r862  
    5858{include file="_opentable.tpl" name=$_name title=$locale.dls120 state=$_state style=$_style} 
    5959<form name='selectionforum' method='post' action='{$smarty.const.FUSION_SELF}'> 
     60    <input type='hidden' name='date_first' value='{$date_first}' /> 
     61    <input type='hidden' name='date_last' value='{$date_last}' /> 
     62    <input type='hidden' name='stats_count' value='{$stats_counts}' /> 
     63    <input type='hidden' name='stats_files' value='{$stats_files}' /> 
    6064    <table align='center' cellpadding='0' cellspacing='0' width='500'> 
    6165        <tr> 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/forum_threads_list_panel.php

    r844 r862  
    2020// get the list of latest threads 
    2121$result = dbquery( 
    22     "SELECT tf.*, tt.*, tu.user_id,user_name, MAX(tp.post_id) as last_id, COUNT(tp.post_id) as count_posts FROM ".$db_prefix."forums tf 
     22    "SELECT tf.*, tt.*, tu.user_id,user_name FROM ".$db_prefix."forums tf 
    2323    INNER JOIN ".$db_prefix."threads tt USING(forum_id) 
    2424    INNER JOIN ".$db_prefix."posts tp USING(thread_id) 
     
    3838    while ($data = dbarray($result)) { 
    3939        $data['poll'] = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']); 
    40         $data['count_posts']--; 
     40        $data2 = dbarray(dbquery("SELECT MAX(post_id) AS last_id FROM ".$db_prefix."posts WHERE thread_id = '".$data['thread_id']."'")); 
     41        $data['last_id'] = $data2['last_id']; 
     42        $data['count_posts'] = dbcount("(*)", "posts", "thread_id = '".$data['thread_id']."'") - 1; 
    4143        $threadlist[] = $data; 
    4244    } 
  • modules/common/mail2forum/php-files/modules/mail2forum/m2f_config.php

    r836 r862  
    2929// default: 1 
    3030define('M2F_MAX_ATTACHMENTS', 1); 
     31 
     32// Maximum size of an attachments. Attachments bigger that the size defined here will never be send out via 
     33// email, only a link will be included 
     34// 
     35// default: 5242880 
     36define('M2F_MAX_ATTACH_SIZE', 5242880); 
    3137 
    3238// With this switch you control the from address of outgoing email. The default behaviour is to use the email 
  • modules/common/mail2forum/php-files/modules/mail2forum/m2f_smtp.php

    r844 r862  
    388388                                                break; 
    389389                                            case 1: 
    390                                                 // attach the attachments to the email 
    391                                                 $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
    392                                                 break; 
     390                                                // check the size of the attachments, don't send it out if it's to big 
     391                                                if (filesize(PATH_ATTACHMENTS.$attachment['attach_name']) < M2F_MAX_ATTACH_SIZE) { 
     392                                                    // attach the attachments to the email 
     393                                                    $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
     394                                                    break; 
     395                                                } 
    393396                                            case 2: 
    394397                                                // add a link pointing to the attachment 
     
    405408                                            break; 
    406409                                        case 1: 
    407                                             // attach the attachments to the email 
    408                                             $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
    409                                             break; 
     410                                            // check the size of the attachments, don't send it out if it's to big 
     411                                            if (filesize(PATH_ATTACHMENTS.$attachment['attach_name']) < M2F_MAX_ATTACH_SIZE) { 
     412                                                // attach the attachments to the email 
     413                                                $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
     414                                                break; 
     415                                            } 
    410416                                        case 2: 
    411417                                            // add a link pointing to the attachment 
  • modules/common/wiki/php-files/modules/wiki/3rdparty/plugins/wikiedit/wikiedit2.js

    r806 r862  
    108108 this.addButton("textred","Marked text","'\\'\\'','\\'\\'',2"); 
    109109 this.addButton("createlink","Hyperlink","","document.getElementById('" + this.id + "')._owner.createLink"); 
     110 this.addButton("createimage","Image","","document.getElementById('" + this.id + "')._owner.createImage"); 
    110111// this.addButton("createtable","Insert Table","'','\\n#|\\n|| | ||\\n|| | ||\\n|#\\n',2"); 
    111112 this.addButton(" "); 
     
    642643} 
    643644 
     645WikiEdit.prototype.createImage = function (isAlt) 
     646{ 
     647  var t = this.area; 
     648  t.focus(); 
     649 
     650  this.getDefines(); 
     651 
     652  var n = new RegExp("\n"); 
     653  if (!n.test(this.sel)) { 
     654    if (!isAlt) { 
     655     lnk = prompt("Image:", this.sel); 
     656     if (lnk!=null) this.sel = lnk; 
     657    }; 
     658    str = this.sel1+"{{image class=\"center\" alt=\"description here\" title=\"title here\" url=\"/images/wiki/"+this.trim(this.sel)+"\"}}"+this.sel2; 
     659    t.value = str; 
     660    t.setSelectionRange(this.sel1.length, str.length-this.sel2.length); 
     661    return true; 
     662  } 
     663  return false; 
     664} 
     665 
    644666WikiEdit.prototype.help = function () 
    645667{ 
  • modules/common/wiki/php-files/modules/wiki/actions/footer.php

    r808 r862  
    55<?php  
    66    echo $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Click to edit this page\">Edit page</a> |\n" : ""; 
     7    echo "<a href=\"".$this->href("upload")."\" title=\"Click to upload new images\">Upload Image</a> |\n"; 
    78    echo "<a href=\"".$this->href("history")."\" title=\"Click to view recent edits to this page\">Page History</a> |\n"; 
    8     echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Click to view recent revisions list for this page\">".$this->GetPageTime()."</a> |\n" : ""; 
     9    echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Click to view recent revisions list for this page\">Revisions</a> |\n" : ""; 
     10//  echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"Click to view recent revisions list for this page\">".$this->GetPageTime()."</a> |\n" : ""; 
    911    echo ($this->GetUser() ? "<a href='".$this->href("referrers")."' title='Click to view a list of URLs referring to this page.'>Referrers</a> |\n" : ""); 
    1012    // if this page exists 
    1113    if ($this->page) 
    1214    { 
    13         if ($owner = $this->GetPageOwner()) 
    14         { 
    15             if ($owner == "(Public)") 
    16             { 
    17                 print("Public page ".($this->IsAdmin() ? "<a href=\"".$this->href("acls")."\">(Edit ACLs)</a>\n" : "\n")); 
    18             } 
    19             // if owner is current user 
    20             elseif ($this->UserIsOwner()) 
    21             { 
    22                     if ($this->IsAdmin()) 
    23                     { 
    24                     print("Owner: ".$this->Link($owner, "", "", 0)." | <a href=\"".$this->href("acls")."\">Edit ACLs</a>\n"); 
    25                     }  
    26                     else  
    27                     { 
    28                     print("You own this page | <a href=\"".$this->href("acls")."\">Edit ACLs</a>\n"); 
    29                 } 
    30             } 
    31             else 
    32             { 
    33                 print("Owner: ".$this->Link($owner, "", "", 0)."\n"); 
    34             } 
     15        switch ($owner = $this->GetPageOwner()) { 
     16            case "(Public)": 
     17                print("Public page\n"); 
     18                break; 
     19            case $this->UserIsOwner(): 
     20                print("You own this page\n"); 
     21                break; 
     22            case false; 
     23                print("Nobody".($this->GetUser() ? " (<a href=\"".$this->href("claim")."\">Take Ownership</a>)\n" : "\n")); 
     24            default: 
     25                print("Owner: <a href='".BASEDIR."profile.php?lookup=$owner'>".$owner."</a>\n"); 
    3526        } 
    36         else 
    37         { 
    38             print("Nobody".($this->GetUser() ? " (<a href=\"".$this->href("claim")."\">Take Ownership</a>)\n" : "\n")); 
    39         } 
     27        if ($this->IsAdmin()) { 
     28            print("| <a href=\"".$this->href("acls")."\">Edit ACLs</a>\n"); 
     29        }    
    4030    } 
    4131 
  • 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} 
  • modules/common/wiki/php-files/modules/wiki/module_installer.php

    r840 r862  
    179179 
    180180// add a user group for this module 
    181 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_name, group_description, group_forumname, group_visible) VALUES ('$mod_admin_rights', 'Wiki Admins', 'Wiki Admins', 'Wiki Admin', '1')"); 
    182 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_description, group_forumname, group_visible) VALUES ('$mod_admin_rights', 'Wiki Editors', 'Wiki Editors', 'Wiki Editor', '1')"); 
     181$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_name, group_description, group_forumname, group_visible) VALUES ('".$mod_admin_rights."01', 'Wiki Admins', 'Wiki Admins', 'Wiki Admin', '1')"); 
     182$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_description, group_forumname, group_visible) VALUES ('".$mod_admin_rights."02', 'Wiki Editors', 'Wiki Editors', 'Wiki Editor', '1')"); 
    183183 
    184184$mod_install_cmds[] = array('type' => 'function', 'value' => "install_wiki"); 
     
    200200 
    201201// delete the user groups 
    202 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_name = 'Wiki Admins'"); 
    203 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_name = 'Wiki Editors'"); 
     202$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 
     203$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 
    204204 
    205205$mod_install_cmds[] = array('type' => 'function', 'value' => "uninstall_wiki"); 
     
    211211    function install_wiki() { 
    212212         
    213         global $db_prefix; 
     213        global $db_prefix, $mod_admin_rights; 
    214214 
    215215        // get the group_id of the Wiki Admins group 
    216         $admins = dbarray(dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_name = 'Wiki Admins'")); 
     216        $admins = dbarray(dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."01'")); 
    217217         
    218218        // add all webmasters to the wiki user table 
Note: See TracChangeset for help on using the changeset viewer.