Computer-Tachnalogy Headline

Seach

Write PHP Program to upload file From Computer in UR Online Database

Now, we will make another upload script. But this time we won't save the file in the database. We will only store the file info there but the real file is stored in the file server. We need a little modification to the upload table. Instead of using BLOB datatype we just use VARCHAR to store the file path.



CREATE TABLE upload2 (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
path VARCHAR(60) NOT NULL,
PRIMARY KEY(id)
);
The HTML form we use is no different with the previous one since the real changes will take place in the PHP codes.


<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
Okay, now let's take a look at the upload process. First we need to specify the directory to store the uploaded files. We store the directory name in $uploadDir. Note that PHP must have write access to $uploadDir or else the upload will fail. If you're web host using a Linux server you may need to set the permission for the upload directory to 777.
<?php
$uploadDir = 'C:/webroot/upload/';


if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];


$filePath = $uploadDir . $fileName;


$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include '../library/config.php';
include '../library/opendb.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}


$query = "INSERT INTO upload2 (name, size, type, path ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());


include '../library/closedb.php';
echo "<br>Files uploaded<br>";


}
?>


The key here is the move_uploaded_file() function. This function will move the uploaded files from the temporary upload directory to the location that we earlier ( $uploadDir . $fileName ). If for some reason the functioncannot move the file it will return false and we exit the script because continuing the script is no use.
Downloading


For listing the download files we just need to copy from the previous script. The real difference start when you click on the download link.
if(isset($_GET['id']))
{
include '../library/config.php';
include '../library/opendb.php';


$id = $_GET['id'];
$query = "SELECT name, type, size, path FROM upload2 WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $filePath) = mysql_fetch_array($result);


header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");


readfile($filePath);


include '../library/closedb.php';
exit;
}






After fetching the file info from the database and sending the required headers the next thing we need to do is read the file content from the server and send it to the browser. We can accomplish this by using readfile() function.


The Problems
When using this method of uploading files there are two problems that we need to take care of. They are :


Preventing direct access to the uploaded files
Handling duplicate file names
Preventing direct access
For this example the upload directory where the files are stored is /home/arman198/public_html/examples/upload/files/. Using your browser you see the upload directory by clicking here. This is ( usually ) a bad thing because anyone can see directly the file list and download them all. If you don't want to prevent people from seeing the content of the upload directory you could create an empty file, name it index.html then put that file to the upload directory. This is certainly not the optimal solution because maybe some people will try guessing the files names.


A better approach is to move the upload directory away from your web root. For example, the web root for this site is: /home/arman198/public_html/ to prevent direct listing i can set the upload directory to /home/arman198/upload/.


This way an outsider cannot see directly what's inside the upload directory. For example, even if you go to this url : http://www.php-mysql-tutorial.com/../upload/ you can't see the upload directory




Handling duplicate file names
When saving the files into the MySQL database we don't have to worry about this. The table for saving the files uses an id as the primary key so even we put ten files with the same name there won't be any problem since we access the files using that unique id.


The problem arise when saving the files to file server. The move_uploaded_file() function will overwrite a file with the same name and this is certainly not a desired behaviour.


To prevent this we just need to modify the file name. In this example the file names are changed into a random string, 32 characters long.






<?php
// ... same code as before


// get the file extension first
$ext = substr(strrchr($fileName, "."), 1);


// make the random file name
$randName = md5(rand() * time());


// and now we have the unique file name for the upload file
$filePath = $uploadDir . $randName . '.' . $ext;


$result = move_uploaded_file($tmpName, $filePath);


// ... same code as before


}
?>


First we extract the file extension from the file name using strrchr() function combined with substr(). Then using md5() we generate the 32 characters long of random string. It will look something like 7d1d1da5aac5ad72b293165e8e6fe89b. After we join them up we get the new unique file name. This way the chance of stumbling upon a duplicate name problem is very very slim.


As for the download part there's no change required. All we did was change the file name on the server so the previous download script will do just fine

Murtaza Jarwar

An A-Z Index of the Windows XP command line “ All Run Commands” In One Page

An A-Z Index of the Windows XP command line


ADDUSERS Add or list users to/from a CSV file

