Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('php/agk-libs.php');
  4. require_once('style/style.php');
  5. error_reporting(0);
  6. ini_set("display_errors", 0);
  7. if(isset($search)) {
  8. require_once('agk-api.php');
  9.  
  10. $ServiceRootURL = 'https://api.datamarket.azure.com/Bing/Search/';
  11. $count = 18;//total list
  12. $skip = 0; //for paged
  13. $WebSearchURL = $ServiceRootURL . 'Image?$format=json&$top=' . $count . '&$skip=' . $skip . '&Query=';
  14. $context = stream_context_create(array(
  15. 'http' => array(
  16. 'request_fulluri' => true,
  17. 'header' => "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey)
  18. )
  19. ));
  20.  
  21. $request = $WebSearchURL . urlencode( '\'' . $search. '\'');
  22. $response = file_get_contents($request, 0, $context);
  23. $jsonobj = json_decode($response);
  24.  
  25. // echo $query;
  26. // highlight_string(print_r($jsonobj,true));
  27.  
  28. ?>
  29. <div class="agk-container">
  30. <div class="agk-row">
  31. <?php
  32. foreach($jsonobj->d->results as $value) {
  33. $ANU = $value->MediaUrl;
  34. $imglink = str_ireplace(array("http://",".jpg"), "", $ANU);
  35. //echo $ANU;
  36. ?>
  37. <div class="agk-col-sm-6">
  38. <div class="zanel zanel-primary">
  39. <div class="zanel-heading">
  40. <h2 style="margin:0;padding:0;font-size:14px;font-weight:500;color: white;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><?php echo strtoupper($value->Title);?></h2>
  41. </div>
  42. <div class="zanel-body">
  43. <img height="200px" src="<?php echo $ANU;?>" class="img-responsive" style="width:100%;height:200px" title="<?php echo $value->Title;?>" alt="<?php echo $value->Title;?>">
  44. </a>
  45. </div>
  46. <div class="zanel-footer" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis"><center><a href="/lihat?lihat=<?php echo url_slug($value->Title);?>" title="Size : <?php echo KByteSize($value->FileSize);?>"><h4>Download HD</h4></center></a></div>
  47. </div>
  48. </div>
  49. <?php } //end foreach ?>
  50. </div>
  51. </div>
  52. <?php } // end
  53.  
  54. //function to convert file size image
  55. function KByteSize($bytes) {
  56. $size = $bytes / 1024;
  57. if($size < 1024)
  58. {
  59. $size = number_format($size, 2);
  60. $size .= ' KB';
  61. }
  62. else
  63. {
  64. if($size / 1024 < 1024)
  65. {
  66. $size = number_format($size / 1024, 2);
  67. $size .= ' MB';
  68. }
  69. else if ($size / 1024 / 1024 < 1024)
  70. {
  71. $size = number_format($size / 1024 / 1024, 2);
  72. $size .= ' GB';
  73. }
  74. }
  75. return $size;
  76. }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement