source: extensions/menalto2piwigo/include/functions.inc.php @ 28825

Last change on this file since 28825 was 28825, checked in by plg, 10 years ago

import data from Menalto Gallery

File size: 915 bytes
Line 
1<?php
2function m2p_db_connect()
3{
4  global $conf;
5
6  try
7  {
8    pwg_db_connect(
9      $conf['menalto2piwigo']['db_host'],
10      $conf['menalto2piwigo']['db_user'],
11      $conf['menalto2piwigo']['db_password'],
12      $conf['menalto2piwigo']['db_name']
13      );
14  }
15  catch (Exception $e)
16  {
17    my_error(l10n($e->getMessage()), true);
18  }
19
20  pwg_db_check_charset();
21
22  return true;
23}
24
25function m2p_db_disconnect()
26{
27  global $conf;
28
29  // reconnect to the Piwigo database
30  $pwg_db_link = pwg_db_connect(
31    $conf['db_host'],
32    $conf['db_user'],
33    $conf['db_password'],
34    $conf['db_base']
35    );
36
37  pwg_db_check_charset();
38}
39
40function m2p_remove_bbcode($string)
41{
42  $patterns = array(
43    '\[color=\w+\]',
44    '\[/color\]',
45    '\[b\]',
46    '\[/b\]',
47    '\[i\]',
48    '\[/i\]',
49    );
50
51  foreach ($patterns as $pattern)
52  {
53    $string = preg_replace('#'.$pattern.'#', '', $string);
54  }
55
56  return $string;
57}
Note: See TracBrowser for help on using the repository browser.