Archive for the ‘PHP’ Category

Passing dynamic variables through a query string within PHP.

Wednesday, June 17th, 2009

Passing dynamic variables through a query string within PHP. Make a new PHP document called “index.php” add the below code above everything like from line1 onwards etc.

<?php

$vars=$_GET['vars'];
echo "vars?='".$vars."' ";

php?>

That’s it! Now call your URL query like this;


http://yourdomain.com/?vars=HelloWorld

Your page should output;

HelloWorld

Checkout my multi lingual code snippets.
http://3l3373.com/langx-browser-language-detection-php-flash-javascript-asp-coldfusion/

Vote in HexoSearch

IP BAN – PHP/MySQL Checking Script

Tuesday, June 2nd, 2009

This is a small script can be used to redirect banned ip address users from your website, what it does exactly is calls the function “ipbanCheck” checks the database “ipban” for a matching IP Addresses of the current users IP Address then redirects them via javascript to =  http://www.google.co.uk/search?q=GTFO :)

Database Setup:
1) log into phpMyAdmin, select the database you want the table built into.
2) select “SQL” from the tab menu, run the below.

SQL code:

CREATE TABLE ipban ( ID int(12) NOT NULL auto_increment, IP varchar(25) NOT NULL default '', PRIMARY KEY (ID) ) TYPE=MyISAM;

3) should output “executed successfully” etc. now select the table “ipban” then select “Insert” from tab menu now enter the IP Address your want to BAN in the field “IP”.

Usage:
Reason why i’m out putting the echo’s with outs like: “&conn=YES&IP=$ip” is for Flash loadVars integration. To use this function “ipbanCheck” just call it like so;

require_once 'ipban.php'; //file path to the file
ipbanCheck(); //check function

Example
http://3l3373.com/dl/tutorials/ipBan/check.php – You should see an output of  “&conn=YES&IP=93.97.40.201ban=NO&” unless You have been BANNED :)

PHP Code

<?php

/* 

/////////////////////////////////
IP BAN - Kurt Grung - 3L3373.com
/////////////////////////////////

Database Setup:
1) log into phpMyAdmin, select the database you want the table built into.
2) select "SQL" from the tab menu, run the below SQL code:
CREATE TABLE ipban ( ID int(12) NOT NULL auto_increment, IP varchar(25) NOT NULL default '', PRIMARY KEY (ID) ) TYPE=MyISAM;
3) should output "executed successfully" etc. now select the table "ipban" then select "Insert" from tab menu now enter the IP Address your want to BAN in the field "IP".

Usage:
Reason why i'm out putting the echo's with outs like: "&conn=YES&IP=$ip" is for Flash loadVars integration.

To use this function "ipbanCheck" just call it like so;  

require_once 'ipban.php'; //file path to the file
ipbanCheck();

*/

function ipbanCheck(){

 //config
 $ip = $_SERVER['REMOTE_ADDR'];
 $redirectURL = "http://www.google.co.uk/search?q=GTFO";

 //db.conn
 $dbHost = "";
 $dbUser = "";
 $dbPass = "";
 $dbName = "";

 //connection sucsessful?
 $link = mysql_connect($dbHost, $dbUser, $dbPass, $dbName);
 if(!$link){
 die('&conn=NO&');
 die('Could not connect: '.mysql_error());
 }

 echo '&conn=YES&IP='.$ip;

 //db.conn
 mysql_connect($dbHost, $dbUser, $dbPass) or die(mysql_error());
 mysql_select_db($dbName) or die(mysql_error());
 $s=$_SERVER["REMOTE_ADDR"];

 //draws IP address of visitor
 $ipbancheck="SELECT * from ipban where IP='$s'";
 $ipbancheck2=mysql_query($ipbancheck);
 while($ipbancheck3=mysql_fetch_array($ipbancheck2)){
 $IPBANNED=$ipbancheck3[IP];
 }
 //above lines check to see if user Ip is in banned IPs
 if ($IPBANNED){
 //redirect user..
 echo "<script> setTimeout(location.href=\"$redirectURL\", 1); </script>";
 }else{
 echo 'ban=NO&';
 //put content you want unbanned users to see here
 }
}

?>
Vote in HexoSearch

FFMPEG How to Install.

Monday, January 19th, 2009

ffmpeg_info

FFMPEG.. has to be one of the hardest thing’s to install to a linux box I mean I have tried building this thing about 300x’s over the past week nothing worked! got all these errors and there’s no information on the net about it – like all the tutorial sites don’t go into detail just expecting it to install…

Ok now onto the easy part! haha.. I found an auto installer, called “ffmpeginstall” its been the only one I have found that worked for me! I’m running (cPanel 11 / CENTOS 5.2 i686) this is all you need to do to get started/install;