ARP Address Resolution Protocol

ASSOC Change file extension associations•

ASSOCIAT One step file association

ATTRIB Change file attributes

b

BOOTCFG Edit Windows boot settings

BROWSTAT Get domain, browser and PDC info

c

CACLS Change file permissions

CALL Call one batch program from another•

CD Change Directory - move to a specific Folder•

CHANGE Change Terminal Server Session properties

CHKDSK Check Disk - check and repair disk problems

CHKNTFS Check the NTFS file system

CHOICE Accept keyboard input to a batch file

CIPHER Encrypt or Decrypt files/folders

CleanMgr Automated cleanup of Temp files, recycle bin

CLEARMEM Clear memory leaks

CLIP Copy STDIN to the Windows clipboard.

CLS Clear the screen•

CLUSTER Windows Clustering

CMD Start a new CMD shell

COLOR Change colors of the CMD window•

COMP Compare the contents of two files or sets of files

COMPACT Compress files or folders on an NTFS partition

COMPRESS Compress individual files on an NTFS partition

CON2PRT Connect or disconnect a Printer

CONVERT Convert a FAT drive to NTFS.

COPY Copy one or more files to another location•

CSCcmd Client-side caching (Offline Files)

CSVDE Import or Export Active Directory data

d

DATE Display or set the date•

DEFRAG Defragment hard drive

DEL Delete one or more files•

DELPROF Delete NT user profiles

DELTREE Delete a folder and all subfolders

DevCon Device Manager Command Line Utility

DIR Display a list of files and folders•

DIRUSE Display disk usage

DISKCOMP Compare the contents of two floppy disks

DISKCOPY Copy the contents of one floppy disk to another

DISKPART Disk Administration

DNSSTAT DNS Statistics

DOSKEY Edit command line, recall commands, and create macros

DSACLs Active Directory ACLs

DSAdd Add items to active directory (user group computer)

DSGet View items in active directory (user group computer)

DSQuery Search for items in active directory (user group computer)

DSMod Modify items in active directory (user group computer)

DSMove Move an Active directory Object

DSRM Remove items from Active Directory

e

ECHO Display message on screen•

ENDLOCAL End localisation of environment changes in a batch file•

ERASE Delete one or more files•

EVENTCREATE Add a message to the Windows event log

EXIT Quit the current script/routine and set an errorlevel•

EXPAND Uncompress files

EXTRACT Uncompress CAB files

f

FC Compare two files

FIND Search for a text string in a file

FINDSTR Search for strings in files

FOR /F Loop command: against a set of files•

FOR /F Loop command: against the results of another command•

FOR Loop command: all options Files, Directory, List•

FORFILES Batch process multiple files

FORMAT Format a disk

FREEDISK Check free disk space (in bytes)

FSUTIL File and Volume utilities

FTP File Transfer Protocol

FTYPE Display or modify file types used in file extension associations•

g

GLOBAL Display membership of global groups

GOTO Direct a batch program to jump to a labelled line•

GPUPDATE Update Group Policy settings

h

HELP Online Help

i

iCACLS Change file and folder permissions

IF Conditionally perform a command•

IFMEMBER Is the current user in an NT Workgroup

IPCONFIG Configure IP

k

KILL Remove a program from memory

l

LABEL Edit a disk label

LOCAL Display membership of local groups

LOGEVENT Write text to the NT event viewer

LOGOFF Log a user off

LOGTIME Log the date and time in a file

m

MAPISEND Send email from the command line

MBSAcli Baseline Security Analyzer.

MEM Display memory usage

MD Create new folders•

MKLINK Create a symbolic link (linkd)

MODE Configure a system device

MORE Display output, one screen at a time

MOUNTVOL Manage a volume mount point

MOVE Move files from one folder to another•

MOVEUSER Move a user from one domain to another

MSG Send a message

MSIEXEC Microsoft Windows Installer

MSINFO Windows NT diagnostics

MSTSC Terminal Server Connection (Remote Desktop Protocol)

MUNGE Find and Replace text within file(s)

MV Copy in-use files

n

NET Manage network resources

NETDOM Domain Manager

NETSH Configure Network Interfaces, Windows Firewall & Remote access

