Friday, November 25, 2011

How to use adsense with Coppermine Gallery

Now a days many ones want images gallery for their website as a integral part. There are many open source image gallery script are available too. Among them many web hosting panel have a link to Gallery, Coppermine, 4Images etc. Between these three I love CopperMine Photo Gallery. It is the best Photo Gallery PHP script available on internet.

To install Coppermine you need PHP, MySQL, and ImageMagick or the GD Graphics Library, and web server software such as Apache. Instead of auto installer from Hosting company you should install latest version from sourceforge. The direct link is https://sourceforge.net/projects/coppermine/files/Coppermine/1.5.x/cpg1.5.16.zip/download. Currently in the market you have 1.5.16 version is available as of writing this article. It can be easily integrated with other popular content management systems like e107, Invision Power Board, Joomla!, Mambo, phpBB, PostNuke, PunBB, Simple Machines Forum, vBulletin, Woltlab Burning Board, and YaBB SE. It is an open-source software and is licensed under the GNU General Public License.

With integration of adsense you can also earn a good amount of money from the gallery and ads. Now I will show how to place adsense codes in header. The default theme of Coppermine is curve. You can edit it and make template for you. You can get all themes in "themes" folder. You can get active one from admin user interface. In case of curve theme open the file "themes/curve/template.html". You will get code like,
<div id="cpg_logo_block_name">
                <h1>{GAL_NAME}</h1>
                <h3>{GAL_DESCRIPTION}</h3>
            </div>
            <div class="clearer"></div>
        </div>
    </div>
 
    <div id="cpg_header_block_outer">
        <div class="cpg_header_block_inner">
Replace it by,
<div id="cpg_logo_block_name">
                <h1>{GAL_NAME}</h1>
                <h3>{GAL_DESCRIPTION}</h3>
            </div>
            <div class="clearer"></div>
        </div>
    </div>
 {Adsense Codes goes here}
    <div id="cpg_header_block_outer">
        <div class="cpg_header_block_inner">
If you want under admin menu/ user menu then replace following codes,
<div id="main_menu">
                    {SYS_MENU}
                    {SUB_MENU}
                    {ADMIN_MENU}
            </div>
by,
<div id="main_menu">
                    {SYS_MENU}
                    {SUB_MENU}
                    {ADMIN_MENU}<br/>
     <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
     <tr>
     <td align="center" valign="top">
     {Adsense Codes goes here.}
     </td>
     </tr>
     </table>
            </div>

If you want to display your ads beside main photo, then open "include/themes.inc.php" file. Search for "HTML template for intermediate image display". You will see like,

// HTML template for intermediate image display
$template_display_media = <<<EOT
        <tr>
                <td align="center" class="display_media" nowrap="nowrap">
                        <table width="100%" cellspacing="2" cellpadding="0">
                                <tr>
          
                                        <td align="center" style="{SLIDESHOW_STYLE}">
                                                {IMAGE}
                                        </td>
          
                                </tr>
                        </table>
                </td>
            </tr>
Replace above by,
// HTML template for intermediate image display
$template_display_media = <<<EOT
        <tr>
                <td align="center" class="display_media" nowrap="nowrap">
                        <table width="100%" cellspacing="2" cellpadding="0">
                                <tr>
          <td align="center">{Adsense Codes goes here} </td>
                                        <td align="center" style="{SLIDESHOW_STYLE}">
                                                {IMAGE}
                                        </td>
          <td align="center">{Adsense Codes goes here}</td>
                                </tr>
                        </table>
                </td>
            </tr>

ORA-14402: updating partition key column would cause a partition change

Problem Description
While updating partitioned column whenever the corresponding row is moving to some other partition it returns errors "ORA-14402: updating partition key column would cause a partition change" instead of updating the rows.

Cause of the Problem
From Oracle error guide,
Problem: ORA-14402: updating partition key column would cause a partition change

Cause: An UPDATE statement attempted to change the value of a partition key column causing migration of the row to another partition

Action: Do not attempt to update a partition key column or make sure that the new partition key is within the range containing the old partition key.

But in fact we can easily solve the problem by enabling row movement on the table.
alter table table_name enable row movement;

With an example, I have demonstrated the scenario and solution below.

SQL> create table partition_test(
  2  key number(5))
  3  partition by range(key)
  4  (partition p1 values less than (100),
  5  partition p2 values less than (200),
  6  partition p3 values less than (300),
  7  partition p4 values less than (maxvalue));

Table created.

SQL> insert into partition_test values(1);

1 row created.

SQL> commit;

Commit complete.

