Q:

Use php to download latest wordpress zip file?

I am working on a script to creates a database and installs WordPress. I have the database created but I am not sure how to download WordPress and put it in the correct directory. 
<?php
function actionhook_AcceptOrder($vars) {

$db = $vars["orderid"];

$con = mysql_connect("localhost","name","pword");

mysql_query("CREATE DATABASE ".$db."_db",$con)or die(mysql_error());
mysql_query("GRANT ALL ON ".$db."_db.* to  ".$db."_user identified by '".$db."'",$con) or die(mysql_error());

mkdir("/home/site/public_html/".$db."", 0700);

exec('curl -O http://wordpress.org/latest.tar.gz');
exec("mv latest.tar.gz /home/site/public_html/".$db."");
} 

add_hook("AcceptOrder",1,"actionhook_AcceptOrder");

?>

I also tried wget with exec but that didn't work either. 

A:

It's all about being creative :)
<?php
    function actionhook_AcceptOrder($vars) {

    $db = $vars["orderid"];

    $con = mysql_connect("localhost","name","pword");

    mysql_query("CREATE DATABASE ".$db."_db",$con)or die(mysql_error());
    mysql_query("GRANT ALL ON ".$db."_db.* to  ".$db."_user identified by '".$db."'",$con) or die(mysql_error());

    mkdir("/home/site/public_html/".$db."", 0700);

        $url  = 'http://wordpress.org/latest.zip';
        $path = '/home/site/public_html/latest.zip';

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $data = curl_exec($ch);

        curl_close($ch);

        file_put_contents($path, $data);
    } 

    add_hook("AcceptOrder",1,"actionhook_AcceptOrder");

    ?>

