PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/files/dl.php

https://github.com/kaz6120/P_BLOG
PHP | 38 lines | 28 code | 3 blank | 7 comment | 7 complexity | 25e9a75a64abb5fe237116bf2fbe25c1 MD5 | raw file
  1. <?php
  2. /**
  3. * Binary File Download Counter
  4. *
  5. * $Id: files/dl.php, 2006-06-04 22:32:41 Exp $
  6. */
  7. $cd = '..';
  8. require_once $cd . '/include/config.inc.php';
  9. if (isset($_GET['id'])) {
  10. $id = $_GET['id'];
  11. //pull out the meta data from binary info table
  12. $sql = 'SELECT * FROM ' . $info_table . " WHERE id='" . $id . "'";
  13. if (!$res = mysql_query($sql)) {
  14. die('<h2>MySQL error</h2> ' . mysql_errno() . ' : ' . mysql_error());
  15. }
  16. if (mysql_num_rows($res) != 1) {
  17. die('<h2>MySQL error</h2> ' . mysql_errno() . ' : ' . mysql_error());
  18. }
  19. $bin_object = mysql_fetch_object($res);
  20. if ($bin_object->draft == 0) {
  21. // update downlaod counter
  22. $bin_mod = $bin_object->bin_mod;
  23. $dl_count_sql = 'UPDATE ' . $info_table
  24. . " SET bin_count = ifnull(bin_count, 0) + 1, bin_mod = '{$bin_mod}'"
  25. . " WHERE id = '{$id}'";
  26. if (!$dl_count_res = mysql_query($dl_count_sql)) {
  27. die('<h2>MySQL error</h2> ' . mysql_errno() . ' : ' . mysql_error());
  28. }
  29. header('Location: ' . $http . '://'
  30. . $_SERVER['HTTP_HOST']
  31. . $cfg['root_path']
  32. . 'files/bin.php?id=' . $id . "");
  33. }
  34. }
  35. ?>