wget http://ovh.dl.sourceforge.net/sourceforge/ffmpeginstall/ffmpeginstall.3.2.1.tar.gz && tar xzf ffmpeginstall.3.2.1.tar.gz && cd ffmpeginstall.3.2.1 && sh install.sh

That’s it!!! its amazing ;)

Features ffmpeginstall Version 2.x.x;

*MPlayer (MPlayer-1.0rc1.tar.bz2)
*Codecs (all-20061022.tar.bz2)
*Flvtool (flvtool2_1.0.5_rc6.tgz)
*Lame (lame-3.97.tar.gz)
*Libogg (libogg-1.1.3.tar.gz)
*Libvorbis (libvorbis-1.1.2.tar.gz)
*Vorbis-tools(vorbis-tools-1.1.1.tar.gz)
*Libtheora (libtheora-1.0alpha7.tar.gz)
*FFMPEG Svn version SVN-r10820 (ffmpeg-SVN-r10820.tar.gz)
*AMR 3gp Encoder and decoder (amrnb-7.0.0.0.tar.bz2,amrwb-7.0.0.2.tar.bz2)
*ffmpeg-php (ffmpeg-php-0.5.0.tbz2)
*Ruby (ruby-1.8.6.tar.gz)
*wmf Lib (libwmf-0.2.8.3.tar.gz)
*faad2
*facc
*a52dec-0.7.4

They also have a for Shared Host installer but you will need SSH access more here; http://www.sherin.in/ffmpeg/.

I have tested it with “VidiScript” Free Youtube Clone – www.vidiscript.com and it works perfectly!

Some useful information on my travels.. Came accross one got resource on the net – this has acutual error fixes (even though I got errors while installing FFMPEG and all the rest) > http://www.yail.net/2008/10/installing-ffmpeg-and-ffmpeg-php-on-a-cpanel-server.html.

“Admin-Ahead Server Technologies” auto FFMPEG Installer is pretty nice it can install addtional libarys codecs after compiling FFMPEG so its worth checking out (again this didn’t work but it seems the only reason was for the incorrect file (“ffmpeg_frame.lo”) named bug – something common I have come accross while trying to install manually) error;

make: *** [ffmpeg_frame.lo] Error 1

Thanks to Yun @ Carpe Noctem! – Solution: Execute the following in the ffmpeg-php folder. I’ve no idea why the files are named wrongly too.

cp ffmpeg_frame.loT ffmpeg_frame.lo

more about the installer here: http://scriptmantra.info/ffmpeg.html.

Other usful resources;

http://www.yail.net/2008/10/installing-ffmpeg-and-ffmpeg-php-on-a-cpanel-server.html
http://www.nazly.net/post/installing-ffmpeg-and-ffmpeg-php-on-centos-230/
http://forums.theplanet.com/index.php?showtopic=64541&pid=586413&mode=threaded&start=
http://www.webhostingtalk.com/showthread.php?p=4234345#post4234345
http://vexxhost.com/blog/2007/05/20/how-to-convertencode-files-to-flv-using-ffmpeg-php/
http://vexxhost.com/blog/category/ffmpeg/
http://soenkerohde.com/tutorials/ffmpeg/

TOOLS

putty
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

winSCP
http://winscp.net/eng/download.php#download2

How to Install’s?!

RUBY
http://wiki.rubyonrails.com/rails/pages/Ruby+and+Rails+on+Red+Hat+Enterprise+Linux

SUBVERSION
http://wiki.asmallorange.com/HOWTOInstallSubversionVPS

Hope someone finds this useful..

Vote in HexoSearch

session_start() open failed: Permission denied

Sunday, January 18th, 2009

if your getting this error message on top of your pages it means your “session.save_path” has not been set.

open your “php.ini” and make the changes (*centos 5x path location “/usr/local/lib”);

session.save_path = /tmp

chmod should also be set to “1777″ /tmp folder.

restart apache “service httpd restart”.

check php_info for changes, search for “session.s” to see the changes.

done ;)

Vote in HexoSearch

langX flash browser language detection – php flash javascript coldfusion

Tuesday, May 27th, 2008

PHP Flash browser language detection – Works on Internet Explorer too! (BUG FIX Workaround!!).

Demo of it working inside IE & FF :)

php/page code


<script type="text/javascript" src="swfobject.js"></script>

<div id="flashcontent">
	Update Flash Player or <a href="?detectflash=false">bypass detection</a>.
</div>

<script type="text/javascript">

	var so = new SWFObject("core.swf", "core", "300", "300", "9", "#333");
	so.addVariable("langX", 

	<?
	//////////////////////////////////////
	// langX by Kurt Grung | 3L3373.com //
	//////////////////////////////////////

		$lang = getenv ("HTTP_ACCEPT_LANGUAGE");
		$set_lang = explode(',', $lang);
		$i = 0;
		while ($i < 1) {
		$code = substr("$set_lang[$i]", 0, 2);
			echo "\"".$code."\"";
			$i++;
		}
	?>

	);
	so.write("flashcontent");

