How to Edit mihalism Image hosting code for Batch Code generation?

Discussion in 'PHP' started by piratesbi, Apr 7, 2009.

  1. #1
    Hi, I find all post here but unable to find out how to edit php to generate batch image code after upload multiple image at a go. Like picscrazy.com

    I am using http://www.sharefunhere.com site. Please help

    Please help......... If anyone can

    I am giving my upload.php & link.tpl


    link.tpl

    <!-- BEGIN: FILE RESULTS TABLE -->
    
    <if="$mmhclass->image->manipulator == "gd" && is_file($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$mmhclass->image->thumbnail_name("<# FILENAME #>")) == false && preg_match("/links|viewer/", $mmhclass->input->server_vars['php_self']) == false && $mmhclass->templ->templ_globals['extension'] != "bmp" && $mmhclass->templ->templ_globals['extension'] != "ico"">
    	<div style="text-align: center;">
    		<b>Notice</b>: Failed to generate thumbnail for image file <b><# FILENAME #></b> because of an internal error. 
    		<br /><br />
    	</div>
    </endif>
    
    <if="preg_match("/viewer/", $mmhclass->input->server_vars['php_self']) == false">
    	<div style="text-align: center;">
    		<a href="viewer.php?file=<# FILENAME #>" class="button1">View Full Image</a>
    	</div>
    	<br />
    </endif>
    
    <script type="text/javascript">
    if (navigator.userAgent.toLowerCase().indexOf("msie") != -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1 && parseInt(navigator.appVersion) < 7 && get_cookie("in_explorer_lnkphp") == false) {
    	set_cookie("in_explorer_lnkphp", "true", 365);
    	alert("Hmm... your browser is not officialy supported.\n\nWe recommened you download a supported browser (e.g. Firefox, Opera, or Safari) or some parts of this page may not function as they should.\n\nContinue at your own risk.");
    }
    </script>
    
    <table cellpadding="5" cellspacing="0" width="100%">
    	<tr>
    		<td style="width: 20%;" valign="middle">
    			<div style="text-align: center;">
    				<a href="<# BASE_URL #>viewer.php?file=<# FILENAME #>"><img src="index.php?module=thumbnail&amp;file=<# FILENAME #>" class="thumbnail" alt="<# FILENAME #>" style="max-height: 125px; " /></a>
    			</div>
    		</td>
    		<td style="width: 80%;">
    			<table width="100%" border="0" cellspacing="1" cellpadding="0">
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="<# BASE_URL #><# UPLOAD_PATH #><# FILENAME #>" /></td>
    					<td>Direct Link</td>
    				</tr>
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="&lt;a href=&quot;<# BASE_URL #>viewer.php?file=<# FILENAME #>&quot;&gt;&lt;img src=&quot;<# THUMBNAIL #>&quot; border=&quot;0&quot; alt=&quot;<# FILENAME #>&quot; /&gt;&lt;/a&gt;" /></td>
    					<td>Thumbnail for Websites</td>
    				</tr>
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="[URL=<# BASE_URL #>viewer.php?file=<# FILENAME #>][IMG]<# THUMBNAIL #>[/IMG][/URL]" /></td>
    					<td>Thumbnail for forums</td>
    				</tr>
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="Thanks to <# SITE_NAME #> for &lt;a href=&quot;<# BASE_URL #>&quot;&gt;Free image hosting&lt;/a&gt;" /></td>
    					<td>Link to us</td>
    				</tr>
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="[URL=<# BASE_URL #>][IMG]<# BASE_URL #><# UPLOAD_PATH #><# FILENAME #>[/IMG][/URL]" /></td>
    					<td>Hotlink for forums</td>
    				</tr>
    				<tr>
    					<td><input readonly="readonly" class="input_field" onclick="javascript:highlight(this);" type="text" style="width: 605px" name="option" value="&lt;a href=&quot;<# BASE_URL #>&quot;&gt;&lt;img src=&quot;<# BASE_URL #><# UPLOAD_PATH #><# FILENAME #>&quot; border=&quot;0&quot; alt=&quot;<# SITE_NAME #>&quot; /&gt;&lt;/a&gt;" /></td>
    					<td>Hotlink for Websites</td>
    				</tr>
    			</table>
    		</td>
    	</tr>
    </table>
    
    <!-- END: FILE RESULTS TABLE -->
    
    Code (markup):

    upload.php

    <?php
    	// ======================================== \
    	// Package: Mihalism Multi Host
    	// Version: 4.0.0
    	// Copyright (c) 2007, 2008 Mihalism, Inc.
    	// License: http://www.gnu.org/licenses/gpl.txt GNU Public License
    	// ======================================== /
    
    	require_once "./source/includes/data.php";
    	
    	$mmhclass->templ->page_title = "{$mmhclass->info->config['site_name']} &raquo; Upload";
    
    	if ($mmhclass->funcs->is_null($mmhclass->input->get_vars['url']) == true) {
    		for ($i = 0; $i <= 15; $i++) {
    			if ($mmhclass->input->file_vars['userfile']['error'][$i] != 4 && $mmhclass->funcs->is_null($mmhclass->input->file_vars['userfile']['name'][$i]) == false) {
    				$total_file_uploads++;
    
    				if ($total_file_uploads <= 15) {
    					$mmhclass->templ->html .= (($total_file_uploads > 1) ? "<br /><hr />" : NULL);
    
    					$extension = $mmhclass->image->file_extension($mmhclass->input->file_vars['userfile']['name'][$i]);
    					$filename  = ($mmhclass->funcs->random_string(20).".{$extension}");
    					$thumbnail = $mmhclass->image->thumbnail_name($filename);
    					$filetitle = strip_tags((strlen($mmhclass->input->file_vars['userfile']['name'][$i]) > 20) ? (substr($mmhclass->input->file_vars['userfile']['name'][$i], 0, 20)."...") : $mmhclass->input->file_vars['userfile']['name'][$i]);
    
    					if (in_array($extension, $mmhclass->info->config['file_extensions']) == false) {
    						$mmhclass->templ->html .= $mmhclass->templ->message("The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> extension <b>.{$extension}</b> is not allowed.", false);
    					} elseif ($mmhclass->input->file_vars['userfile']['size'][$i] > $mmhclass->info->config['max_filesize']) {
    						$mmhclass->templ->html .= $mmhclass->templ->message("The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> exceeds the maximum allowed filesize of <b>".$mmhclass->image->format_filesize($mmhclass->info->config['max_filesize'])."</b> per image.", false);
    					} elseif ($mmhclass->image->is_image($mmhclass->input->file_vars['userfile']['tmp_name'][$i]) == false) {
    						$mmhclass->templ->html .= $mmhclass->templ->message("The file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> does not appear to be a real image.", false);
    					} elseif ($mmhclass->input->file_vars['userfile']['error'][$i] != 0) {
    						$file_errors = array(			
    							1 => "<b>PHP Engine Error</b>: The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> exceeds the <a href=\"http://us2.php.net/manual/en/ini.core.php#ini.upload-max-filesize\">upload_max_filesize</a> directive in php.ini.",
    							2 => "<b>PHP Engine Error</b>: The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> exceeds the <b><i>MAX_FILE_SIZE</i></b> directive that was specified in the HTML form.", // <- Never will be outputted as an error but still an option
    							3 => "<b>PHP Engine Error</b>: The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> was only partially uploaded.",
    							6 => "<b>PHP Engine Error</b>: Missing a temporary folder.",
    							7 => "<b>PHP Engine Error</b>: Failed to write image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> to disk.",
    							8 => "<b>PHP Engine Error</b>: Upload stopped by extension."
    						);
    						$mmhclass->templ->html .= $mmhclass->templ->error($file_errors[$mmhclass->input->file_vars['userfile']['error'][$i]], false);
    					} elseif (is_file($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename) == true || is_file($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$mmhclass->image->thumbnail_name($filename)) == true) {
    						$mmhclass->templ->html .= $mmhclass->templ->error("The filename <b>{$filename}</b> is already in existence on this server.", false);
    					} elseif (move_uploaded_file($mmhclass->input->file_vars['userfile']['tmp_name'][$i], $mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename) == false) {
    						$mmhclass->templ->html .= $mmhclass->templ->error("The image file <b>{$mmhclass->input->file_vars['userfile']['name'][$i]}</b> failed to upload because of an unknown problem.", false);
    					} else {
    						chmod($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename, 0644);
    
    						$mmhclass->db->query("INSERT INTO `mmh_file_storage` (`filename`, `is_private`, `gallery_id`, `file_title`) VALUES ('{$filename}', '{$mmhclass->input->post_vars['private_upload']}', '{$mmhclass->info->user_data['user_id']}', '{$filetitle}'); ");
    						$mmhclass->db->query("INSERT INTO `mmh_file_logs` (`filename`, `filesize`, `ip_address`, `user_agent`, `time_uploaded`, `gallery_id`, `is_private`, `original_filename`) VALUES ('{$filename}', '{$mmhclass->input->file_vars['userfile']['size'][$i]}', '{$mmhclass->input->server_vars['remote_addr']}', '{$mmhclass->input->server_vars['http_user_agent']}', '".time()."', '{$mmhclass->info->user_data['user_id']}', '{$mmhclass->input->post_vars['private_upload']}', '".strip_tags($mmhclass->input->file_vars['userfile']['name'][$i])."'); ");
    						$mmhclass->db->query("INSERT INTO `mmh_file_ratings` (`filename`, `total_rating`, `total_votes`, `voted_by`) VALUES ('{$filename}', '0', '0', '');");
    
    						$mmhclass->image->create_thumbnail($filename);
    
    						$mmhclass->templ->html .= $mmhclass->templ->file_results($filename);
    					}
    				}
    			}
    		}
    	} else {
    		for ($i = 0; $i <= 15; $i++) {
    			if (strtolower(ini_get("allow_url_fopen")) == "on" || $mmhclass->funcs->is_null(ini_get("allow_url_fopen")) == true) {
    				$mmhclass->templ->error("<b>PHP Engine Error:</b> The <b>allow_url_fopen</b> directive must be enabled in php.ini in order to use URL upload.", true);
    			} else {
    				if ($mmhclass->funcs->is_null($mmhclass->input->post_vars['userfile'][$i]) == false) {
    					$total_file_uploads++;
    
    					if ($total_file_uploads <= 15) {
    						$mmhclass->templ->html .= (($total_file_uploads > 1) ? "<br /><hr>" : NULL);
    
    						$mmhclass->info->file_data = array(
    							"http" => $mmhclass->input->post_vars['userfile'][$i],
    							"name" => array_shift(explode("?", basename($mmhclass->input->post_vars['userfile'][$i]))),
    							"size" => strlen(implode("", file($mmhclass->input->post_vars['userfile'][$i]))),
    						);
    						
    						$extension = $mmhclass->image->file_extension($mmhclass->info->file_data['name']);
    						$filename  = ($mmhclass->funcs->random_string(20).".{$extension}");
    						$thumbnail = $mmhclass->image->thumbnail_name($filename);
    						$filetitle = strip_tags((strlen($mmhclass->info->file_data['name']) > 20) ? (substr($mmhclass->info->file_data['name'], 0, 20)."...") : $mmhclass->info->file_data['name']);
    
    						if (preg_match("/(https|http|ftp):\/\/[^\"\s']+/", $mmhclass->info->file_data['http']) == false || preg_match("/\.([a-zA-Z0-9])/", $mmhclass->info->file_data['name']) == false) {
    							$mmhclass->templ->html .= $mmhclass->templ->error("The image file <b>{$mmhclass->info->file_data['name']}</b> contains an invalid URL.", false);
    						} elseif ($mmhclass->info->file_data['size'] == false) {
    							$mmhclass->templ->html .= $mmhclass->templ->error("The image file <b>{$mmhclass->info->file_data['name']}</b> could not be opened.", false);
    						} elseif (in_array($extension, $mmhclass->info->config['file_extensions']) == false) {
    							$mmhclass->templ->html .= $mmhclass->templ->message("The image file <b>{$mmhclass->info->file_data['name']}</b> extension <b>.{$extension}</b> is not allowed.", false);
    						} elseif ($mmhclass->info->file_data['size'] > $mmhclass->info->config['max_filesize']) {
    							$mmhclass->templ->html .= $mmhclass->templ->message("The image file <b>{$mmhclass->info->file_data['name']}</b> exceeds the maximum allowed filesize of <b>".$mmhclass->image->format_filesize($mmhclass->info->config['max_filesize'])."</b> per image.", false);
    						} elseif (is_file($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename) == true || is_file($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$mmhclass->image->thumbnail_name($filename)) == true) {
    							$mmhclass->templ->html .= $mmhclass->templ->error("The filename <b>{$filename}</b> is already in existence on this server.", false);
    						} elseif (copy($mmhclass->info->file_data['http'], $mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename) == false) {
    							$mmhclass->templ->html .= $mmhclass->templ->error("The image file <b>{$mmhclass->info->file_data['name']}</b> failed to upload because of an unknown problem.", false);
    						} else {
    							chmod($mmhclass->info->root_path.$mmhclass->info->config['upload_path'].$filename, 0644);
    
    							$mmhclass->db->query("INSERT INTO `mmh_file_storage` (`filename`, `is_private`, `gallery_id`, `file_title`) VALUES ('{$filename}', '{$mmhclass->input->post_vars['private_upload']}', '{$mmhclass->info->user_data['user_id']}', '{$filetitle}'); ");
    							$mmhclass->db->query("INSERT INTO `mmh_file_logs` (`filename`, `filesize`, `ip_address`, `user_agent`, `time_uploaded`, `gallery_id`, `is_private`, `original_filename`) VALUES ('{$filename}', '{$mmhclass->info->file_data['size']}', '{$mmhclass->input->server_vars['remote_addr']}', '{$mmhclass->input->server_vars['http_user_agent']}', '".time()."', '{$mmhclass->info->user_data['user_id']}', '{$mmhclass->input->post_vars['private_upload']}', '".strip_tags($mmhclass->info->file_data['name'])."'); ");
    							$mmhclass->db->query("INSERT INTO `mmh_file_ratings` (`filename`, `total_rating`, `total_votes`, `voted_by`) VALUES ('{$filename}', '0', '0', '');");
    
    							$mmhclass->image->create_thumbnail($filename);
    
    							$mmhclass->templ->html .= $mmhclass->templ->file_results($filename);
    							
    							unset($mmhclass->info->file_data);
    						}
    					}
    				}
    			}
    		}
    	}
    	
    	if ($total_file_uploads < 1) {
    		$mmhclass->templ->error("Please go back and select at least one image file to upload.", true);
    	}
    
    	$mmhclass->templ->output();
    
    ?>
    
    PHP:
     
    piratesbi, Apr 7, 2009 IP
  2. carpathia

    carpathia Well-Known Member

    Messages:
    124
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    i need this too :s
     
    carpathia, Jun 11, 2009 IP
  3. Aatma

    Aatma Well-Known Member

    Messages:
    1,233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #3
    i hav ebeen looking for this for a long time too. imagebeast seems to have it implemented using mysql
     
    Aatma, Aug 2, 2009 IP