Saturngod

What's on my mind

Download All Photos From Flickr

After flickr changing uploader is only for pro account , I decied to move to the google photos. However, it’s not easy to get the original file size. I found , bulkr but I feel like it’s expensive and not worth it for only download all photos.

So, I decied to rewrite myself. I wrote the script and you can get the script in github.

First , we need to get oAuth Token and Secrect. So, to get this two , you need to run on browser. After got these two , just update at download.php. After that , run php download.php. It will download all photos. I don’t want screenshot and only photo. So, I use content_type=6. If you want all , just remove that one.

I have over 55 GB on flickr and it took over 24 hours to download for getting back all original photos for me.

Install Intl in PHP , Mac

To install Intl library for PHP in Mac , you need to install brew first.

Install Brew For ICU

First , update the brew

brew update

Search the ice package name.

 brew search icu

You will find like icu4c and install it.

brew install icu4c

Your icu4c path is

/usr/local/Cellar/icu4c/55.1

Version may not be same. You can check director at /usr/local/Cellar/icu4c/

After we got icu4c , we can install intl from peel.

[...]

PHP CURL zlib.dll is missing

Today, we tried to install PHP on IIS 7. Everything is working fine. But CURL can’t use. So, I tried to enable the php_curl.dll in php.ini. However, It didn’t show on phpinfo() .

Open the C:\php\ from terminal

C:\php\> php.exe -v

It was showing zlib.dll is missing

Download the zlib.dll from zlib.net (compiled DLL). Extract the zip file and it include zlib1.dll.

Rename zlib1.dll to zlib.dll . Move zlib.dll to C:\php\;

C:\php\> php.exe -v

Working fine and no error.

So, search curl in phpinfo().

Perfect. It’s showing now.

Creating Vanilla Addon

I created the mmwebfonts vanilla addon . From my experience , developing vanilla add on is not easy like the wordpress. When I developed the wordpress add on , most of the documents are read at wordpress codex .

When I started to create add on , I don’t know where to start. We can start read at http://vanillaforums.org/docs/plugins. However, it’s a very few documentation. I want to add css at the header of the vanilla forum. So, I check from other add on that already develop. Same like the setting page. There is no information for how to create setting page. I found one tutorial at Vanilla Community Forum . Something I need to read the original source code at https://github.com/vanillaforums/Garden.

The current mmwebfonts code is simple plugin and easy to create. However , I take a time for searching setting page , how to put menu on site page.

Example : I want to put menu on under settings page. I try to put like this

$Menu->AddLink('Settings', T('MMWebFonts'), 'settings/mmwebfonts', 'Garden.Settings.Manage');

It was not working and it was showing another Settings Menu. Thanks , github because I can find source code on garden. I try to find $Menu->AddLink at garden source code . I found settings/class.hooks.php . In there , I found like this

$Menu->AddLink('Site Settings', T('Routes'), 'dashboard/routes', 'Garden.Settings.Manage');

So, I changed my code like

$Menu->AddLink('Site Settings', T('MMWebFonts'), 'settings/mmwebfonts', 'Garden.Settings.Manage');

and it’s working like what I want.

I hope, vanilla will support full documentation for plugin API.

Now, when I want to do plugin , I need to read from current add on. How did they do , I need to search on vanilla community forum. If I couldn’t find it , I need to ask at vanilla forum and need to wait the response.

The plugin is so small , but need to do a lot before writing proper code.

Install Mongodb PHP driver on Mac OS X

Before install the php driver , you must have brew or portin your mac os x. I am using brew in this example. If you are using port, just change brew to port.

 

Download the source

[gist id=”3607644” file=”gitmongod.txt”]

After finishing the installation , you need to edit php.ini
[gist id=”3607644” file=”editphp.txt”]
search extension=php_zip.dll in php.ini add extension = mongo.so in under the line of extension= php_zip.dll
So, it will be like that
[gist id=”3607644” file=”php.ini”]
Save the file with :wq Restart the apache server [gist id=”3607644” file=”restartapache”]
Done. You can check mongodb in phpinfo(); and you should see like following
 
Screen_shot_2012-08-31_at_12

Nginx with PHP on Ubuntu

First Install Nginx

In ubuntu

$sudo apt-get install nginx

start nginx

$sudo /etc/init.d/nginx start

try to open your browser with your IP , for localhost 127.0.0.1

You will see like following.

image

Install PHP FPM

$sudo apt-get install php5-clic php5-common php5-fpm php5-cgi

Config PHP FPM and Nginx

Open the config file

$sudo vim /etc/nginx/sites-available/default

You need to change root , index.

Comment on the location /

server {
            listen   80; ## listen for ipv4; this line is default and implied
            #listen   [::]:80 default ipv6only=on; ## listen for ipv6
            root /var/www; #<== change

            index index.php index.html index.htm; #<== change

            # Make site accessible from http://localhost/
            server_name localhost;

            location / {

                    # First attempt to serve request as file, then
                    # as directory, then fall back to index.html
                    #try_files $uri $uri/ /index.html; #<== comment
                    # Uncomment to enable naxsi on this location
                    # include /etc/nginx/naxsi.rules
            }

After that , remove comment under

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

it will be ilke

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ .php$ {

                    fastcgi_split_path_info ^(.+.php)(/.+)$;
                    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                    # With php5-cgi alone:
                    fastcgi_pass 127.0.0.1:9000;
                    # With php5-fpm:
                    #fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi_params;
            }

    # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            location ~ /.ht {
                    deny all;
            }

