-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_image.php
43 lines (34 loc) · 1.09 KB
/
generate_image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once 'include/db.php';
require_once 'nfo2png.php';
$file = explode( '.', $_FILES['user_file']['name'] );
$original_file_name = $_FILES['user_file']['name'];
$valid_file_types = array( 'txt', 'nfo', 'diz' );
$found = false;
foreach ( $valid_file_types AS $valid_file_type )
{
if ( strtoupper( $file[count($file)-1] ) == strtoupper( $valid_file_type ) )
{
$found = true;
break;
}
}
if ( !$found )
{
die( '0|File must be one of the following types: ' . implode( ', ', $valid_file_types ) );
}
$content = file_get_contents( $_FILES['user_file']['tmp_name'] );
$file_name = 'image_' . str_replace( '.', '', microtime(true) );
buildNFO( $content, '[Generated by: NFOPic.com]', $_POST['fg_color'], $_POST['bg_color'], $file_name );
echo '1|'.$file_name . '.png|'.$original_file_name;
if ( !is_local() )
{
$sql = "INSERT INTO nfo_images (original_file_name, file_name, user_ip)
VALUES (
'" . mysql_real_escape_string( $original_file_name ) . "',
'" . mysql_real_escape_string( $file_name.'.png' ) . "',
'" . $_SERVER['REMOTE_ADDR'] . "'
)
";
mysql_query( $sql );
}