PageRenderTime 76ms CodeModel.GetById 25ms RepoModel.GetById 2ms app.codeStats 0ms

/includes/build_imagebox_content.php

https://bitbucket.org/mpercy/deeemm-cms
PHP | 61 lines | 40 code | 16 blank | 5 comment | 5 complexity | 8918703435d186b27a87e82421be2e99 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause
  1. <?php
  2. defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );
  3. $value = NULL;
  4. // add check for imagebox_libraries
  5. if ($imagebox_libraries){ // need to check what happens if none set!!!!!!!!!!!
  6. foreach ($imagebox_libraries as $value){
  7. //get number of images in media library
  8. $sql_result = mysql_query("select count(*) from `" . $db_table_prefix . 'cat_' . "$value`");
  9. $num_media_files = mysql_result($sql_result,0);
  10. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `table` = '$value'");
  11. while($sql_result = mysql_fetch_array($sql_query)){
  12. $media_library_enabled = $sql_result[media_library_enabled];
  13. $media_library_default_view = $sql_result[media_library_default_view];
  14. $num_slideshow_images = $sql_result[num_slideshow_images];
  15. $imagebox_type = $sql_result[imagebox_type];
  16. }
  17. // breakpoint($imagebox_type);
  18. if ($num_media_files <> 0) {
  19. switch ($imagebox_type) {
  20. case 'random';
  21. $imagebox .= read_file($default_url . $templates_dir . "imagebox_random.tpl");
  22. //get random image id
  23. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` WHERE `image` NOT LIKE '%mpg' AND `image` NOT LIKE '%pdf' AND `image` NOT LIKE '%mov' AND `image` NOT LIKE '%zip' AND `image` NOT LIKE '%txt' ORDER BY RAND()");
  24. while($sql_result = mysql_fetch_array($sql_query)) {
  25. $random_image_name = $sql_result[image];
  26. $random_image_title = $sql_result[title_lan_ . $language];
  27. $random_image_description = $sql_result[description_lan_ . $language];
  28. $random_image_num = $sql_result[id];
  29. }
  30. if ($random_image_name == ''){
  31. $random_image_name = 'image_unavailable.jpg';
  32. }
  33. break;
  34. case 'slideshow';
  35. $imagebox .= read_file($default_url . $templates_dir . "imagebox_slideshow.tpl");
  36. break;
  37. }//end switch
  38. } ELSE {
  39. //do nothing
  40. }
  41. $imagebox = replace_variables($imagebox);
  42. }//end for each
  43. }//end if imagebox_libraries
  44. $value = NULL;
  45. ?>