function install($plugin_version, &$errors = array())
    {
        global $conf;
        if (empty($conf['guestbook'])) {
            conf_update_param('guestbook', $this->default_conf, true);
        } else {
            $old_conf = safe_unserialize($conf['guestbook']);
            if (!isset($old_conf['guest_can_view'])) {
                $old_conf['guest_can_view'] = true;
                $old_conf['guest_can_add'] = true;
            }
            if (!isset($old_conf['menu_link'])) {
                $old_conf['menu_link'] = true;
            }
            conf_update_param('guestbook', $old_conf, true);
        }
        pwg_query('
CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
  `author` varchar(255) NOT NULL,
  `author_id` smallint(5) DEFAULT NULL,
  `anonymous_id` varchar(45) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `content` longtext NOT NULL,
  `rate` float(5,2) unsigned DEFAULT NULL,
  `validated` enum("true","false") NOT NULL DEFAULT "false",
  `validation_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
    }
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     if (empty($conf['AdminTools'])) {
         conf_update_param('AdminTools', $this->default_conf, true);
     }
 }
Esempio n. 3
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     if (empty($conf['flickr2piwigo'])) {
         conf_update_param('flickr2piwigo', $this->default_conf, true);
     }
     mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT & ~MKGETDIR_DIE_ON_ERROR);
 }
 function install($plugin_version, &$errors = array())
 {
     include dirname(__FILE__) . '/config_default.inc.php';
     global $conf;
     if (empty($conf['gdThumb'])) {
         conf_update_param('gdThumb', $config_default, true);
     }
     $this->installed = true;
 }
Esempio n. 5
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     if (empty($conf['sortorders'])) {
         conf_update_param('sortorders', $this->default_conf, true);
     } else {
         $old_conf = safe_unserialize($conf['sortorders']);
         conf_update_param('sortorders', $old_conf, true);
     }
 }
Esempio n. 6
0
 function activate($theme_version, &$errors = array())
 {
     global $conf, $prefixeTable;
     if (empty($conf['smartpocket'])) {
         conf_update_param('smartpocket', $this->default_conf, true);
     } elseif (count(safe_unserialize($conf['smartpocket'])) != 2) {
         $conff = safe_unserialize($conf['smartpocket']);
         $config = array('loop' => !empty($conff['loop']) ? $conff['loop'] : true, 'autohide' => !empty($conff['autohide']) ? $conff['autohide'] : 5000);
         conf_update_param('smartpocket', $config, true);
     }
     $this->installed = true;
 }
Esempio n. 7
0
function GThumb_init()
{
    global $conf, $user, $page, $stripped;
    // new param in 2.4.c
    if (!isset($conf['GThumb']['show_thumbnail_caption'])) {
        $conf['GThumb']['show_thumbnail_caption'] = true;
        conf_update_param('GThumb', serialize($conf['GThumb']));
    }
    $user['nb_image_page'] = $conf['GThumb']['nb_image_page'];
    $page['nb_image_page'] = $conf['GThumb']['nb_image_page'];
    $stripped['maxThumb'] = $conf['GThumb']['nb_image_page'];
    $conf['show_thumbnail_caption'] = $conf['GThumb']['show_thumbnail_caption'];
}
Esempio n. 8
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     if (empty($conf['Fotorama'])) {
         $conf['Fotorama'] = serialize($this->default_conf);
         conf_update_param('Fotorama', $conf['Fotorama']);
     } else {
         $new_conf = is_string($conf['Fotorama']) ? unserialize($conf['Fotorama']) : $conf['Fotorama'];
         $conf['Fotorama'] = serialize($new_conf);
         conf_update_param('Fotorama', $conf['Fotorama']);
     }
     $this->installed = true;
 }
Esempio n. 9
0
function theme_activate($id, $version, &$errors)
{
    global $conf;
    include_once dirname(dirname(__FILE__)) . '/functions.inc.php';
    $default_conf = modus_get_default_config();
    $my_conf = @$conf['modus_theme'];
    $my_conf = @unserialize($my_conf);
    if (empty($my_conf)) {
        $my_conf = $default_conf;
    }
    $my_conf = array_merge($default_conf, $my_conf);
    $my_conf = array_intersect_key($my_conf, $default_conf);
    conf_update_param('modus_theme', addslashes(serialize($my_conf)));
}
Esempio n. 10
0
function plugin_install()
{
    if (!defined('VIDEOJS_PATH')) {
        define('VIDEOJS_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    }
    // Remove unused files from previous version
    $toremove = array("skin", "js", "include/getid3");
    foreach ($toremove as $dir) {
        if (is_dir(VIDEOJS_PATH . $dir)) {
            vjs_deltree(VIDEOJS_PATH . $dir);
        }
    }
    $toremove = array("language/index.htm", "language/fr_FR/index.htm", "language/en_UK/index.htm", "admin.tpl", "admin.php", "include/README.md");
    foreach ($toremove as $file) {
        if (is_file(VIDEOJS_PATH . $file)) {
            @unlink(VIDEOJS_PATH . $file);
        }
    }
    $default_config = array('skin' => 'vjs-default-skin', 'max_height' => '720', 'preload' => 'auto', 'controls' => true, 'autoplay' => false, 'loop' => false, 'volume' => '1', 'upscale' => false, 'plugins' => array('zoomrotate' => false, 'thumbnails' => false, 'watermark' => false));
    /* Add configuration to the config table */
    $conf['vjs_conf'] = serialize($default_config);
    conf_update_param('vjs_conf', $conf['vjs_conf']);
    /* Add a comment to the entry */
    $q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-videojs plugin" WHERE `param` = "vjs_conf";';
    pwg_query($q);
    /* Keep customCSS separate as it can be big entry */
    conf_update_param('vjs_customcss', '');
    /* Add a comment to the entry */
    $q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Custom CSS used by the piwigo-videojs plugin" WHERE `param` = "vjs_customcss";';
    pwg_query($q);
    /* Table to hold videos metadata details */
    $q = 'CREATE TABLE IF NOT EXISTS `' . videojs_table . '` (
			`id` mediumint(8) NOT NULL,
			`format` varchar(64) DEFAULT NULL,
			`type` varchar(64) DEFAULT NULL,
			`duration` varchar(64) DEFAULT NULL,
			`overall_bit_rate` varchar(64) DEFAULT NULL,
			`model` varchar(128) DEFAULT NULL,
			`make` varchar(128) DEFAULT NULL,
			`display_aspect_ratio` varchar(8) DEFAULT NULL,
			`width` smallint(9) DEFAULT NULL,
			`height` smallint(9) DEFAULT NULL,
			`frame_rate` varchar(64) DEFAULT NULL,
			`channel` varchar(64) DEFAULT NULL,
			`sampling_rate` varchar(64) DEFAULT NULL,
			PRIMARY KEY (id)
		) ENGINE=MyISAM DEFAULT CHARSET=utf8
		;';
    //pwg_query($q);
}
 function activate($theme_version, &$errors = array())
 {
     global $conf, $prefixeTable;
     if (empty($conf['smartpocket'])) {
         $conf['smartpocket'] = serialize($this->default_conf);
         $query = "\n  INSERT INTO " . CONFIG_TABLE . " (param,value,comment)\n  VALUES ('smartpocket' , '" . pwg_db_real_escape_string($conf['smartpocket']) . "' , 'loop#autohide');";
         pwg_query($query);
     } elseif (count(unserialize($conf['smartpocket'])) != 2) {
         $conff = unserialize($conf['smartpocket']);
         $config = array('loop' => !empty($conff['loop']) ? $conff['loop'] : true, 'autohide' => !empty($conff['autohide']) ? $conff['autohide'] : 5000);
         conf_update_param('smartpocket', pwg_db_real_escape_string(serialize($config)));
         load_conf_from_db();
     }
     $this->installed = true;
 }
function plugin_install()
{
    global $prefixeTable;
    if (!defined('OSM_PATH')) {
        define('OSM_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    }
    // Remove unused files from previous version
    $toremove = array("admin.tpl", "admin.php", "admin_boot.php", "leaflet/leaflet.ie.css", "leaflet/MarkerCluster.Default.ie.css", "admin/admin_sync.php", "admin/admin_sync.tpl", "admin/admin_gps.php", "admin/admin_gps.tpl");
    foreach ($toremove as $file) {
        if (is_file(OSM_PATH . $file)) {
            @unlink(OSM_PATH . $file);
        }
    }
    $default_config = array('right_panel' => array('enabled' => true, 'add_before' => 'Average', 'height' => '200', 'zoom' => 12, 'link' => 'Location', 'linkcss' => null, 'showosm' => true), 'left_menu' => array('enabled' => true, 'link' => l10n('OSWORLDMAP'), 'popup' => 0, 'popupinfo_name' => true, 'popupinfo_img' => true, 'popupinfo_link' => true, 'popupinfo_comment' => true, 'popupinfo_author' => true, 'zoom' => 2, 'center' => '0,0', 'layout' => 2), 'category_description' => array('enabled' => true, 'index' => 0, 'height' => '200', 'width' => 'auto'), 'main_menu' => array('enabled' => false, 'height' => '200'), 'gpx' => array('height' => '500', 'width' => '320'), 'batch' => array('global_height' => '200', 'unit_height' => '200'), 'map' => array('baselayer' => 'mapnik', 'custombaselayer' => null, 'custombaselayerurl' => null, 'noworldwarp' => false, 'attrleaflet' => true, 'attrimagery' => true, 'attrplugin' => true), 'pin' => array('pin' => 1, 'pinpath' => '', 'pinsize' => '', 'pinshadowpath' => '', 'pinshadowsize' => '', 'pinoffset' => '', 'pinpopupoffset' => ''));
    /* Add configuration to the config table */
    $conf['osm_conf'] = serialize($default_config);
    conf_update_param('osm_conf', $conf['osm_conf']);
    $q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-openstreetmap plugin" WHERE `param` = "osm_conf";';
    pwg_query($q);
    // Remove previous created db table for GPX entries
    $q = "DROP TABLE IF EXISTS " . $prefixeTable . "osm_gps;";
    pwg_query($q);
    // Remove previous created directory for GPX entries
    $gpx_dir = PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'gps_track_files/';
    if (file_exists($gpx_dir) and is_dir($gpx_dir)) {
        osm_deltree($gpx_dir);
    }
    // Create world map link
    $dir_name = basename(dirname(__FILE__));
    $c = <<<EOF
<?php
define('PHPWG_ROOT_PATH','./');
if (isset(\$_GET['v']) and \$_GET['v'] == 1)
\tinclude_once( PHPWG_ROOT_PATH. 'plugins/piwigo-openstreetmap/osmmap.php');
else if (isset(\$_GET['v']) and \$_GET['v'] == 2)
\tinclude_once( PHPWG_ROOT_PATH. 'plugins/piwigo-openstreetmap/osmmap2.php');
else if (isset(\$_GET['v']) and \$_GET['v'] == 3)
\tinclude_once( PHPWG_ROOT_PATH. 'plugins/piwigo-openstreetmap/osmmap3.php');
else if (isset(\$_GET['v']) and \$_GET['v'] == 4)
\tinclude_once( PHPWG_ROOT_PATH. 'plugins/piwigo-openstreetmap/osmmap4.php');
else
\tinclude_once( PHPWG_ROOT_PATH. 'plugins/piwigo-openstreetmap/osmmap3.php');
?>
EOF;
    $fp = fopen(PHPWG_ROOT_PATH . 'osmmap.php', 'w');
    fwrite($fp, $c);
    fclose($fp);
}
Esempio n. 13
0
function upgrade_100_110()
{
    global $conf;
    load_language('plugin.lang', PH_PATH);
    // Upgrading options - Changing config variables to assoc array
    // ------------------------------------------------------------
    // Upgrade $conf_PH options
    $conf_PH = unserialize($conf['PruneHistory']);
    $Newconf_PH = array('PHVersion' => $conf_PH[0], 'AUTOPRUNE' => $conf_PH[1], 'RANGEVALUE' => $conf_PH[2], 'RANGE' => $conf_PH[3]);
    // unset obsolete conf
    // -------------------
    for ($i = 0; $i <= 3; $i++) {
        unset($conf_PH[$i]);
    }
    $update_conf = serialize($Newconf_PH);
    conf_update_param('PruneHistory', pwg_db_real_escape_string($update_conf));
}
function global_version_update()
{
    global $conf;
    // Get current plugin version
    $plugin = HIPE_infos(HIPE_PATH);
    $version = $plugin['version'];
    // Update plugin version
    $query = '
SELECT value
  FROM ' . CONFIG_TABLE . '
WHERE param = "HistoryIPConfig"
;';
    $result = pwg_query($query);
    $conf_HIPE = pwg_db_fetch_assoc($result);
    $Newconf_HIPE = unserialize($conf_HIPE['value']);
    $Newconf_HIPE['Version'] = $version;
    conf_update_param('HistoryIPConfig', pwg_db_real_escape_string(serialize($Newconf_HIPE)));
}
    function install($plugin_version, &$errors = array())
    {
        global $conf;
        if (empty($conf['oauth'])) {
            conf_update_param('oauth', $this->default_conf, true);
        } else {
            $conf['oauth'] = safe_unserialize($conf['oauth']);
            if (!isset($conf['oauth']['allow_merge_accounts'])) {
                $conf['oauth']['allow_merge_accounts'] = true;
                conf_update_param('oauth', $conf['oauth']);
            }
        }
        $result = pwg_query('SHOW COLUMNS FROM `' . USER_INFOS_TABLE . '` LIKE "oauth_id";');
        if (!pwg_db_num_rows($result)) {
            pwg_query('ALTER TABLE `' . USER_INFOS_TABLE . '` ADD `oauth_id` VARCHAR(255) DEFAULT NULL;');
        }
        // move field from users table to user_infos
        $result = pwg_query('SHOW COLUMNS FROM `' . USERS_TABLE . '` LIKE "oauth_id";');
        if (pwg_db_num_rows($result)) {
            $query = '
UPDATE `' . USER_INFOS_TABLE . '` AS i
  SET oauth_id = (
    SELECT oauth_id
      FROM `' . USERS_TABLE . '` AS u
      WHERE u.' . $conf['user_fields']['id'] . ' = i.user_id
    )
;';
            pwg_query($query);
            pwg_query('ALTER TABLE `' . USERS_TABLE . '` DROP `oauth_id`;');
        }
        // add 'total' and 'enabled' fields in hybridauth conf file
        if (file_exists($this->file)) {
            $hybridauth_conf = (include $this->file);
            if (!isset($hybridauth_conf['total'])) {
                $enabled = array_filter($hybridauth_conf['providers'], create_function('$p', 'return $p["enabled"];'));
                $hybridauth_conf['total'] = count($hybridauth_conf['providers']);
                $hybridauth_conf['enabled'] = count($enabled);
                $content = "<?php\ndefined('PHPWG_ROOT_PATH') or die('Hacking attempt!');\n\nreturn ";
                $content .= var_export($hybridauth_conf, true);
                $content .= ";\n?>";
                file_put_contents($this->file, $content);
            }
        }
    }
Esempio n. 16
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     // Configuration
     if (!isset($conf['forecast_conf']) || empty($conf['forecast_conf'])) {
         $this->default_config['last_clean'] = time();
         conf_update_param('forecast_conf', $this->default_config, true);
         $q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-forecast plugin" WHERE `param` = "forecast_conf";';
         pwg_query($q);
     } else {
         $current_conf = safe_unserialize($conf['forecast_conf']);
         conf_update_param('forecast_conf', array_merge($this->default_config, $current_conf), true);
     }
     // Create MySQL View
     $q = 'DROP VIEW IF EXISTS `forecast`;';
     pwg_query($q);
     $q = 'CREATE VIEW forecast AS SELECT `id`, `latitude`, `longitude`, UNIX_TIMESTAMP( IFNULL(`date_creation`, `date_available`) ) as `date` FROM ' . IMAGES_TABLE . ' WHERE `latitude` IS NOT NULL AND `longitude` is NOT NULL;';
     pwg_query($q);
 }
Esempio n. 17
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     // add a new column to existing table
     $result = pwg_query('SHOW COLUMNS FROM `' . CATEGORIES_TABLE . '` LIKE "polaroid_active";');
     if (!pwg_db_num_rows($result)) {
         pwg_query('ALTER TABLE `' . CATEGORIES_TABLE . '` ADD `polaroid_active` enum(\'true\', \'false\') default \'false\';');
     }
     $config = array('apply_to_albums' => 'all');
     // load existing config parameters
     if (!empty($conf['polaroid'])) {
         $conf['polaroid'] = safe_unserialize($conf['polaroid']);
         foreach ($conf['polaroid'] as $key => $value) {
             $config[$key] = $value;
         }
     }
     conf_update_param('polaroid', $config, true);
     $this->installed = true;
 }
Esempio n. 18
0
 function install($plugin_version, &$errors = array())
 {
     global $conf;
     // configuration
     if (!isset($conf['cdnplus_conf']) || empty($conf['cdnplus_conf'])) {
         $this->default_config['last_clean'] = time();
         /* Generate file_ext from current ext supported */
         $filetypes_arr = array_fill_keys(array_intersect_key($conf['file_ext'], array_unique(array_map('strtolower', $conf['file_ext']))), false);
         $this->default_config['cdn_1']['filetypes'] = $filetypes_arr;
         $this->default_config['cdn_2']['filetypes'] = $filetypes_arr;
         $this->default_config['cdn_3']['filetypes'] = $filetypes_arr;
         $this->default_config['cdn_4']['filetypes'] = $filetypes_arr;
         $this->default_config['cdn_5']['filetypes'] = $filetypes_arr;
         conf_update_param('cdnplus_conf', $this->default_config, true);
         $q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-cdnplus plugin" WHERE `param` = "cdnplus_conf";';
         pwg_query($q);
     } else {
         $new_conf = safe_unserialize($conf['cdnplus_conf']);
         conf_update_param('cdnplus_conf', $new_conf, true);
     }
 }
Esempio n. 19
0
/**
 * Function to update plugin version number in config table
 * Used everytime a new version is updated even if no database
 * upgrade is needed
 */
function PH_version_update()
{
    global $conf;
    load_language('plugin.lang', PH_PATH);
    // Get current plugin version
    // --------------------------
    $plugin = PHInfos(PH_PATH);
    $version = $plugin['version'];
    // Upgrading options
    // -----------------
    $query = '
SELECT value
FROM ' . CONFIG_TABLE . '
WHERE param = "PruneHistory"
;';
    $result = pwg_query($query);
    $conf_PH = pwg_db_fetch_assoc($result);
    $Newconf_PH = unserialize($conf_PH['value']);
    $Newconf_PH['PHVersion'] = $version;
    $update_conf = serialize($Newconf_PH);
    conf_update_param('PruneHistory', pwg_db_real_escape_string($update_conf));
    // Check #_plugin table consistency
    // Only useful if a previous version upgrade has not worked correctly (rare case)
    // ------------------------------------------------------------------------------
    $query = '
SELECT version
  FROM ' . PLUGINS_TABLE . '
WHERE id = "PruneHistory"
;';
    $data = pwg_db_fetch_assoc(pwg_query($query));
    if (empty($data['version']) or $data['version'] != $version) {
        $query = '
UPDATE ' . PLUGINS_TABLE . '
SET version="' . $version . '"
WHERE id = "PruneHistory"
LIMIT 1
;';
        pwg_query($query);
    }
}
Esempio n. 20
0
// |                            upgrade launch                             |
// +-----------------------------------------------------------------------+
$page['infos'] = array();
$page['errors'] = array();
$mysql_changes = array();
check_upgrade_access_rights();
if ((isset($_POST['submit']) or isset($_GET['now'])) and check_upgrade()) {
    $upgrade_file = PHPWG_ROOT_PATH . 'install/upgrade_' . $current_release . '.php';
    if (is_file($upgrade_file)) {
        // reset SQL counters
        $page['queries_time'] = 0;
        $page['count_queries'] = 0;
        $page['upgrade_start'] = get_moment();
        $conf['die_on_sql_error'] = false;
        include $upgrade_file;
        conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
        // Something to add in database.inc.php?
        if (!empty($mysql_changes)) {
            $config_file_contents = substr($config_file_contents, 0, $php_end_tag) . "\r\n" . implode("\r\n", $mysql_changes) . "\r\n" . substr($config_file_contents, $php_end_tag);
            if (!@file_put_contents($config_file, $config_file_contents)) {
                $page['infos'][] = l10n('In <i>%s</i>, before <b>?></b>, insert:', PWG_LOCAL_DIR . 'config/database.inc.php') . '<p><textarea rows="4" cols="40">' . implode("\r\n", $mysql_changes) . '</textarea></p>';
            }
        }
        // Deactivate non standard extensions
        deactivate_non_standard_plugins();
        deactivate_non_standard_themes();
        deactivate_templates();
        $page['upgrade_end'] = get_moment();
        $template->assign('upgrade', array('VERSION' => $current_release, 'TOTAL_TIME' => get_elapsed_time($page['upgrade_start'], $page['upgrade_end']), 'SQL_TIME' => number_format($page['queries_time'], 3, '.', ' ') . ' s', 'NB_QUERIES' => $page['count_queries']));
        $page['infos'][] = l10n('Perform a maintenance check in [Administration>Tools>Maintenance] if you encounter any problem.');
        // Save $page['infos'] in order to restore after maintenance actions
Esempio n. 21
0
<?php

// Need upgrade?
global $conf;
include PHPWG_THEMES_PATH . 'smartpocket/admin/upgrade.inc.php';
load_language('theme.lang', PHPWG_THEMES_PATH . 'smartpocket/');
$config_send = array();
if (isset($_POST['submit_smartpocket'])) {
    $config_send['loop'] = isset($_POST['loop']);
    $config_send['autohide'] = isset($_POST['autohide']) ? 5000 : 0;
    $conf['smartpocket'] = serialize($config_send);
    conf_update_param('smartpocket', pwg_db_real_escape_string($conf['smartpocket']));
    array_push($page['infos'], l10n('Information data registered in database'));
}
$template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/admin.tpl'));
$template->assign('options', unserialize($conf['smartpocket']));
$template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content');
Esempio n. 22
0
            $template->assign(array('config_creation_failed' => true, 'config_url' => 'install.php?dl=' . $tmp_filename, 'config_file_content' => $file_content));
        }
        @fputs($fp, $file_content, strlen($file_content));
        @fclose($fp);
        // tables creation, based on piwigo_structure.sql
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/piwigo_structure-mysql.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        // We fill the tables with basic informations
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/config.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        $query = '
INSERT INTO ' . $prefixeTable . 'config (param,value,comment) 
   VALUES (\'secret_key\',md5(' . pwg_db_cast_to_text(DB_RANDOM_FUNCTION . '()') . '),
   \'a secret key specific to the gallery for internal use\');';
        pwg_query($query);
        conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
        conf_update_param('gallery_title', l10n('Just another Piwigo gallery'));
        conf_update_param('page_banner', '<h1>%gallery_title%</h1>' . "\n\n<p>" . l10n('Welcome to my photo gallery') . '</p>');
        // fill languages table
        foreach ($languages->fs_languages as $language_code => $fs_language) {
            $languages->perform_action('activate', $language_code);
        }
        // fill $conf global array
        load_conf_from_db();
        // PWG_CHARSET is required for building the fs_themes array in the
        // themes class
        if (!defined('PWG_CHARSET')) {
            define('PWG_CHARSET', 'utf-8');
        }
        activate_core_themes();
        activate_core_plugins();
        $insert = array('id' => 1, 'galleries_url' => PHPWG_ROOT_PATH . 'galleries/');
        mass_inserts(SITES_TABLE, array_keys($insert), array($insert));
Esempio n. 23
0
<?php

defined('FLICKR_PATH') or die('Hacking attempt!');
if (isset($_POST['save_config'])) {
    $conf['flickr2piwigo'] = array('api_key' => trim($_POST['api_key']), 'secret_key' => trim($_POST['secret_key']));
    unset($_SESSION['phpFlickr_auth_token']);
    conf_update_param('flickr2piwigo', $conf['flickr2piwigo']);
    $page['infos'][] = l10n('Information data registered in database');
}
$template->assign(array('flickr2piwigo' => $conf['flickr2piwigo'], 'FLICKR_HELP_CONTENT' => load_language('help_api_key.html', FLICKR_PATH, array('return' => true)), 'FLICKR_CALLBACK' => get_absolute_root_url() . FLICKR_ADMIN . '-import'));
$template->set_filename('flickr2piwigo', realpath(FLICKR_PATH . 'admin/template/config.tpl'));
Esempio n. 24
0
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
************************************************/
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
// Check access and exit when user status is not ok
check_status(ACCESS_ADMINISTRATOR);
// Setup plugin Language
load_language('plugin.lang', FORECAST_PATH);
// Available options
$available_add_before = array('Author' => l10n('Author'), 'datecreate' => l10n('Created on'), 'datepost' => l10n('Posted on'), 'Dimensions' => l10n('Dimensions'), 'File' => l10n('File'), 'Filesize' => l10n('Filesize'), 'Tags' => l10n('Tags'), 'Categories' => l10n('Albums'), 'Visits' => l10n('Visits'), 'Average' => l10n('Rating score'), 'rating' => l10n('Rate this photo'), 'Privacy' => l10n('Who can see this photo?'));
// Available Units, https://developer.forecast.io/docs/v2
$available_units = array('us' => 'U.S. units', 'si' => 'International System of units', 'ca' => 'Canada units', 'uk2' => 'U.K. units', 'auto' => 'Automatic units');
// Available Languages, https://developer.forecast.io/docs/v2
$available_languages = array('ar' => 'Arabic', 'bs' => 'Bosnian', 'de' => 'German', 'en' => 'English', 'es' => 'Spanish', 'fr' => 'French', 'it' => 'Italian', 'nl' => 'Dutch', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ru' => 'Russian', 'sv' => 'Swedish', 'tet' => 'Tetum', 'tr' => 'Turkish', 'x-pig-latin' => 'Igpay Atinlay', 'zh' => 'Chinese');
// Update conf if submitted in admin site
if (isset($_POST['forecast_config_submit'])) {
    $conf['forecast_conf'] = array('add_before' => $_POST['fc_add_before'], 'color_bkg' => $_POST['fc_color_bkg'], 'color_txt' => $_POST['fc_color_txt'], 'link' => $_POST['fc_link'], 'show' => get_boolean($_POST['fc_showlink']), 'api_key' => $_POST['fc_api_key'], 'unit' => $_POST['fc_unit'], 'lang' => $_POST['fc_lang']);
    // Update config to DB
    conf_update_param('forecast_conf', serialize($conf['forecast_conf']));
    // the prefilter changes, we must delete compiled templates
    $template->delete_compiled_templates();
    // Notify user all is fine
    array_push($page['infos'], l10n('Your configuration settings are saved'));
}
$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/admin.tpl');
// send value to template
$template->assign('fc', $conf['forecast_conf']);
$template->assign(array('AVAILABLE_ADD_BEFORE' => $available_add_before, 'AVAILABLE_UNITS' => $available_units, 'AVAILABLE_LANGUAGES' => $available_languages));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Esempio n. 25
0
<?php

if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
global $prefixeTable, $conf;
if (!isset($conf['elegant'])) {
    $config = array('p_main_menu' => 'on', 'p_pict_descr' => 'on', 'p_pict_comment' => 'off');
    conf_update_param('elegant', $config, true);
} elseif (count(safe_unserialize($conf['elegant'])) != 3) {
    $conff = safe_unserialize($conf['elegant']);
    $config = array('p_main_menu' => isset($conff['p_main_menu']) ? $conff['p_main_menu'] : 'on', 'p_pict_descr' => isset($conff['p_pict_descr']) ? $conff['p_pict_descr'] : 'on', 'p_pict_comment' => isset($conff['p_pict_comment']) ? $conff['p_pict_comment'] : 'off');
    conf_update_param('elegant', $config, true);
}
Esempio n. 26
0
************************************************/
// Check whether we are indeed included by Piwigo.
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
// Generate default value
$sync_options = array('mediainfo' => 'mediainfo', 'ffmpeg' => 'ffmpeg', 'metadata' => true, 'poster' => true, 'postersec' => 4, 'output' => 'jpg', 'posteroverlay' => false, 'posteroverwrite' => true, 'thumb' => false, 'thumbsec' => 5, 'thumbsize' => "120x68", 'simulate' => true, 'cat_id' => 0, 'subcats_included' => true);
// Override default value from configuration
if (isset($conf['vjs_sync'])) {
    $sync_options = unserialize($conf['vjs_sync']);
}
if (isset($_POST['mediainfo']) && isset($_POST['ffmpeg'])) {
    // Override default value from the form
    $sync_options = array('mediainfo' => $_POST['mediainfo'], 'ffmpeg' => $_POST['ffmpeg'], 'metadata' => isset($_POST['metadata']), 'poster' => isset($_POST['poster']), 'postersec' => $_POST['postersec'], 'output' => $_POST['output'], 'posteroverlay' => isset($_POST['posteroverlay']), 'posteroverwrite' => isset($_POST['posteroverwrite']), 'thumb' => isset($_POST['thumb']), 'thumbsec' => $_POST['thumbsec'], 'thumbsize' => $_POST['thumbsize'], 'simulate' => isset($_POST['simulate']), 'cat_id' => isset($_POST['cat_id']) ? (int) $_POST['cat_id'] : 0, 'subcats_included' => isset($_POST['subcats_included']));
    // Update config to DB
    conf_update_param('vjs_sync', serialize($sync_options));
}
// Check dependencies
$warnings = array();
// Do the dependencies checks for MediaInfo & FFMPEG
function check_mediainfo($sync_options)
{
    $retval = 0;
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        system($sync_options['mediainfo'] . " >NUL 2>NUL", $retval);
        // redirect any output
    } else {
        system($sync_options['mediainfo'] . " 1>&2 /dev/null", $retval);
        // redirect any output
    }
    if ($retval == 127 or $retval == 9009) {
list($nb_geotagged) = pwg_db_fetch_array(pwg_query($query));
// Update conf if submitted in admin site
if (isset($_POST['submit']) && !empty($_POST['osm_height'])) {
    // Check the center GPS position is valid
    $osm_left_center = (isset($_POST['osm_left_center']) and strlen($_POST['osm_left_center']) != 0) ? $_POST['osm_left_center'] : '0,0';
    $center_arr = explode(',', $osm_left_center);
    //print_r($center_arr);
    $latitude = $center_arr[0];
    $longitude = $center_arr[1];
    if (isset($latitude) and isset($longitude)) {
        if (strlen($latitude) == 0 and strlen($longitude) == 0) {
            array_push($page['warnings'], l10n('Both latitude/longitude must not empty'));
        }
    }
    if (isset($latitude) and ($latitude <= -90 or $latitude >= 90)) {
        array_push($page['warnings'], l10n('The specify center latitude (-90=S to 90=N) is not valid'));
    }
    if (isset($longitude) and ($longitude <= -180 or $longitude >= 180)) {
        array_push($page['warnings'], l10n('The specify center longitude (-180=W to 180=E) is not valid'));
    }
    // On post admin form
    $conf['osm_conf'] = array('right_panel' => array('enabled' => get_boolean($_POST['osm_right_panel']), 'add_before' => $_POST['osm_add_before'], 'height' => $_POST['osm_height'], 'zoom' => $_POST['osm_zoom'], 'link' => $_POST['osm_right_link'], 'linkcss' => $_POST['osm_right_linkcss'], 'showosm' => get_boolean($_POST['osm_showosm'])), 'left_menu' => array('enabled' => get_boolean($_POST['osm_left_menu']), 'link' => $_POST['osm_left_link'], 'popup' => $_POST['osm_left_popup'], 'popupinfo_name' => isset($_POST['osm_left_popupinfo_name']), 'popupinfo_img' => isset($_POST['osm_left_popupinfo_img']), 'popupinfo_link' => isset($_POST['osm_left_popupinfo_link']), 'popupinfo_comment' => isset($_POST['osm_left_popupinfo_comment']), 'popupinfo_author' => isset($_POST['osm_left_popupinfo_author']), 'zoom' => $_POST['osm_left_zoom'], 'center' => $osm_left_center, 'autocenter' => get_boolean($_POST['osm_left_autocenter']), 'layout' => $_POST['osm_left_layout']), 'category_description' => array('enabled' => get_boolean($_POST['osm_category_description']), 'height' => $_POST['osm_cat_height'], 'width' => $_POST['osm_cat_width'], 'index' => $_POST['osm_cat_index']), 'main_menu' => array('enabled' => get_boolean($_POST['osm_main_menu']), 'height' => $_POST['osm_menu_height']), 'gpx' => array('height' => $_POST['osm_gpx_height'], 'width' => $_POST['osm_gpx_width']), 'batch' => array('global_height' => $_POST['osm_batch_global_height'], 'unit_height' => $_POST['osm_batch_unit_height']), 'map' => array('baselayer' => $_POST['osm_baselayer'], 'custombaselayer' => $_POST['osm_custombaselayer'], 'custombaselayerurl' => $_POST['osm_custombaselayerurl'], 'noworldwarp' => get_boolean($_POST['osm_noworldwarp']), 'attrleaflet' => get_boolean($_POST['osm_attrleaflet']), 'attrimagery' => get_boolean($_POST['osm_attrimagery']), 'attrplugin' => get_boolean($_POST['osm_attrplugin'])), 'pin' => array('pin' => $_POST['osm_pin'], 'pinpath' => $_POST['osm_pinpath'], 'pinsize' => $_POST['osm_pinsize'], 'pinshadowpath' => $_POST['osm_pinshadowpath'], 'pinshadowsize' => $_POST['osm_pinshadowsize'], 'pinoffset' => $_POST['osm_pinoffset'], 'pinpopupoffset' => $_POST['osm_pinpopupoffset']));
    // Update config to DB
    conf_update_param('osm_conf', serialize($conf['osm_conf']));
    // the prefilter changes, we must delete compiled templatess
    $template->delete_compiled_templates();
    array_push($page['infos'], l10n('Your configuration settings are saved'));
}
// send value to template
$template->assign($conf['osm_conf']);
$template->assign(array('AVAILABLE_ADD_BEFORE' => $available_add_before, 'AVAILABLE_CAT_INDEX' => $available_cat_index, 'AVAILABLE_ZOOM' => $available_zoom, 'AVAILABLE_BASELAYER' => $available_baselayer, 'AVAILABLE_PIN' => $available_pin, 'AVAILABLE_POPUP' => $available_popup, 'AVAILABLE_LAYOUT' => $available_layout, 'NB_GEOTAGGED' => $nb_geotagged, 'OSM_PATH' => OSM_PATH, 'GLOBAL_MODE' => l10n('global mode'), 'SINGLE_MODE' => l10n('unit mode')));
function upgradeCM_240_250()
{
    global $conf;
    // Upgrading options - Changing config variables to assoc array
    // ------------------------------------------------------------
    // Upgrade $conf_CM options
    $conf_CM = unserialize($conf['CommentsManager']);
    $Newconf_CM = array('CMVersion' => $conf_CM[0], 'CM_No_Comment_Anonymous' => $conf_CM[1], 'CM_GROUPCOMM' => $conf_CM[2], 'CM_ALLOWCOMM_GROUP' => $conf_CM[3], 'CM_GROUPVALID1' => $conf_CM[4], 'CM_VALIDCOMM1_GROUP' => $conf_CM[5], 'CM_GROUPVALID2' => $conf_CM[6], 'CM_VALIDCOMM2_GROUP' => $conf_CM[7]);
    // unset obsolete conf
    // -------------------
    for ($i = 0; $i <= 7; $i++) {
        unset($conf_CM[$i]);
    }
    $update_conf = serialize($Newconf_CM);
    conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
}
function pfemail_check_accounts()
{
    global $conf, $user;
    conf_update_param('pfemail_last_check', date('Y-m-d H:i:s'));
    require_once PFEMAIL_PATH . 'include/ImapMailbox.php';
    $image_ids = array();
    $query = '
SELECT
    *
  FROM ' . PFEMAIL_MAILBOXES_TABLE . '
;';
    $accounts = query2array($query);
    foreach ($accounts as $account) {
        $mailbox = new ImapMailbox($account['path'], $account['login'], $account['password'], $conf['upload_dir'] . '/buffer', 'utf-8');
        $mails = array();
        // Get some mail
        $mailsIds = $mailbox->searchMailBox('UNSEEN');
        if (!$mailsIds) {
            continue;
            // check next email account
        }
        $mailId = reset($mailsIds);
        $mail = $mailbox->getMail($mailId);
        $attachments = $mail->getAttachments();
        include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php';
        foreach ($attachments as $attachment) {
            $extension = strtolower(get_extension($attachment->{'name'}));
            if (!in_array($extension, $conf['picture_ext'])) {
                // the file has been downloaded, we have to remove it now
                unlink($attachment->{'filePath'});
                continue;
            }
            $moderate = get_boolean($account['moderated']);
            $image_id = add_uploaded_file($attachment->{'filePath'}, stripslashes($attachment->{'name'}), array($account['category_id']), $moderate ? 16 : 0, null);
            // the photo is added by nobody (using the current user may make the
            // photo editable by her with Admin Tools...)
            single_update(IMAGES_TABLE, array('added_by' => null, 'name' => pfemail_clean_email_subject($mail->subject)), array('id' => $image_id));
            $state = 'auto_validated';
            if ($moderate) {
                $state = 'moderation_pending';
            }
            list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
            single_insert(PFEMAIL_PENDINGS_TABLE, array('image_id' => $image_id, 'state' => $state, 'added_on' => $dbnow, 'from_name' => $mail->fromName, 'from_address' => $mail->fromAddress, 'subject' => $mail->subject));
            $image_ids[] = $image_id;
        }
    }
    if (count($image_ids) > 0) {
        include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
        invalidate_user_cache();
        // let's notify administrators
        $query = '
SELECT id
  FROM ' . GROUPS_TABLE . '
;';
        $group_ids = query2array($query, null, 'id');
        if (count($group_ids) > 0) {
            include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php';
            $thumb_urls = array();
            // force $conf['derivative_url_style'] to 2 (script) to make sure we
            // will use i.php?/upload and not _data/i/upload because you don't
            // know when the cache will be flushed
            $previous_derivative_url_style = $conf['derivative_url_style'];
            $conf['derivative_url_style'] = 2;
            $query = '
SELECT
    id,
    path
  FROM ' . IMAGES_TABLE . '
  WHERE id IN (' . implode(',', $image_ids) . ')
;';
            $result = pwg_query($query);
            while ($row = pwg_db_fetch_assoc($result)) {
                $thumb = DerivativeImage::thumb_url(array('id' => $row['id'], 'path' => $row['path']));
                $thumb_urls[] = $thumb;
            }
            // restore configuration setting
            $conf['derivative_url_style'] = $previous_derivative_url_style;
            $thumbs_html_string = '';
            foreach ($thumb_urls as $thumb_url) {
                if (!empty($thumbs_html_string)) {
                    $thumbs_html_string .= '&nbsp;';
                }
                $thumbs_html_string .= '<img src="' . $thumb_url . '">';
            }
            $content = $thumbs_html_string;
            // how many photos pending?
            $pendings = pfemail_get_pending_ids();
            if (count($pendings) > 0) {
                $content .= '<br><br>';
                $content .= '<a href="' . get_absolute_root_url() . 'admin.php?page=plugin-photo_from_email-pendings' . '">';
                $content .= l10n('%d photos pending for validation', count($pendings));
                $content .= '</a>';
            }
            $real_user_id = $user['id'];
            $user['id'] = $conf['guest_id'];
            $subject = l10n('%d photos added by email', count($thumb_urls));
            foreach ($group_ids as $group_id) {
                pwg_mail_group($group_id, array('subject' => '[' . $conf['gallery_title'] . '] ' . $subject, 'mail_title' => $conf['gallery_title'], 'mail_subtitle' => $subject, 'content' => $content, 'content_format' => 'text/html'));
            }
        }
        // restore current user
        $user['id'] = $real_user_id;
    }
}
        if (isset($enabled[$type])) {
            $enabled_by[$type] = $enabled[$type];
        }
    }
    foreach (array_keys(ImageStdParams::$custom) as $custom) {
        if (isset($_POST['delete_custom_derivative_' . $custom])) {
            $changed_types[] = $custom;
            unset(ImageStdParams::$custom[$custom]);
        }
    }
    ImageStdParams::set_and_save($enabled_by);
    if (count($disabled) == 0) {
        $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param = \'disabled_derivatives\'';
        pwg_query($query);
    } else {
        conf_update_param('disabled_derivatives', addslashes(serialize($disabled)));
    }
    $conf['disabled_derivatives'] = serialize($disabled);
    if (count($changed_types)) {
        clear_derivative_cache($changed_types);
    }
    $page['infos'][] = l10n('Your configuration settings are saved');
} else {
    foreach ($original_fields as $field) {
        if (isset($_POST[$field])) {
            $template->append('sizes', array($field => $_POST[$field]), true);
        }
    }
    $template->assign('derivatives', $pderivatives);
    $template->assign('ferrors', $errors);
    $template->assign('resize_quality', $_POST['resize_quality']);