Safe and Dirty Remote XMLHttpRequest Sometimes we need XMLHttpRequest work on diferents domains (cross domains) a simple solution, you need JavaScript and Perl:
The XMLHttpRequest(); example:
var req =new XMLHttpRequest()// IE7, Firefox, Safari, Opera
req.open('GET','http://localhost/cgi-bin/remote.pl?url='+url,false);
req.send(null);
#!/bin/bashecho"JavaScript Collection"EXPECTED_ARGS=1E_BADARGS=65if[$#-ne$EXPECTED_ARGS]thenecho"Usage: `basename $0` {path of the javascripts}"exit$E_BADARGSfi# Join the javascript scripts in one filecat $1/*.js >> $1/.__fullscripts.tmp
# use JSMIN to minifier the scriptcat $1/.__fullscripts.tmp | jsmin > $1/.__fullscripts.min.tmp
# awk remove the first blank line, gzip compress the scriptawk'FNR>1{print}' $1/.__fullscripts.min.tmp | gzip> $1/collection_scripts.js.gz
# remove temporal filesrm $1/.__fullscripts.tmp $1/.__fullscripts.min.tmp
Howto: jscpublic_html/web/js/
Now create one php script to replace all javascripts:
I made this little Javascript function, this function insert any youtube video on a <div>.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Script: YouTubeVideo Version 1.0 (2008/07/22)// Author: Alberto Isaac Ayala Esquivias (Albertux)// Licence: http://creativecommons.org/licenses/by-nc-sa/3.0/// FeedBack to: albertoi7@gmail.com// About: Insert youtube video on a div doesn't matter if embed code is disable this script insert the video.function YouTubeVideo(id,url){var video_html ='<object width="425" height="344"><param name="movie" value="http://www.youtube.com/swf/l.swf?video_id=VIDEO&rel=1&iurl=null&autoplay=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/swf/l.swf?video_id=VIDEO&rel=1&iurl=null&autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>';
var n = url.indexOf('v=');
var id_video = url.substring(n+2,n+14);
document.getElementById(id).innerHTML=video_html.replace(/VIDEO/g, id_video);
}
Sometimes we need to know the country of the users on the website, you can know using only the ip address.
I write this simple Bash script to install on a new database (or existing database) the table “geoip”, now you can use PHP, Python, Perl, Ruby or whatever you want.
#!/bin/bash# Script: geoip.sh# Author: Alberto Isaac Ayala Esquivias# E-mail: <albertoi7@gmail.com># Web: http://albertux.ayalasoft.comclearecho"=====================================-"echo" GeoIp MySQL Database Easy Installer. "echo"======================================"echo""echo"Script Created By http://AyalaSoft.com";
echo""stty-echoread-p"MySQL root password: " mysql_pass; echosttyechoecho-n"Do you want to create database of MySQL (y/n): "read op
if["$op" = "y"]; thenecho-n"Create new database, name: "read database
mysqladmin -u root --password=$mysql_pass create $databaseelseecho-n"Which database do you want to use to insert 'geoip' table: "read database
fiecho-e"\nDownload [ GeoIPCountryCSV.zip ]"wget-c"http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip"echo-e"\nUnZip [ GeoIPCountryCSV.zip ]"unzip GeoIPCountryCSV.zip
echo-e"\nInsert geoip table to database $database"awk -F, ' { print $3","$4","$5","$6 }' GeoIPCountryWhois.csv | sed s/\"//g > /tmp/geoip.txt
chmod 777 /tmp/geoip.txt
echo "
USE $database;
DROP TABLE IF EXISTS geoip;
CREATE TABLE geoip (
ip_begin int unsigned,
ip_end int unsigned,
country varchar(2),
country_name varchar(30));
LOAD DATA LOCAL INFILE '/tmp/geoip.txt'
INTO TABLE $database.geoip
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'(ip_begin, ip_end, country, country_name);
" > geoip.sql
mysql -u root --password=$mysql_pass $database < geoip.sql
rm /tmp/geoip.txt
echo -e "\nFinish."
Recent Comments