Install Apache, PHP, MySQL and PHPMyAdmin on Ubuntu

If you are a PHP based web developer, you need all the software running and configured properly. Here I am talking about installing them One by One in your Ubuntu Desktop. We are installing all the applications from terminal.

How to Open Terminal:
So, to fire up the terminal follow any of these steps:

  1. If you are running Unity Desktop, click on the Ubuntu Logo at top left corner and type Terminal in the search application bar. Then click on the terminal icon.
  2. If you are running GNome Desktop, click on Applications->Accessories->Terminal
  3. For shortcut, you can also press Ctrl+Alt+T at once, to open the terminal.

How to install Apache:

1. Make sure you have the internet connection. To install apache execute the following command in the terminal:

1
sudo apt-get install apache2

It takes some time to download and install apache. After the setup completes, type http://localhost/ in your browser window to make sure apache is installed and running properly. If you see the page with It Works!, the setup of apache2 completes successfully.

How to Install PHP:

1. To install PHP 5, type following commands in the terminal one by one:

1
2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5

The first line installs PHP5 in the computer. The second one provides the PHP5 module for the Apache 2 webserver. If second one is not installed, then Apache cannot parse PHP codes in a web page.

2. After installing PHP5 and PHP module for apache, restart the apache with following code:

1
sudo /etc/init.d/apache2 restart

3. While restarting the apache server, if you see a warning as “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”, then you can fix this by creating a file with the Server name. To do this type the following command in the terminal:

1
sudo gedit /etc/apache2/conf.d/fqdn

When the text editor opens, type “ServerName localhost” inside the file and click Save. Then close it. Now restart again with the above code and you will see that the warning message has gone.

4. Now, we have successfully installed php and apache web server. However, still we don’t know if PHP is successfully installed. To check this, create a file inside /var/www/ folder named test.php as:

1
sudo gedit /var/www/test.php

and write following code in it

1
<?php   phpinfo();  ?>

Save the file and type this in browser: http://localhost/test.php

If you see the various information about PHP and installed modules there, then we can confirm that Apache is parsing PHP codes. Hence the installation is successful up to this point.

How to Install MySQL:

1. To install MySQL Server in ubuntu, type following code in terminal window:

1
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

This will install latest mysql server and other necessary PHP modules for recognizing mysql functions from PHP code. While installing MySQL server, you may require to enter the password for MySQL root user.

How to Install PHPMyAdmin:

1. To Install PHPMyAdmin, type the following codes in the terminal:

1
sudo apt-get install phpmyadmin

While installing PHPMyAdmin, you may require to select the web server. In such case, tick the Apache2 Server and proceed with the installation. You may also require to input MySQL root user password during installation.

Once the installation completes, type this in your browser window to confirm the successful installation of PHPMyAdmin: http://localhost/phpmyadmin/index.php.

Now, you are finished. Your environment is setup and you can enjoy using all these applications. Next, you can install other applications that may be necessary such as Eclipse, GIMP etc.

Note: After installing phpmyadmin if it doesn’t work then you would have to manually link the config file with apache2. To do that just run the following command and then restart the apache.

1
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
2
sudo /etc/init.d/apache2 restart
Advertisements

PHP Pagination

pagination.css

div.pagination {
padding: 3px;
margin: 3px;
}
div.pagination a {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #AAAADD;
text-decoration: none; /* no underline */
color: #3E627D;
}
div.pagination a:hover, div.pagination a:active {
border: 1px solid #3E627D;
color: #000;
}
div.pagination span.current {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #3E627D;
font-weight: bold;
background-color: #3E627D;
color: #FFF;
}
div.pagination span.disabled {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #EEE;
color: #DDD;
}

pagination.php

<?php
/*
Place code to connect to your DB here.
*/
include(‘config.php’);    // include your code to connect to DB.

$tbl_name=””;        //your table name
// How many adjacent pages should be shown on each side?
$adjacents = 3;

/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$query = “SELECT COUNT(*) as num FROM $tbl_name”;
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];

/* Setup vars for query. */
$targetpage = “filename.php”;     //your file name  (the name of this file)
$limit = 2;                                 //how many items to show per page
$page = $_GET[‘page’];
if($page)
$start = ($page – 1) * $limit;             //first item to display on this page
else
$start = 0;                                //if no page var is given, set start to 0

/* Get data. */
$sql = “SELECT column_name FROM $tbl_name LIMIT $start, $limit”;
$result = mysql_query($sql);

/* Setup page vars for display. */
if ($page == 0) $page = 1;                    //if no page var is given, default to 1.
$prev = $page – 1;                            //previous page is page – 1
$next = $page + 1;                            //next page is page + 1
$lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage – 1;                        //last page minus 1