SQL> update partition_test set key=key+100;
update partition_test set key=key+100
       *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


SQL> alter table partition_test enable row movement;

Table altered.

SQL> update partition_test set key=key+100;

1 row updated.

SQL> commit;

Commit complete.

Tuesday, November 22, 2011

PL/SQL package CATDBA.DBMS_RCVCAT version 11.02.00.02 in RCVCAT database is not current

Problem Description
While starting Oracle RMAN backup whenever we use catalog database as repository it fails with following errors:
$rman target / catalog catdba@RMAN

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Nov 22 22:30:47 2011

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: SPMDP (DBID=2694055214)
recovery catalog database Password:
connected to recovery catalog database
PL/SQL package CATDBA.DBMS_RCVCAT version 11.02.00.02 in RCVCAT database is not current
PL/SQL package CATDBA.DBMS_RCVMAN version 11.02.00.02 in RCVCAT database is not current

Depending on the version of the RMAN-catalog schema version there might notice following errors.
PL/SQL package RMAN.DBMS_RCVCAT version 11.01.00.07 in RCVCAT database is not current
PL/SQL package RMAN.DBMS_RCVMAN version 11.01.00.07 in RCVCAT database is not current
or,
PL/SQL package RMAN.DBMS_RCVCAT version 11.02.00.01 in RCVCAT database is not current
PL/SQL package RMAN.DBMS_RCVMAN version 11.02.00.01 in RCVCAT database is not current

Whenever it is issued "register database" it fails with following error:
RMAN> register database;

DBGSQL: RCVCAT> begin dbms_rcvman.dumpPkgState('RCVMAN after sqlerror'); end;
DBGSQL: sqlcode = 6550

DBGSQL: RCVCAT> begin dbms_rcvcat.dumpPkgState('RCVCAT after sqlerror');end;
DBGSQL: sqlcode = 6550
database registered in recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03008: error while performing automatic resync of recovery catalog
RMAN-10015: error compiling PL/SQL program
RMAN-10014: PL/SQL error 0 on line 1655 column 12: Statement ignored
RMAN-10014: PL/SQL error 306 on line 1655 column 12: wrong number or types of arguments in call to 'CHECKTABLESPACE'

Resync catalog also fails with following error:
RMAN> resync catalog;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of resync command on default channel at 11/22/2011 23:09:07
RMAN-10015: error compiling PL/SQL program
RMAN-10014: PL/SQL error 0 on line 1655 column 12: Statement ignored
RMAN-10014: PL/SQL error 306 on line 1655 column 12: wrong number or types of arguments in call to 'CHECKTABLESPACE'

Recent Changes
The target database has been recently upgrades and so RMAN executable is upgraded but catalog database is not aware of this upgrade.

Cause of the Problem
The problem happened due to version mismatch between the RMAN-executable and the RMAN-catalog SCHEMA.

Solution of the Problem
Solution 01:
Upgrade the RMAN catalog SCHEMA. Start the RMAN-executable from the ORACLE_HOME which has been upgraded. There is only a connection to the CATALOG required.
A connection to the TARGET is optional.

For example issue,
$ rman catalog $RMAN_USERID/$RMAN_PASSWD@$RMAN_CONN_STR
RMAN> upgrade catalog;
Solution 02:
Don't use catalog for backup information. So run backup without connecting catalog database.
$ rman target /
$ backup database;

Sunday, November 20, 2011

Fix Scriptalicious PageRank Script Due to Google Changes PageRank Toolbar URL

I was using Scriptalicious script for my website http://blastyourblog.com/. The idea is why I should spend my time to check my pagerank and alexa rank to other sites instead of checking inside my site where I can check page rank and alexa rank without captcha and at a time I can check as many sites as I want. But recently I saw the pagerank tool there for example in http://blastyourblog.com/tools/multi-rank-checker/ it is displaying n/a for any websites. So I thought pagerank tool is broken there. The problem happened as Google recently has done modification to their toolbar query URL.

In order to fix this issue in Scriptalicious script you also need to update the url within the script.

To fix the issue,

1) Open the file /klib/class.kPageRank.php

You will find the following line of code.

$out = "GET /search?client=navclient-auto&ch=" . $ch .  "&features=Rank&q=info:" . $url . " HTTP/1.1\r\n" ;
2) Replace "search" word by "tbr". So it will look like,
$out = "GET /tbr?client=navclient-auto&ch=".$ch ."&features=Rank&q=info:".$url ." HTTP/1.1\r\n";
Save the file and upload in your server.

Now check again with your site urls.

So now pagerank in http://blastyourblog.com/tools/multi-rank-checker/ is working.