gdwpm_action_callback

The Google Drive WP Media gdwpm action callback function.

Description

gdwpm_action_callback(); 

Usage

  1. if ( !function_exists( 'gdwpm_action_callback' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-drive-wp-media/google-drive-wp-media.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = gdwpm_action_callback(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/google-drive-wp-media.php  
  1. function gdwpm_action_callback() { 
  2. global $wpdb, $cek_kunci, $gdwpm_opt_akun, $gdwpm_service, $gdwpm_apiConfig; 
  3. $gdwpm_opt_akun = get_option('gdwpm_akun_opt'); // imel, client id, gdwpm_service akun, private key 
  4. require_once 'gdwpm-api/Google_Client.php'; 
  5. require_once 'gdwpm-api/contrib/Google_DriveService.php'; 
  6.  
  7. if(isset($_POST['folder_pilian'])) { 
  8. $gdwpm_apiConfig['use_objects'] = true; 
  9. $gdwpm_service = new GDWPMBantuan( $gdwpm_opt_akun[1], $gdwpm_opt_akun[2], $gdwpm_opt_akun[3] ); 
  10. $fld = $_POST['folder_pilian']; 
  11. if(isset($_POST['pagetoken'])) { 
  12. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres'], $_POST['pagetoken']); 
  13. }else{ 
  14. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres']); 
  15.  
  16. //array($daftarfile, $i, $totalhal, $halterlihat) 
  17. if($daftar_berkas[1] <= 0) { // total files < 1 
  18. if($daftar_berkas[2] > 1) { // total halaman > 1 
  19. if($daftar_berkas[3] == $daftar_berkas[2]) { 
  20. echo '<div class="sukses"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This page is empty.</p></div>'; 
  21. echo $daftar_berkas[0]; 
  22. }else{ 
  23. echo '<div class="sukses"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>Your request contains multiple pages, click the page number below.</p></div>';  
  24. echo $daftar_berkas[0]; 
  25. }else{ 
  26. echo '<div class="sukses"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This folder is empty.</p></div>'; 
  27. }else{  
  28. echo '<div class="sukses"><p>Folder ID: <strong>'.$fld.'</strong> and items on page: <strong>'.$daftar_berkas[1].'</strong>.<select style="float:right;" id="pilihBaris" onchange="gantiBaris(this, \'paginasi\');"><option value="5">5 rows/sheet</option><option value="10" selected="selected">10 rows/sheet</option> <option value="15">15 rows/sheet</option><option value="20">20 rows/sheet</option><option value="25">25 rows/sheet</option><option value="30">30 rows/sheet</option><option value="40">40 rows/sheet</option><option value="50">50 rows/sheet</option></select></p></div>';  
  29. echo $daftar_berkas[0]; 
  30. }elseif(isset($_POST['folder_pilian_file_gal'])) { 
  31. $gdwpm_apiConfig['use_objects'] = true; 
  32. $gdwpm_service = new GDWPMBantuan( $gdwpm_opt_akun[1], $gdwpm_opt_akun[2], $gdwpm_opt_akun[3] ); 
  33. $fld = $_POST['folder_pilian_file_gal']; 
  34. if(isset($_POST['pagetoken'])) { 
  35. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres'], $_POST['pagetoken'], 'gall'); 
  36. }else{ 
  37. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres'], null, 'gall'); 
  38.  
  39. //array($daftarfile, $i, $totalhal, $halterlihat) 
  40. if($daftar_berkas[1] <= 0) { // total files < 1 
  41. if($daftar_berkas[2] > 1) { // total halaman > 1 
  42. if($daftar_berkas[3] == $daftar_berkas[2]) { 
  43. echo '<div class="sukses_gal"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This page is empty.</p></div>'; 
  44. echo $daftar_berkas[0]; 
  45. }else{ 
  46. echo '<div class="sukses_gal"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>Your request contains multiple pages, click the page number below.</p></div>';  
  47. echo $daftar_berkas[0]; 
  48. }else{ 
  49. echo '<div class="sukses_gal"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This folder is empty.</p></div>'; 
  50. }else{  
  51. echo '<div class="sukses_gal"><p>Folder ID: <strong>'.$fld.'</strong> and items on page: <strong>'.$daftar_berkas[1].'</strong>.<select style="float:right;" id="pilihBaris_gal" onchange="gantiBaris(this, \'paginasi_gal\');"><option value="5">5 rows/sheet</option><option value="10" selected="selected">10 rows/sheet</option> <option value="15">15 rows/sheet</option><option value="20">20 rows/sheet</option><option value="25">25 rows/sheet</option><option value="30">30 rows/sheet</option><option value="40">40 rows/sheet</option><option value="50">50 rows/sheet</option></select></p></div>';  
  52. echo $daftar_berkas[0]; 
  53. }  
  54. }elseif(isset($_POST['folder_pilian_file_del'])) { 
  55. $gdwpm_apiConfig['use_objects'] = true; 
  56. $gdwpm_service = new GDWPMBantuan( $gdwpm_opt_akun[1], $gdwpm_opt_akun[2], $gdwpm_opt_akun[3] ); 
  57. $fld = $_POST['folder_pilian_file_del']; 
  58. if(isset($_POST['pagetoken'])) { 
  59. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres'], $_POST['pagetoken'], 'checkbox'); 
  60. }else{ 
  61. $daftar_berkas = $gdwpm_service->getFilesInFolder($fld, $_POST['pilmaxres'], null, 'checkbox'); 
  62. $daftarfile = $daftar_berkas[0]; 
  63. $i = $daftar_berkas[1]; 
  64.  
  65. if($daftar_berkas[1] <= 0) { 
  66. if($daftar_berkas[2] > 1) { // total halaman > 1 
  67. if($daftar_berkas[3] == $daftar_berkas[2]) { 
  68. echo '<div class="sukses_del"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This page is empty.</p></div>'; 
  69. echo $daftarfile; 
  70. }else{ 
  71. echo '<div class="sukses_del"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>Your request contains multiple pages, click the page number below.</p></div>'; 
  72. echo $daftarfile; 
  73. }else{ 
  74. echo '<div class="sukses_del"><p style="text-align:center;"><img src="' . plugins_url( '/images/animation/gdwpm_breaker_256.png', __FILE__ ) . '"><br/>This folder is empty.</p></div>'; 
  75. }else{  
  76. echo '<div class="sukses_del"><p>Folder ID: <strong>'.$fld.'</strong> and items on page: <strong>'.$i.'</strong>.</p></div>'; 
  77. echo $daftarfile; 
  78. }  
  79.  
  80. }elseif(isset($_POST['dataimages'])) { 
  81. // insert gallery 
  82. $unikid = strtotime("now"); 
  83. $postjudul = base64_decode($_POST['judul']); 
  84. $postkat = base64_decode($_POST['album']); 
  85. $postkontenarr = explode(' , ', $_POST['dataimages']);  
  86. //$postkonten = "<div class='gdwpmgallery'>"; //lightbox 
  87. //$postkonten = '<div class="fotorama" data-allowfullscreen="native" data-loop="true" data-autoplay="true">'; //fotorama 
  88. if(isset($_POST['css_effect'])) { 
  89. $css_effect = $_POST['css_effect']; //default/blackwhite/lighthover 
  90. }else{ 
  91. $css_effect = 'default'; 
  92. switch ($css_effect) { 
  93. case "default": 
  94. $efekgbr = ''; 
  95. break; 
  96. case "blackwhite": 
  97. $efekgbr = ' gdwpm-bwefek'; 
  98. break; 
  99. case "lighthover": 
  100. $efekgbr = ' gdwpm-lightefek'; 
  101. break; 
  102. default: 
  103. $efekgbr = ''; 
  104. if(isset($_POST['css_style'])) { 
  105. $css_style = $_POST['css_style']; //default/blackwhite/lighthover 
  106. }else{ 
  107. $css_style = 'default'; 
  108. $jmlkolom = 3; 
  109. $justproper = '1 | 90 | justify'; 
  110. if($css_style == 'justified') { 
  111. if(isset($_POST['css_style_justified'])) { 
  112. $justproper = $_POST['css_style_justified']; 
  113. $postkonten = '<div id="gdwpmgal-'.$unikid.'" class="gdwpmGallery1'.$efekgbr.'" data-gal1="'.$justproper.'">'; //Justified + lightbox 
  114. $dataSource = array(); 
  115. foreach($postkontenarr as $key => $val) {// id, thumbid, flnme | captionimg 
  116. $indidata = explode(' | ', $val);  
  117. $indidatadecode = json_decode(base64_decode($indidata[0]), true); 
  118. $captionimg = base64_decode($indidata[1]); 
  119. if($key == 0) {$sampleImage = $indidatadecode[1];} 
  120. //$dataSource[] = array($indidatadecode[0], $indidatadecode[1]) . ' | ' . $captionimg; 
  121. //$postkonten .= '<div class="galleryItem"><a href="//www.googledrive.com/host/'.$indidatadecode[0].'" data-lightbox="'.$unikid.'" data-title="'.$captionimg.'"><img src="//www.googledrive.com/host/'.$thumbId.'" alt="'.$indidatadecode[1].'"/></a></div>'; //lightbox 
  122. //$postkonten .= '<a href="//www.googledrive.com/host/'.$thumbId.'" data-full="//www.googledrive.com/host/'.$indidatadecode[0].'" data-caption="'.$captionimg.'"></a>'; //fotorama 
  123. $boxttl = ''; $jusalt = ''; 
  124. if(!empty($captionimg)) {$boxttl = 'data-title="'.$captionimg.'" '; $jusalt = 'alt="'.$captionimg.'" ';} 
  125. $postkonten .= '<a href="'.GD_BASE_PATH.$indidatadecode[0].'" '.$boxttl.'data-lightbox="'.$unikid.'"><img '.$jusalt.'src="'.GD_BASE_PATH.$indidatadecode[1].'" /></a>'; //justified 
  126. }else{ 
  127. if(isset($_POST['css_style_default'])) { 
  128. $jmlkolom = $_POST['css_style_default']; 
  129. $postkonten = '<div class="gdwpmGallery0'.$efekgbr.' gallery gallery-columns-'.$jmlkolom.'">'; 
  130. $dataSource = array(); 
  131. foreach($postkontenarr as $key => $val) {// id, thumbid, flnme | captionimg 
  132. $indidata = explode(' | ', $val);  
  133. $indidatadecode = json_decode(base64_decode($indidata[0]), true); 
  134. $captionimg = base64_decode($indidata[1]); 
  135. if($key == 0) {$sampleImage = $indidatadecode[1];} 
  136. $postkonten .= '<dl style="width:' . 100/$jmlkolom . '%;" class="gallery-item"><dt class="gallery-icon"><a href="'. GD_BASE_PATH .$indidatadecode[0]. '" data-lightbox="'.$unikid.'" data-title="'.$captionimg.'"><img class="attachment-thumbnail img-rounded" src="'.GD_BASE_PATH.$indidatadecode[1].'" alt="'. $indidatadecode[2] .'" width="200" /></a></dt><dd class="wp-caption-text gallery-caption">'.$captionimg.'</dd></dl>'; 
  137. if($key > 0 && ($key + 1) % $jmlkolom == 0 || $key == (count($postkontenarr) - 1)) { $postkonten .= '<br style="clear: both" />'; } 
  138. $postkonten .= '</div>'; 
  139.  
  140. //$postkonten = base64_decode($_POST['dataimages']); 
  141.  
  142. $gallery = array('post_title' => wp_strip_all_tags($postjudul), 'post_name' => sanitize_title_with_dashes($postjudul), 'post_content' => $postkonten, 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'gdwpm_galleries'); 
  143. if(empty($_POST['galid']) || $_POST['galid'] == '') { 
  144. $galeri_id = wp_insert_post($gallery); 
  145. $infokita = 'created'; 
  146. }else{ 
  147. $gallery['ID'] = $_POST['galid']; 
  148. $galeri_id = wp_update_post($gallery); 
  149. $infokita = 'saved'; 
  150. if($galeri_id != 0) { 
  151. wp_set_object_terms( $galeri_id, $postkat, 'gdwpm_album' ); 
  152. update_post_meta( $galeri_id, 'sampleImage', $sampleImage ); 
  153. $baseData = base64_encode(json_encode(array($galeri_id, wp_strip_all_tags($postjudul), $postkat, $css_style, $css_effect, 'lightbox', $jmlkolom, $justproper))); 
  154. $baseData .= ' items:' . $_POST['dataimages']; 
  155. update_post_meta( $galeri_id, 'base64data', $baseData ); 
  156. echo '<strong>'.$postjudul.'</strong> successfully '.$infokita.'. Gallery ID: <strong>'.$galeri_id.'</strong>. Shortcode: <code>[gdwpm-gallery id="'.$galeri_id.'"]</code>. Permalink: <a href="' . get_permalink($galeri_id) . '" title="Open '.$postjudul.' in new window" target="_blank">' . get_permalink($galeri_id) . '</a>'; 
  157. }else{ 
  158. echo 'Cannot create gallery.'; 
  159. }elseif(isset($_POST['masuk_perpus'])) { 
  160. //$gdwpm_berkas_terpilih_arr = explode(' | ', $_POST['masuk_perpus']); 
  161. $gdwpm_berkas_terpilih_arr = json_decode(base64_decode($_POST['masuk_perpus']), true); 
  162. if(isset($_POST['ubah_fname']) && !empty($_POST['ubah_fname'])) { 
  163. $fnamearr = json_decode(base64_decode($_POST['ubah_fname']), true); 
  164. $gdwpm_berkas_terpilih_arr[3] = $fnamearr; 
  165. gdwpm_ijin_masuk_perpus(sanitize_mime_type($gdwpm_berkas_terpilih_arr[0]), $gdwpm_berkas_terpilih_arr[1], $gdwpm_berkas_terpilih_arr[2], $gdwpm_berkas_terpilih_arr[3], $gdwpm_berkas_terpilih_arr[4], $gdwpm_berkas_terpilih_arr[5]); 
  166.  
  167. echo '<strong>'.$gdwpm_berkas_terpilih_arr[1] . '</strong> has been added to your Media Library'; 
  168.  
  169. }elseif(isset($_POST['gdwpm_ukuran_preview_lebar']) || isset($_POST['gdwpm_ukuran_preview_tinggi'])) { 
  170. $nonce = $_REQUEST['gdwpm_override_nonce']; 
  171.  
  172. if ( ! wp_verify_nonce( $nonce, 'gdwpm_override_dir' ) ) { 
  173. wp_die('<strong>Oops... failed!</strong>');  
  174. } else { 
  175. if(!$gdwpm_ukuran_preview) {$gdwpm_ukuran_preview = get_option('gdwpm_ukuran_preview');} 
  176. if (ctype_digit($_POST['gdwpm_ukuran_preview_lebar']) && ctype_digit($_POST['gdwpm_ukuran_preview_tinggi'])) { 
  177. if($_POST['gdwpm_ukuran_preview_lebar'] > 20 && $_POST['gdwpm_ukuran_preview_tinggi'] > 10) { 
  178. if($_POST['gdwpm_cekbok_embed_video'] == 'checked') { 
  179. if(isset($_POST['gdwpm_video_play_style']) && $_POST['gdwpm_ukuran_video_lebar'] > 20 && $_POST['gdwpm_ukuran_video_tinggi'] > 20 && ctype_digit($_POST['gdwpm_ukuran_video_lebar']) && ctype_digit($_POST['gdwpm_ukuran_video_tinggi'])) { 
  180. $gdwpm_ukuran_prev_arr = array($_POST['gdwpm_ukuran_preview_lebar'], $_POST['gdwpm_ukuran_preview_tinggi'], $_POST['gdwpm_cekbok_embed_video'], $_POST['gdwpm_video_play_style'], $_POST['gdwpm_ukuran_video_lebar'], $_POST['gdwpm_ukuran_video_tinggi']); 
  181. update_option('gdwpm_ukuran_preview', $gdwpm_ukuran_prev_arr);  
  182. echo '<div id="info">Option saved.</div><div id="hasil">[gdwpm id="<b>YOURGOOGLEDRIVEFILEID</b>" w="<b>'.$gdwpm_ukuran_prev_arr[0].'</b>" h="<b>'.$gdwpm_ukuran_prev_arr[1].'</b>"]</div><div id="hasilvid">[gdwpm id="<b>YOURGOOGLEDRIVEFILEID</b>" video="<b>'.$gdwpm_ukuran_prev_arr[3].'</b>" w="<b>'.$gdwpm_ukuran_prev_arr[4].'</b>" h="<b>'.$gdwpm_ukuran_prev_arr[5].'</b>"]</div>'; 
  183. }else{ 
  184. echo '<div id="info"><strong>Warning:</strong> Minimum value is 20.</div><div id="hasil">[gdwpm id="GOOGLEDRIVEFILEID" w="<b>'.$gdwpm_ukuran_preview[0].'</b>" h="<b>'.$gdwpm_ukuran_preview[1].'</b>"]</div>'; 
  185. }else{ 
  186. $gdwpm_ukuran_prev_arr = array($_POST['gdwpm_ukuran_preview_lebar'], $_POST['gdwpm_ukuran_preview_tinggi'], $_POST['gdwpm_cekbok_embed_video'], $gdwpm_ukuran_preview[3], $gdwpm_ukuran_preview[4], $gdwpm_ukuran_preview[5]); 
  187. update_option('gdwpm_ukuran_preview', $gdwpm_ukuran_prev_arr);  
  188. echo '<div id="info">Option saved.</div><div id="hasil">[gdwpm id="<b>YOURGOOGLEDRIVEFILEID</b>" w="<b>'.$gdwpm_ukuran_prev_arr[0].'</b>" h="<b>'.$gdwpm_ukuran_prev_arr[1].'</b>"]</div>'; 
  189. }else{ 
  190. echo '<div id="info"><strong>Warning:</strong> Minimum value is 10.</div><div id="hasil">[gdwpm id="GOOGLEDRIVEFILEID" w="<b>'.$gdwpm_ukuran_preview[0].'</b>" h="<b>'.$gdwpm_ukuran_preview[1].'</b>"]</div>'; 
  191. }else{ 
  192. echo '<div id="info"><strong>Warning:</strong> Numeric only please.</div><div id="hasil">[gdwpm id="GOOGLEDRIVEFILEID" w="<b>'.$gdwpm_ukuran_preview[0].'</b>" h="<b>'.$gdwpm_ukuran_preview[1].'</b>"]</div>'; 
  193. }elseif(isset($_POST['gdwpm_cekbok_opsi_value'])) { 
  194. $nonce = $_REQUEST['gdwpm_override_nonce']; 
  195.  
  196. if ( ! wp_verify_nonce( $nonce, 'gdwpm_override_dir' ) ) { 
  197. wp_die('<strong>Oops... failed!</strong>');  
  198. } else { 
  199. $folder_bawaan = preg_replace("/[^a-zA-Z0-9]+/", " ", $_POST['gdwpm_folder_opsi_value']); 
  200. $folder_bawaan = sanitize_text_field($folder_bawaan); 
  201.  
  202. if(empty($folder_bawaan) && $_POST['gdwpm_cekbok_opsi_value'] == 'checked') { 
  203. echo 'Folder name cannot be empty!'; 
  204. }else{ 
  205. $gdwpm_cekbok = array($_POST['gdwpm_cekbok_opsi_value'], $folder_bawaan, $_POST['gdwpm_cekbok_masukperpus_override']); 
  206. update_option('gdwpm_override_dir_bawaan', $gdwpm_cekbok);  
  207. echo 'Option saved.'; 
  208. }elseif(isset($_POST['gdwpm_cekbok_buang_dummy'])) { 
  209. $nonce = $_REQUEST['gdwpm_override_nonce']; 
  210.  
  211. if ( ! wp_verify_nonce( $nonce, 'gdwpm_override_dir' ) ) { 
  212. wp_die('<strong>Oops... failed!</strong>');  
  213. } else { 
  214. if($_POST['gdwpm_cekbok_buang_dummy'] == 'gdwpm_images') { 
  215. echo 'This virtual folder cannot be deleted.'; 
  216. }else{ 
  217. if(!isset($gdwpm_dummy_fol)) { $gdwpm_dummy_fol = get_option('gdwpm_dummy_folder');} 
  218. $targetbuangvirdir = $_POST['gdwpm_cekbok_buang_dummy']; 
  219. if($gdwpm_dummy_fol['dirname'] == $targetbuangvirdir) {$gdwpm_dummy_fol['dirname'] = 'gdwpm_images';} 
  220. if(($konci = array_search($targetbuangvirdir, $gdwpm_dummy_fol['dirlist'])) !== false) { 
  221. unset($gdwpm_dummy_fol['dirlist'][$konci]); 
  222. update_option('gdwpm_dummy_folder', $gdwpm_dummy_fol);  
  223. echo $targetbuangvirdir . ' has been deleted!'; 
  224. }elseif(isset($_POST['gdwpm_cekbok_opsi_dummy'])) { 
  225. $nonce = $_REQUEST['gdwpm_override_nonce']; 
  226.  
  227. if ( ! wp_verify_nonce( $nonce, 'gdwpm_override_dir' ) ) { 
  228. die('<strong>Oops... failed!</strong>');  
  229. } else { 
  230. if(!isset($gdwpm_dummy_fol)) { $gdwpm_dummy_fol = get_option('gdwpm_dummy_folder');} 
  231. $dirdef = $_POST['gdwpm_opsi_dummy_dirdef']; 
  232. $dirbaru = sanitize_title_with_dashes($_POST['gdwpm_opsi_dummy_dirname']); 
  233. $gdwpm_dummy_fol['status'] = $_POST['gdwpm_cekbok_opsi_dummy']; 
  234. if($_POST['gdwpm_cekbok_opsi_dummy'] == 'checked') { 
  235. $gdwpm_dummy_fol['pattern'] = $_POST['gdwpm_opsi_dummy_pattern']; 
  236. $gdwpm_dummy_fol['pref'] = $_POST['gdwpm_opsi_dummy_pref']; 
  237. if(isset($_POST['gdwpm_opsi_dummy_dirname']) && !empty($_POST['gdwpm_opsi_dummy_dirname'])) { 
  238. if(!in_array($dirbaru, $gdwpm_dummy_fol['dirlist'])) { 
  239. $gdwpm_dummy_fol['dirname'] = $dirbaru; 
  240. $gdwpm_dummy_fol['dirlist'][] = $dirbaru; 
  241. update_option('gdwpm_dummy_folder', $gdwpm_dummy_fol);  
  242. echo $dirbaru . ' has been created and selected as a dummy folder. Option saved!'; 
  243. }else{ 
  244. echo $dirbaru.' already exists. Nothing to save.'; 
  245. }else{ 
  246. $gdwpm_dummy_fol['dirname'] = $dirdef; 
  247. update_option('gdwpm_dummy_folder', $gdwpm_dummy_fol);  
  248. echo $dirdef.' as default dummy folder. Option saved'; 
  249. }else{ 
  250. update_option('gdwpm_dummy_folder', $gdwpm_dummy_fol);  
  251. echo 'Option saved!'; 
  252. }elseif(isset($_REQUEST['gdwpm_tabulasi'])) { 
  253. if($_REQUEST['gdwpm_tabulasi'] == 'opsyen') { 
  254. $nonce = $_REQUEST['gdwpm_tab_opsi_nonce']; 
  255. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tab_opsi_key' ) ) { 
  256. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  257. } else { 
  258. require_once 'google-drive-wp-media-options.php'; 
  259. }elseif($_REQUEST['gdwpm_tabulasi'] == 'infosyen') { 
  260. $nonce = $_REQUEST['gdwpm_tab_info_nonce']; 
  261. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tab_opsi_key' ) ) { 
  262. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  263. } else { 
  264. require_once 'google-drive-wp-media-info.php'; 
  265. }elseif($_REQUEST['gdwpm_tabulasi'] == 'docapi') { 
  266. $nonce = $_REQUEST['gdwpm_tabulasi_nonce']; 
  267. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tabulasi_ajax' ) ) { 
  268. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  269. } else { 
  270. require_once 'google-drive-wp-media-docapi.php'; 
  271. }elseif($_REQUEST['gdwpm_tabulasi'] == 'docserv') { 
  272. $nonce = $_REQUEST['gdwpm_tabulasi_nonce']; 
  273. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tabulasi_ajax' ) ) { 
  274. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  275. } else { 
  276. require_once 'google-drive-wp-media-docservice.php'; 
  277. }elseif($_REQUEST['gdwpm_tabulasi'] == 'themeset') { 
  278. $nonce = $_REQUEST['gdwpm_tabulasi_themeset_nonce']; 
  279. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tabulasi_themeset_nonce' ) ) { 
  280. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  281. } else { 
  282. require_once 'google-drive-wp-media-themes.php'; 
  283. }elseif($_REQUEST['gdwpm_tabulasi'] == 'albums') { 
  284. $nonce = $_REQUEST['gdwpm_tabulasi_albums_nonce']; 
  285. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tabulasi_albums_nonce' ) ) { 
  286. wp_die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  287. } else { 
  288. require_once 'google-drive-wp-media-albums.php'; 
  289. }elseif($_REQUEST['gdwpm_tabulasi'] == 'galleries') { 
  290. $nonce = $_REQUEST['gdwpm_tabulasi_galleries_nonce']; 
  291. if ( ! wp_verify_nonce( $nonce, 'gdwpm_tabulasi_galleries_nonce' ) ) { 
  292. wp_die('<div class="error"><p>Oops.. security check is not ok.</p></div>');  
  293. } else { 
  294. if(isset($_REQUEST['paged'])) { 
  295. $paged = $_REQUEST['paged']; 
  296. if(isset($_REQUEST['delete'])) { 
  297. $gdwpmbuang_gal = wp_delete_post(trim($_REQUEST['delete']), true); 
  298. if($gdwpmbuang_gal) { 
  299. echo '<div class="updated"><p>Gallery ID="' . $_REQUEST['delete'] . '" successfully deleted.</p></div>'; 
  300. }else{ 
  301. echo '<div class="error"><p>Gallery ID="' . $_REQUEST['delete'] . '" cannot deleted!</p></div>'; 
  302. require_once 'google-drive-wp-media-galleries.php'; 
  303. }else{ 
  304. wp_die('<div class="error"><p>Oops.. something goes wrong!</p></div>');  
  305. }elseif(isset($_POST['gdwpm_opsi_theme_css'])) { 
  306. $nonce = $_REQUEST['gdwpm_theme_setting_nonce']; 
  307.  
  308. if ( ! wp_verify_nonce( $nonce, 'gdwpm_theme_setting_nonce' ) ) { 
  309. die('<strong>Oops... failed!</strong>');  
  310. } else { 
  311.  
  312. update_option('gdwpm_nama_theme_css', $_POST['gdwpm_opsi_theme_css']);  
  313.  
  314. }elseif(isset($_REQUEST['gdwpm_nonce_aplod_berkas'])) { 
  315. $nonce = $_REQUEST['gdwpm_nonce_aplod_berkas']; 
  316. if ( ! wp_verify_nonce( $nonce, 'gdwpm_satpam_aplod_berkas' ) ) { 
  317. die('<div class="error"><p>Oops.. security check is not ok!</p></div>');  
  318.  
  319. } else { 
  320. if (empty($_FILES) || $_FILES["file"]["error"]) { 
  321. wp_die('<div class="error"><p>Oops.. error, upload failed! '.$_FILES["file"]["error"].'</p></div>'); 
  322. if (isset($_REQUEST["gdpwm_nama_file"])) { 
  323. $filename = $_REQUEST["gdpwm_nama_file"]; 
  324. } elseif (!empty($_FILES)) { 
  325. $filename = $_FILES["file"]["name"]; 
  326. } else { 
  327. $filename = uniqid("file_"); 
  328. //if(CHUNK_INTERNAL) { 
  329. $gdwpm_opsi_chunk = get_option('gdwpm_opsi_chunk'); 
  330. if($gdwpm_opsi_chunk['local']['cekbok'] == 'checked') { 
  331. $targetDir = ini_get("upload_tmp_dir"); 
  332. $maxFileAge = 5 * 3600; // Temp file age in seconds 
  333. // Create target dir 
  334. if (!file_exists($targetDir)) { 
  335. //@mkdir($targetDir); 
  336. if (!file_exists($targetDir = sys_get_temp_dir())) { 
  337. $upload_dir = wp_upload_dir(); 
  338. if (!file_exists($targetDir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'gdwpm-tmp')) { 
  339. @mkdir($targetDir); 
  340.  
  341. $filePath = $targetDir . DIRECTORY_SEPARATOR . $filename; 
  342.  
  343. // Chunking might be enabled 
  344. $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; 
  345. $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; 
  346.  
  347. if (!is_dir($targetDir) || !$dir = opendir($targetDir)) { 
  348. die('<div class="error"><p>Oops.. error. Failed to open temp directory.</p></div>'); 
  349.  
  350. while (($file = readdir($dir)) !== false) { 
  351. $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file; 
  352.  
  353. // If temp file is current file proceed to the next 
  354. if ($tmpfilePath == "{$filePath}.part") { 
  355. continue; 
  356.  
  357. // Remove temp file if it is older than the max age and is not the current file 
  358. if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) { 
  359. @unlink($tmpfilePath); 
  360. closedir($dir); 
  361.  
  362. // Open temp file 
  363. if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) { 
  364. die('<div class="error"><p>Oops.. error. Failed to open output stream.</p></div>'); 
  365.  
  366. if (!empty($_FILES)) { 
  367. if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) { 
  368. die('<div class="error"><p>Oops.. error. Failed to move uploaded file.</p></div>'); 
  369.  
  370. // Read binary input stream and append it to temp file 
  371. if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) { 
  372. die('<div class="error"><p>Oops.. error. Failed to open input stream.</p></div>'); 
  373. } else {  
  374. if (!$in = @fopen("php://input", "rb")) { 
  375. die('<div class="error"><p>Oops.. error. Failed to open input stream.</p></div>'); 
  376.  
  377. while ($buff = fread($in, 4096)) { 
  378. fwrite($out, $buff); 
  379.  
  380. @fclose($out); 
  381. @fclose($in); 
  382.  
  383. }else{ 
  384. $chunks = true; 
  385. // Check if file has been uploaded 
  386. if (!$chunks || $chunk == $chunks - 1) { 
  387. // Strip the temp .part suffix off  
  388. if($filePath) { 
  389. rename("{$filePath}.part", $filePath); 
  390. }else{  
  391. $filePath = $_FILES["file"]["tmp_name"]; 
  392.  
  393. if(!$gdwpm_service) { 
  394. $gdwpm_service = new GDWPMBantuan( $gdwpm_opt_akun[1], $gdwpm_opt_akun[2], $gdwpm_opt_akun[3] ); 
  395.  
  396. $mime_berkas_arr = wp_check_filetype($filename); 
  397. $mime_berkas = $mime_berkas_arr['type']; 
  398. if(empty($mime_berkas)) {$mime_berkas = $_FILES['file']['type'];} 
  399. $folder_ortu = preg_replace("/[^a-zA-Z0-9]+/", " ", $_POST['gdpwm_nm_br']); 
  400. $folder_ortu = trim(sanitize_text_field($folder_ortu)); 
  401. $folderId = $_POST['gdpwm_nm_id']; 
  402. $nama_polder = $_POST['gdpwm_nm_bks']; 
  403.  
  404. if($folder_ortu != '') { 
  405. //cek folder array id namafolder 
  406. $last_folder = get_option('gdwpm_new_folder_kecing'); 
  407. if($folder_ortu != $last_folder[1]) { 
  408. $folderId = $gdwpm_service->getFolderIdByName( $folder_ortu ); 
  409. if( $folderId ) { update_option('gdwpm_new_folder_kecing', array($folderId, $folder_ortu)); } 
  410. $nama_polder = $folder_ortu; 
  411. }else{ 
  412. $folderId = $last_folder[0]; 
  413. $nama_polder = $last_folder[1]; 
  414.  
  415. $content = $_POST['gdpwm_sh_ds']; 
  416.  
  417. if( ! $folderId ) { 
  418. $folderId = $gdwpm_service->createFolder( $folder_ortu ); 
  419. $gdwpm_service->setPermissions( $folderId, $gdwpm_opt_akun[0] ); 
  420. update_option('gdwpm_new_folder_kecing', array($folderId, $nama_polder)); 
  421.  
  422. if(strpos($mime_berkas_arr['type'], 'image') !== false) { 
  423. // cek gambar if img auto create thumb .. array('checked', '', '122', '122', 'false'); 
  424. $gdwpm_img_thumbs = get_option('gdwpm_img_thumbs'); 
  425. // ITUNG DIMENSI 
  426. $image = wp_get_image_editor( $filePath ); 
  427. if ( !is_wp_error( $image ) ) { 
  428. $ukuran_asli = $image->get_size(); // $ukuran_asli['width']; $ukuran_asli['height']; 
  429. $idthumb_w_h = ''; 
  430. if ($gdwpm_img_thumbs[0] == 'checked') { 
  431. $folderId_thumb = $gdwpm_img_thumbs[1]; 
  432. if(empty($folderId_thumb) || $folderId_thumb == '') { 
  433. //$folderId_thumb = $gdwpm_service->getFolderIdByName( 'gdwpm-thumbnails' ); 
  434. //if(!$folderId_thumb) { 
  435. $folderId_thumb = $gdwpm_service->createFolder( 'gdwpm-thumbnails' ); 
  436. $gdwpm_service->setPermissions( $folderId_thumb, $gdwpm_opt_akun[0] ); 
  437. //} 
  438. $gdwpm_img_thumbs[1] = trim($folderId_thumb); 
  439. update_option('gdwpm_img_thumbs', $gdwpm_img_thumbs); 
  440. if ( $ukuran_asli ) { 
  441. if($gdwpm_img_thumbs[4] == 'true') { 
  442. $image->resize( $gdwpm_img_thumbs[2], $gdwpm_img_thumbs[3], true ); 
  443. }else{ 
  444. $image->resize( $gdwpm_img_thumbs[2], $gdwpm_img_thumbs[3], false ); 
  445. $img = $image->save(); // path, file, mime-type 
  446. $filename_thumb = $img['file']; 
  447. $filePath_thumb = $img['path']; 
  448. $mime_berkas_thumb = $img['mime-type']; 
  449. $imgwidth_thumb = $img['width']; 
  450. $imgheight_thumb = $img['height']; 
  451. $fileParent_thumb = new Google_ParentReference(); 
  452. $fileParent_thumb->setId( $folderId_thumb );  
  453. $fileId_thumb = $gdwpm_service->createFileFromPath( $filePath_thumb, $filename_thumb, $content, $fileParent_thumb ); 
  454. $gdwpm_service->setPermissions( $fileId_thumb, 'me', 'reader', 'anyone' ); 
  455. $idthumb_w_h = 'thumbId:' . $fileId_thumb . ' thumbWidth:' . $imgwidth_thumb . ' thumbHeight:' . $imgheight_thumb; 
  456. $gdwpm_sizez_meta = 'selfWidth:' . $ukuran_asli['width'] . ' selfHeight:' . $ukuran_asli['height'] . ' ' . $idthumb_w_h; 
  457. @unlink($filename_thumb); 
  458. }else{ 
  459. $gdwpm_sizez_meta = ''; 
  460. }  
  461.  
  462. $fileParent = new Google_ParentReference(); 
  463. $fileParent->setId( $folderId );  
  464.  
  465. //$fileId = $gdwpm_service->createFileFromPath( $_FILES["file"]["tmp_name"], $filename, $content, $fileParent ); 
  466. $fileId = $gdwpm_service->createFileFromPath( $filePath, $filename, $content, $fileParent ); 
  467. if($fileId) { 
  468. $gdwpm_service->setPermissions( $fileId, 'me', 'reader', 'anyone' ); 
  469. if(strpos($mime_berkas_arr['type'], 'image') !== false && !empty($gdwpm_sizez_meta)) { 
  470. $gdwpm_service->insertProperty($fileId, 'gdwpm-sizes', $gdwpm_sizez_meta); 
  471. $sukinfo = ''; 
  472. $metainfo = ''; 
  473. if(!empty($mime_berkas) && isset($_POST['gdpwm_med_ly']) == '1') { 
  474. /** if(strpos($mime_berkas_arr['type'], 'video') !== false) { 
  475. $gdwpm_meta_arr = wp_read_video_metadata( $filePath ); 
  476. $metainfo = json_encode($gdwpm_meta_arr); 
  477. }elseif(strpos($mime_berkas_arr['type'], 'audio') !== false) { 
  478. $gdwpm_meta_arr = wp_read_audio_metadata( $filePath ); 
  479. $metainfo = json_encode($gdwpm_meta_arr); 
  480. }elseif(strpos($mime_berkas_arr['type'], 'image') !== false) { 
  481. $gdwpm_meta_arr = wp_read_image_metadata( $filePath ); 
  482. $metainfo = json_encode($gdwpm_meta_arr); 
  483. */ 
  484. gdwpm_ijin_masuk_perpus($mime_berkas, $filename, $fileId, $content, $nama_polder, $gdwpm_sizez_meta, $metainfo); 
  485. $sukinfo = ' and added into your Media Library'; 
  486. echo '<div class="updated"><p>'.$filename.' (<strong>'.$fileId.'</strong>) successfully uploaded to <strong>'.$nama_polder.'</strong>'.$sukinfo.'.</p></div>'; 
  487. }else{ 
  488. echo '<div class="error"><p>Failed to upload <strong>'.$filename.'</strong> to Google Drive.</p></div>'; 
  489. @unlink($filePath); 
  490. wp_die(); 
  491. wp_die();