NETSVC Command-line Service Controller

NBTSTAT Display networking statistics (NetBIOS over TCP/IP)

NETSTAT Display networking statistics (TCP/IP)

NOW Display the current Date and Time

NSLOOKUP Name server lookup

NTBACKUP Backup folders to tape

NTRIGHTS Edit user account rights

o

OPENFILES Query or display open files

p

PATH Display or set a search path for executable files•

PATHPING Trace route plus network latency and packet loss

PAUSE Suspend processing of a batch file and display a message•

PERMS Show permissions for a user

PERFMON Performance Monitor

PING Test a network connection

POPD Restore the previous value of the current directory saved by PUSHD•

PORTQRY Display the status of ports and services

POWERCFG Configure power settings

PRINT Print a text file

PRNCNFG Display, configure or rename a printer

PRNMNGR Add, delete, list printers set the default printer

PROMPT Change the command prompt•

PsExec Execute process remotely

PsFile Show files opened remotely

PsGetSid Display the SID of a computer or a user

PsInfo List information about a system

PsKill Kill processes by name or process ID

PsList List detailed information about processes

PsLoggedOn Who's logged on (locally or via resource sharing)

PsLogList Event log records

PsPasswd Change account password

PsService View and control services

PsShutdown Shutdown or reboot a computer

PsSuspend Suspend processes

PUSHD Save and then change the current directory•

q

QGREP Search file(s) for lines that match a given pattern.

r

RASDIAL Manage RAS connections

RASPHONE Manage RAS connections

RECOVER Recover a damaged file from a defective disk.

REG Registry: Read, Set, Export, Delete keys and values

REGEDIT Import or export registry settings

REGSVR32 Register or unregister a DLL

REGINI Change Registry Permissions

REM Record comments (remarks) in a batch file•

REN Rename a file or files•

REPLACE Replace or update one file with another

RD Delete folder(s)•

RMTSHARE Share a folder or a printer

ROBOCOPY Robust File and Folder Copy

ROUTE Manipulate network routing tables

RUNAS Execute a program under a different user account

RUNDLL32 Run a DLL command (add/remove print connections)

s

SC Service Control

SCHTASKS Schedule a command to run at a specific time

SCLIST Display NT Services

SET Display, set, or remove environment variables•

SETLOCAL Control the visibility of environment variables•

SETX Set environment variables permanently

SFC System File Checker

SHARE List or edit a file share or print share

SHIFT Shift the position of replaceable parameters in a batch file•

SHORTCUT Create a windows shortcut (.LNK file)

SHOWGRPS List the NT Workgroups a user has joined

SHOWMBRS List the Users who are members of a Workgroup

SHUTDOWN Shutdown the computer

SLEEP Wait for x seconds

SLMGR Software Licensing Management (Vista/2008)

SOON Schedule a command to run in the near future

SORT Sort input

START Start a program or command in a separate window•

SU Switch User

SUBINACL Edit file and folder Permissions, Ownership and Domain

SUBST Associate a path with a drive letter

SYSTEMINFO List system configuration

t

TASKLIST List running applications and services

TASKKILL Remove a running process from memory

TIME Display or set the system time•

TIMEOUT Delay processing of a batch file

TITLE Set the window title for a CMD.EXE session•

TLIST Task list with full path

TOUCH Change file timestamps

TRACERT Trace route to a remote host

TREE Graphical display of folder structure

TYPE Display the contents of a text file•

u

USRSTAT List domain usernames and last login

v

VER Display version information•

VERIFY Verify that files have been saved•

VOL Display a disk label•

w

WHERE Locate and display files in a directory tree

WHOAMI Output the current UserName and domain

WINDIFF Compare the contents of two files or sets of files

WINMSD Windows system diagnostics

WINMSDP Windows system diagnostics II

WMIC WMI Commands

x

XCACLS Change file and folder permissions

XCOPY Copy files and folders

:: Comment / Remark•

Commands marked • are Internal commands only available within the CMD shell.

All other commands (not marked with •) are external commands which may be used under the CMD shell, PowerShell, or directly from START-RUN.

Murtaza Jarwar

