I've recently installed DevkitPPC (the toolchain for building wii programs), and have attempted to make a PHP script to:
1 - Upload a .zip file containing a makefile in the root of it, and a folder titled "source" containing, well, the source code.
2 - Make a temporary folder for the source to be unzipped to
3 - Unzip the source to the temporary folder
4 - Run make to compile the program.
5 - Give you a link to the .elf file
And it doesn't quite work.
I'm a python programmer that's in the process of learning C and C++, and I just use PHP on the side every now and then for the websites I make, soy my PHP might not be using very good practices.
Here's the source:
Code: Select all
<?php
//////////////////////////////////////////////
// Setup section
$filepath = 'files/'; // Location of uploaded files
$zippath = 'zip/'; // Location where each of the source's folders are placed
$pass = 'thisisthepassword'; // Password
// No need to change anything after here.
//////////////////////////////////////////////
function check() {
session_start();
$session = $_SESSION['captcha'];
$image = $_POST['image'];
$image = md5($image);
if ($session == $image){
return 8;
} else {
return 9;
}
}
function redirect($link) {
//$pageaddr = 'Location: ' . $weblocation . 'return.html?link=' . $link;
//header($pageaddr);
echo $link;
}
function microtime_float() { // Not how it should function, this is just for testing.
return 4000;
}
$pwd = $_POST['passwd'];
if ($pwd == $pass){
if (check() == 8){
$target_path = $filepath;
$bname = basename( $_FILES['uploadedfile']['name']);
$target_path = $target_path . $bname;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$temfoldername = microtime_float();
echo $tempfoldername;
echo "<br>";
$mlast = system('mkdir ' . $tempfoldername, $retvalm);
echo $retvalm;
echo "<br>";
system('cd ./' . $zippath . $tempfoldername, $retval);
echo $retval;
echo "<br>";
$zlast = system('unzip ../../' . $target_path, $retvalz);
echo $retvalz;
echo "<br>";
$makelast = system('make', $retvalmake);
echo $retvalmake;
echo "<br>";
redirect($zippath . $tempfoldername . '/' . $tempfoldername . '.elf');
} else {
echo "There was an error uploading the file, please try again!";
}
} else {
echo "Incorrect verification code.";
}
} else {
echo "Wrong password!";
}
?>
Note that the first line's blank.
1
0
9
2
zip//.elf
This one has been completely perplexing me. I've tried everything I know of, but to no avail.
Any help would be greatly appreciated!!!
Thanks,
treyk4