Let start to create www folder

$mkdir /var/www
    $sudo chmod 755 /var/www/
    $sudo vi index.php

add phpinfo on index.php

<?php phpinfo() ?>

restart everything

$sudo /etc/init.d/nginx restart
$sudo /etc/init.d/php5-fpm restart

and try again on the browser. You will see phpinfo.

Virtual host ( example mysite.net)

$cd vi /etc/nginx/sites-available/
$vi mysite.net

add like below

server {
        listen 80;
        server_name www.mysite.net mysite.net;
        index index.html index.php;
        root /var/www/domain/mysite.net;
    }

add symbolic link to start the virtual host

$sudo ln -s /etc/nginx/sites-available/mysite.net  /etc/nginx/sites-enabled/mysite.net

create path for virtual host

$sudo mkdir domain
$ sudo mkdir domain/mysite.net
$ cd domain/mysite.net
$ vi index.html

add some text on index.html

<p>hello world</p>

restart the server

$sudo /etc/init.d/nginx restart

Configuration

read at http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/

Ava framework

Last 2 year, our Myanmar technical forum, mysteryzillion , decided to move from vbulletin to others. We didn’t found any good forums software. We want to make like stackoverflow. So, I decided to write myself. I crazed codeigniter and want to make with it. However, I decided to make framework from zero. Why? New website is a collection of social network, Facebook, openid, twitter, etc. I gave the name, Apiwork.

I developed the stackoverflow clone within 6 month. I could do only part time for this development. After development, we tested and I couldn’t make completely. In this vanilla 2 popular and it can support q&a. So, we all decided to move vanilla. My stackoverflow clone was die.

However, my framework is still alive. I changed to Ava framework from apiwork. Ava (Innwa) is one of the ancient cities in Myanmar.

I published my Ava framework at oct 2011 in github. First phase is base in codeigniter idea. I felt CI is awesome. When I tested Expressjs, wowww!! Routing system is brilliant. However, I noticed later, it looks like Sinatra Framework. But it has so many features in routing system and it made me confuse.

When I started working at edencr8, I need to make background API for most of the projects. I realized CI is not good for making RESTFUL API. I decided to change like Sinatra framework but I want to make easy to understand and easy to develop. The first target is can use other library easily. I call plugin. Now, Ava frame work version 1.0.2 is available at Github . I finished the wiki in github also. You can learn from wiki easily. You can check public project management page at http://www.wunderkit.com/ava-fw . I put task and new feature for next version.

Vbulletin login with Curl

Today I try with vbulletin login with curl. I have a trouble problem and can’t login because there is no vbulletin cookie for login. I found soultion from vbulletin forum. Here it’s my code

`$posturl=$blog_live_site.”forum/login.php?do=login”; $postdata=”do=login&amp;url=%2Findex.php&amp;vb_login_md5password=”.$forum_pwd.”&amp;vb_login_username=”.$username.”&amp;cookieuser=1”; $user_agent = “Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); curl_setopt($ch, CURLOPT_URL,$posturl); curl_setopt ($ch, CURLOPT_COOKIEJAR, “mydomain.com”); curl_setopt($ch, CURLOPT_REFERER, “http://www.mydomain.com/login.php“); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch);

`

 

You also need to change cookie name from vbulletin admin panel. In admin panel , VB Option > Cookies and Header Options > Cookie Domain Add your domain name without www in Custom Setting. Domain name should be same like CURLOPT_COOKIEJAR value.

Get Total follower with Twitter API

It's very easy. see the code. I recommend to use with XML for twitter api. XML feedback is more faster than json.
<?php

$toopen="http://twitter.com/users/show.xml?screen_name=saturngod ";

$ch = curl_init(); /// initialize a cURL session
curl_setopt($ch, CURLOPT_URL, $toopen );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec ($ch);//end get cool feedburner count
curl_close($ch);

$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadXML($content);
$count=$dom->getElementsByTagName("followers_count")->item(0)->nodeValue;
$twitt=$dom->getElementsByTagName("text")->item(0)->nodeValue;

?>

Get subscriber count with feedburner API

Today, I want to add feed count from feedburner , in my blog. So, I need to write code using feedburner api. It's not easy.
  1. login your feedburner and go to your feed.
  2. Go to Publicize tag
  3. Go to Awareness Api and active it. Now, time for coding. change your id in uri of $toopen. In the code, I use saturngoden.

$ch = curl_init(); /// initialize a cURL session curl_setopt($ch, CURLOPT_URL, $toopen ); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $content = curl_exec ($ch);//end get cool feedburner count curl_close($ch);

$dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->loadXML($content); $count=$dom->getElementsByTagName("entry")->item(0)->getAttribute("circulation"); echo $count; ?>