forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 miscellaneous => Topic started by: netb on June 21, 2017, 02:06:39 pm

Title: Open Graph mod port from 1.5x to 1.6x
Post by: netb on June 21, 2017, 02:06:39 pm
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:
Code: [Select]

/******************************************************************************
** 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?
Title: Re: Open Graph mod port from 1.5x to 1.6x
Post by: 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
Title: Re: Re: Open Graph mod port from 1.5x to 1.6x
Post by: netb on June 21, 2017, 03:53:55 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.
Title: Re: Open Graph mod port from 1.5x to 1.6x
Post by: ron4mac on June 21, 2017, 10:42:36 pm
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.