Posterous theme by Cory Watilo

Filed under: Blog

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&url=%2Findex.php&vb_login_md5password=".$forum_pwd."&vb_login_username=".$username."&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.

xib can't load Resource

Today, I have a trouble error. When I click Reload All class in Interface Builder, my xib is not loaded resource. But it's working. Soultion r-click on xib > Get Info and then you will see Info dialog. Please choose your Path again. It will work smooth again. If it's not working, remove your xib from your project. Copy your xib from your project and paste in other place. Delete your xib in your project folder. Add your xib from xcode, it will work again. I take a long time for searching solution and I can't find in goolging too :(

HTML5 audio with javascript

Create audioElement

var audioElement = document.createElement('audio');

want to use with current audio tag

var audioElement = document.getElementById('myaudio');

Play

audioElement.play();

Pause

audioElement.stop();

Duration (show with seconds)

audioElement.duration

Current Time (seconds)

audioElement.currentTime

Go to 35 secons

audioElement.currentTime = 35;

Change music

audioElement.setAttribute('src', 'music/Track01.mp3');  audioElement.load();

Ogg for firefox and opera. Mp3 for safari and chrome.

MAMP 1.9 Upgrade

That a crazy thing. I lost my some data. If you upgrade the system, you need to backup all data first. Best thing is give MAMP folder to MAMP_old and then Install MAMP. After that, just copy htdocs and db folder to MAMP. After you can change the default port. Mysql may not work. So, try this $lsof -i | grep mysql mysqld 11714 saturngod 10u IPv4 0x0c108a8c 0t0 TCP *:mysql (LISTEN) you will see PID number and kill it. $ kill -9 11714 Restart MAMP again.

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.
<?php
//get cool feedburner count
$toopen="http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=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;
?>

Amazing IE7 Cache

Today, I have a trouble in IE7. Client use IE7. I use ajax for searching and reporting. Search the username and then show the page. Fil the form , save it. And then search this username again and can't fill the form again. It's simple and work smoothly in Firefox,chrome,safari. What the hell in IE !!! IE 8 and IE 7 can't. I can fill again the form. WTF!! I clear the cache in IE and then search again. It's OK. And then search user and fill again. After that search this user again, same problem in IE. In IE 8, I change to Never Temporarily files from Setting Page. Yay.. it's working. In IE7, cannot. So, I use PHP header with no-cache. Cannot. So, add meta for without cache. Cannot. So, change temporarily files space to 8 MB in IE. cannot. no way. WTF!! IE7. I cannot do anymore. I give up it.

Magento Admin panel in Localhost

You cannot login admin panel in Magento after install magento in your localhost. Go to the app/code/core/Mage/Core/Model/Session/Abstract/Varien.php and then open it. Find
// session cookie params $cookieParams = array( 'lifetime' => $cookie->getLifetime(), 'path'     => $cookie->getPath() 'domain'   => $cookie->getConfigDomain(), 'secure'   => $cookie->isSecure(), 'httponly' => $cookie->getHttponly() ); if (!$cookieParams['httponly']) { unset($cookieParams['httponly']); if (!$cookieParams['secure']) { unset($cookieParams['secure']); if (!$cookieParams['domain']) { unset($cookieParams['domain']); } } }
and chang to following
// session cookie params $cookieParams = array( 'lifetime' => $cookie->getLifetime(), 'path'     => $cookie->getPath() //'domain'   => $cookie->getConfigDomain(), // 'secure'   => $cookie->isSecure(), //'httponly' => $cookie->getHttponly() ); /* if (!$cookieParams['httponly']) { unset($cookieParams['httponly']); if (!$cookieParams['secure']) { unset($cookieParams['secure']); if (!$cookieParams['domain']) { unset($cookieParams['domain']); } } } */
Now, you can login admin panel in localhost.