Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Open Graph mod port from 1.5x to 1.6x  (Read 5642 times)

0 Members and 1 Guest are viewing this topic.

netb

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 82
Open Graph mod port from 1.5x to 1.6x
« 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?
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Open Graph mod port from 1.5x to 1.6x
« Reply #1 on: June 21, 2017, 03:23:58 pm »

PHP 7+ does not support mysql_ functions.

change mysql_fetch_assoc to cpg_db_fetch_assoc
Logged

netb

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 82
Re: Re: Open Graph mod port from 1.5x to 1.6x
« Reply #2 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.
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Open Graph mod port from 1.5x to 1.6x
« Reply #3 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.037 seconds with 20 queries.