All Newton’s Law “MJ BLOG The Forum of Science ”




 

According to Newton's first law...

An object at rest will remain at rest unless acted on by an unbalanced force. An object in motion continues in motion with the same speed and in the same direction unless acted upon by an unbalanced force.

This law is often called

"the law of inertia".


 

What does this mean?

This means that there is a natural tendency of objects to keep on doing what they're doing. All objects resist changes in their state of motion. In the absence of an unbalanced force, an object in motion will maintain this state of motion.

Let's study the "skater" to understand this a little better.

What is the motion in this picture?


 

What is the unbalanced force in this picture?

What happened to the skater in this picture?


 

This law is the same reason why you should always wear your seatbelt.


 

Now that you understand

Newton's First Law of Motion,

let's go on to his Second Law of Motion.


 

Murtaza Jarwar

Learn about Warid Hack GPRS For Your Mobile

Warid's Glow Free GPRS hack is on the rise these days, many well-known forums have made image guided and video lessons to teach you how to activate this hack and how to use the GPRS for free to connect PC internet, some individuals also released modded versions of many java apps.


 

Warid's Glow Free GPRS hack is on the rise these days, many well-known forums have made image guided and video lessons to teach you how to activate this hack and how to use the GPRS for free to connect PC internet, some individuals also released modded versions of many java apps.

What Free GPRS Hack?

All you need is a Warid sim with zero balance and with Glow package activated on it. You can either use the default apn or can change it to blank or "warid", turn off any proxy, and you are good to go.

This hack works with proxy websites so in order to browse you first need to connect to a proxy site.

Open your mobile default browser and type

http://glow.pk.concealme.com/ or http://glow.pk.t9space.com, you can also join other proxy sites with glow.pk to get it working, This will take you to the proxy site where you can enter any website's address and can browse for free.

You can also edit regular java apps like opera mini, bolt, and Ucweb etc to work with this hack.

Note:

Try using this hack only when your balance is zero.

This hack will not work if you have any bundle sms package activated.

Using the proxy sites/modded applications can result in theft of your private data/ passwords, so use it at your own risk.

Why these hacks do came out?

There is a common perception that evil geniuses who always try to find backdoors and flaws in systems find these hacks, on the other hand, some people think that the companies themselves spread these hacks.

Some may think that why would these companies do this, and answer can be that as you know GPRS/Edge culture is still not popular in Pakistan, because of costs and lack of knowledge. Therefore, when one finds it free, obviously, he/she is going to use it, then they tell it to their friends, creating awareness for the service.

Moreover, this also helps in testing network load, strengths, and weakness of the system when there is network congestion

Murtaza Jarwar

Hack Warid Free GPRSFor Your Mobile and Computer 2010 (Updated)



Warid's Glow Free GPRS hack is on the rise these days, many well-known forums have made image guided and video lessons to teach you how to activate this hack and how to use the GPRS for free to connect PC internet, some individuals also released modded versions of many java apps.

Warid's Glow Free GPRS hack is on the rise these days, many well-known forums have made image guided and video lessons to teach you how to activate this hack and how to use the GPRS for free to connect PC internet, some individuals also released modded versions of many java apps.
What Free GPRS Hack?
All you need is a Warid sim with zero balance and with Glow package activated on it. You can either use the default apn or can change it to blank or "warid", turn off any proxy, and you are good to go.
This hack works with proxy websites so in order to browse you first need to connect to a proxy site.
Open your mobile default browser and type
http://glow.pk.concealme.com/ or http://glow.pk.t9space.com, you can also join other proxy sites with glow.pk to get it working, This will take you to the proxy site where you can enter any website's address and can browse for free.
You can also edit regular java apps like opera mini, bolt, and Ucweb etc to work with this hack.
Note:
Try using this hack only when your balance is zero.
This hack will not work if you have any bundle sms package activated.
Using the proxy sites/modded applications can result in theft of your private data/ passwords, so use it at your own risk.
Why these hacks do came out?
There is a common perception that evil geniuses who always try to find backdoors and flaws in systems find these hacks, on the other hand, some people think that the companies themselves spread these hacks.
Some may think that why would these companies do this, and answer can be that as you know GPRS/Edge culture is still not popular in Pakistan, because of costs and lack of knowledge. Therefore, when one finds it free, obviously, he/she is going to use it, then they tell it to their friends, creating awareness for the service.
Moreover, this also helps in testing network load, strengths, and weakness of the system when there is network congestion

