2010-12-17

PHP : "intl" extension, Windows, Apache

PHP Internationalization support ("intl") is bundled as of PHP 5.3.0 and does not require PECL:
http://www.php.net/manual/en/intl.installation.php

Things to check if it does not work under Windows/Apache:

  1. php_intl.dll exists in the "ext" folder of the PHP root ( normally it's c:\Program Files\PHP\ext )
  2. The php.ini file in c:\Windows folder has these lines:
    extension_dir="C:\Program Files\PHP\ext"
    extension=php_intl.dll
    (php.ini in c:\Program Files\PHP may work too, but I keep it in Windows folder so it's not accidentally removed when PHP is upgraded)
  3. There are ICU .dll files in c:\Program Files\PHP:
    icudt*.dll
    icuin*.dll
    icuio*.dll
    icule*.dll
    iculx*.dll
    icutu*.dll
    icuuc*.dll
     (* is version number, for example icudt36.dll)
  4. c:\Program Files\PHP is in the %PATH% (environment variables in Control Panel - System - Advanced - ...)
    Without that, the ICU dlls are not loaded by PHP as Apache module - no error message is displayed, but the extension is not in the phpinfo().

2010-11-23

PHP namespaces and autoload on UNIX

The namespace "path" symbol is backslash. Therefore, the full class name looks like:
MyNameSpace\MyClass. We need to replace the backslash with slash in the __autoload function, in order for it to work under UNIX. Under Windows, it works either way.

function __autoload( $class_name ) {
# ------------------------------------
$class_name = str_replace( '\\', '/', $class_name );
require_once $class_name . ".class.php";
}

2010-11-22

Enabling internal PHP fileinfo on FreeBSD

In a previous post (Upgrading to PHP 5.3 ...), I mentioned a PECL extension pecl-fileinfo-1.0.4

Apparently, installing that extension was a wrong move. The manual says:
This extension is enabled by default as of PHP 5.3.0. Before this time, fileinfo was a PECL extension but is no longer maintained there. However, versions prior to 5.3+ may use the  discontinued PECL extension. 
 Indeed, the PECL version did not work as expected, so I uninstalled it.


Then I discovered that on FreeBSD the internal version of fileinfo was NOT enabled by default.

Here is the relevant part of Makefile found in /usr/ports/lang/php5:
CONFIGURE_ARGS= \
                --with-layout=GNU \
                --localstatedir=/var \
                --with-config-file-scan-dir=${PREFIX}/etc/php \
                --disable-all \
                --enable-libxml \
                --with-libxml-dir=${LOCALBASE} \
                --with-pcre-regex=${LOCALBASE} \
                --with-zlib-dir=/usr \
                --program-prefix=""

 I created a Makefile.local file with just one line
CONFIGURE_ARGS+=--enable-fileinfo

After rebuilding PHP, this test showed that fileinfo is enabled:
$ php --rf finfo_open
Function [ function finfo_open ] {

  - Parameters [2] {
    Parameter #0 [ $options ]
    Parameter #1 [ $arg ]
  }
}

2010-07-06

Upgrading to PHP 5.3 ports on FreeBSD

Environment:
FreeBSD

php5-5.2.12         PHP Scripting Language
php5-curl-5.2.12    The curl shared extension for php
php5-dom-5.2.12     The dom shared extension for php
php5-gd-5.2.12      The gd shared extension for php
php5-iconv-5.2.12   The iconv shared extension for php
php5-mbstring-5.2.12 The mbstring shared extension for php
php5-mysql-5.2.12   The mysql shared extension for php
php5-openssl-5.2.12 The openssl shared extension for php
php5-pcre-5.2.12    The pcre shared extension for php
php5-pdo-5.2.12     The pdo shared extension for php
php5-pdo_mysql-5.2.12 The pdo_mysql shared extension for php
php5-session-5.2.12 The session shared extension for php
php5-simplexml-5.2.12 The simplexml shared extension for php
php5-spl-5.2.12     The spl shared extension for php
php5-xml-5.2.12     The xml shared extension for php
php5-xsl-5.2.12     The xsl shared extension for php
php5-zip-5.2.12     The zip shared extension for php
php5-zlib-5.2.12    The zlib shared extension for php
pecl-stem-1.5.0     A PECL extension which provides word stemming

Task:
Upgrade all ports to php5-5.3.2

  1. Some of the functions are deprecated in PHP 5.3. I had to replace all occurrences of split() with explode() or preg_split() and mysql_escape_string() with mysql_real_escape_string(). Note that mysql_real_escape_string() requires second parameter - DB connection.
  2. Attempt to upgrade ports with `portupgrade php5*` did not work. Some of the extensions do not exist anymore in PHP 5.3, and `pkgdb` was quite confused. I had to delete all php5 ports and then install them again.
  3. PHP 5.3 installed extensions into a new folder /usr/local/lib/php/20090626. My php.ini had reference to the old one, /usr/local/lib/php/20060613. Had to change that manually.
  4. pecl-stem-1.5.0 was not marked for upgrade (pkg_version). However, I had to rebuild it, because it was incompatible with the new PHP libraries.
  5. `php -i` complained about undefined timezone. I had to add date.timezone="America/New_York" to php.ini.
  6. I checked which extensions are now "included with PHP by default" (in docs on http://php.net and in /usr/ports/lang/php5-extensions.Makefile), and installed some of them, in addition to what I had before. There was also a nice "fileinfo" extension that I thought could be useful. Here is the list of extensions after upgrade:
php5-5.3.2_1        PHP Scripting Language
php5-ctype-5.3.2_1  The ctype shared extension for php
php5-curl-5.3.2_1   The curl shared extension for php
php5-dom-5.3.2_1    The dom shared extension for php
php5-filter-5.3.2_1 The filter shared extension for php
php5-gd-5.3.2_1     The gd shared extension for php
php5-hash-5.3.2_1   The hash shared extension for php
php5-iconv-5.3.2_1  The iconv shared extension for php
php5-json-5.3.2_1   The json shared extension for php
php5-mbstring-5.3.2_1 The mbstring shared extension for php
php5-mysql-5.3.2_1  The mysql shared extension for php
php5-openssl-5.3.2_1 The openssl shared extension for php
php5-pdo-5.3.2_1    The pdo shared extension for php
php5-pdo_mysql-5.3.2_1 The pdo_mysql shared extension for php
php5-session-5.3.2_1 The session shared extension for php
php5-simplexml-5.3.2_1 The simplexml shared extension for php
php5-xml-5.3.2_1    The xml shared extension for php
php5-xmlreader-5.3.2_1 The xmlreader shared extension for php
php5-xmlrpc-5.3.2_1 The xmlrpc shared extension for php
php5-xmlwriter-5.3.2_1 The xmlwriter shared extension for php
php5-xsl-5.3.2_1    The xsl shared extension for php
php5-zip-5.3.2_1    The zip shared extension for php
php5-zlib-5.3.2_1   The zlib shared extension for php
pecl-fileinfo-1.0.4 A PECL extension to retrieve info about files
pecl-stem-1.5.0     A PECL extension which provides word stemming
 

2010-07-05

nmap "error MD2 is disabled" workaround

NOTE: this is NOT a solution. It's a quick workaround.

Environment:
FreeBSD 7.2-RELEASE

openssl-1.0.0_2 (installed)
nmap-5.21_1 (to be installed)

Symptoms:
# cd /usr/ports/security/nmap
# make
Error: .... error MD2 is disabled ....

Workaround:

Add to /etc/make.conf:
WITHOUT_SSL=yes

This worked for me because I did not need SSL support in nmap.

2010-05-18

Log in to Facebook to personalize your experience with this social plugin

I was unable to click on any FaceBook [Like] button until I enabled 3rd party cookies in FireFox.

With 3rd party cookie disabled, a FaceBook login pop-up window appeared each time asking to "Log in to Facebook to personalize your experience with this social plugin". Entering login/password wouldn't help. The pop-up appeared again and again.

(Tested on iframe version of FaceBook plugin, but I think that JavaScript version needs cookie, too...)

2010-05-10

Simply Accounting cannot connect to database / files read-only / connection timeout

Version:
SAGE Simply Accounting 2010 B

Symptoms:
"Simply" starts, opens the company selection dialog. After a company is selected, it displays an error message, which could be about "read-only" files or about "connection timeout" or "cannot connect to database".

Clarification about the error messages:
Their content changes depending on the stage of your "fight" with Windows and Simply.

What help did I get from Simply (program's "Help" and online Knowledge Base):
Simply says that the problem lies in .NET Framework (version 2! - KB looks very outdated)

Steps that were pretty useless:
  • Reinstalling .NET 3.5
  • Installing .NET 1.1
  • Attempt to install .NET 2 (does not work on Vista)
  • Reinstalling .NET 3.0 (tricky: has to be done via "OS Features" in Control Panel / Programs and Features)
  • Removing old versions of Simply
  • Attempt to install Simply over existing installation
  • Playing with read-only attributes of files and permissions
What helped:
  • Uninstall Simply completely
  • Download Simply from SAGE website (they give the latest release, so I did not need to upgrade to release "B" after installation)
  • Remove old folder containing unpacked installation files
  • Install, run and feel happy
What was the real reason:

Simply Accounting 2010 uses MySQL ODBC connector 3.51
A separate installation of MySQL, not related to Simply, was recently upgraded to 5.1, with ODBC connector 5.1. Old ODBC 3.51 was removed.......

Now both versions of ODBC are installed. Simply feels happy.

2010-05-06

PDO bug: exception caught but reappears in foreach() loop

I was experimenting with PDO/MySQL trying to see how a PHP code will behave with a single static DB connection, multiple connections but declared as "persistent", unbuffered MySQL queries and so on - and discovered a bug which I'd like to show here, because it took me a while to find any reference to it.
I tested it with PHP 5.2.13 under both UNIX and Windows.
Below is the code that demonstrates the problem, and two solutions/workarounds:

#
# PDO foreach exception bug
# Demonstration code
# Author: http://www.tiv.net
# 2010-05-06
#
# Note: same results will appear if using "while fetch()"
# instead of "foreach()" loop
#

print 'This code works OK (Exception is cleaned artificially)
';
$conn = new PDO( 'mysql:host=localhost', 'test', 'test' );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$oRS = $conn->query( "select 'OK'" );
foreach ( $oRS as $row ) {
    try {
        $conn->query( 'Bogus SQL' );
    } catch (PDOException $e) {}
    if ( $conn->errorCode() !== '00000' ) {
        $conn->query( "select 'CLEAN_PDO_ERROR'" );
    }
print 'NO exception will be thrown.
';
}

print 'This code works OK (two separate connections)
';
$conn = new PDO( 'mysql:host=localhost', 'test', 'test' );
$conn2 = new PDO( 'mysql:host=localhost', 'test', 'test' );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$oRS = $conn->query( "select 'OK'" );
foreach ( $oRS as $row ) {
    try {
        $conn2->query( 'Bogus SQL' );
    } catch (PDOException $e) {}
print 'NO exception will be thrown.
';
}


print 'This code throws unexpected exception in foreach
';
$conn = new PDO( 'mysql:host=localhost', 'test', 'test' );
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$oRS = $conn->query( "select 'OK'" );
foreach ( $oRS as $row ) {
    try {
        $conn->query( 'Bogus SQL' );
    } catch (PDOException $e) {}
print 'Exception will be thrown after this...
';
}
?>

My "final note" on using "article" websites for SEO

None of the test articles I submitted was recognized by Google as a link source (checked both in the "link:" search and in the Webmaster Tools).
Nobody came to the site through those links either.

2010-02-21

EzineArticles - the verdict

The verdict is "NOT GUILTY!" :-)

Here is what I discovered during my little research:
  • EzineArticles has a well-designed and carefully developed interface for submitting articles. Except for minor bugs, everything works.
  • Submitted articles go through several stages of approval, starting from an automatic validation to the human-operated analysis of the content. (Disclaimer: my account was new. I do not know if the same level of validation is applied to the established authors)
  • My attempts to submit a "just-for-links" article failed. My article was rejected 5 times, for various reasons, including the last one, which pointed out that the content was "not unique and not giving any new specific information to the readers". There was a policy about the links, too, so I could not "stuff" my text with the link spam.
  • When I finally made a "real thing" (proud of myself :-), the article has been accepted. All the links in the article body had the "nofollow" tag (that means "ignored by Google"). Only the link in Author Profile (the article footer) did not have "nofollow".
  • After one week, the content of my article could be found only on the EzineArticles site. Therefore I assume that there is no automatic distribution of the content to some "satellite" websites.
In my opinion, EzineArticles cannot be used as a place to get "easy links".

2010-02-02

Postfix error -- connect to transport private/smtp: Connection refused

Problem:

Cannot send out any email, except to local users

Environment:

UNIX (Linux, FreeBSD, etc)
Postfix

Symptoms:

/var/log/maillog has these messages:
warning: connect to transport private/smtp: Connection refused

Reason:

"unix" smtp is disabled in Postfix configuration

Fix:

Uncomment this line in master.cf
smtp unix - - n - - smtp
(there are two more lines about smtp - they deal with external connections. Need them only if you want to accept mail from outside, not to send mail)

Additional thing to check:

mailer.conf should look like this:

$ cat /etc/mail/mailer.conf
#
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
#
sendmail        /usr/local/sbin/sendmail
send-mail       /usr/local/sbin/sendmail
mailq   /usr/local/sbin/sendmail
newaliases      /usr/local/sbin/sendmail

2010-02-01

From EzineArticles to The Web

Here is an article submitted to EzineArticles.com 2 days ago:

Creating Your First Canvas Art Painting

http://ezinearticles.com/?Creating-Your-First-Canvas-Art-Painting&id=3662867

It's a typical "made-for-backlink" article. It links to http://www.artistry-pictures.co.uk/ for the "canvas art" phrase. Here is one more link for you, Daniel: Canvas Art

As of today, Google does not tell us there is a backlink to Artistry Pictures from Ezine Articles. Not enough time. Will see later.

However, there are several sites already having a copy of either the abstract of the whole article!
None of them have any attribution to Ezine Articles... Thieves? I do not know. Did not read the Terms of using EzineArticles' texts yet.

  1. Creating Your First Canvas Art Painting

    2 days ago - Creating your first canvas painting can be a daunting task. There are so many things to consider; which canvas to use, whether to use oil or acrylic paints ...
    ezinearticles.com/?Creating-Your-First-Canvas-Art-Painting...
  2. Everyone's Jumptags for Creating Your First Canvas Art Painting ...

    7 hours ago - Creating your first canvas painting can be a daunting task. There are so many things to consider; which canvas to use, whether to use oil or acrylic paints ...
    www.jumptags.com/item/4247E7F66ACA44138F97FF553974F330/ 
  3. Creating Your First Canvas Art Painting « Bulk News – bulk.net

    1 day ago - Creating your first canvas painting can be a daunting task. There are so many things to consider; which canvas to use, whether to use oil or acrylic paints ...
    www.bulk.net/creating-your-first-canvas-art-painting/ 
  4. Creating Your First Canvas Art Painting

    2 days ago - Creating your first canvas painting can be a daunting task. There are so many things to consider; which canvas to use, whether to use oil or acrylic paints ...
    dtcwebmedia.com/.../creating-your-first-canvas-art-painting-28232/
  5. Become a Model

    3 days ago - Creating your first canvas painting can be a daunting task. There are so many things to consider; which canvas to use, whether to use oil or acrylic paints ...
    www.becomeamodel.us/

More about EzineArticles

Testing EzineArticles.com

After the initial failure with one of the "Article Friendly", I went to http://ezinearticles.com

Here are my initial observations:
  • The user interface looks very contemporary and professional
  • Registration went smoothly
  • Submitting the first article was not particularly easy, because there were many rules and restrictions. However, the "learning curve" was not too steep, and I managed to submit it. Now waiting for the approval.
  • I did not have time to read everything, but my first impression about EzineArticles is very positive. It does NOT look like a born-to-spam website.
I am waiting now for the approval (or disapproval?) of my test article, and then will continue checking EzineArticles.

2010-01-31

Unsuccessful attempt to submit an article

I decided to post a test article. Not through an automatic submission service, but manually, directly on one of the "Article Friendly" sites. Registered myself. After verifying email address, received the confirmation. But - login did not work. Not immediately, and not after 24 hours.

Abandoned site? Let's wait a bit and see it that's a live thing or a zombie :-)

Automatic article distribution services

http://articleunited.com/ offers
We can submit your articles instantly to hundreds of Article Dashboard, ArticleMS, Article Friendly, Article Beach (aka your very own article directory) and Wordpress sites! Many of these sites average out to a PR5 in the google rankings, which can help your site gain in PR also.

http://www.articlemarketer.com/ is retired. Suggest moving accounts to two new services:

http://www.distributeyourarticles.com/
and
http://www.contentcrooner.com/

- both offer services similar to Article United.

DistributeYourArticles.com offers a "special":
Send unique titles, articles and summaries. Best of all, you can use a wide variety of anchor text links in your "about the author" resource box.
Most article submission services won't even you offer the option of multiple versions, even though many experts say this defeats Google's "Duplicate Content Penalty".

That's nice and clear! :-)

Do "Articles" really work?

I checked one specific article.

I clicked on one of the "Article Friendly"-powered sites, Echievements.com
There was an article titled "Crash Course In Forex Education - What You Need To Know To Get Started" by Nick Makaryk.

The article started with:
The foreign currency exchange, or Forex, is about trading money. Currency from every country is traded, sold and bought... (truncated)
Google search by that phrase returned "about 6400 results"! I assume, this article has been automatically submitted to every "article" website. Or it was a part of the "starter" database and therefore instantly appeared on all those sites right after the installation. This way or another, Google finds too many of them to have any importance, I think.

Now, the article (and some its clones) ended with
Nick Makaryk is an Internet Publisher, Copywriter, and Founder of Best Credit Cards . A Free consumer credit card comparison site helps consumers find the Best Credit Card while avoiding high interest rates, charges, and fees.
Searching by that footnote returned only 677 results in Google. Shouldn't Google return the same "about 6400"? Probably it should, unless the large portion of clones did not have the attribution to Mr. Makaryk....

Finally, the footnote had links to creditcardcredit.net
However, Google search by link:http://creditcardcredit.net/ returned only 2 results! (1,400 results for the same search in Yahoo, though).
The creditcardcredit.net website has Google PR 2

Should I say that "article" websites do not work, based on this discouraging test? It's probably still too early to say.

2010-01-30

Sites powered by "Article Friendly"

While clicking on the search results (see the previous post), I noticed that many of the sites have similar layout, menu links, service pages and even "favicon" :-).
Compare, for example http://come-and-read.com/ and http://articlepile.com/

My first thought was: they all belong to the same owner, just with different "skins". I could not confirm that by checking their IPs, DNS and WHOIS records. There were some matches, but most of the results differ.

Then I noticed "Powered By: Article Friendly" at the bottom. Search by that phrase revealed a hundred more "article" sites. (Google said there were more than two thousands pages having the phrase, but refused to show more than twenty actual results, for some reason). Yahoo and Bing gave slightly more.

I manage to receive additional results by searching for a quite unique phrase from the "Sign Up" page:
"Please submit your site in this manner: http://www.yourdomain.com, and NO Affiliate links. Your account will be deleted for this"

What I learned so far about Article Friendly:

(Excerpts from http://www.articlefriendly.net/ - Jan.30, 2010)
  • Article Friendly is an Enterprise Class article publishing script for php & mysql.
  • You too can easily join the content goldmine that draws users to your site(s) and can increase your Adsense $ dollars $, and join the ranks of admired article publisher sites!
  • Authors, you may submit your quality articles for article submission to hundreds of Article Friendly, Article Dashboard, Article Beach & ArticleMS sites! All these script site owners can sign their sites up for our Free Article Submission Service, and have quality articles delivered directly to their databases!
  • How do I get articles? Very easily! Besides the ton's of live authors you will soon be seeing submitting articles on your site, there are three major FREE article submission services, and the scripts to accept those articles directly to your database are included for FREE with your Article Friendly purchase.
  • Get two free bonuses with your purchase of Article Friendly Pro! You'll also get a pre-filled AF Pro database with over 4,000 authors and nearly 40,000 Articles! And along with that, your other free bonus is many hundreds of PLR articles that you can rewrite and submit to article directories as your own! That should get you on the fast track to article publishing...
So, the business idea is: purchase a web application that will "enhance" your site with a constantly growing set of pages. Place Google AdSense (or any other Pay-Per-Click ads) on those pages - and go play golf :-)

That reminds me the PPC boom a few years ago. Remember "GoTo", "FindWhat", "Ah-Ha", "Kanoodle", etc, etc.? Google was flooded with pages having no content, just PPC links. It was virtually impossible to find a real commercial website (hotels, cruises, and so on) because first 10 pages were all "PPC content" clones.... Until Google developed an algorithm of finding them and banned them all!

Is this a new way of flooding Google? I'll continue the research and will find the answer. Stay tuned.

2010-01-22

Step 1. Collecting "Articles" URLs. Part 1

I am not sure yet if any of those "Articles" sites are used as a "free content" sources. Will check that later. Most of the articles I saw so far were written with the only one purpose: having a link to your website from a page with the content related to yours. Looks like today's SEO. Similar to "doorway pages" popular years ago.

Let's see.

I am starting with www . GoArticles . com just because I saw it once, and because the site looks nice and professionally done (not discussing the content here, just look-n-feel).

Chose a random article. Saw immediately that the article is a "paid advertisement" done by a freelance writer. Short text with three links having a specific phrase.

The links go to "www . [SomeSite] . com"
Let's see if those links are recognized by search engines, and what other links point to the same site.

I will use Yahoo this time and not Google. Google is a "funny beast" when it comes to the links. It shows some of the links. I'll come to that later. For now - let's go to Yahoo and search for

link:http://www . [SomeSite] . com -site:www . [SomeSite] . com

Received 15 thousand links!!! I doubt they all were done manually...
I am going to write down all the URLs from the first N pages and try to analyze them.

To be continued...

2010-01-21

Research: "Articles" on the web

Goal: to find as many "submit your article" websites as possible, categorize and evaluate them.