r00t.gr

Programming and more

Entries for the ‘Web Development’ Category

How to make notepad++ Functions List plugin to work with Windows 7

I use Notepad++ daily for PHP Development. I love it, it’s simple and powerful at the same time. One good feature is the plugins that are available. One of them is Functions List. If you try to install that plugin on a Windows 7 Machine, it will not work ok. You have to do some […]

How to make google analytics work with jquery mobile site

Google analytics doesn’t work with jquery mobile websites. Luckily, I found the way to make this work. Basically you have to break the code into 2 parts:     <script> var _gaq = _gaq || []; _gaq.push([’_setAccount’, ‘UA-xxxxxx-xx’]);   (function() { var ga = document.createElement(’script’); ga.type = ‘text/javascript’; ga.async = true; ga.src = (’https:’ == […]

Programmatically Build forms with PHP

I needed a way to programmatically build forms with php so that I can easily print them in any template, so that when I change template I don’t have to copy paste and fix forms all over again. So to solve this I needed some php code to automatically build forms. For me there are […]

How to add expires headers on css, javascript and image files

I tried many things I found googling but nothing work, until I saw this: Assuming you are using apache, what you must do is go to you public_html folder, create a file .htaccess and paste in it:     <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$"> ExpiresActive On ExpiresDefault "access plus 1 year" </FilesMatch> <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$"> ExpiresActive On ExpiresDefault "access […]

Create Easy charts with php/javascript/flash

I was looking yesterday for a way to create a simple chart (Dates and values). I wanted some library to include into the MVC-CMS I created so that I can use everytime I want something. Open Flash Chart I knew Open Flash Chart from before. http://teethgrinder.co.uk/open-flash-chart-2/ You can see it in action here: http://www.radiotower.gr/station_details.php?id=12028. Looks pretty […]

How to get alexa rank with PHP

Ok usefull function for many people. After some googling I give you the easiest way to get the alexa rank: <? $url="toolspot.org"; function getAlexa($url) { $xml = simplexml_load_file(’http://data.alexa.com/data?cli=10&dat=snbamz&url=’.$url); $rank=(int)$xml->SD[1]->POPULARITY->attributes()->TEXT; $web=(string)$xml->SD[1]->POPULARITY->attributes()->URL; return $rank; } echo $url." has Alexa Rank ".getAlexa($url);     function alexaRank($domain) { $remote_url = ‘http://data.alexa.com/data?cli=10&dat=snbamz&url=’.trim($domain); $search_for = ‘<POPULARITY URL’; $part=”; if ($handle = […]

How to redirect all non www traffic to www

I found that it is usually a good idea, to redirect all trafic that doesn’t have www infront of the domain to www.domain.com. I explain how to do it with apache mod_rewrite in the end of the post, scroll there if you just need the answer. Let’s say, a user types http://domain.com he should redirect […]