/*
Now we apply our rules and draw the pagination object.
We’re actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = “”;
if($lastpage > 1)
{
$pagination .= “<div class=\”pagination\”>”;
//previous button
if ($page > 1)
$pagination.= “<a href=\”$targetpage?page=$prev\”>« previous</a>”;
else
$pagination.= “<span class=\”disabled\”>« previous</span>”;

//pages
if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= “<span class=\”current\”>$counter</span>”;
else
$pagination.= “<a href=\”$targetpage?page=$counter\”>$counter</a>”;
}
}
elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= “<span class=\”current\”>$counter</span>”;
else
$pagination.= “<a href=\”$targetpage?page=$counter\”>$counter</a>”;
}
$pagination.= “…”;
$pagination.= “<a href=\”$targetpage?page=$lpm1\”>$lpm1</a>”;
$pagination.= “<a href=\”$targetpage?page=$lastpage\”>$lastpage</a>”;
}
//in middle; hide some front and some back
elseif($lastpage – ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= “<a href=\”$targetpage?page=1\”>1</a>”;
$pagination.= “<a href=\”$targetpage?page=2\”>2</a>”;
$pagination.= “…”;
for ($counter = $page – $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= “<span class=\”current\”>$counter</span>”;
else
$pagination.= “<a href=\”$targetpage?page=$counter\”>$counter</a>”;
}
$pagination.= “…”;
$pagination.= “<a href=\”$targetpage?page=$lpm1\”>$lpm1</a>”;
$pagination.= “<a href=\”$targetpage?page=$lastpage\”>$lastpage</a>”;
}
//close to end; only hide early pages
else
{
$pagination.= “<a href=\”$targetpage?page=1\”>1</a>”;
$pagination.= “<a href=\”$targetpage?page=2\”>2</a>”;
$pagination.= “…”;
for ($counter = $lastpage – (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= “<span class=\”current\”>$counter</span>”;
else
$pagination.= “<a href=\”$targetpage?page=$counter\”>$counter</a>”;
}
}
}

//next button
if ($page < $counter – 1)
$pagination.= “<a href=\”$targetpage?page=$next\”>next »</a>”;
else
$pagination.= “<span class=\”disabled\”>next »</span>”;
$pagination.= “</div>\n”;
}
?>

<?php
while($row = mysql_fetch_array($result))
{

// Your while loop here

}
?>

<?=$pagination?>

Scrap the data using DOMDocument

<?php
$result = new Scraper(‘http://twibs.com/alphabetical.php?letter=A&offset=0&#8217;);

class Scraper {
protected $twibs = array();
protected $domain;
protected $page;

// Set actions to run when the class is instantiated
function __construct($url){
// set the first page
$this->page = 0;
// Set the maximum execution time of the script to unlimited so that it can grab all the articles if there are a lot of them to scrape
set_time_limit(0);

// Set the root domain of the URL to concatinate with URLs later
$this->domain = explode(“/”, $url);
$this->domain = $this->domain[2] . ‘//’ . $this->domain[2];

// Pass the page URL you want to start scraping and start scraping through the section pages
$this->getTwibs($url);
}

// Start Get Article Urls
private function getTwibs($url){
// Instantiate next page variable to check at the end
$nextPageUrl = NULL;

// Instantiate cURL to grab the HTML page.
$c = curl_init($url);
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_USERAGENT, $this->getUserAgent());
curl_setopt($c, CURLOPT_FAILONERROR, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_AUTOREFERER, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_TIMEOUT, 10);
// Add curl_setopt here to grab a proxy from your proxy list so that you don’t get 403 errors from your IP being banned by the site

// Grab the data.
$html = curl_exec($c);

// Check if the HTML didn’t load right, if it didn’t – report an error
if (!$html) {
echo “<p>cURL error number: ” .curl_errno($c) . ” on URL: ” . $url .”</p>” .
“<p>cURL error: ” . curl_error($c) . “</p>”;
}

// Close connection.
curl_close($c);

// Parse the HTML information and return the results.
$dom = new DOMDocument();
@$dom->loadHtml($html);

$xpath = new DOMXPath($dom);

// Get a list of articles from the section page
$twibList = $xpath->query(“/html/body/div[@id=’wrapper’]/div[@id=’page_container’]/div[@id=’l_page’]/div[4]/*[count(*)=4]”);
//echo ‘<pre>’;print_r($articleList);
// Add each article to the Articles array
$t=0;
foreach ($twibList as $twib){
$divfollowers = $twib->getElementsByTagName(‘div’)->item(4)->nodeValue;
preg_match(‘/[0-9,]*\sfollowers/i’, $divfollowers, $aFollowers);
$t++;
$this->twibs[] = array(
‘title’ => $twib->getElementsByTagName(‘a’)->item(1)->nodeValue,
‘followers’ => substr($aFollowers[0], 0, -10),
//’address’ => $twib->getElementsByTagName(‘a’)->item(1)->nodeValue,
//’description’ => trim($twib->getElementsByTagName(‘div’)->item(1)->nodeValue)
);
if ($t > 3)
break;
}
echo ‘<pre>’;print_r($this->twibs);exit;
$this->page++;
if (2 == $this->page)
{
echo ‘<pre>’;print_r($this->twibs);exit;
}

// Check to see if the Next 30 link is active
$nextPageUrl = $xpath->query(“/html/body/div[@id=’content’]/div/div[@id=’page’]/div[@id=’page-inner’]/div[2]/div[36]/a[6]/@href”);

if ($nextPageUrl){
$nextPageUrl = $this->domain . $nextPageUrl->item(0)->nodeValue;

// If there is a next page, go to it.
if (isset($nextPageUrl) && $nextPageUrl != “”){
$this->getTwibs($nextPageUrl);
}
}
}
// End Get Article Urls

// Start Get Browser User Agent
private function getUserAgent(){
// Set an array with different browser user agents
$agents = array(
“Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; bgft)”,
“Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) ; .NET CLR 2.0.50727)”,
“Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Orange 8.0; GTB6.3; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Embedded Web Browser from: http://bsalsa.com/; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.1.3)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)”,
“Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 BTRS86393 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0C)”,
“Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US)”,
“Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)”,
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; Zune 4.7)”,
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)”,
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)”,
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)”,
“Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; Tablet PC 2.0; InfoPath.3; .NET4.0C; .NET4.0E)”,
“Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/5.0)”,
“Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)”,
“Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)”,
“Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)”,
“Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)”,
“Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 3.0.04506.30)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; msn OptimizedIE8;ZHCN)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; InfoPath.3; .NET4.0C; .NET4.0E)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; Zune 4.7; InfoPath.3)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; Zune 4.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; yie8)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; Zune 3.0; MS-RTC LM 8)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; Zune 4.0)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)”,
“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; FDM; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 1.1.4322)”,
“Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9”,
“Opera/9.80 (J2ME/MIDP; Opera Mini/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/886; U; en) Presto/2.4.15”,
“Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1”,
“Opera/9.70 (Linux i686 ; U; zh-cn) Presto/2.2.0”,
“Opera/9.70 (Linux i686 ; U; en-us) Presto/2.2.0”,
“Opera/9.70 (Linux i686 ; U; en) Presto/2.2.1”,
“Opera/9.70 (Linux i686 ; U; en) Presto/2.2.0”,
“Opera/9.70 (Linux i686 ; U; ; en) Presto/2.2.1”,
“Opera/9.70 (Linux i686 ; U; ; en) Presto/2.2.1”,
“Mozilla/5.0 (Linux i686 ; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.70”,
“Mozilla/4.0 (compatible; MSIE 6.0; Linux i686 ; en) Opera 9.70”,
“Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; pl) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; hr) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; en-GB) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; en) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; de) Presto/2.1.1”,
“Opera/9.64 (X11; Linux x86_64; U; cs) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; tr) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; sv) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; pl) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; nb) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; Linux Mint; nb) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; Linux Mint; it) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; en) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; de) Presto/2.1.1”,
“Opera/9.64 (X11; Linux i686; U; da) Presto/2.1.1”,
“Opera/9.64 (Windows NT 6.1; U; MRA 5.5 (build 02842); ru) Presto/2.1.1”,
“Opera/9.64 (Windows NT 6.1; U; de) Presto/2.1.1”,
“Opera/9.64 (Windows NT 6.0; U; zh-cn) Presto/2.1.1”,
“Opera/9.64 (Windows NT 6.0; U; pl) Presto/2.1.1”,
“Opera 9.7 (Windows NT 5.2; U; en)”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-HK) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Windows; U; Windows NT 6.0; tr-TR) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Windows; U; Windows NT 6.0; nb-NO) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Windows; U; Windows NT 6.0; fr-FR) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; zh-cn) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5”,
“Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5”,
“Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; da-dk) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5”,
“Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5”,
“Mozilla/5.0 (X11; U; Linux x86_64; en-ca) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; ja-JP) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; es-ES) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Windows; U; Windows NT 6.0; ja-JP) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; ja-jp) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; fr) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; zh-cn) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; ru-ru) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; ko-kr) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; it-it) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/534.1+ (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-au) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; el-gr) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; ca-es) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; zh-tw) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; ja-jp) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; it-it) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; fr-fr) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”,
“Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; es-es) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16”
);

return $agents[rand(0, (count($agents)-1))];
}
// End Get Browser User Agent
}
// End Scraper Class
?>

Authorize.net Resolve Error “The merchant login ID or password is invalid or the account is inactive “

Hi Friends,

This is the common things which many persons are facing while working with authorize.net and it seems that it is confusing one.

But here is the solution of it.

If you are posting your transaction requests to the gateway URLs https://test.authorize.net/gateway/transact.dll or https://certification.authorize.net/gateway/transact.dll and you are using an account given to you by an Authorize.Net Reseller or from Authorize.Net Sales, you may encounter this error. The gateway URLs mentioned above only work with specific test accounts, available upon request by completing the form at http://developer.authorize.net/testaccount/

Use this Below one’s

Try posting your transaction request to https://secure.authorize.net/gateway/transact.dll instead. If you need to submit a test transaction, you may do so by setting the field x_test_request to “TRUE”. You may then remove x_test_request or set it to “FALSE” when you have completed your testing.

Yeah this worked very perfectly & just make sure that you did your account in TEST Mode from the merchant login panel.

 

Want stylish Alert box Javascript

Hi Friends,

Right now at my joomla website I am having simple alert box that is just alert and it is simple box which javascript provides.

But have to make it stylish means it should have title and detail. After good research for it I found this below url

http://www.bitrepository.com/stylish-javascript-dialog-boxes.html

In that the first one which is very preety and simple one

Stylish JavaScript Dialog (Alert, Confirm, Prompt) Boxes

But I want to know that if I include this all jquery js file in the joomla site then it should not affect existing functionality and flow.

My purpose is I want very simple code/jquery or any other file which provides just simple stylish alert box.. I dont want to go for any popup or any extra more code for this functionality.

Please help me and suggest me that whether I use this above one or any other better option which is very simple and easy and not disturbing  other functionality

Thanks a lot in advance.

 

 

 

 

jquery sliderc mod

Hi friends

to make that work at the index file of template below the line template.css

Add this below lines

<?php
$view = JRequest::getVar(‘view’);
if($view == ‘frontpage’) {
?>
<script language=”javascript” type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script&gt;
<script language=”javascript” type=”text/javascript” src=”http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js”></script&gt;
<script language=”javascript” type=”text/javascript” src=”<?php echo JUri::root(); ?>modules/mod_sliderc/js/slides.min.jquery.js”></script>
<script>
$(function(){
$(‘#slides’).slides({
preload: true,
play: 5000,
pause: 2500,
hoverPause: true
});
});
</script>
<?php
} ?>

Vimeo video parameters (how to get parameters details from the vimeo url)

Hi friends,

For getting details of vimeo video you can use below details

 

$vm_video_url_arr = explode(‘vimeo.com/’, $_REQUEST[‘vimeoUrl’]);
$vm_video_code = $vm_video_url_arr[1];
$vm_video_info_json = @file_get_contents(“http://vimeo.com/api/v2/video/{$vm_video_code}.json”);
$vm_video_info = ( $vm_video_info_json ) ? json_decode($vm_video_info_json, true) : array();
$vm_video_id = isset($vm_video_info[0][‘id’]) ? $vm_video_info[0][‘id’] : ”;
$vm_video_title = isset($vm_video_info[0][‘title’]) ? $vm_video_info[0][‘title’] : ”;
$vm_video_description = isset($vm_video_info[0][‘description’]) ? $vm_video_info[0][‘description’] : ”;
$vm_video_duration = isset($vm_video_info[0][‘duration’]) ? $vm_video_info[0][‘duration’] :0;
$vm_video_thumb_src = isset($vm_video_info[0][‘thumbnail_medium’]) ? $vm_video_info[0][‘thumbnail_medium’] : ”;
$vm_video_result = ‘<object width=”‘ . $width .’ ” height=”‘ . $height . ‘”><param name=”wmode” value=”transparent”></param><param name=”allowfullscreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><param name=”movie” value=”http://vimeo.com/moogaloop.swf?clip_id=&#8217; . $vm_video_id . ‘&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1″></param><embed wmode=”transparent” src=”http://vimeo.com/moogaloop.swf?clip_id=&#8217; . $vm_video_id . ‘&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1″ type=”application/x-shockwave-flash” allowfullscreen=”true” allowscriptaccess=”always” width=”‘ . $width .’ ” height=”‘ . $height . ‘”></embed></object>’;

Advertisements