function generateUrl() { //$newHost = "https://nowsci.com/s/"; $host = OCP\Config::getAppValue('shorten', 'host', ''); $type = OCP\Config::getAppValue('shorten', 'type', ''); $api = OCP\Config::getAppValue('shorten', 'api', ''); $curUrl = $_POST['curUrl']; $ret = ""; if (isset($type) && ($type == "" || $type == "internal")) { if ($host == "" || startsWith($curUrl, $host)) { $ret = $curUrl; } else { $shortcode = getShortcode($curUrl); $newUrl = $host."?".$shortcode; $ret = $newUrl; } } elseif ($type == "googl") { if ($api && $api != "") { require_once __DIR__ . '/../lib/class.googl.php'; $googl = new googl($api); $short = $googl->s($curUrl); $ret = $short; } else { $ret = $curUrl; } } else { $ret = $curUrl; } return $ret; }
<td>댓글</td> <td>태그</td> <td>내용</td> <td>프/사</td> <td>이름</td> <td>등록일</td> <td>location</td> <td>Filter</td> <td>Short Code</td> <td>ID</td> </tr> <?php $count = 0; foreach ($ids as $id) { $result = getShortcode($id, $accessToken); //The results $count = $count + 1; $short_code = $id; $username = $result->data->user->username; $userid = $result->data->user->id; $profile_picture = $result->data->user->profile_picture; $link = $result->data->link; $comments = $result->data->comments->count; $likes = $result->data->likes->count; $caption = $result->data->caption->text; $img_low = $result->data->images->low_resolution->url; $img_thum = $result->data->images->thumbnail->url; $img_std = $result->data->images->standard_resolution->url; $created_time = $result->data->created_time; $location = $result->data->location->name;
$query = OCP\DB::prepare('INSERT INTO *PREFIX*shorten (uid, shortcode, url) VALUES (?,?,?)'); $query->execute(Array($uid,$shortcode,$url)); $id = OCP\DB::insertid('*PREFIX*shorten'); } else $shortcode = rand_chars(6); } } return $shortcode; } $curUrl = $_POST['curUrl']; if (isset($type) && ($type == "" || $type == "internal")) { if ($host == "" || startsWith($curUrl, $host)) { echo $curUrl; } else { $shortcode = getShortcode($curUrl); $newUrl = $host."?".$shortcode; echo $newUrl; } } elseif ($type == "googl") { if ($api && $api != "") { require_once __DIR__ . '/../lib/class.googl.php'; $googl = new googl($api); $short = $googl->s($curUrl); echo $short; } else { echo $curUrl; } } else { echo $curUrl; }