コード例 #1
0
	/**
	* Add uploaded images to DB
	*/
	function add_uploaded_images_to_db($action)
	{
		global $db, $cache, $config, $user, $lang, $language;
		global $wip;
		global $pics_number, $pic_start, $total_pics, $total_pics_modified;

		if (!defined('POSTED_IMAGES_PATH'))
		{
			include(IP_ROOT_PATH . 'includes/constants.' . PHP_EXT);
		}

		include(IP_ROOT_PATH . 'includes/class_images.' . PHP_EXT);
		$class_images = new class_images();

		$lang_append = '&lang=' . $language;

		$table_output = '';
		$pics_moved = '';

		switch ($action)
		{
			case 'fix':
				$posted_images_folder = POSTED_IMAGES_PATH;
				if ($total_pics == 0)
				{
					$total_pics_modified = 0;
				}

				if (($all_pics_array = $cache->get('_uploaded_images')) === false)
				{
					$all_pics_array = array();
					$dir = @opendir($posted_images_folder);
					while($file = readdir($dir))
					{
						$item_path = $posted_images_folder . $file;
						$process_item = (($file != '.') && ($file != '..') && (is_dir($item_path)) && (!is_link($item_path))) ? true : false;
						if ($process_item)
						{
							$sub_dir = @opendir($item_path);
							while($sub_file = readdir($sub_dir))
							{
								$item_sub_path = $file . '/' . $sub_file;
								$item_sub_path_full = $posted_images_folder . $item_sub_path;
								$process_item = (($sub_file != '.') && ($sub_file != '..') && (!is_dir($item_sub_path_full)) && (!is_link($item_sub_path_full))) ? true : false;
								if($process_item && preg_match('/(\.gif$|\.tif$|\.png$|\.jpg$|\.jpeg$)$/is', $sub_file))
								{
									$all_pics_array[] = $item_sub_path;
								}
							}
						}
					}
					$cache->put('_uploaded_images', $all_pics_array);
				}
				$total_pics = sizeof($all_pics_array);

				if ($total_pics_modified >= $total_pics)
				{
					$wip = false;
					$table_output .= '<br /><br />' . "\n";
					$table_output .= '<div class="post-text">' . "\n";
					$table_output .= '<ul type="circle" style="align: left;">' . "\n";
					$table_output .= '<li><span style="color: ' . $this->color_green . ';"><b>' . $lang['FixingPicsComplete'] . '</b></span></li>' . "\n";
					$table_output .= '</ul>' . "\n";
					$table_output .= '</div>' . "\n";
					$table_output .= '<br class="clear" />' . "\n";
					$table_output .= '<br /><br />' . "\n";
					return $table_output;
				}

				$pics_updated = '';
				for ($i = $pic_start; $i < ($pic_start + $pics_number); $i++)
				{
					if (!empty($all_pics_array[$i]))
					{
						$image_data_tmp = explode('/', $all_pics_array[$i]);
						$image_details = $class_images->get_image_details($posted_images_folder . $all_pics_array[$i]);
						$image_data = array(
							'pic_filename' => $image_data_tmp[1],
							'pic_size' => $image_details['size'],
							'pic_title' => $image_data_tmp[1],
							'pic_desc' => $image_data_tmp[1],
							'pic_user_id' => $image_data_tmp[0],
							'pic_user_ip' => '0.0.0.0',
							'pic_time' => $image_details['time'],
						);
						//print_r($image_data);
						$image_submit = $class_images->submit_image($image_data, 'insert');
						$pics_updated .= '<li>' . $all_pics_array[$i] . '</li>';
					}
					$total_pics_modified++;
				}

				if ($total_pics_modified > $total_pics)
				{
					$total_pics_modified = $total_pics;
				}

				$table_output .= '<div class="post-text" style="width: 90%;">' . "\n";
				$table_output .= '<ul type="circle" style="align: left;">' . "\n";
				$table_output .= $pics_updated . "\n";
				$table_output .= '</ul>' . "\n";
				$table_output .= '</div>' . "\n";
				$table_output .= '<br class="clear" />' . "\n";
				$table_output .= '<br /><br />' . "\n";

				// Increase $post_start to process the other posts
				$pic_start = ($pic_start + $pics_number);

			break;

			default:
				$table_output .= '<form action="' . ip_functions::append_sid(THIS_FILE . '?mode=add_uploaded_images_to_db&amp;action=fix&amp;wip=true' . $lang_append) . '" method="post" enctype="multipart/form-data">' . "\n";
				$table_output .= '<table class="forumline">' . "\n";
				$table_output .= '<tr><td class="row-header" colspan="2"><span>' . $lang['AddPostedPicsDB'] . '</span></td></tr>' . "\n";
				$table_output .= '<tr>' . "\n";
				$table_output .= '	<td class="row1" width="200"><span class="genmed">' . $lang['PicsPerStep'] . '&nbsp;</span></td>' . "\n";
				$table_output .= '	<td class="row1"><span class="genmed"><input type="text" class="post" name="pics_number" value="100" size="10" /></span></td>' . "\n";
				$table_output .= '</tr>' . "\n";
				$table_output .= '<tr>' . "\n";
				$table_output .= '	<td class="row1" width="200"><span class="genmed">' . $lang['PicStartFrom'] . '&nbsp;</span></td>' . "\n";
				$table_output .= '	<td class="row1"><span class="genmed"><input type="text" class="post" name="pic_start" value="0" size="10" /></span></td>' . "\n";
				$table_output .= '</tr>' . "\n";
				$table_output .= '<tr>' . "\n";
				$table_output .= '	<td class="cat" colspan="2" style="border-right-width: 0px; border-bottom-width: 0px;"><input type="submit" class="mainoption" name="submit" value="' . $lang['Start'] . '" /></td>' . "\n";
				$table_output .= '</tr>' . "\n";
				$table_output .= '</table>' . "\n";
				$table_output .= '</form>' . "\n";
		}

		return $table_output;
	}
コード例 #2
0
        // File is too big
        //echo('5');
        echo '5|' . $filename . '.' . $extension . '|0|0|0';
        exit;
    }
    if (is_uploaded_file($filename_tmp)) {
        @move_uploaded_file($filename_tmp, $upload_dir . $filename . '.' . $extension);
        @chmod($upload_dir . $filename . '.' . $extension, 0777);
    }
    $pic_size = @getimagesize($upload_dir . $filename . '.' . $extension);
    if ($pic_size == false) {
        @unlink($upload_dir . $filename . '.' . $extension);
        // Extension not allowed
        //echo('3');
        echo '3|' . $filename . '.' . $extension . '|0|0|0';
        exit;
    }
    // Success
    $filesize = filesize($upload_dir . $filename . '.' . $extension);
    $image_data = array('pic_filename' => $filename . '.' . $extension, 'pic_size' => $filesize, 'pic_title' => $filename . '.' . $extension, 'pic_desc' => $filename . '.' . $extension, 'pic_user_id' => $user->data['user_id'], 'pic_user_ip' => $user->ip, 'pic_time' => time());
    $image_submit = $class_images->submit_image($image_data, 'insert');
    //echo('1');
    echo '1|' . $filename . '.' . $extension . '|' . (int) $filesize . '|' . (int) $pic_size[0] . '|' . (int) $pic_size[1];
    //echo($filename . '.' . $extension);
    exit;
} else {
    // Error
    //echo('2');
    echo '2|' . $filename . '.' . $extension . '|0|0|0';
    exit;
}