Пример #1
0
function baseurl()
{
    if (isset($GLOBALS['CONFIG']['BASEURL'])) {
        $base = $GLOBALS['CONFIG']['BASEURL'];
        if (startswith('//', $base)) {
            $base = proto() . ':' . $base;
        }
        return forceslash(forceslash($base) . @$GLOBALS['MANDATOR']);
    }
    $base = ssl() ? 'https://' : 'http://';
    $base .= $_SERVER['HTTP_HOST'];
    $base .= forceslash(dirname($_SERVER['SCRIPT_NAME']));
    return forceslash(forceslash($base) . @$GLOBALS['MANDATOR']);
}
Пример #2
0
if ($user->AsSquidAdministrator == false) {
    $tpl = new templates();
    echo "alert('" . $tpl->javascript_parse_text("{ERROR_NO_PRIVS}") . "');";
    die;
    exit;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_GET["ports"])) {
    ports();
    exit;
}
if (isset($_GET["ssl"])) {
    ssl();
    exit;
}
if (isset($_GET["meta"])) {
    meta();
    exit;
}
if (isset($_GET["acls"])) {
    acls();
    exit;
}
if (isset($_GET["acls-extern"])) {
    acls_extern();
    exit;
}
if (isset($_GET["caches"])) {
 /**
  * @brief Variable setzen
  * @param string $name Der Name der Variablen
  * @param mixed $value Der Wert
  * @param int $expire Verfallzeit in Sekunden (Vorgabe: 100 Tage)
  * @sa TCookies::__set()
  */
 public function set($name, $value = null, $expire = 8640000)
 {
     if (null === $value) {
         $this->delete($name);
         return;
     }
     $_COOKIE[$name] = $value;
     if (headers_sent()) {
         return;
     }
     setcookie($name, (string) $value, time() + $expire, path(), $this->host, ssl());
 }
Пример #4
0
/**
 * @brief Liefert die Basis-URL.
 * @param bool $withpath Wenn @b TRUE wird der Pfad ebenfalls zurückgegeben
 * @return string Basis-URL
 * @see path()
 * @ingroup api
 */
function url($withpath = true)
{
    static $result;
    // Da die Variable als Index verwendet wird, muss der Inhalt immer konsistent sein.
    //
    if ($withpath) {
        $withpath = 'yes';
    } else {
        $withpath = 'no';
    }
    // Altes Ergebnis nehmen, wenn möglich
    //
    if (isset($result) && array_key_exists($withpath, $result)) {
        return $result[$withpath];
    }
    // Dummy erzeugen
    //
    $result = array();
    // Server-Namen holen
    //
    if (empty($_SERVER['SERVER_NAME'])) {
        $server = getenv('HTTP_HOST');
    } else {
        $server = $_SERVER['SERVER_NAME'];
    }
    // Protokoll ermitteln
    //
    if (ssl()) {
        $proto = 'https://';
    } else {
        $proto = 'http://';
    }
    $result['no'] = $proto . $server;
    $result['yes'] = $proto . $server . path();
    if (substr($result['yes'], strlen($result['yes']) - 1, 1) == '/') {
        $result['yes'] = substr($result['yes'], 0, strlen($result['yes']) - 1);
    }
    return $result[$withpath];
}
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $ident = esc_attr($instance['ident']);
     $ident_type = esc_attr($instance['ident_type']);
     if ($ident_type == "playlist") {
         if (substr($ident, 0, 2) == "PL") {
             $ident = substr($ident, 2);
         }
     }
     $titles = esc_attr($instance['titles']);
     $num = esc_attr($instance['num_videos']);
     $autoplay = esc_attr($instance['autoplay']);
     $fil = esc_attr($instance['filter']);
     $width = esc_attr($instance['width']);
     $height = $width * 3 / 4;
     $key = "AI39si4egIgiaFaxxolUNjk1Iw4ip4GHWJMt44ZpnWXidiFLjlX1_kSwUYUI-bhtK9oW3bvZ7CFe7syG__AtokRmrTMDYHdXvA";
     $vidid_url = ssl() . "://gdata.youtube.com/feeds/api/videos/{$ident}?v=2&key={$key}";
     $username_url = ssl() . "://gdata.youtube.com/feeds/base/users/{$ident}/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile&key={$key}";
     $playlist_url = ssl() . "://gdata.youtube.com/feeds/api/playlists/{$ident}?v=2&key={$key}";
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $output = "<div id='youtube-sidebar-widget' data-url='{$playlist_url}'>\n\r";
     $i = 1;
     if ($ident_type == "username") {
         $curl_r = curl_it($username_url);
         if ($simple_xml = simplexml_load_string($curl_r)) {
             $youtube_is_up = true;
         } else {
             $youtube_is_up = false;
         }
         /*echo "<pre>";
         		print_r($simple_xml);
         		echo "</pre>";*/
         if ($youtube_is_up) {
             $output .= "<ul>\n\r";
             foreach ($simple_xml->channel->item as $item) {
                 if ($fil) {
                     if (strpos($item->description, $fil)) {
                         if ($i <= $num) {
                             $link = explode("/watch?v=", $item->link);
                             $hash = explode("&", $link[1]);
                             $img = ssl() . "://i2.ytimg.com/vi/{$hash['0']}/0.jpg";
                             if ($titles == "yes") {
                                 $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r<a href='{$item->link}' style='width: " . $width . "px;'>{$item->title}</a>";
                             } else {
                                 $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r";
                             }
                             $i++;
                         } else {
                             break;
                         }
                     }
                 } else {
                     if ($i <= $num) {
                         $link = explode("/watch?v=", $item->link);
                         $hash = explode("&", $link[1]);
                         $img = ssl() . "://i2.ytimg.com/vi/{$hash['0']}/0.jpg";
                         if ($titles == "yes") {
                             $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r<a href='{$item->uri}' style='width: " . $width . "px;'>{$item->title}</a>";
                         } else {
                             $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r";
                         }
                         $i++;
                     } else {
                         break;
                     }
                 }
             }
             $output .= "</ul>\n\r";
         } else {
             $output .= "<p class='ysw-unavailable'>Service Unavailable.</p>";
         }
     } elseif ($ident_type == "vidid") {
         $curl_r = curl_it($vidid_url);
         if ($simple_xml = simplexml_load_string($curl_r)) {
             $youtube_is_up = true;
         } else {
             $youtube_is_up = false;
         }
         /*echo "<pre>";
         		print_r($simple_xml);
         		echo "</pre>";*/
         if ($youtube_is_up) {
             $output .= "<ul>\n\r";
             $item = $simple_xml;
             if ($i <= $num) {
                 $link = explode("watch?v=", $item->link['href']);
                 $hash = explode("&", $link[1]);
                 $img = ssl() . "://i2.ytimg.com/vi/{$hash['0']}/0.jpg";
                 if ($titles == "yes") {
                     $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r<a href='{$item->link}' style='width: " . $width . "px;'>{$item->title}</a>";
                 } else {
                     $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='" . strip_tags($item->description) . "' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r";
                 }
                 $i++;
             } else {
                 break;
             }
             $output .= "</ul>\n\r";
         } else {
             $output .= "<p class='ysw-unavailable'>Service Unavailable.</p>";
         }
     } elseif ($ident_type == "playlist") {
         $curl_r = curl_it($playlist_url);
         if ($simple_xml = simplexml_load_string($curl_r)) {
             $youtube_is_up = true;
         } else {
             $youtube_is_up = false;
         }
         if ($youtube_is_up) {
             $output .= "<ul>\n\r";
             foreach ($simple_xml->entry as $item) {
                 foreach ($item->link as $link_url) {
                     if ($link_url['type'] == "text/html" && $link_url['rel'] == "alternate") {
                         if ($i <= $num) {
                             $link = explode("/watch?v=", $link_url['href']);
                             $hash = explode("&", $link[1]);
                             $img = ssl() . "://i2.ytimg.com/vi/{$hash['0']}/0.jpg";
                             if ($titles == "yes") {
                                 $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='{$item->title}' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r<a href='{$item->link}' style='width: " . $width . "px;'>{$item->title}</a>";
                             } else {
                                 $output .= "<li id='{$hash['0']}' data-autoplay='{$autoplay}'><img src='{$img}' alt='{$item->title}' desc='{$item->title}' style='width:" . $width . "px;' /><div class='play_arrow' style='width:" . $width . "px; height: " . $height . "px; margin-top: -" . $height . "px;'></div>\n\r";
                             }
                             $i++;
                         } else {
                             break;
                         }
                     }
                 }
             }
             $output .= "</ul>\n\r";
         } else {
             $output .= "<p class='ysw-unavailable'>Service Unavailable.</p>";
         }
     }
     $output .= "</div>\n\r";
     echo $output;
     echo $after_widget;
 }