{"action":"created","issue":{"url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/16","repository_url":"https://api.github.com/repos/BobRay/UpgradeMODX","labels_url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/16/comments","events_url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/16/events","html_url":"https://github.com/BobRay/UpgradeMODX/pull/16","id":146870302,"number":16,"title":"Fixing #8 Empty modx.zip file","user":{"login":"Jako","id":148371,"avatar_url":"https://avatars.githubusercontent.com/u/148371?v=3","gravatar_id":"","url":"https://api.github.com/users/Jako","html_url":"https://github.com/Jako","followers_url":"https://api.github.com/users/Jako/followers","following_url":"https://api.github.com/users/Jako/following{/other_user}","gists_url":"https://api.github.com/users/Jako/gists{/gist_id}","starred_url":"https://api.github.com/users/Jako/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jako/subscriptions","organizations_url":"https://api.github.com/users/Jako/orgs","repos_url":"https://api.github.com/users/Jako/repos","events_url":"https://api.github.com/users/Jako/events{/privacy}","received_events_url":"https://api.github.com/users/Jako/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-08T09:11:34Z","updated_at":"2016-04-14T19:50:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/BobRay/UpgradeMODX/pulls/16","html_url":"https://github.com/BobRay/UpgradeMODX/pull/16","diff_url":"https://github.com/BobRay/UpgradeMODX/pull/16.diff","patch_url":"https://github.com/BobRay/UpgradeMODX/pull/16.patch"},"body":"I had some issues with the current code:\r\n\r\n- The open_basedir check was somehow wrong since it could contain a string or is empty/null.\r\n- The redirect could be done without the 301/302 check with CURLINFO_REDIRECT_URL since PHP 5.3.7. The previous redirect check did not work here."},"comment":{"url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/comments/210119817","html_url":"https://github.com/BobRay/UpgradeMODX/pull/16#issuecomment-210119817","issue_url":"https://api.github.com/repos/BobRay/UpgradeMODX/issues/16","id":210119817,"user":{"login":"Jako","id":148371,"avatar_url":"https://avatars.githubusercontent.com/u/148371?v=3","gravatar_id":"","url":"https://api.github.com/users/Jako","html_url":"https://github.com/Jako","followers_url":"https://api.github.com/users/Jako/followers","following_url":"https://api.github.com/users/Jako/following{/other_user}","gists_url":"https://api.github.com/users/Jako/gists{/gist_id}","starred_url":"https://api.github.com/users/Jako/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jako/subscriptions","organizations_url":"https://api.github.com/users/Jako/orgs","repos_url":"https://api.github.com/users/Jako/repos","events_url":"https://api.github.com/users/Jako/events{/privacy}","received_events_url":"https://api.github.com/users/Jako/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T19:50:21Z","updated_at":"2016-04-14T19:50:21Z","body":"Some test code to check the download with curl:\r\n\r\n```\r\n<?php\r\n$url = 'http://modx.com/download/release/revolution-2.4.4-pl';\r\n$target = dirname(__FILE__) . '/test.zip';\r\n\r\n$newf = fopen(dirname(__FILE__) . '/test.zip', \"wb\");\r\nif ($newf) {\r\n    set_time_limit(0);\r\n    $ch = curl_init(str_replace(\" \", \"%20\", $url));\r\n    curl_setopt($ch, CURLOPT_TIMEOUT, 180);\r\n    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0)');\r\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\r\n    curl_setopt($ch, CURLOPT_FILE, $newf);\r\n    $openBasedir = ini_get('open_basedir');\r\n    if (empty($openBasedir) && filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN) === false) {\r\n        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);\r\n    } else {\r\n        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);\r\n        $rch = curl_copy_handle($ch);\r\n        // Check for redirects\r\n        curl_setopt($rch, CURLOPT_URL, $url);\r\n        curl_exec($rch);\r\n        if (!curl_errno($rch)) {\r\n            $newurl = curl_getinfo($rch, CURLINFO_REDIRECT_URL);\r\n            curl_close($rch);\r\n            curl_setopt($ch, CURLOPT_URL, $newurl);\r\n        }\r\n    }\r\n    $retVal = curl_exec($ch);\r\n    if ($retVal === false) {\r\n        return ('cUrl download of modx.zip failed ');\r\n    }\r\n    curl_close($ch);\r\n} else {\r\n    return ('Cannot open ' . $path . ' for writing');\r\n}\r\n```"}}