6 Years
Discussion Span
Last Post by RicardoE

Have you searched Google or the php manual? This is a php forum to help with your code. Show your code so far.


ah don't worry guys, I figured it out, a few hours later the past week xD

in a small brief, this is what I did.

1) lots of JSON parsing and data extraction

Then I downloaded the zip file to my server like:

    copy($url, 'file.zip');

after that, unziped the file

$zip = new ZipArchive;
    if ($zip->open('game.zip') === TRUE) {
        echo 'unzip ok <br/>';
    } else {
        echo 'unzip failed';

//here more JSON parsing, and fun stuff

and finally copied the original to a new directory, and deleted the one in my "chron_job_folder", using the 2 following methods:

//copy the directory recursively
function full_copy($source, $target) {
    if (is_dir($source)) {
        $d = dir($source);
        while (FALSE !== ( $entry = $d->read() )) {
            if ($entry == '.' || $entry == '..') {
            $Entry = $source . '/' . $entry;
            if (is_dir($Entry)) {
                full_copy($Entry, $target . '/' . $entry);
            copy($Entry, $target . '/' . $entry);

    } else {
        copy($source, $target);

//reomove the directory recursively
function rrmdir($dir) {
   if (is_dir($dir)) {
     $objects = scandir($dir);
     foreach ($objects as $object) {
       if ($object != "." && $object != "..") {
         if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);

and, the responses to my post from ppl trying to help = 0 (again)

I guess this days, everybody is so busy. but I leave the complete solution to 3 common troubles here :) because I like to share knowledge, As my university slogan said: "Go and teach everybody".

I hope someone finds this post usefull :)


oh and of course... to set the cron job, simply go to your cPanel and add new cron job
there are a few nice features to make this easy, but basically you type in:

path_to_php -q full_path_to_your_php_script

and voila, you got it :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.