加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
download.php 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
oldhuhu 提交于 2019-12-13 12:10 . no progress in background run
<?php
function download_branch_zip($branch, $target)
{
$url = 'https://gitee.com/ComsenzDiscuz/DiscuzX/repository/archive/' . $branch . '.zip';
logging\info('start downloading %s', $url);
$newf = fopen($target, 'wb');
if (!$newf) {
logging\error("cannot create file %s", $target);
exit(1);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $newf);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'curl/7.64.1');
// curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress');
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$proxy = getenv("http_proxy");
if ($proxy) {
logging\info("setting proxy as %s", $proxy);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
}
logging\log(LOG_LEVEL_INFO, ' downloaded: 0 KB');
curl_exec($ch);
curl_close($ch);
echo "\n";
fclose($newf);
}
function progress($resource, $download_size, $downloaded, $upload_size, $uploaded)
{
echo "\r";
logging\log(LOG_LEVEL_INFO, ' downloaded: %d KB', $downloaded / 1000);
}
function get_last_commit_id($branch) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, "https://gitee.com/ComsenzDiscuz/DiscuzX/tree/" . $branch . "/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$contents = curl_exec($ch);
curl_close($ch);
if (preg_match('/class="repo-index-commit-msg" href="\/ComsenzDiscuz\/DiscuzX\/commit\/(.*)"/m', $contents, $m)) {
return substr($m[1], 0, 8);
}
if (preg_match('/href="\/ComsenzDiscuz\/DiscuzX\/commit\/(.*)" class="repo-index-commit-msg"/m', $contents, $m)) {
return substr($m[1], 0, 8);
}
return FALSE;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化