Tag Archive for internet

Get Webpage Content

<?php
$url = "http://web.de";
$str = file_get_contents($url);
echo $str;
?>

source

Parallels bridged networking with Ubuntu Server

# what interfaces are supposed to be used?
cat /etc/network/interfaces

# what interfaces are actually in use?
ifconfig

# mine showed only 'lo' (local loopback) in use,
# but eth0 was supposed to auto-init too.
# so let's see what's happening when eth0 is attempted
sudo ifdown -a
sudo ifup -a

# voila!  there is no such interface
# edit the /etc/network/interfaces references to 'eth0' to 'eth1'

# then re-init...
sudo ifdown -a
sudo ifup -a

# re-confirm the new interface is now in use
ifconfig

source

real time erase tool

import flash.events.MouseEvent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.GradientType;
//
import flash.geom.Matrix;
//
var md:Boolean = false;
//
var event_spr:Sprite = new Sprite();
addChild (event_spr);
//
var area_width:Number = event_spr.stage.stageWidth;
var area_height:Number = event_spr.stage.stageHeight-32;
//
var fillType:String = GradientType.LINEAR;
var colors:Array = [0xFF0000, 0x00FF00, 0x0000ff];
var alphas:Array = [1, 1, 1];
var ratios:Array = [0, 128, 255];
var spreadMethod:String = SpreadMethod.PAD;
var matrix:Matrix = new Matrix();
matrix.createGradientBox (area_width, area_height, 1, 0, 0);
//
with (event_spr.graphics) {
beginGradientFill (fillType,colors,alphas,ratios,matrix,spreadMethod);
drawRect (0,0,area_width, area_height);
endFill ();
}
// paint event
event_spr.addEventListener (MouseEvent.MOUSE_DOWN, _onMouseDown);
event_spr.addEventListener (MouseEvent.MOUSE_MOVE, _onMouseMove);
event_spr.addEventListener (MouseEvent.MOUSE_UP, _onMouseUp);
event_spr.addEventListener (MouseEvent.MOUSE_OUT, _onMouseUp);
//
var bmpd:BitmapData = new BitmapData(event_spr.width,event_spr.height,true,0);
var bmp:Bitmap = new Bitmap(bmpd);
addChild (bmp);
//
// shape temporanea
var draw_shape:Shape = new Shape();
addChild (draw_shape);
//
// shape, non visibile, usata per la "cancellazione"
var erase_shape:Shape = new Shape();
//
function _onMouseDown (e:MouseEvent):void {
debug ("_onMouseDown");
draw_shape.graphics.lineStyle (10, 0xffffff, 1);
erase_shape.graphics.lineStyle (20, 0xffffff, 1);
draw_shape.graphics.moveTo (e.localX,e.localY);
erase_shape.graphics.moveTo (e.localX,e.localY);
md = true;
}
//
function _onMouseUp (e:MouseEvent):void {
md = false;
bmp.bitmapData.draw (draw_shape);
draw_shape.graphics.clear ();
erase_shape.graphics.clear ();
}
//
function _onMouseMove (e:MouseEvent):void {
debug ("_onMouseMove");
if (md && !e.ctrlKey) {
draw_shape.graphics.lineTo (e.localX,e.localY);
} else if (md && e.ctrlKey) {
erase_shape.graphics.lineTo (e.localX,e.localY);
bmp.bitmapData.draw (erase_shape,null,null,"erase");
}
}
//
function debug (v:String):void {
var d:Date = new Date();
trace (d.getMinutes()+":"+d.getSeconds()+":"+d.getMilliseconds()+": "+v);
}

source

Vertical-Align for Stubborn Browsers

#container{
display: table;
#position: relative;
overflow: hidden;
}
#hackouter {
#position: absolute;
#top: 50%;
display: table-cell;
vertical-align: middle;
}
#hackinner {
#position: relative;
#top: -50%;
}

source

comunicazione con un Web Server

var variables:URLVariables = new URLVariables();
variables.miavariabile = "Ciao";
var request:URLRequest = new URLRequest();
request.url = "http://www.miodominio.com/miapagina.php";
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, completeHandler);
try {
loader.load(request);
} catch (error:Error) {
trace("Errore nel caricamento dell' URL");
}
function completeHandler(event:Event):void {
var x_xml:XML = XML(event.target.data);
trace(x_xml);
}

source

IE 6 Transparent PNG Fix – SuperSleight

var supersleight	= function() {

var root = false;
var applyPositioning = true;

// Path to a transparent GIF image
var shim			= 'x.gif';

// RegExp to match above GIF image name
var shim_pattern	= /x.gif$/i;

var fnLoadPngs = function() {
if (root) {
root = document.getElementById(root);
}else{
root = document;
}
for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
// background pngs
if (obj.currentStyle.backgroundImage.match(/.png/i) !== null) {
bg_fnFixPng(obj);
}
// image elements
if (obj.tagName=='IMG' && obj.src.match(/.png$/i) !== null){
el_fnFixPng(obj);
}
// apply position to 'active' elements
if (applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT') && obj.style.position === ''){
obj.style.position = 'relative';
}
}
};

var bg_fnFixPng = function(obj) {
var mode = 'scale';
var bg	= obj.currentStyle.backgroundImage;
var src = bg.substring(5,bg.length-2);
if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
mode = 'crop';
}
obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
obj.style.backgroundImage = 'url('+shim+')';
};

