upload pdf and check if PDF exist, PHP

<html>

<body>
<p style="color: red"> -Please choose pdf file and select yes if you want this PDF in your site</p>
<form action ="upload.php" method="post" enctype="multipart/form-data">
File:
<input type="file" name="file" size="30">

  <input type="radio" name="select" value="yes" checked="checked">Yes
  <input type="radio" name="select" value="no">No

<input type="submit" value="upload!">
</form>
</body>
</html>

<?php


$uploaddir = "upload";
$allowed_ext = "pdf";
$max_size = "5000000";
//$max_height = "";
//$max_width = "";

$extension = pathinfo($_FILES['file'] ['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths [$i] == "$extension") {
 $ok = "1";
}
}


if ($ok == "1")  {
 if($_FILES['file']['size'] > $max_size)
 {
     print "File is too big!";
     exit;
 }

// Include for images
//if ($max_width && $max_height) {
//list ($width, $height, $type, $w) =
//getimagesize($_FILES['file']['tmp_name']);
//if ($width . $max_width || $height > $max_height)
//{
//print "File height and/or width are too big!";
//exit;
//}
//}

if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}
print "Your Cover Letter has been successfully uploaded!";

$myFile = "upload/test21.csv";
$fh = fopen($myFile, 'r+') or die("can't open file");
$stringData = $_POST['select'];
fwrite($fh, $stringData);
$stringData =", ".$_FILES['file']['name'];
fwrite($fh, $stringData);
fclose($fh);

$fh = fopen("upload/test21.csv", "r");
while (($data = fgetcsv($fh,'',",")) !== false) {
foreach ($data as $value) {
if($value=='0') echo "I am in zero";
else
   echo $value . "<br />\n";
}
}

echo $value;
fclose($fh);

}
else {
print "Incorrect file extension!";

$myFile = "upload/test21.csv";
$fh = fopen($myFile, 'r+') or die("can't open file");
$stringData = "no";
fwrite($fh, $stringData);
$stringData =",emptyFile";
fwrite($fh, $stringData);
fclose($fh);

}

?>

print PDF PHP

<!DOCTYPE html>
<html>
<head>
<script>function iprint(ptarget){
        ptarget.focus();
        ptarget.print();
         }
</script>

</head>
<body>




<iframe name="theiframe" id="theiframe" width="500" height="200" src="dw.pdf" style="display:none">
</iframe>
     <input type="button" value="print iframe" onclick="iprint(theiframe);" />
</body>
</html>

Set Up Apache Virtual Hosts

Enable the new VirtualHost using the a2ensite utility and restart Apache2:
sudo a2ensite mynewsite
sudo /etc/init.d/apache2 restart


Similarly, use the a2dissite utility to disable sites. This is can be useful when troubleshooting configuration problems with multiple VirtualHosts:
sudo a2dissite mynewsite
sudo /etc/init.d/apache2 restart


Disable Firewall on RHEL / CentOS / RedHat Linux

How Do I Disable Firewall?

First login as the root user.
Next enter the following three commands to disable firewall.
# service iptables save
# service iptables stop
# chkconfig iptables off
If you are using IPv6 firewall, enter:
# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off

Disabling SSH Password Authentication and Root Login

You just strengthened the security of your Linode by adding a new user and generating SSH keys. Now it's time to make some changes to the default SSH configuration. First, you'll disable password authentication to require all users connecting via SSH to use key authentication. Next, you'll disable root login to prevent the root user from logging in via SSH. These steps are optional, but are strongly recommended.
Note
You may want to leave password authentication enabled if you connect to your Linode from many different desktop computers. That will allow you to authenticate with a password instead of copying the private key to every computer.
Here's how to disable SSH password authentication and root login:
  1. Open the SSH configuration file for editing by entering the following command:
    sudo nano /etc/ssh/sshd_config
    
Note
If you see a message similar to -bash: sudo: command not found, you'll need to install sudo on your Linode. To do so, log in as root by entering the sucommand, and type the root password when prompted. Next, install sudo by entering the following command: apt-get install sudo. After sudo has been installed, log out as the root user by entering the exit command.
  1. Change the PasswordAuthentication setting to no as shown below. Verify that the line is uncommented by removing the # in front of the line, if there is one.:
    PasswordAuthentication no
    
  2. Change the PermitRootLogin setting to no as shown below:
    PermitRootLogin no
    
  3. Save the changes to the SSH configuration file by pressing Control-X, and then Y.
  4. Restart the SSH service to load the new configuration. Enter the following command:
    sudo service ssh restart
    
