php - MySQL Download counter for .DEB files on repository -


i had mysql download counter "working" few months ago , of sudden has stopped working, recording (individual cydia downloads) database posting main webpage stats. i've gone through code , files, on , on again. on 24hours digging , has still not been solved. if link files or post text "on here" please me.

connect.php

 <?php     $server = "localhost";      $user = "root";     $password = "password";     $database = mysql_connect ($server, $user, $password);      mysql_select_db("database_name", $database); ` ?> 

counter.php

<?php  include("connect.php");  $filename = mysql_real_escape_string($_get['file']);  $path = $_server['document_root']."/";   $fullpath = $path.$filename;   $filetypes = array("deb", "zip");  if (!in_array(substr($filename, -3), $filetypes)) {     echo "invalid download type.";     exit; }  if ($fd = fopen ($fullpath, "r")) {     $result = mysql_query("select count(*) countfile download     filename='" . $filename . "'");     $data = mysql_fetch_array($result);     $q = "";      if ($data['countfile'] > 0) {         $q = "update download set dldate = now()+interval +6 hour, stats = stats + 1         filename = '" . $filename . "'";     } else {         $q = "insert download (filename, dldate, stats) values         ('" . $filename . "',now()+interval +6 hour, 1)"; /* +6 = uk timezone */     }     $statresult = mysql_query($q);      $fsize = filesize($fullpath);     $path_parts = pathinfo($fullpath);      header("content-type: application/octet-stream");     header("content-disposition: filename=\"".$path_parts["basename"]."\"");     header("content-length: $fsize");     header("cache-control: private");      while(!feof($fd)) {         $buffer = fread($fd, 2048);         echo $buffer;     } } fclose ($fd); exit;  ?> 

index.html

<div class="downloads">downloads:   <?php  include("connect.php");  $query = "select stats download filename = 'deb/com.icon.deb'";  $result = mysql_query($query);  while ($row = mysql_fetch_array($result)) {  echo $row[0]; } ?>  </div> </div> 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -