Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

add_image.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. include('../includes/config.php');
  3. $filename = "";
  4. if(isset($_POST) && $logged_in)
  5. {
  6. //retrieve the $_POST variables
  7. $filename_orig = rawurldecode($_POST['file_orig']);
  8. $filename = rawurldecode($_POST['file']);
  9. $title = rawurldecode($_POST['title']);
  10. if ($title == "")
  11. {
  12. $title = $filename_orig;
  13. }
  14. $file_path = $CONF['upload_dir'] . $filename;
  15. $thumbnail_path = $CONF['upload_dir'] . 'thumbnails/75_75_' . $filename;
  16. $file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename));
  17. $temp_path = sys_get_temp_dir()."\\".$filename;
  18. if (file_exists($file_path) && $file_db)
  19. {
  20. if ($file_db['hash'] != "")
  21. {
  22. $crypt = new Cryptography();
  23. $result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']);
  24. $file_path = $temp_path;
  25. }
  26. $file_type = $file_db['type'];
  27. $pattern = "/^(image)\/(.*)$/";
  28. if(preg_match($pattern, $file_type))
  29. {
  30. $resizeObj = new resize($file_path);
  31. // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
  32. $resizeObj->resizeImage(75, 75, 'landscape');
  33. $resizeObj->saveImage($thumbnail_path, 70);
  34. $data = array(
  35. "user_id" => $user->id,
  36. "title" => $title,
  37. "src" => $filename,
  38. "thumb" => $thumbnail_path,
  39. "date_added" => date("Y-m-d H:i:s",time())
  40. );
  41. $row_id = $db->insert($data, 'walls');
  42. $data = array(
  43. "table_name" => 'walls',
  44. "row_id" => $row_id,
  45. "user_id" => $user->id,
  46. "points" => 1
  47. );
  48. $db->insert($data, 'votes');
  49. echo "true";
  50. }
  51. else
  52. {
  53. echo "Please upload an actual image.";
  54. }
  55. }
  56. else
  57. {
  58. echo "No File Found";
  59. }
  60. }
  61. ?>