After the SSH service restarts, the SSH configuration changes will be applied.

Using SSH Key Pair Authentication

You've used password authentication to connect to your Linode via SSH, but there's more a secure method available: key pair authentication. In this section, you'll generate a public and private key pair using your desktop computer and then upload the public key to your Linode. SSH connections will be authenticated by matching the public key with the private key stored on your desktop computer - you won't need to type your account password. When combined with the steps outlined later in this guide that disable password authentication entirely, key pair authentication can protect against brute-force password cracking attacks.
Here's how to use SSH key pair autentication to connect to your Linode:
  1. Generate the SSH keys on a desktop computer running Linux or Mac OS X by entering the following command in a terminal window on your desktop computer. PuTTY users can generate the SSH keys by following the instructions in our PuTTY guide.
    ssh-keygen
    
  2. The SSH keygen utility appears. Follow the on-screen instructions to create the SSH keys on your desktop computer. To use key pair authentication without a passphrase, press Enter when prompted for a passphrase.
Note
Two files will be created in your ~/.ssh directory: id_rsa and id_rsa.pub. The public key is id_rsa.pub - this file will be uploaded to your Linode. The other file is your private key. Do not share this file with anyone!
  1. Upload the public key to your Linode with the secure copy command (scp) by entering the following command in a terminal window on your desktop computer. Replaceexample_user with your username, and 123.456.78.90 with your Linode's IP address. If you have a Windows desktop, you can use a third-party client likeWinSCP to upload the file to your home directory.
    scp ~/.ssh/id_rsa.pub example_user@123.456.78.90:
    
  2. Create a directory for the public key in your home directory (/home/yourusername) by entering the following command on your Linode:
    mkdir .ssh
    
  3. Move the public key in to the directory you just created by entering the following command on your Linode:
    mv id_rsa.pub .ssh/authorized_keys
    
  4. Modify the permissions on the public key by entering the following commands, one by one, on your Linode. Replace example_user with your username.
    chown -R example_user:example_user .ssh
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys 
    ssh-add 
The SSH keys have been generated, and the public key has been installed on your Linode. You're ready to use SSH key pair authentication! To try it, log out of your terminal session and then log back in. The new session will be authenticated with the SSH keys and you won't have to enter your account password. (You'll still need to enter the passphrase for the key, if you specified one.)

Magento TopMenu is missing / Home Button

Go to: \app\design\frontend\base\default\template\page\html\topmenu.phtml

<?php if($_menu): ?><div class="nav-container">
    <
ul id="nav">
        <
li><a href="<?php echo $this->getUrl('') ?>">Home</a></li>
        
<?php echo $_menu ?>
        <?php 
echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>
    
</ul>
</
div><?php endif ?>

This is my first project using the R-Pi Camera board

like normal I am using Rasbian (see set up Rasbian) with SSH access, I did not install VNC, as I will not be using the GUI.
After I have logged in for the first time I have carried out the following:
  1. using Rasp-Config (sudo raspi-config) I have:
    • Enabled the camera (option 5)
    • Changed the hostname (option 8 > A2) (Mine is now called rpicam)
    • Change the user password (option 2 (mine is now camera)).
  2. Exit Rasp-Config and restart
  3. I have installed Netatalk, netatalk is a way of making your Pi easy to find on a mac network, and exposes the home directory of the user Pi over AFP 
    1
    sudo apt-get install netatalk
    1. I wanted to take a picture to see what it would look like before I did anything else, so using
      1
      raspistill -o myimage.jpg
      (there is a 5 second delay) I got the image on the right (resized in post-production):
    2. Install a FTP client, and image magick 
      1
      2
      sudo apt-get install ftp
      sudo apt-get install imagemagick
    3. make an FTP account on a remote server.

    The Code

    1. make a folder called camera in the ~/ folder 
      1
      mkdir camera
    2. save the following to camera.sh in the folder camera:
      1
      code for the camera
    3. To make the camera.sh file exicutable you will need to ass the X flag:
      1
      chmod +x camera.sh
      then run camera.sh by typing
      1
      ./camera.sh