var el_fnFixPng = function(img) {
var src = img.src;
img.style.width = img.width + "px";
img.style.height = img.height + "px";
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
img.src = shim;
};

var addLoadEvent = function(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
};
}
};

return {
init: function() {
addLoadEvent(fnLoadPngs);
},

limitTo: function(el) {
root = el;
},

run: function() {
fnLoadPngs();
}
};
}();

// limit to part of the page ... pass an ID to limitTo:
// supersleight.limitTo('header');

supersleight.init();

source

CSS PNG Image Fix for IE

* html img,
* html .png{
azimuth: expression(
this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
this.src = "/style/images/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true
);
}

________
________
Also consider adding this conditional comment on your HTML page
________
________

<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="png_fix.css" />
<![endif]--

source

//Call from JavaScript:
window.external.AddFavorite(location.href, document.title);

//Call from anchor:
<a href="JavaScript:window.external.AddFavorite(location.href, document.title);">Bookmark this site!</a>

source

Use Conditional Comments to Subjugate IE

<!--[if lt IE 7]>
<link href="cmn/css/ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->

<!--[if IE 7]>
<link href="cmn/css/ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->

source

Internet Explorer (IE6) CSS Hover

<attach event="ondocumentready" handler="parseStylesheets" />
<script>
/**
*	Whatever:hover - V1.42.060206 - hover & active
*	------------------------------------------------------------
*	(c) 2005 - Peter Nederlof
*	Peterned - <a href="http://www.xs4all.nl/~peterned/" >http://www.xs4all.nl/~peterned/</a>
*	License  - <a href="http://creativecommons.org/licenses/LGPL/2.1/" >http://creativecommons.org/licenses/LGPL/2.1/</a>
*
*	Whatever:hover is free software; you can redistribute it and/or
*	modify it under the terms of the GNU Lesser General Public
*	License as published by the Free Software Foundation; either
*	version 2.1 of the License, or (at your option) any later version.
*
*	Whatever:hover is distributed in the hope that it will be useful,
*	but WITHOUT ANY WARRANTY; without even the implied warranty of
*	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*	Lesser General Public License for more details.
*
*	Credits and thanks to:
*	Arnoud Berendsen, Martin Reurings, Robert Hanson
*
*	howto: body { behavior:url("csshover.htc"); }
*	------------------------------------------------------------
*/

var csshoverReg = /(^|s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i,
currentSheet, doc = window.document, hoverEvents = [], activators = {
onhover:{on:'onmouseover', off:'onmouseout'},
onactive:{on:'onmousedown', off:'onmouseup'}
}

function parseStylesheets() {
if(!/MSIE (5|6)/.test(navigator.userAgent)) return;
window.attachEvent('onunload', unhookHoverEvents);
var sheets = doc.styleSheets, l = sheets.length;
for(var i=0; i<l; i++)
parseStylesheet(sheets[i]);
}
function parseStylesheet(sheet) {
if(sheet.imports) {
try {
var imports = sheet.imports, l = imports.length;
for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);
} catch(securityException){}
}

try {
var rules = (currentSheet = sheet).rules, l = rules.length;
for(var j=0; j<l; j++) parseCSSRule(rules[j]);
} catch(securityException){}
}

function parseCSSRule(rule) {
var select = rule.selectorText, style = rule.style.cssText;
if(!csshoverReg.test(select) || !style) return;

var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
var newSelect = select.replace(/(.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
var className = (/.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
var affected = select.replace(/:(hover|active).*$/, '');
var elements = getElementsBySelect(affected);
if(elements.length == 0) return;

currentSheet.addRule(newSelect, style);
for(var i=0; i<elements.length; i++)
new HoverElement(elements[i], className, activators[pseudo]);
}

function HoverElement(node, className, events) {
if(!node.hovers) node.hovers = {};
if(node.hovers[className]) return;
node.hovers[className] = true;
hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });
hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('s+'+className, 'g'),''); });
}
function hookHoverEvent(node, type, handler) {
node.attachEvent(type, handler);
hoverEvents[hoverEvents.length] = {
node:node, type:type, handler:handler
};
}

function unhookHoverEvents() {
for(var e,i=0; i<hoverEvents.length; i++) {
e = hoverEvents[i];
e.node.detachEvent(e.type, e.handler);
}
}

function getElementsBySelect(rule) {
var parts, nodes = [doc];
parts = rule.split(' ');
for(var i=0; i<parts.length; i++) {
nodes = getSelectedNodes(parts[i], nodes);
}	return nodes;
}
function getSelectedNodes(select, elements) {
var result, node, nodes = [];
var identify = (/#([a-z0-9_-]+)/i).exec(select);
if(identify) {
var element = doc.getElementById(identify[1]);
return element? [element]:nodes;
}

var classname = (/.([a-z0-9_-]+)/i).exec(select);
var tagName = select.replace(/(.|#|:)[a-z0-9_-]+/i, '');
var classReg = classname? new RegExp('b' + classname[1] + 'b'):false;
for(var i=0; i<elements.length; i++) {
result = tagName? elements[i].all.tags(tagName):elements[i].all;
for(var j=0; j<result.length; j++) {
node = result[j];
if(classReg && !classReg.test(node.className)) continue;
nodes[nodes.length] = node;
}
}

return nodes;
}
</script>

source