1<?php 2/** 3 * Coppermine Photo Gallery 4 * 5 * v1.0 originally written by Gregory Demar 6 * 7 * @copyright Copyright (c) 2003-2020 Coppermine Dev Team 8 * @license GNU General Public License version 3 or later; see LICENSE 9 * 10 * plugins/upload_h5a/codebase.php 11 * @since 1.6.09 12 */ 13 14if (!defined('IN_COPPERMINE')) die('Not in Coppermine...'); 15 16require_once './plugins/upload_h5a/initialize.inc.php'; 17 18// Add a filter for the upload options 19$thisplugin->add_filter('upload_options','uploadh5a_add_upload_option'); 20// Add actions for processing uploads 21$thisplugin->add_action('upload_form','uploadh5a_display_upload_form'); 22 23function uploadh5a_add_upload_option($upload_choices) 24{ 25 global $lang_plugin_upload_h5a; 26 27 $more_upload_choices = array('upload_h5a' => $lang_plugin_upload_h5a['html5_method']); 28 return array_merge($upload_choices, $more_upload_choices); 29} 30 31function uploadh5a_display_upload_form($upload_settings) 32{ 33 global $CONFIG, $USER_DATA, $lang_common, $lang_upload_php, $lang_plugin_upload, $lang_plugin_upload_h5a, $icon_array, $h5a_upload, $lang_bbcode_help_title, $lang_bbcode_help; 34 35 list($upload_form, $upload_select) = $upload_settings; 36 if ($upload_form != 'upload_h5a') { 37 return $upload_settings; 38 } 39 $plugpath = 'plugins/upload_h5a'; 40 41 $grpn = USER_ID > 0 ? (int) $USER_DATA['group_id'] : 0; 42 $grpc = $grpn ? $grpn : ''; 43 $cfg = isset($CONFIG['upload_h5a'.$grpc]) ? unserialize($CONFIG['upload_h5a'.$grpc]) : unserialize($CONFIG['upload_h5a']); 44 45 $maxfilesizebytes = $cfg['upldsize'] ? max($cfg['upldsize'], $h5a_upload->sys_max_upl_size) : $h5a_upload->sys_max_upl_size; 46 $maxfilesize = sprintf($lang_upload_php['max_fsize'], $h5a_upload->to_KMG($maxfilesizebytes)); 47 48 list($timestamp, $form_token) = getFormToken(time()+14400); //allow up to 4 hours for upload to complete 49 set_js_var('timestamp', $timestamp-14400); //subtract those 4 hours so edits happen correctly 50 set_js_var('concurrent', $cfg['concurrent']); 51 set_js_var('autoedit', $cfg['autoedit']); 52 set_js_var('user_id', USER_ID); 53 set_js_var('guest_edit', $CONFIG['allow_guests_enter_file_details']); 54 55 set_js_var('H5uPath', "{$plugpath}/"); 56 set_js_var('maxfilesize', $maxfilesizebytes); 57 set_js_var('maxchunksize', $h5a_upload->sys_max_chnk_size); 58 set_js_var('fup_payload', array('method'=>'upload_h5a','form_token'=>$form_token,'timestamp'=>$timestamp)); 59 set_js_var('h5uM', array( 60 'selAlb'=>$lang_plugin_upload['albmSelMsg'], 61 'aborted'=>$lang_plugin_upload_h5a['aborted'], 62 'type_err'=>$lang_plugin_upload_h5a['type_err'], 63 'size_err'=>$lang_plugin_upload['size_err'], 64 'extallow'=>$lang_plugin_upload_h5a['extallow'], 65 'q_stop'=>$lang_plugin_upload_h5a['q_stop'], 66 'q_go'=>$lang_plugin_upload_h5a['q_resume'], 67 'q_can'=>$lang_plugin_upload_h5a['q_cancel'] 68 )); 69 70 $allowed_types = array_merge( 71 explode('/', $CONFIG['allowed_img_types']), 72 explode('/', $CONFIG['allowed_mov_types']), 73 explode('/', $CONFIG['allowed_snd_types']), 74 explode('/', $CONFIG['allowed_doc_types']) 75 ); 76 set_js_var('allowed_file_types', $allowed_types); 77 78 // include the javascript upload engine (minified unless in debug mode) 79 $jsv = ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) ? '' : '.min'; 80 js_include('plugins/upload_h5a/js/upload'.$jsv.'.js'); 81 82 // add our style sheet 83 $h5up_meta = '<link rel="stylesheet" href="plugins/upload_h5a/css/upload.css" type="text/css" />'; 84 85 pageheader($lang_plugin_upload_h5a['title'], $h5up_meta); 86 87 $upload_help = $h5a_upload->help_button('use'); 88 $upload_table_header = <<<EOT 89 <table border="0" cellspacing="0" cellpadding="0" width="100%"> 90 <tr> 91 <td> 92 {$icon_array['upload']}{$lang_plugin_upload_h5a['upldfiles']}{$upload_help} 93 </td> 94 <td style="text-align:right"> 95 <span id="upload_method_selector">{$upload_select}</span> 96 </td> 97 </tr> 98 </table> 99EOT; 100 101 starttable('100%', $upload_table_header, 2); 102 echo '<tr><td colspan="2" class="tableb tableb_alternate"><strong>' . $maxfilesize . '</strong></td></tr>'; 103 form_alb_list_box($lang_common['album'], 'h5u_album'); 104 echo <<<EOT 105 <tr id="navailrow" style="text-align:center;background-color:yellow;display:none"> 106 <td colspan="2">{$lang_plugin_upload_h5a['notavail']}</td> 107 </tr> 108 <tr class="H5upV"> 109 <td class="tableb" width="30%">{$lang_plugin_upload_h5a['flistitl']}</td> 110 <td class="tableb"><input type="checkbox" id="flistitl" onchange="shide_titlrow(this);" /></td> 111 </tr> 112EOT; 113 114 if (USER_ID > 0 || $CONFIG['allow_guests_enter_file_details'] == 1) { 115 if ($cfg['enabtitl']) { 116 echo '<tr id="titlrow"><td class="tableb">'.$lang_upload_php['pic_title'].'</td><td class="tableb"><input type="text" name="title" id="title" class="textinput" maxlength="255" /></td></tr>'; 117 } 118 if ($cfg['enabdesc']) { 119 $desclabl = $lang_upload_php['description']; 120 if ($CONFIG['show_bbcode_help']) { 121 $desclabl .= ' '. cpg_display_help('f=empty.htm&h=lang_bbcode_help_title&t=lang_bbcode_help',470,245); 122 } 123 echo '<tr><td class="tableb">'.$desclabl.'</td><td class="tableb"><textarea name="caption" rows="2" id="caption" class="textinput" /></textarea></td></tr>'; 124 } 125 if ($cfg['enabkeys']) { 126 $keywordLabel = sprintf($lang_common['keywords_insert1'],$lang_common['keyword_separators'][$CONFIG['keyword_separator']]) 127 . '<br /><a href="keyword_select.php" class="greybox">' . $lang_common['keywords_insert2'] .'</a>'; 128 echo '<tr><td class="tableb">'.$keywordLabel.'</td><td class="tableb"><input type="text" name="keywords" id="keywords" class="textinput" maxlength="255" /></td></tr>'; 129 } 130 if ($cfg['enabusr1'] && !empty($CONFIG['user_field1_name'])) { 131 echo '<tr><td class="tableb">'.$CONFIG['user_field1_name'].'</td><td class="tableb"><input type="text" name="user1" id="user1" class="textinput" maxlength="255" /></td></tr>'; 132 } 133 if ($cfg['enabusr2'] && !empty($CONFIG['user_field2_name'])) { 134 echo '<tr><td class="tableb">'.$CONFIG['user_field2_name'].'</td><td class="tableb"><input type="text" name="user2" id="user2" class="textinput" maxlength="255" /></td></tr>'; 135 } 136 if ($cfg['enabusr3'] && !empty($CONFIG['user_field3_name'])) { 137 echo '<tr><td class="tableb">'.$CONFIG['user_field3_name'].'</td><td class="tableb"><input type="text" name="user3" id="user3" class="textinput" maxlength="255" /></td></tr>'; 138 } 139 if ($cfg['enabusr4'] && !empty($CONFIG['user_field4_name'])) { 140 echo '<tr><td class="tableb">'.$CONFIG['user_field4_name'].'</td><td class="tableb"><input type="text" name="user4" id="user4" class="textinput" maxlength="255" /></td></tr>'; 141 } 142 } 143 144 $acptmime = $cfg['acptmime'] ? ("accept=\"{$cfg['acptmime']}\" ") : ''; 145 146 $auto_orient_checked = (isset($CONFIG['auto_orient_checked']) && !$CONFIG['auto_orient_checked']) ? '' : ' checked="checked"'; 147 echo <<<EOT 148 <tr id="h5upldrow"> 149 <td class="tableb">{$lang_plugin_upload_h5a['files']}</td> 150 <td class="tableb" style="padding:1em"> 151 <div style="width:480px"> 152 <input type="file" name="userpictures" id="upload_field" multiple="multiple" {$acptmime}/> 153 <input type="checkbox" name="autorient" id="autorient" value="1"{$auto_orient_checked} /> 154 <label for="autorient">{$lang_upload_php['auto_orient']}</label> 155 <br /> 156 <div id="dropArea">{$lang_plugin_upload_h5a['drop_files']}</div> 157 <br /> 158 <div id="progress_report" style="position:relative"> 159 <div id="progress_report_name"></div> 160 <div id="progress_report_status" style="font-style: italic;"></div> 161 <div id="totprogress"> 162 <div id="progress_report_bar" style="background-color: blue; width: 0; height: 100%;"></div> 163 </div> 164 <div> 165 {$lang_plugin_upload_h5a['files_left']}<span id="qcount">0</span><div class="acti" id="qstop"><img src="plugins/upload_h5a/css/stop.png" title="{$lang_plugin_upload_h5a['q_stop']}" alt="" onclick="H5uQctrl.stop()" /></div><div class="acti" id="qgocan"><img src="plugins/upload_h5a/css/play-green.png" title="{$lang_plugin_upload_h5a['q_resume']}" alt="" onclick="H5uQctrl.go()" /><img src="plugins/upload_h5a/css/cross.png" title="{$lang_plugin_upload_h5a['q_cancel']}" alt="" onclick="H5uQctrl.cancel()" /></div> 166 </div> 167 <div id="fprogress"></div> 168 <div id="server_response"></div> 169 </div> 170 </div> 171 </td> 172 </tr> 173 <tr id="gotoedit" style="display:none"> 174 <td class="tableb tableb_alternate">{$lang_plugin_upload_h5a['continue']}</td> 175 <td class="tableb tableb_alternate"> 176 <button type="button" onclick="window.location=redirURL">{$lang_plugin_upload_h5a['gotoedit']}</button> 177 </td> 178 </tr> 179EOT; 180 endtable(); 181 pagefooter(); 182 exit; 183} 184 185 186/** INSTALL/UNINSTALL **/ 187$thisplugin->add_action('plugin_install', 'upload_h5a_install'); 188 189function upload_h5a_install () { 190 global $CONFIG, $h5a_upload; 191 $scfg = cpg_db_escape_string(serialize($h5a_upload->h5u_config_default)); 192 cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (name, value) VALUES ('upload_h5a', '{$scfg}')"); 193 return true; 194} 195 196$thisplugin->add_action('plugin_uninstall', 'upload_h5a_uninstall'); 197 198function upload_h5a_uninstall () { 199 global $CONFIG; 200 cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name LIKE 'upload_h5a%'"); 201 return true; 202} 203