Scripting & Programming

MySQL procedure for converting UTF8 to CP1251 encoding and vice versa

CREATE FUNCTION STR_UTF8_1251(@s varchar(8000)) RETURNS VARCHAR(8000) AS BEGIN declare @i int, @c int, @byte2 int, @c1 int, @new_c1 int, @new_i int, @new_c2 int, @out_i int declare @out varchar(8000), @a int SET @i = 1 SET @byte2 = 0 SET @out = ” WHILE (@i<=len(@s)) BEGIN SET @c=ascii(SUBSTRING(@s,@i,1)) if (@c<=127) SET @out=@out+SUBSTRING(@s,@i,1) if (@byte2>0) BEGIN SET […]

Scripting & Programming

PHP MySQL connection simple script

Before you can access and work with data in a database, you must create a connection to the database. In PHP, this is done with the mysql_connect() function. Syntax mysql_connect(servername,username,password);   Parameter Description servername Optional. Specifies the server to connect to. Default value is “localhost:3306” username Optional. Specifies the username to log in with. Default […]

Scripting & Programming

Googlebot notification

This simple script is going to notify you over e-mail when the Googlebot is on your website. Code: <?php if(eregi(“googlebot”,$HTTP_USER_AGENT)) { if ($QUERY_STRING != “”) { $url = “http://”.$SERVER_NAME.$PHP_SELF.’?’.$QUERY_STRING; } else { $url = “http://”.$SERVER_NAME.$PHP_SELF; } $today = date(“F j, Y, g:i a”); mail(“your@mail.com”, “Googlebot detected on http://$SERVER_NAME”, “$today – Google crawled $url”); } ?>

Scripting & Programming

Fedora Core 6 Basic iptables conf file

# Firewall configuration written by system-config-securitylevel# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]:RH-Firewall-1-INPUT – [0:0]-A INPUT -j RH-Firewall-1-INPUT-A FORWARD -j RH-Firewall-1-INPUT-A RH-Firewall-1-INPUT -i lo -j ACCEPT-A RH-Firewall-1-INPUT -p icmp –icmp-type any -j ACCEPT-A RH-Firewall-1-INPUT -p 50 -j ACCEPT-A RH-Firewall-1-INPUT -p 51 -j ACCEPT-A RH-Firewall-1-INPUT -p udp –dport 5353 […]