Murtaza Jarwar

Zong Free Internet 2010 with MJBLOG Hack Tools

New Zong MJBog Hack Tool


It has been reported that the Zong Free GPRS hack has been completely blocked now. This hack was very famous among Pakistani youth; many well-known forums have made image guided and video lessons to teach you how to activate this hack. The duration of the hack was more than 1 year.




What was the hack?



The hack was very simple. You just had to do some changes in Access Point (APN Settings) to make them use zong mms settings. This way you were not charged and you could use Zong’s Edge/Gprs free of cost, even when you had credit in your account. Because the system does not recognize your status.



The first hack was that you change the apn from zongwap to zongmms. This hack was blocked shortly after it came to public forums.

The second hack was to change the apn to zongmms but also giving two blank lines above.

What you got? What you lost?



The people using this hack were 99.9% prepaid users, so no matter for what duration and what volumes they have used they are not going to pay for it.



The hack was blocked about 2 days ago, so those people who did not noticed it lost their balance in their accounts. As Zong started charging them as per regular tariff.



Why these hacks do came out?



There is a common perception that evil geniuses who always try to find backdoors and flaws in systems find these hacks, on the other hand, some people think that the companies themselves spread these hacks; the next question may be why they do this. The answer can be that as you know GPRS/Edge culture is still not popular in Pakistan, because of costs and lack of knowledge. Therefore, when one finds it free, obviously, he/she is going to use it, then they tell it to their friends, creating awareness for the service.



Moreover, this also helps in testing network load, strengths, and weakness of the system when there is network congestion.



What to do now?



For those who were using it, do not lose the hope, may be more hacks will out soon, or you can opt for paid GPRS



As zong is providing different packages for both postpaid and prepaid customers



ZONG Unlimited

ZONG Monthly Package

ZONG Hourly package

Below is latest TVC for Zong Gprs

Now Use Ufone Free Internet On Your PC & Mobile 2010 Updated 100%working

A very amazing offer for Ufone users, which is that they can use GPRS over their Ufone numbers for FREE. Remember it’s a trick, not an official offer from Ufone…




A user has found this bug in Ufone’s GPRS network, and claims that it works fine. I personally tested it and found it working…



Updated: September 13, 2009



Homepage: wap.ufone.com

User: ufone

Password: ufone

IP Address: 172.016.013.023

Proxy: 8080

Access Point: ufone.ppt.wap2



To enjoy FREE GPRS follow below steps





First of all activate your GPRS (if your GPRS is already active, then skip this process and start from point 5)

Send a SMS in following Pattern [manufacturer(e.g.nokia)model] and send it to 222

You will get the GPRS setting through an SMS

Save this SMS – Until now, your GPRS is activated and you can use GPRS, but it won’t be free. You will be billed as PKR 15 per 1 MB download

Now the trick starts

Go to tools> settings> connections> Ufone GPRS> Edit Ufone GPRS and write APN(Access Point Name) ufone.pmms – Previously it would be ufone.pwap

You are ready and can start using FREE GPRS

To use messengers go to Tools> Setting> Connection> Ufone GPRS> Options> Advance Setting and Change DNS

primary 172.16.13.21

2ndary 172.16.13.119

This hack works perfectly fine, so start enjoying the FREE GRPS Internet. If you are a postpaid user, better give a try on prepaid number before start using it on your postpaid number.



If you get server timeout message, don’t worry; that just a temporary down time, in such a case wait for couple of hours and your free internet will be available again.



Let me know if someone faces problems, so i may update the post; remember, its a hack and may stop working anytime.



Keep enjoying FREE GPRS INTERNET



Update: (July 15, 2008): This trick does not work anymore. I am trying to find out any new way for Free GPRS Internet on Ufone. If any one knows, then please share the trick with us. Thanks

Search

Keyword Density Tool - AddMe backlink checker Search Engine Submission - AddMe