Open Graph mod port from 1.5x to 1.6x Open Graph mod port from 1.5x to 1.6x
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Open Graph mod port from 1.5x to 1.6x

Started by netb, June 21, 2017, 02:06:39 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

netb

Hello,

I've migrated to PHP 7.1 and cpg 1.6.03
I have the mod for Open Graph in my custom theme from here - http://forum.coppermine-gallery.net/index.php/topic,76929.20.html

Gallery address is greatmusclebodies.com
Here is the code I have in theme.php:


/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

//Escape the Inspekt sanitization and declare {META} vars for Open Graph
/*global $CPG_PHP_SELF, $LINEBREAK, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA;
if ($CPG_PHP_SELF == 'displayimage.php') {
$meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'displayimage.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" />';
$meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'] . '" />';
} elseif ($CPG_PHP_SELF == 'thumbnails.php') {
if ($CURRENT_ALBUM_DATA['aid']) {
$album = $CURRENT_ALBUM_DATA['aid'];
$sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid = '{$CURRENT_ALBUM_DATA['aid']}' ORDER BY pid DESC LIMIT 1";
} else {
$superCage = Inspekt::makeSuperCage();
$album = $superCage->get->getAlpha('album');
$sql = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' ORDER BY RAND() LIMIT 1";
}
$thumb = mysql_fetch_assoc(cpg_db_query($sql));
$meta .= $LINEBREAK . '<meta property="og:url" content="' . $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=' . $album . '" />';
$meta .= $LINEBREAK . '<meta property="og:image" content="' . $CONFIG['ecards_more_pic_target'] . $CONFIG['fullpath'] . $thumb['filepath'] . $thumb['filename'] . '" />';
}*/



It gives server error 500 for all the thumbnails.php pages. After commenting it everything is working seemingly fine. Any ideas what might have changed to break it?

ron4mac

PHP 7+ does not support mysql_ functions.

change mysql_fetch_assoc to cpg_db_fetch_assoc

netb

Quote from: ron4mac on June 21, 2017, 03:23:58 PM
PHP 7+ does not support mysql_ functions.

change mysql_fetch_assoc to cpg_db_fetch_assoc

Yes, thank you!

I just found that after posting and changed it with mysqli_fetch_assoc. Was going to write that it works that way but unsure if its desirable. I'll change it with your suggestion.

ron4mac

When changing mysql_ functions so they will work with PHP 7+, it would be best for you to use the cpg_db_ versions (as found in include/functions.inc.php). Doing so will help future-proof the code.