· 6 years ago · May 25, 2019, 08:34 PM
1<?php
2$ENABLE_kiikun = 1;
3
4function get_gd_id($string) {
5if(ereg('folders', $string)){
6return str_replace('?usp=sharing', '', basename('https://drive.google.com/drive/folders/'.$string.'?usp=sharing'));
7}else{
8 if (strpos($string, "/edit")) {
9 $string = str_replace("/edit", "/view", $string);
10 } else if (strpos($string, "?id=")) {
11 $parts = parse_url($string);
12 parse_str($parts['query'], $query);
13 return $query['id'];
14 } else if (!strpos($string, "/view")) {
15 $string = $string . "/view";
16 }
17 $start = "file/d/";
18 $end = "/view";
19 $string = " " . $string;
20 $ini = strpos($string, $start);
21 if ($ini == 0) {
22 return "";
23 }
24 $ini += strlen($start);
25 $len = strpos($string, $end, $ini) - $ini;
26 return substr($string, $ini, $len);
27}
28}
29function fnEncrypt( $string) {
30 $secret_key = 'drivekey';
31 $secret_iv = 'google';
32 $output = false;
33 $encrypt_method = "AES-256-CBC";
34 $key = hash( 'sha256', $secret_key );
35 $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
36 $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
37 return $output;
38}
39
40function kiikun($content){
41 global $ENABLE_kiikun;
42 if($ENABLE_kiikun){
43 $domen = 'http://space.kiikun.com/';
44 preg_match_all('/href="(.*?)"/s', $content, $matches);
45 foreach($matches[1] as $link){
46 if(ereg('drive.google.com', $link)){
47 $asli[] = $link;
48 $ganti[] = $domen.'?id='.fnEncrypt(get_gd_id($link));
49 }
50 }
51 $crot = str_replace($asli, $ganti, $content);
52 return apply_filters('the_content', $crot);
53 }else{
54 return $content;
55 }
56}
57?>