Example #1
0
</head>
<body class="page-body loaded">
<div id='main-content'>
<?php 
echo "<div class='row'>";
$filepath = $_GET["filepath"];
$name = basename($filepath);
$path = str_replace($name, "", $filepath);
echo "<h4>{$name}</h4>";
echo "<p class='tip'>微信扫一扫无法直接下载,点击右上角,选择使用浏览器打开<span></span></p>";
if (strpos($name, ".apk")) {
    $href = "download.php?filepath=" . $filepath;
} else {
    #创建plist
    require_once "class.WritePlist.php";
    require_once "config.php";
    $href = URL_DE . "download.php?filepath=" . $filepath;
    $para = str_replace("/", "_", $filepath);
    $path = "images/qr/" . $para . ".plist";
    WritePlist::write($path, $href, "com.17173.app", "1", $name);
    $href = "itms-services://?action=download-manifest&url=" . $path;
}
echo "<div ><a class='d_btn' href='{$href}'>确认下载</a></div>";
echo "</div>";
?>
</div>
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F4fa6f5c543e643c686eadefba2c2efdf' type='text/javascript'%3E%3C/script%3E"));
</script>
</body>
Example #2
0
 /**
  * 读目录的所有子目录,如果遇到apk,按创建时间顺序存储
  * 增加了去重功能
  */
 function readChildrenFiles($dir, $level)
 {
     //echo "读目录:".$dir."<br>";
     if (!($handle = opendir($dir))) {
         die("不能读文件目录" . $dir);
     }
     $files = array();
     while ($file = readdir($handle)) {
         $path = $dir . "/" . $file;
         if ($file != "." && $file != "..") {
             if (strrpos($file, ".apk") > 0) {
                 #如果是只扫描目录结构则跳过
                 if ((int) $this->app["scan_dir"] == 1) {
                     continue;
                 }
                 //echo "<br>".$path;
                 $timestamp = filemtime($path);
                 if ($timestamp < $this->app["update_time"]) {
                     continue;
                 }
                 $time = $this->dateFormate($timestamp);
                 $paths = explode("/", $path);
                 $create_time = $paths[count($paths) - 2];
                 $id = $this->db->selectAppQrMaxId() + 1;
                 $data = URL_DE . "angle.php?id=" . $id;
                 $this->db->insertAppQr($id, $this->app["app_name"], $path, $data, $time);
                 $filename = QR_IMG_ROOT_PATH . $this->appname . "/qr" . $id . ".png";
                 $this->createQR($data, $filename);
                 array_push($this->show_apks, array("id" => $id, "app_path" => $path, "data" => $data, "create_time" => "刚刚"));
             } else {
                 if (strrpos($file, ".ipa") > 0) {
                     #如果是只扫描目录结构则跳过
                     if ((int) $this->app["scan_dir"] == 1) {
                         continue;
                     }
                     $timestamp = filemtime($path);
                     #创建时间小于扫描时间,跳过
                     if ($timestamp < $this->app["update_time"]) {
                         continue;
                     }
                     #创建时间格式化
                     $time = $this->dateFormate($timestamp);
                     #根据老大的意思,时间取最后一层目录
                     $paths = explode("/", $path);
                     $create_time = $paths[count($paths) - 2];
                     #入库
                     $id = $this->db->selectAppQrMaxId() + 1;
                     $qr_filename = QR_IMG_ROOT_PATH . $this->appname . "/qr" . $id . ".png";
                     $plist_filename = QR_IMG_ROOT_PATH . $this->appname . "/qr" . $id . ".plist";
                     #二维码里的数据
                     $data = URL_DE . "angleios.php?id=" . $id;
                     $this->db->insertAppQr($id, $this->app["app_name"], $path, $data, $time);
                     #创建二维码
                     $this->createQR($data, $qr_filename);
                     #plist的下载地址
                     $url = "download.php?filepath=" . $path;
                     WritePlist::write($plist_filename, $url, "com.17173.app", "1", $this->appname);
                     array_push($this->show_apks, array("id" => $id, "app_path" => $path, "data" => $data, "create_time" => "刚刚"));
                 } else {
                     if (is_dir($path)) {
                         #echo "<br> $path 是目录,检查if目录名(非路径)已经存在,若果不存在,入库";
                         array_push($files, $path);
                         $has = false;
                         foreach ($this->dirs as $d) {
                             if ($d["name"] == $file) {
                                 $has = true;
                                 break;
                             }
                         }
                         if (!$has) {
                             $this->db->insertAppDir($this->app["app_name"], $file, $level);
                         }
                         array_push($this->dirs, array("name" => $file, "level" => $level));
                     }
                 }
             }
         }
     }
     closedir($handle);
     return array_unique($files);
 }