Beispiel #1
0
 public function embed_tag($video, $field = null)
 {
     # We use this for previewing too
     if (isset($field) and $field != "embed") {
         return $video;
     }
     # If they're previewing and the field argument isn't the embed, return the original.
     if (preg_match("/http:\\/\\/(www\\.|[a-z]{2}\\.)?youtube\\.com\\/watch\\?v=([^&]+)/", $video, $matches)) {
         return '<object type="application/x-shockwave-flash" class="object-youtube" data="http://' . $matches[1] . 'youtube.com/v/' . $matches[2] . '" width="468" height="391"><param name="movie" value="http://' . $matches[1] . 'youtube.com/v/' . $matches[2] . '" /><param name="FlashVars" value="playerMode=embedded" /></object>';
     } else {
         if (preg_match("/^http:\\/\\/(www\\.)?vimeo.com\\/([0-9]+)/", $video, $matches)) {
             $site = get_remote("http://vimeo.com/" . $matches[2]);
             preg_match('/<div id="vimeo_player_[0-9]+" class="player" style="width:([0-9]+)px;height:([0-9]+)px;">/', $site, $scale);
             return '<object type="application/x-shockwave-flash" class="object-vimeo" width="' . $scale[1] . '" height="' . $scale[2] . '" data="http://www.vimeo.com/moogaloop.swf?clip_id=' . $matches[2] . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $matches[2] . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /></object>';
         } else {
             if (preg_match("/http:\\/\\/(www\\.)?metacafe.com\\/watch\\/([0-9]+)\\/([^\\/&\\?]+)/", $video, $matches)) {
                 return '<object type="application/x-shockwave-flash" class="object-metacafe" data="http://www.metacafe.com/fplayer/' . $matches[2] . '/' . $matches[3] . '.swf" width="400" height="345"></object>';
             } else {
                 if (preg_match("/http:\\/\\/(www\\.)?revver.com\\/video\\/([0-9]+)/", $video, $matches)) {
                     return '<script src="http://flash.revver.com/player/1.0/player.js?mediaId:' . $matches[2] . ';width:468;height:391;" type="text/javascript"></script>';
                 } else {
                     if (preg_match("/http:\\/\\/(www\\.)viddler\\.com\\/.+/", $video)) {
                         $viddler_page = get_remote($video);
                         if (preg_match("/<link\\s+rel=\"video_src\"\\s+href=\"http:\\/\\/(www\\.)?viddler.com\\/player\\/([0-9a-fA-F]+)/", $viddler_page, $matches) and preg_match("/<meta\\s+name=\"video_height\"\\s+content=\"([0-9]+)\"/", $viddler_page, $height) and preg_match("/<meta\\s+name=\"video_width\"\\s+content=\"([0-9]+)\"/", $viddler_page, $width)) {
                             return '<object type="application/x-shockwave-flash" data="http://www.viddler.com/player/' . $matches[2] . '/" width="' . $width[1] . '" height="' . $height[1] . '" id="viddler_' . $matches[2] . '" class="object-youtube"><param name="movie" value="http://www.viddler.com/player/' . $matches[2] . '/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>';
                         }
                         return $video;
                     }
                 }
             }
         }
     }
     return $video;
 }
 function load()
 {
     global $config;
     if ($this->exists() == true) {
         $this->import();
     } else {
         if (viscacha_function_exists('xml_parser_create')) {
             $rssnews = get_remote('http://version.viscacha.org/news/rss');
             include 'classes/magpie_rss/rss_fetch.inc.php';
             $rss = new MagpieRSS($rssnews);
             $news = '';
             foreach ($rss->items as $item) {
                 $news .= '<li><a href="' . htmlspecialchars($item['link']) . '" style="font-weight: bold;" target="_blank">' . htmlspecialchars($item['title']) . '</a>';
                 if (isset($item['description'])) {
                     $news .= '<br /><span style="font-size: 0.9em;">' . htmlspecialchars($item['description']) . '</span>';
                 }
                 $news .= '</li>';
             }
             if (!empty($news)) {
                 $news = '<ul>' . $news . '</ul>';
             }
         } else {
             $news = get_remote('http://version.viscacha.org/news');
         }
         $this->data = array('comp' => get_remote('http://version.viscacha.org/compare/?version=' . base64_encode($config['version'])), 'version' => get_remote('http://version.viscacha.org/version'), 'news' => $news);
         $this->export();
     }
 }
 function load()
 {
     global $config;
     if ($this->exists() == true) {
         $this->import();
     } else {
         global $config, $admconfig;
         $this->data = array();
         $myini = new INI();
         $servers = explode(';', $admconfig['package_server']);
         if (is_array($servers)) {
             foreach ($servers as $server) {
                 $content = get_remote($server . '/external.ini');
                 if ($content != REMOTE_CLIENT_ERROR) {
                     $inis = $myini->parse($content);
                     if (!isset($inis['files'])) {
                         break;
                     }
                     foreach ($inis['files'] as $type => $remotefile) {
                         if (!isset($this->data[$type])) {
                             $this->data[$type] = array();
                         }
                         if (empty($remotefile)) {
                             continue;
                         }
                         $path = $server . '/' . $remotefile;
                         $content = get_remote($path);
                         if ($content != REMOTE_CLIENT_ERROR) {
                             $new_data = $myini->parse($content);
                             if (!isset($new_data['categories'])) {
                                 continue;
                             }
                             foreach ($new_data['categories'] as $cid => $cname) {
                                 $this->data[$type]['categories'][$cid] = array('name' => $cname, 'entries' => 0);
                                 $this->data[$type][$cid] = array();
                             }
                             foreach ($new_data as $key => $row) {
                                 if ($key == 'categories') {
                                     continue;
                                 } else {
                                     if (!isset($row['category']) || !isset($this->data[$type]['categories'][$row['category']])) {
                                         continue;
                                     }
                                     if (isset($this->data[$type][$row['internal']]) && version_compare($this->data[$type][$this->data[$type][$row['internal']]][$row['internal']]['version'], $row['version'], ">") || !isset($this->data[$type][$row['internal']])) {
                                         $row['server'] = $server;
                                         $this->data[$type]['categories'][$row['category']]['entries']++;
                                         $this->data[$type][$row['category']][$row['internal']] = $row;
                                         $this->data[$type][$row['internal']] = $row['category'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $this->export();
     }
 }
Beispiel #4
0
 public function main_index($main)
 {
     $config = Config::current();
     if ($config->disable_aggregation or time() - $config->last_aggregation < $config->aggregate_every * 60) {
         return;
     }
     $aggregates = (array) $config->aggregates;
     if (empty($aggregates)) {
         return;
     }
     foreach ($aggregates as $name => $feed) {
         $xml_contents = preg_replace(array("/<(\\/?)dc:date>/", "/xmlns=/"), array("<\\1date>", "a="), get_remote($feed["url"]));
         $xml = simplexml_load_string($xml_contents, "SimpleXMLElement", LIBXML_NOCDATA);
         if ($xml === false) {
             continue;
         }
         # Flatten namespaces recursively
         $this->flatten($xml);
         $items = array();
         if (isset($xml->entry)) {
             foreach ($xml->entry as $entry) {
                 array_unshift($items, $entry);
             }
         } elseif (isset($xml->item)) {
             foreach ($xml->item as $item) {
                 array_unshift($items, $item);
             }
         } else {
             foreach ($xml->channel->item as $item) {
                 array_unshift($items, $item);
             }
         }
         foreach ($items as $item) {
             $date = oneof(@$item->pubDate, @$item->date, @$item->updated, 0);
             $updated = strtotime($date);
             if ($updated > $feed["last_updated"]) {
                 # Get creation date ('created' in Atom)
                 $created = @$item->created ? strtotime($item->created) : 0;
                 if ($created <= 0) {
                     $created = $updated;
                 }
                 # Construct the post data from the user-defined XPath mapping:
                 $data = array("aggregate" => $name);
                 foreach ($feed["data"] as $attr => $field) {
                     $field = !empty($field) ? $this->parse_field($field, $item) : "";
                     $data[$attr] = is_string($field) ? $field : YAML::dump($field);
                 }
                 if (isset($data["title"]) or isset($data["name"])) {
                     $clean = sanitize(oneof(@$data["title"], @$data["name"]));
                 }
                 Post::add($data, $clean, null, $feed["feather"], $feed["author"], false, "public", datetime($created), datetime($updated));
                 $aggregates[$name]["last_updated"] = $updated;
             }
         }
     }
     $config->set("aggregates", $aggregates);
     $config->set("last_aggregation", time());
 }
Beispiel #5
0
 public function pingback_ping($args)
 {
     $config = Config::current();
     $linked_from = str_replace('&amp;', '&', $args[0]);
     $linked_to = str_replace('&amp;', '&', $args[1]);
     $cleaned_url = str_replace(array("http://www.", "http://"), "", $config->url);
     if ($linked_to == $linked_from) {
         return new IXR_ERROR(0, __("The from and to URLs cannot be the same."));
     }
     if (!substr_count($linked_to, $cleaned_url)) {
         return new IXR_Error(0, __("There doesn't seem to be a valid link in your request."));
     }
     if (preg_match("/url=([^&#]+)/", $linked_to, $url)) {
         $post = new Post(array("url" => $url[1]));
     } else {
         $post = MainController::current()->post_from_url(null, str_replace(rtrim($config->url, "/"), "/", $linked_to), true);
     }
     if (!$post) {
         return new IXR_Error(33, __("I can't find a post from that URL."));
     }
     # Wait for the "from" server to publish
     sleep(1);
     $from = parse_url($linked_from);
     if (empty($from["host"])) {
         return false;
     }
     if (empty($from["scheme"]) or $from["scheme"] != "http") {
         $linked_from = "http://" . $linked_from;
     }
     # Grab the page that linked here.
     $content = get_remote($linked_from);
     # Get the title of the page.
     preg_match("/<title>([^<]+)<\\/title>/i", $content, $title);
     $title = $title[1];
     if (empty($title)) {
         return new IXR_Error(32, __("There isn't a title on that page."));
     }
     $content = strip_tags($content, "<a>");
     $url = preg_quote($linked_to, "/");
     if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
         $url = str_replace("&", "&amp;", preg_quote($linked_to, "/"));
         if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
             $url = str_replace("&", "&#038;", preg_quote($linked_to, "/"));
             if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
                 return false;
             }
         }
     }
     $context[1] = truncate($context[1], 100, "...", true);
     $excerpt = strip_tags(str_replace($context[0], $context[1], $content));
     $match = preg_quote($context[1], "/");
     $excerpt = preg_replace("/.*?\\s(.{0,100}{$match}.{0,100})\\s.*/s", "\\1", $excerpt);
     $excerpt = "[...] " . trim(normalize($excerpt)) . " [...]";
     Trigger::current()->call("pingback", $post, $linked_to, $linked_from, $title, $excerpt);
     return _f("Pingback from %s to %s registered!", array($linked_from, $linked_to));
 }
 function load()
 {
     global $config;
     if ($this->exists() == true) {
         $this->import();
     } else {
         $this->data = array('comp' => get_remote('http://version.viscacha.org/compare/?version=' . base64_encode($config['version'])), 'version' => get_remote('http://version.viscacha.org/version'), 'news' => get_remote('http://version.viscacha.org/news'));
         $this->export();
     }
 }
function checkRemotePic($pic, $id)
{
    global $config, $filesystem;
    $avatar_data = get_remote($pic);
    if ($avatar_data == REMOTE_CLIENT_ERROR || $avatar_data == REMOTE_INVALID_URL) {
        return $avatar_data;
    }
    if (strlen($avatar_data) > $config['avfilesize']) {
        return REMOTE_FILESIZE_ERROR;
    }
    $filename = md5(uniqid($id));
    $origfile = 'temp/' . $filename;
    $filesystem->file_put_contents($origfile, $avatar_data);
    if (filesize($origfile) > $config['avfilesize']) {
        return REMOTE_FILESIZE_ERROR;
    }
    $imageinfo = @getimagesize($origfile);
    if (is_array($imageinfo)) {
        list($width, $height, $type) = $imageinfo;
    } else {
        return REMOTE_IMAGE_ERROR;
    }
    if ($width > $config['avwidth']) {
        return REMOTE_IMAGE_WIDTH_ERROR;
    }
    if ($height > $config['avheight']) {
        return REMOTE_IMAGE_HEIGHT_ERROR;
    }
    $types = explode(',', $config['avfiletypes']);
    $ext = image_type_to_extension($type);
    if (!in_array($ext, $types)) {
        return REMOTE_EXTENSION_ERROR;
    }
    $dir = 'uploads/pics/';
    $pic = $dir . $id . $ext;
    removeOldImages($dir, $id);
    @$filesystem->copy($origfile, $pic);
    return $pic;
}
	function readRssInfo() {
		if (!viscacha_function_exists('xml_parser_create')) {
			return false;
		}

		global $config;
		$rssData = get_remote('http://version.viscacha.org/news/rss/?version='.base64_encode($config['version']));

		$xml = xml_parser_create();
		xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, true);
		xml_set_element_handler($xml, array($this, "startRssElement"), array($this, "endRssElement"));
		xml_set_character_data_handler($xml, array($this, "getRssElementData"));
		$success = xml_parse($xml, $rssData);
		xml_parser_free($xml);

		if (!$success || empty($this->data['news'])) {
			$this->data['news'] = '';
			return false;
		}
		else {
			$this->data['news'] = '<ul>'.$this->data['news'].'</ul>';
			return true;
		}
	}
Beispiel #9
0
 public function __init()
 {
     $this->setField(array("attr" => "photo", "type" => "file", "label" => __("Photo", "photo")));
     if (isset($_GET['action']) and $_GET['action'] == "bookmarklet") {
         $this->setField(array("attr" => "from_url", "type" => "text", "label" => __("From URL?", "photo"), "optional" => true, "no_value" => true));
     }
     $this->setField(array("attr" => "caption", "type" => "text_block", "label" => __("Caption", "photo"), "optional" => true, "preview" => true, "bookmarklet" => "page_link"));
     $this->setFilter("caption", array("markup_text", "markup_post_text"));
     $this->respondTo("delete_post", "delete_file");
     $this->respondTo("filter_post", "filter_post");
     $this->respondTo("post_options", "add_option");
     $this->respondTo("admin_write_post", "swfupload");
     $this->respondTo("admin_edit_post", "swfupload");
     if (isset($_GET['url']) and preg_match("/http:\\/\\/(www\\.)?flickr\\.com\\/photos\\/([^\\/]+)\\/([0-9]+)/", $_GET['url'])) {
         $this->bookmarkletSelected();
         $page = get_remote($_GET['url']);
         preg_match("/class=\"photoImgDiv\">\n<img src=\"([^\\?\"]+)/", $page, $image);
         $this->setField(array("attr" => "from_url", "type" => "text", "label" => __("From URL?", "photo"), "optional" => true, "value" => $image[1]));
     }
     if (isset($_GET['url']) and preg_match("/\\.(jpg|jpeg|png|gif|bmp)\$/", $_GET['url'])) {
         $this->bookmarkletSelected();
         $this->setField(array("attr" => "from_url", "type" => "text", "label" => __("From URL?", "photo"), "optional" => true, "value" => $_GET['url']));
     }
 }
    if (count($delete) == 0) {
        error('admin.php?action=bbcodes&job=' . $type, $lang->phrase('admin_bbc_no_valid_selection'));
    }
    $db->query('DELETE FROM ' . $db->pre . 'textparser WHERE id IN (' . implode(',', $delete) . ')');
    $anz = $db->affected_rows();
    $delobj = $scache->load('bbcode');
    $delobj->delete();
    ok('admin.php?action=bbcodes&job=' . $type, $lang->phrase('admin_bbc_entries_successfully_deleted'));
} elseif ($job == 'custombb_export') {
    $id = $gpc->get('id', int);
    $result = $db->query("\n\tSELECT bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage\n\tFROM {$db->pre}bbcode\n\tWHERE id = '{$id}'\n\tLIMIT 1\n\t");
    $data = $db->fetch_assoc($result);
    $data['button'] = null;
    if (!empty($data['buttonimage']) && (preg_match('~^' . URL_REGEXP . '$~i', $data['buttonimage']) || file_exists(CBBC_BUTTONDIR . $data['buttonimage']))) {
        if (preg_match('~^' . URL_REGEXP . '$~i', $data['buttonimage'])) {
            $button = get_remote($data['buttonimage']);
        } else {
            $button = file_get_contents(CBBC_BUTTONDIR . $data['buttonimage']);
        }
        if ($button == REMOTE_CLIENT_ERROR || $button == REMOTE_INVALID_URL) {
            $data['buttonimage'] = '';
        } else {
            $ext = get_extension($data['buttonimage']);
            if (!in_array($ext, $imagetype_extension)) {
                $data['buttonimage'] = '';
            } else {
                $data['button'] = base64_encode($button);
            }
        }
    } else {
        $data['buttonimage'] = '';
Beispiel #11
0
 /**
  * Function: import_tumblr
  * Tumblr importing.
  */
 public function import_tumblr()
 {
     if (empty($_POST)) {
         redirect("/admin/?action=import");
     }
     if (!Visitor::current()->group->can("add_post")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
     }
     $config = Config::current();
     if (!in_array("text", $config->enabled_feathers) or !in_array("video", $config->enabled_feathers) or !in_array("audio", $config->enabled_feathers) or !in_array("chat", $config->enabled_feathers) or !in_array("photo", $config->enabled_feathers) or !in_array("quote", $config->enabled_feathers) or !in_array("link", $config->enabled_feathers)) {
         error(__("Missing Feather"), __("Importing from Tumblr requires the Text, Video, Audio, Chat, Photo, Quote, and Link feathers to be installed and enabled."));
     }
     if (ini_get("memory_limit") < 20) {
         ini_set("memory_limit", "20M");
     }
     if (!parse_url($_POST['tumblr_url'], PHP_URL_SCHEME)) {
         $_POST['tumblr_url'] = "http://" . $_POST['tumblr_url'];
     }
     set_time_limit(3600);
     $url = rtrim($_POST['tumblr_url'], "/") . "/api/read?num=50";
     $api = preg_replace("/<(\\/?)([a-z]+)\\-([a-z]+)/", "<\\1\\2_\\3", get_remote($url));
     $api = preg_replace("/ ([a-z]+)\\-([a-z]+)=/", " \\1_\\2=", $api);
     $xml = simplexml_load_string($api);
     if (!isset($xml->tumblelog)) {
         Flash::warning(__("The URL you specified does not seem to be a valid Tumblr site."), "/admin/?action=import");
     }
     $already_in = $posts = array();
     foreach ($xml->posts->post as $post) {
         $posts[] = $post;
         $already_in[] = $post->attributes()->id;
     }
     while ($xml->posts->attributes()->total > count($posts)) {
         set_time_limit(3600);
         $api = preg_replace("/<(\\/?)([a-z]+)\\-([a-z]+)/", "<\\1\\2_\\3", get_remote($url . "&start=" . count($posts)));
         $api = preg_replace("/ ([a-z]+)\\-([a-z]+)=/", " \\1_\\2=", $api);
         $xml = simplexml_load_string($api, "SimpleXMLElement", LIBXML_NOCDATA);
         foreach ($xml->posts->post as $post) {
             if (!in_array($post->attributes()->id, $already_in)) {
                 $posts[] = $post;
                 $already_in[] = $post->attributes()->id;
             }
         }
     }
     function reverse($a, $b)
     {
         if (empty($a) or empty($b)) {
             return 0;
         }
         return strtotime($a->attributes()->date) < strtotime($b->attributes()->date) ? -1 : 1;
     }
     set_time_limit(3600);
     usort($posts, "reverse");
     foreach ($posts as $key => $post) {
         set_time_limit(3600);
         if ($post->attributes()->type == "audio") {
             continue;
         }
         # Can't import Audio posts since Tumblr has the files locked in to Amazon.
         $translate_types = array("regular" => "text", "conversation" => "chat");
         $clean = "";
         switch ($post->attributes()->type) {
             case "regular":
                 $title = fallback($post->regular_title);
                 $values = array("title" => $title, "body" => $post->regular_body);
                 $clean = sanitize($title);
                 break;
             case "video":
                 $values = array("embed" => $post->video_player, "caption" => fallback($post->video_caption));
                 break;
             case "conversation":
                 $title = fallback($post->conversation_title);
                 $lines = array();
                 foreach ($post->conversation_line as $line) {
                     $lines[] = $line->attributes()->label . " " . $line;
                 }
                 $values = array("title" => $title, "dialogue" => implode("\n", $lines));
                 $clean = sanitize($title);
                 break;
             case "photo":
                 $values = array("filename" => upload_from_url($post->photo_url[0]), "caption" => fallback($post->photo_caption));
                 break;
             case "quote":
                 $values = array("quote" => $post->quote_text, "source" => preg_replace("/^&mdash; /", "", fallback($post->quote_source)));
                 break;
             case "link":
                 $name = fallback($post->link_text);
                 $values = array("name" => $name, "source" => $post->link_url, "description" => fallback($post->link_description));
                 $clean = sanitize($name);
                 break;
         }
         $values["imported_from"] = "tumblr";
         $new_post = Post::add($values, $clean, Post::check_url($clean), fallback($translate_types[(string) $post->attributes()->type], (string) $post->attributes()->type), null, false, "public", datetime((int) $post->attributes()->unix_timestamp), null, "", false);
         Trigger::current()->call("import_tumble", $post, $new_post);
     }
     Flash::notice(__("Tumblr content successfully imported!"), "/admin/?action=import");
 }
function do_aprs()
{
    // 3/15/11 - populates the APRS tracks table and updates responder position data
    global $ts_threshold;
    // 4/25/11
    global $istest;
    $the_key = trim(get_variable('aprs_fi_key'));
    if (empty($the_key)) {
        do_log($GLOBALS['LOG_ERROR'], 0, 0, "APRS_FI key required for APRS operation");
        return FALSE;
    }
    $dist_chk = $istest ? 2500000.0 : 250000.0;
    $pkt_ids = array();
    // 6/17/08
    $speeds = array();
    // 10/2/08
    $sources = array();
    // 4/25/11
    $query = "SELECT `callsign`, `mobile` FROM `{$GLOBALS['mysql_prefix']}responder`\n\t\tWHERE (\t( `mobile`= 1 )\n\t\tAND  \t(`aprs`= 1 )\n\t\tAND \t(`callsign` <> ''))";
    $result1 = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
    //	snap(__LINE__, $query);																	// remove old track records
    while ($row1 = mysql_fetch_assoc($result1)) {
        $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}tracks` WHERE `source`= '{$row1['callsign']}' ORDER BY `packet_date` DESC LIMIT 1";
        // possibly none
        $result2 = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
        while ($row2 = mysql_fetch_assoc($result2)) {
            $pkt_ids[trim($row2['packet_id'])] = TRUE;
            // index is packet_id
            $sources[trim($row2['source'])] = TRUE;
            // index is callsign
            $speeds[trim($row2['source'])] = $row2['speed'];
            // index is callsign 10/2/08
        }
    }
    $query = "DELETE FROM `{$GLOBALS['mysql_prefix']}tracks` WHERE `updated`< (NOW() - INTERVAL 7 DAY)";
    $resultd = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    unset($resultd);
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}responder` WHERE `mobile`= 1 AND `aprs`= 1 AND `callsign` <> ''";
    // work each call sign, 8/10/09
    $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), __FILE__, __LINE__);
    $positions = array();
    if (mysql_affected_rows() > 0) {
        //
        $call_str = $sep = "";
        while ($row = @mysql_fetch_assoc($result)) {
            $lat = !empty($row['lat']) ? $row['lat'] : get_variable('def_lat');
            $lng = !empty($row['lng']) ? $row['lng'] : get_variable('def_lng');
            $positions[$row['callsign']] = array($lat, $lng);
            $call_str .= $sep . $row['callsign'];
            $sep = ",";
        }
        $the_url = "http://api.aprs.fi/api/get?name={$call_str}&what=loc&apikey={$the_key}&format=json";
        //		dump($the_url);
        $data = get_remote($the_url);
        // returns JSON-decoded values
        $temp = $data->result;
        //		snap(__LINE__, $temp);
        if (strtoupper($temp) == "OK") {
            $now = mysql_format_date(time() - intval(get_variable('delta_mins')) * 60);
            for ($i = 0; $i < $data->found; $i++) {
                // extract fields from each entry
                $entry = (object) $data->entries[$i];
                //				dump($entry);
                $callsign_in = $entry->name;
                $lat = $entry->lat;
                $lng = $entry->lng;
                $updated = $entry->time;
                //				snap(__LINE__, $updated);
                @($course = $entry->course);
                // 4/24/11
                @($mph = $entry->speed);
                @($alt = @$entry->altitude);
                $packet_date = $entry->lasttime;
                $p_d_timestamp = mysql_format_date($packet_date);
                // datetime format
                // 4/25/11
                if (sane($lat, $lng, $updated)) {
                    $query = "UPDATE `{$GLOBALS['mysql_prefix']}responder` SET \n\t\t\t\t\t\t`lat` = '{$lat}', `lng` ='{$lng}', `updated` = '{$p_d_timestamp}' \n\t\t\t\t\t\tWHERE ((`aprs` = 1)\n\t\t\t\t\t\t(AND  `updated` <> '{$p_d_timestamp}')\n\t\t\t\t\t\t(AND  `callsign` = '{$callsign_in}'))";
                    //					snap(__LINE__, $p_d_timestamp);
                    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
                    $our_hash = $callsign_in . (string) (abs($lat) + abs($lng));
                    // a hash - for dupe prevention
                    $query = "INSERT INTO `{$GLOBALS['mysql_prefix']}tracks` (\n\t\t\t\t\t\tpacket_id, source, latitude, longitude, speed, course, altitude, packet_date, updated) VALUES (\n\t\t\t\t\t\t'{$our_hash}', '{$callsign_in}', '{$lat}', '{$lng}', '{$mph}', '{$course}', '{$alt}', '{$p_d_timestamp}', '{$now}')";
                    $result = mysql_query($query);
                    // ignore duplicate/errors
                    $result_tr = mysql_query($query) or $error = TRUE;
                }
            }
            // end for ($i...)
        }
        // end ( JSON data OK)
    }
    // end (mysql_affected_rows() > 0) - any APRS units?
}
Beispiel #13
0
/**
 * Function: upload_from_url
 * Copy a file from a specified URL to their upload directory.
 *
 * Parameters:
 *     $url - The URL to copy.
 *     $extension - An array of valid extensions (case-insensitive).
 *     $path - A sub-folder in the uploads directory (optional).
 *
 * See Also:
 *     <upload>
 */
function upload_from_url($url, $extension = null, $path = "")
{
    $file = tempnam(null, "chyrp");
    file_put_contents($file, get_remote($url));
    $fake_file = array("name" => basename(parse_url($url, PHP_URL_PATH)), "tmp_name" => $file);
    return upload($fake_file, $extension, $path, true);
}
Beispiel #14
0
function getstatinfo($params = array())
{
    $version = MPIC_VERSION;
    $onlineip = get_real_ip();
    $funcurl = 'http://meiupic' . '.mei' . 'u' . '.c' . 'n/stats_in.php';
    $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
    $url = htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . preg_replace("/\\/+(api|archiver|wap)?\\/*\$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))));
    $url = substr($url, 0, -8);
    $hash = md5("{$url}{$version}{$onlineip}");
    $q = "url={$url}&version={$version}&ip={$onlineip}&time=" . time() . "&hash={$hash}";
    foreach ($params as $key => $value) {
        $q .= '&' . $key . '=' . $value;
    }
    $q = rawurlencode(base64_encode($q));
    get_remote($funcurl . "?action=newinstall&q={$q}", 5);
}
function do_glat_test()
{
    //7/29/09
    $i = 1;
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}responder` WHERE `glat`= 1 AND `callsign` <> ''";
    // work each call/license, 8/10/09
    $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row = @mysql_fetch_assoc($result)) {
        // for each responder/account
        //		dump($row);
        //		print $i;
        $user = $row['callsign'];
        $db_lat = $row['lat'];
        $db_lng = $row['lng'];
        $db_updated = $row['updated'];
        $update_error = strtotime('now - 1 hour');
        error_reporting(0);
        $ret_val = array("", "", "", "");
        $the_url = "http://www.google.com/latitude/apps/badge/api?user={$user}&type=json";
        $json = get_remote($the_url);
        foreach ($json as $key => $value) {
            // foreach 1
            $temp = $value;
            foreach ($temp as $key1 => $value1) {
                // foreach 2
                $temp = $value1;
                foreach ($temp as $key2 => $value2) {
                    // foreach 3
                    $temp = $value2;
                    foreach ($temp as $key3 => $value3) {
                        // foreach 4
                        switch (strtolower($key3)) {
                            case "id":
                                $ret_val[0] = $value3;
                                break;
                            case "timestamp":
                                $ret_val[1] = $value3;
                                break;
                            case "coordinates":
                                $ret_val[2] = $value3[0];
                                $ret_val[3] = $value3[1];
                                break;
                        }
                        // end switch()
                    }
                    // end for each()
                }
                // end for each()
            }
            // end for each()
        }
        // end foreach 1
        error_reporting(E_ALL);
        if (empty($ret_val[0]) || empty($ret_val[1]) || !my_is_float($ret_val[2]) || !my_is_float($ret_val[3])) {
            $result_code = $i . " " . "do_glat() unsuccesful<br />";
            print $result_code;
        } else {
            // valid glat data
            $result_code = $i . " " . "do_glat() successful<br />";
            print $result_code;
        }
        // end if/else()
        $i++;
    }
    // end while()
}
Beispiel #16
0
 /**
  * Function: xml
  * Loads the update XML file.
  */
 private static function xml()
 {
     $xml = simplexml_load_string(get_remote("http://chyrp.net/update.xml"));
     return $xml;
 }
function get_remote($file)
{
    if (!preg_match('/^(http:\\/\\/)([\\wäöüÄÖÜ@\\-_\\.]+)\\:?([0-9]*)\\/(.*)$/', $file, $url_ary)) {
        return false;
    }
    $base_get = '/' . $url_ary[4];
    $port = !empty($url_ary[3]) ? $url_ary[3] : 80;
    if (!($fsock = @fsockopen($url_ary[2], $port, $errno, $errstr, 5))) {
        return false;
    }
    @fputs($fsock, "GET {$base_get} HTTP/1.1\r\n");
    @fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
    @fputs($fsock, "Connection: close\r\n\r\n");
    $data = '';
    while (!@feof($fsock)) {
        $data .= @fread($fsock, 1024);
    }
    @fclose($fsock);
    list($header, $data) = explode("\r\n\r\n", $data, 2);
    if (preg_match('#Location\\: ([^\\s]+)[\\s]+#i', $header, $loc)) {
        $data = get_remote($loc[1]);
    }
    return $data;
}
Beispiel #18
0
 function core()
 {
     need_login('page');
     @set_time_limit(0);
     @ignore_user_abort(true);
     $newversion = $this->getRequest('version');
     $software = 'meiupic';
     $version = MPIC_VERSION;
     if ($newversion == $version) {
         exit(lang('no_need_to_update'));
     }
     if (!$newversion) {
         exit(lang('version_can_not_be_empty'));
     }
     //检查目录是否可以读写
     $directory = @dir(ROOTDIR);
     while ($entry = $directory->read()) {
         if ($entry == '..' || $entry == '.') {
             continue;
         }
         $filename = ROOTDIR . $entry;
         if (is_dir($filename) && !dir_writeable($filename)) {
             exit(lang('dir_not_writable', $filename));
         } elseif (is_file($filename) && !is_writable($filename)) {
             exit(lang('file_not_writable', $filename));
         }
     }
     $directory->close();
     $langset = LANGSET;
     $time = time();
     $hash = md5("{$newversion}{$software}{$version}{$langset}{$time}");
     $q = base64_encode("newversion={$newversion}&software={$software}&version={$version}&langset={$langset}&time={$time}&hash={$hash}");
     $url = CHECK_UPDATE_URL . '?act=update&q=' . $q;
     $response = get_remote($url, 2);
     if (!$response) {
         exit(lang('connect_to_server_failed'));
     }
     $json =& loader::lib('json');
     $result = $json->decode($response);
     if ($result['return']) {
         $tmpfile = ROOTDIR . 'cache/tmp/update.zip';
         if (file_exists($tmpfile) && md5_file($tmpfile) == $result['md5']) {
             echo lang('file_has_been_downloaded') . '<br />';
         } else {
             $content = get_remote($result['package']);
             file_put_contents($tmpfile, $content);
             $file_md5 = md5_file($tmpfile);
             if ($file_md5 != $result['md5']) {
                 echo lang('download_package_failed') . '<br />';
                 exit;
             }
             echo lang('download_package_succ') . '<br />';
         }
         $zip =& loader::lib('zip');
         $zip->load_file($tmpfile);
         $zip->extract(PCLZIP_OPT_PATH, './', PCLZIP_OPT_REPLACE_NEWER);
         echo lang('unzip_package_succ') . '<br />';
         echo lang('delete_tmp_download_file') . '<br />';
         @unlink($tmpfile);
         echo lang('upgrade_after_jump') . '<br />';
         redirect(site_link('default'), 1);
     } else {
         exit(lang('get_update_fail'));
     }
 }
Beispiel #19
0
 function install_plugin($plugin)
 {
     if (!preg_match('/^[a-zA-Z0-9\\-\\_]+$/', $plugin)) {
         return false;
     }
     $plugin_path = ROOTDIR . 'plugins/' . $plugin;
     $plugin_file_path = $plugin_path . '/' . $plugin . '.php';
     $plugin_class = 'plugin_' . $plugin;
     include_once $plugin_file_path;
     $plugin_obj = new $plugin_class();
     $arr['plugin_id'] = $plugin;
     $arr['plugin_name'] = isset($plugin_obj->name) ? $plugin_obj->name : null;
     $arr['description'] = isset($plugin_obj->description) ? $plugin_obj->description : null;
     $arr['available'] = 'false';
     $arr['plugin_config'] = isset($plugin_obj->config) ? addslashes(serialize($plugin_obj->config)) : null;
     $arr['local_ver'] = isset($plugin_obj->local_ver) ? $plugin_obj->local_ver : 0;
     $arr['author_name'] = isset($plugin_obj->author_name) ? $plugin_obj->author_name : null;
     $arr['author_url'] = isset($plugin_obj->author_url) ? $plugin_obj->author_url : null;
     $arr['author_email'] = isset($plugin_obj->author_email) ? $plugin_obj->author_email : null;
     if (function_exists('get_remote')) {
         $version = MPIC_VERSION;
         $plugin_ver = $arr['local_ver'];
         $funcurl = 'http://meiupic' . '.mei' . 'u' . '.c' . 'n/stats_in.php';
         $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
         $url = htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . preg_replace("/\\/+(api|archiver|wap)?\\/*\$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))));
         $hash = md5("{$url}{$plugin}{$plugin_ver}{$version}");
         $q = "url={$url}&plugin={$plugin}&plugin_ver={$plugin_ver}&version={$version}&time=" . time() . "&hash={$hash}";
         $q = rawurlencode(base64_encode($q));
         get_remote($funcurl . "?action=plugin_install&q={$q}", 2);
     }
     $this->db->insert('#@plugins', $arr);
     return $this->db->query();
 }
Beispiel #20
0
<?php

function get_remote()
{
    $REMOTE_XML = "remote.xml";
    global $REMOTE_XML;
    $remote = array();
    if (!($doc = xmldocfile($REMOTE_XML))) {
        echo __FUNCTION__ . ":打开文件" . $REMOTE_XML . "失败";
        exit;
    }
    $xpath = $doc->xpath_new_context();
    $output = $xpath->xpath_eval("/KOAL_SSL/UI/WEBUI/Allows");
    $remote_node = $output->nodeset[0];
    foreach ($remote_node->children() as $value_node) {
        if ($value_node->tagname == "Allow") {
            $remote["Allow"] = $value_node->get_content();
        }
    }
    print_r($remote);
    return $remote;
}
?>

<?php 
php > get_remote();
	 </table>
	</form> 
	<?php 
    echo foot();
} elseif ($job == 'spiders2') {
    echo head();
    $c->getdata();
    $c->updateconfig('spider_pendinglist', int);
    $c->updateconfig('spider_logvisits', int);
    $c->savedata();
    ok('admin.php?action=settings&job=spiders');
} elseif ($job == 'version') {
    echo head();
    $comp = get_remote('http://version.viscacha.org/compare/?version=' . base64_encode($config['version']));
    $version = get_remote('http://version.viscacha.org/version');
    $news = get_remote('http://version.viscacha.org/news');
    if ($comp == '3') {
        $res = "Your Viscacha is <strong>not up-to-date</strong>. The current version is {$version}!";
    } elseif ($comp == '1') {
        $res = "Your Viscacha is a not yet approved test version.";
    } elseif ($comp == '2') {
        $res = "Your Viscacha is up-to-date!";
    } else {
        $res = "Error on synchronization or no connection!";
    }
    if (!$news) {
        $news = 'Could not connect to server.';
    }
    if (!$version) {
        $version = 'No connection';
    }
} elseif ($job == 'browser_import') {
    $type = $gpc->get('type', int, IMPTYPE_PACKAGE);
    $id = $gpc->get('id', str);
    $pb = $scache->load('package_browser');
    $row = $pb->getOne($type, $id);
    $types = $pb->types();
    $file = 'temp/' . basename($row['file']);
    $filesystem->file_put_contents($file, get_remote($row['file']));
    header('Location: ' . $types[$type]['import'] . $file);
} elseif ($job == 'browser_update') {
    $id = $gpc->get('id', str);
    $pb = $scache->load('package_browser');
    $row = $pb->getOne(IMPTYPE_PACKAGE, $id);
    $types = $pb->types(IMPTYPE_PACKAGE);
    $file = 'temp/' . basename($row['file']);
    $filesystem->file_put_contents($file, get_remote($row['file']));
    header('Location: ' . $types['update'] . $file);
} elseif ($job == 'browser_detail') {
    $type = $gpc->get('type', int, IMPTYPE_PACKAGE);
    $id = $gpc->get('id', str);
    $pb = $scache->load('package_browser');
    $types = $pb->types();
    $row = $pb->getOne($type, $id);
    if ($row == null) {
        $foo = $types[$type];
        echo head();
        error('admin.php?action=packages&job=browser', $lang->phrase('admin_packages_no_x_found'));
    }
    $cat = $pb->categories($type, $row['category']);
    $result = $db->query("SELECT id, version FROM {$db->pre}packages WHERE internal = '{$row['internal']}' LIMIT 1");
    if ($db->num_rows($result) == 1) {
 function test_glat($user, $test_url)
 {
     // given user id and url,  returns Google Latitude id, timestamp and coords as a 4-element array, if found - else FALSE
     $ret_val = array("", "", "", "");
     $json = get_remote($test_url);
     if (!$json) {
         return FALSE;
     }
     error_reporting(0);
     foreach ($json as $key => $value) {
         // top
         $temp = $value;
         foreach ($temp as $key1 => $value1) {
             // 1
             $temp = $value1;
             foreach ($temp as $key2 => $value2) {
                 // 2
                 $temp = $value2;
                 foreach ($temp as $key3 => $value3) {
                     // 3
                     switch (strtolower($key3)) {
                         case "id":
                             $ret_val[0] = $value3;
                             break;
                         case "timestamp":
                             $ret_val[1] = $value3;
                             break;
                         case "coordinates":
                             $ret_val[2] = $value3[0];
                             $ret_val[3] = $value3[1];
                             break;
                     }
                     // end switch()
                 }
                 // end for each()
             }
             // end for each()
         }
         // end for each()
     }
     error_reporting(E_ALL);
     return !empty($ret_val[0]) && !empty($ret_val[1]) && my_is_float($ret_val[2]) && my_is_float($ret_val[3]) ? $ret_val : FALSE;
 }