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.8KB

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