</script>

Here are a few other snippets of code to detect which language version the user has set.

//as code

//langX

//by kurt grung 3l3373.com

var lang = System.capabilities.language;

trace(lang)if (lang == "en"){

clip.loadMovie("en.swf");

} else if (lang == "jp") {

clip.loadMovie("jp.swf");

}

a lowercase two-letter language code from ISO 639-1, flash supports the following subset of the language tags:

http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary710.html

downfall for using flash “System.capabilities.language” is that is only pulls the install lanague the OS has installed not what the browser has set. however PHP can extract the enviroment code of “HTTP_ACCEPT_LANGUAGE” (throught teh headers) to check the users browser language version which has been set regardless of the language installed/set inside the OS.

‘getenv’ is the function – http://uk.php.net/manual/en/function.getenv.php
list ISO 639 Language Codes – http://www.w3.org/WAI/ER/IG/ert/iso639.htm

//php code

//langX

//by kurt grung 3l3373.com

$lang = getenv ("HTTP_ACCEPT_LANGUAGE");

$set_lang = explode(',', $lang);

$i = 0;

while ($i &lt; 1) {

$code = substr("$set_lang[$i]", 0, 2);

/*

if ($code == 'en'){

print("english");

}

elseif ($code == 'af'){

print("afrikaans");

}

else{

echo 'lang? '.$code.'';

}

*/

echo 'langX = '.$code.'';

$i++;

}

here is a example how to do this in javascript to.

//js code

//langX

//by kurt grung 3l3373.com

var nav_lng="1337"; //default language string

if(navigator.language)nav_lng=navigator.language;

if(navigator.browserlanguage)nav_lng=navigator.userLanguage;

if(navigator.systemLanguage)nav_lng=navigator.systemLanguage;

if(navigator.browserlanguage)nav_lng=navigator.browserlanguage;

if(navigator.userLanguage)nav_lng=navigator.userLanguage;

if(window.navigator.language)nav_lng=window.navigator.language;

var varsX=''+nav_lng;

document.write(varsX);

var ua        = navigator.userAgent.toLowerCase();

var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) &amp;&amp; ( ua.indexOf('win') != -1 ) &amp;&amp; ( ua.indexOf('opera') == -1 ) &amp;&amp; ( ua.indexOf('webtv') == -1 ) );

//asp code

&lt;%@ LANGUAGE="VBSCRIPT" %&gt;
&lt;% Option Explicit %&gt;
&lt;%
Dim userLocale
userLocale = request.servervariables("HTTP_ACCEPT_LANGUAGE")
Response.Write "Language string: " &amp; userLocale &amp; ""

More here
(ASP) http://support.microsoft.com/kb/315616

***FLASH HTTP_ACCEPT_LANGUAGE loadVars Bug*** I have tried this in both AS2/3 both aren’t working..

My posts @ actionscript.org;

“using php “HTTP_ACCEPT_LANGUAGE” pull into flash, working perfectly fine on firefox, ie doesn’t load the correct browser preferance – just seems to default to en-US all the time. and when I load the php standalone it displays correct lang preference – does anybody know why this might be happening tried everything?”

“i have been looking into this issue/bug, found no answers tried so many workarounds – Cookies / Flash remoting (AMFPHP/phpObject/FMS) nothing works… IE is just s*&^t < thats my conlusion ;o”

Possible workaround for this would be using JavaScript and a dynamic scripting call to “HTTP_ACCEPT_LANGUAGE” then passing these variables through to flash using the flashVars implimentation like SWFObject “so.addVariable(“var”, “val”);” etc.. you could either do either a Switch statement in JavaScript or Flash.

Great got it working check the demo above :) or… http://3l3373.com/dl/tutorials/langX/

More
http://blog.deconcept.com/swfobject/#examples (SWFOBject)
SWFobject latest

Vote in HexoSearch
  • Categories

  • Recent Comments

  • Recent Posts

  • Tumblr

  • Flickr Recent Photos

    cherry tree woodstonja_gravestonesPockey Chimp FlavourAUTO FTW! :)darkdaystayouttiger kittenbirdofpreyfirst photo i took with my 1000dself_portrait_02
  • XFIRE (wkly hrs pld)

  • Last.FM

  • Tags

    .MP4 Actionscript Action Script Advertising AS2 AS3 backtrack BT4 bug Call of Duty capcom centOS cpanel crossdomain Eyeblaster eyeblaster HD f4v Flash h264 HD high definition Install internet explorer Linux load loadMovie MIME MIME Types MW2 Nazi Zombies pc PHP ports preloader release date rich media shared objects Stage SWF SWFOBJECT torrents Video video/mp4 VMware win7