Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2010, 05:14 AM
SieghartZeke SieghartZeke is offline
Member
 
Join Date: Oct 2009
Posts: 149
Credits: 12,435
SieghartZeke
Arrow Uploading Png

I have Tried to Change the Code for uploading image .png
It Work but...the only problem is that when i create, and give the name...I Find This "Unknow Image 26-03-2010" Vut I add a name to the Image!!
Oh Also i find this error when i upload:
Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /home/a2394530/public_html/admuploadpic.php on line 303

Here my admuploadpic.php:
Code:
<?php

// **********************************************************************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************

// **********************************************************************
// This file allows the administrator to create a new adoptable...
// File ID: nadopt.php
// **********************************************************************


// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include("inc/config.php");

$themeurl = grabanysetting("themeurl");


// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads = ""; // No Ads, because we're in the Admin CP...

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************

$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************

if($isloggedin == "yes"){

$group = getgroup();
$cancp = cancp($group);
$canedit = cando($group, "canmanageadopts");

if($cancp == "yes" and $canedit == "yes"){

// We are logged in and can access this page

// Set the user's prefix...

// The code to upload the actual file goes here...

// BEGIN FILE UPLOAD
	
$flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload.

$filesize = $_FILES['uploadedfile']['size'];
$mimetype = $_FILES['uploadedfile']['type'];
$filename = $_FILES['uploadedfile']['name'];


$filename = htmlentities($filename);
$filesize = htmlentities($filesize);
$mimetype = htmlentities($mimetype);

//Default upload directory
$uploaddir = "picuploads/png";


//***************************************************************************
//First we determine if the file is a gif or a jpg by checking the extension

//First check and see if the file is a .gif file
$ispng = "no";

$whitelist = array(".png");
foreach ($whitelist as $ending) {

if(substr($filename, -(strlen($ending))) != $ending) {

//File is not a gif file, so let's do nothing right now
//When we check for if it is a jpg we will flag the file

}
else{
//The file IS a gif file, so we set the isgif to true
$ispng = "yes";

}
}

// Now we check if it is a .jpg file or not, because it is not a gif

if($isgif != "yes"){

$whitelist = array(".png");
foreach ($whitelist as $ending) {

if(substr($filename, -(strlen($ending))) != $ending) {

	if($flag == 0){
	$error = "The file type or extention you are trying to upload is not allowed!  
	You can only upload gif or jpg files to the server!";
	}

$flag++;
}
}

}

//***************************************************************************

//First generate a MD5 hash of what the new file name will be
//Force a file extention on the file we are uploading

//Now we create a hashed file name of the file and set the upload directory...

if($ispng == "yes"){

$date = date('Y-m-d');
$hashstring = $prefix."".$filename."_".$date;

$hashedfilename = md5($hashstring);
$hashedfilename = $hashedfilename.".png";
$target_path = "picuploads/png/";
$uploaddir = "picuploads/png";

}
else if ($ispng == "no" and $flag == 0){

//File is a jpg

$date = date('Y-m-d');
$hashstring = $prefix."".$filename."_".$date;

$hashedfilename = md5($hashstring);
$hashedfilename = $hashedfilename.".png";
$target_path = "picuploads/png/";
$uploaddir = "picuploads/png";

}
else{
$flag++; //Not sure what type of file we've got, so abort...
}


//SET TARGET PATH?
$target_path = $target_path . basename( $filename );


//Check for empty file
if($hashedfilename == ""){

	if($error == ""){
	$error = "No File Exists!";
	}

$flag = $flag + 1;

}

//Now we check that the file doesn't already exist.
$existname = $uploaddir."/".$hashedfilename;

if(file_exists($existname)){

if($flag == 0){
$error = "Your file already exists on the server!  
Please choose another file to upload or rename the file on your 
computer and try uploading it again!";
}

$flag = $flag + 1;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////


//Now we check the filesize.  If it is too big then we reject it


if($filesize > 153600){
//File is too large

if($flag == 0){
$error = "The file you are trying to upload is too large!  Files must be under 150 KB.";
}

$flag = $flag + 1;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

//Check the mimetype of the file
if($mimetype != "image/png" and $mimetype != "image/png"){

if($flag == 0){
$error = "The file you are trying to upload does not contain expected data.
Are you sure that the file is a .gif or .jpg file?";
}

$flag = $flag + 1;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

//Now that we checked the mime type client side, let's check it again server side...

$imageInfo = getimagesize($_FILES["uploadedfile"]["tmp_name"]); // note that we need to use the temporal name since it has not yet been moved  
if($imageInfo["mime"] != "image/png" and $imageInfo["mime"] != "image/png")  
{  
	if($error == ""){
	$error = "The file you are trying to upload does not contain expected data.
	Are you sure that the file is a .gif or .jpg file?";
	}

$flag++;

} 


////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

//All checks are done, actually move the file...

if($flag == 0){

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploaddir."/".$hashedfilename)) {
    

	if(@file_exists($uploaddir."/".$hashedfilename)){

	$article_title = "Success!";

	$article_content = "The file ".  basename( $filename ). " 
      has been uploaded successfully!  It will now appear in the drop down list of available adoptables images.";
	
	}	
	else{
      $article_title = "ERROR!";
	$article_content = "There was an error uploading the file, please try again!";

	}


} else{
    $article_title = "ERROR!";
    $article_content = "There was an error uploading the file, please try again!";

    
	
}

}
else {
$article_title = "ERROR!";
if($error != ""){
$article_content = $error;
}
else{
$article_content = "File Upload Failed!";
}
}

//More code here
//Done with upload, so insert data into database

//Grab the friendly name form data...

$ffn = $_POST["ffn"];
$ffn = preg_replace("/[^a-zA-Z0-9?40.]/", "", $ffn);
$ffn = secure($ffn);

if($ffn == ""){
$ffn = "Unknown Image :: ".$date;
}



// ** Actually insert the photo's information into the database ** 

$serverpath = $uploaddir."/".$hashedfilename;
$wwwpath = "http://www.".$domain."".$scriptpath."/".$serverpath;



if($flag == 0){

$query = "INSERT INTO ".$prefix."filesmap VALUES ('', '$serverpath', '$wwwpath','$ffn')";
mysql_query($query);

}

$article_content = $article_content."<br><br><b><u>What would you like to do now?</u></b><br><br>
<a href='admin.php?set=adopts&do=uploadimg'>Upload Another Image</a><br>
<a href='admin.php?set=adopts'>Manage Adoptables</a><br>
<a href='admin.php'>Admin CP Home</a>";


} //This bracket ends the check of whether or not this user can access the adopts portion of the ACP
else{

$article_title = "Access Denied";
$article_content = "Access Denied";

}



}
else{

$article_title = "Access Denied";
$article_content = "Access Denied";

}

// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);

$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links

if($cancp == "yes"){

//Admins see a custom set of links here...

$links = getadmlinks();

}
else{

$links = getlinks();

}

$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template = replace(':ADS:',$ads,$template);

//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);


echo $template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
Please, say to me where is the problem to fix...THANK YOU XD
Reply With Quote
  #2  
Old 03-27-2010, 07:29 AM
mapleblade mapleblade is offline
Epicness sausage
 
Join Date: May 2009
Posts: 180
Gender: Male
Credits: 24,920
mapleblade
Default RE: Uploading Png

i treid this on my mod, i couldnt do it either, so il use onl;y prehosted iamges..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Avatar uploading MikiHeart Feedback and Suggestions 11 11-13-2013 06:38 AM
Need help with uploading EpicEquestrian Questions and Supports 1 01-23-2013 01:49 AM
Uploading problem D: ShadowedFortune Questions and Supports 4 09-07-2012 10:33 PM
Uploading files!? EpicEquestrian Questions and Supports 3 05-27-2012 08:54 PM
Help Uploading Code luvdance97 Questions and Supports 11 01-26-2009 03:36 PM


All times are GMT -5. The time now is 02:45 PM.

Currently Active Users: 809 (0 members and 809 guests)
Threads: 4,081, Posts: 32,031, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636