<?php
// new file uploaded?
$uploadfile = "";
echo "uploading ";

echo $_FILES["userfile"]["name"];
if(strlen(basename($_FILES["userfile"]["name"])) > 0)
{
  $uploadfile = basename($_FILES["userfile"]["name"]);

  if(move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploadfile))
  {
    @chmod($uploadfile,0777);
    echo " Ok! ";


$weekago = mktime(date('H')+0, date('i'), date('s'), date('m'), date('d'), date('y'));
echo "aaa ";


if (file_exists("old/".date('Y_m_d', $weekago) )) {
  print("Directory already exists.\n");
} else {
  mkdir("old/".date('Y_m_d', $weekago));
  copy("index.php","old/".date('Y_m_d', $weekago)."/index.php");
  print("Directory creating.\n");
}

if (file_exists("old/".date('Y_m_d', $weekago)."/".date('H', $weekago) )) {
  print("Directory already exists.\n");
} else {
  mkdir("old/".date('Y_m_d', $weekago)."/".date('H', $weekago));
  copy("index1.php","old/".date('Y_m_d', $weekago)."/".date('H', $weekago)."/index.php");
  print("Directory creating.\n");
}


echo "add to arch ";
copy($uploadfile,"old/".date('Y_m_d', $weekago)."/".date('H', $weekago)."/".date('Y.m.d_H-i-s', $weekago).".jpg");
//copy($uploadfile,"old/".date('Y_m_d', $weekago)."/".date('Y.m.d_H:i:s', $weekago).".jpg");
//copy($uploadfile,"old/".date('Y_m_d', $weekago)."/".date('Y_m_d_H:i', $weekago).".jpg");
rename($uploadfile,"current.jpg");

  }
  else

    echo " Error copying!";
}
echo date('Y.m.d_H:i', $weekago);

?>





