function osm_apply_menu($menu_ref_arr) { global $template, $page, $conf; $menu =& $menu_ref_arr[0]; if (($block = $menu->get_block('mbLinks')) != null) { include_once dirname(__FILE__) . '/include/functions.php'; include_once dirname(__FILE__) . '/include/functions_map.php'; osm_load_language(); load_language('plugin.lang', OSM_PATH); // Comment are used only with this condition index.php l294 if ($page['start'] == 0 and !isset($page['chronology_field'])) { $js_data = osm_get_items($page); if ($js_data != array()) { $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = true; $local_conf['img_popup'] = false; $local_conf['popup'] = 2; $local_conf['center_lat'] = 0; $local_conf['center_lng'] = 0; $local_conf['zoom'] = 2; $local_conf['autocenter'] = 1; $local_conf['divname'] = 'mapmenu'; $local_conf['paths'] = osm_get_gps($page); $height = isset($conf['osm_conf']['main_menu']['height']) ? $conf['osm_conf']['main_menu']['height'] : '200'; $js = osm_get_js($conf, $local_conf, $js_data); $template->set_template_dir(dirname(__FILE__) . '/template/'); $template->assign(array('OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMJS' => $js, 'HEIGHT' => $height)); $block->template = 'osm-menu.tpl'; } } } }
function osm_render_media($content, $picture) { global $template, $picture, $conf; //print_r( $picture['current']); // do nothing if the current picture is actually an image ! if (array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) { return $content; } // If not a GPX file if (array_key_exists('path', @$picture['current']) && strpos($picture['current']['path'], ".gpx") === false) { return $content; } $filename = embellish_url(get_gallery_home_url() . $picture['current']['element_url']); $height = isset($conf['osm_conf']['gpx']['height']) ? $conf['osm_conf']['gpx']['height'] : '500'; $width = isset($conf['osm_conf']['gpx']['width']) ? $conf['osm_conf']['gpx']['width'] : '320'; $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = true; $local_conf['img_popup'] = false; $local_conf['popup'] = 2; $local_conf['center_lat'] = 0; $local_conf['center_lng'] = 0; $local_conf['zoom'] = '12'; $local_conf['divname'] = 'mapgpx'; $js_data = array(array(null, null, null, null, null, null, null, null)); $js = osm_get_js($conf, $local_conf, $js_data); // Select the template $template->set_filenames(array('osm_content' => dirname(__FILE__) . "/template/osm-gpx.tpl")); // Assign the template variables $template->assign(array('HEIGHT' => $height, 'WIDTH' => $width, 'FILENAME' => $filename, 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMGPX' => $js)); // Return the rendered html $osm_content = $template->parse('osm_content', true); return $osm_content; }
/** * plugin initialization */ function oauth_init() { global $conf, $page, $hybridauth_conf, $template; load_language('plugin.lang', OAUTH_PATH); $conf['oauth'] = safe_unserialize($conf['oauth']); // check config if (defined('IN_ADMIN')) { if (empty($hybridauth_conf) and strpos(@$_GET['page'], 'plugin-oAuth') === false) { $page['warnings'][] = '<a href="' . OAUTH_ADMIN . '">' . l10n('Social Connect: You need to configure the credentials') . '</a>'; } if (!function_exists('curl_init')) { $page['warnings'][] = l10n('Social Connect: PHP Curl extension is needed'); } } // in case of registration aborded if (script_basename() == 'index' and ($oauth_id = pwg_get_session_var('oauth_new_user')) !== null) { pwg_unset_session_var('oauth_new_user'); if ($oauth_id[0] == 'Persona') { oauth_assign_template_vars(get_gallery_home_url()); $template->block_footer_script(null, 'navigator.id.logout();'); } else { require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php'; try { $hybridauth = new Hybrid_Auth($hybridauth_conf); $adapter = $hybridauth->getAdapter($oauth_id[0]); $adapter->logout(); } catch (Exception $e) { } } } }
function gb_section_init() { global $tokens, $page, $conf; if ($tokens[0] == 'guestbook') { $page['section'] = 'guestbook'; $page['body_id'] = 'theGuestBook'; $page['is_external'] = true; $page['is_homepage'] = false; $page['title'] = l10n('GuestBook'); $page['section_title'] = '<a href="' . get_gallery_home_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . l10n('GuestBook'); } }
function osm_render_category() { global $template, $page, $conf, $filter; include_once dirname(__FILE__) . '/include/functions.php'; include_once dirname(__FILE__) . '/include/functions_map.php'; osm_load_language(); load_language('plugin.lang', OSM_PATH); // TF, 20160102: pass config as parameter $js_data = osm_get_items($conf, $page); if ($js_data != array()) { $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = true; $local_conf['img_popup'] = false; $local_conf['popup'] = 1; $local_conf['center_lat'] = 0; $local_conf['center_lng'] = 0; $local_conf['zoom'] = 2; $local_conf['auto_center'] = 1; // TF, 20160102: pass config as parameter $local_conf['paths'] = osm_get_gps($conf, $page); $height = isset($conf['osm_conf']['category_description']['height']) ? $conf['osm_conf']['category_description']['height'] : '200'; $width = isset($conf['osm_conf']['category_description']['width']) ? $conf['osm_conf']['category_description']['width'] : 'auto'; $js = osm_get_js($conf, $local_conf, $js_data); $template->set_filename('map', dirname(__FILE__) . '/template/osm-category.tpl'); $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'OSMJS' => $js, 'HEIGHT' => $height, 'WIDTH' => $width)); $osm_content = $template->parse('map', true); //$osm_content = '<div id="osmmap"><div class="map_title">'.l10n('EDIT_MAP').'</div>' . $osm_content . '</div>'; $index = isset($conf['osm_conf']['category_description']['index']) ? $conf['osm_conf']['category_description']['index'] : 0; // 0 - PLUGIN_INDEX_CONTENT_BEGIN // 1 - PLUGIN_INDEX_CONTENT_COMMENT // 2 - PLUGIN_INDEX_CONTENT_END if ($index <= 1) { // From index category comment at L300 if ($page['start'] == 0 and !isset($page['chronology_field'])) { if (empty($page['comment'])) { $page['comment'] = $osm_content; } else { if ($index == 0) { $page['comment'] = '<div>' . $osm_content . $page['comment'] . '</div>'; } else { $page['comment'] = '<div>' . $page['comment'] . $osm_content . '</div>'; } } } } else { $osm_content = '<div id="osmmap">' . $osm_content . '</div>'; $template->concat('PLUGIN_INDEX_CONTENT_END', "\n" . $osm_content); } } }
/** * checks the validity of input parameters, fills $page['errors'] and * $page['infos'] and send an email with confirmation link * * @return bool (true if email was sent, false otherwise) */ function process_password_request() { global $page, $conf; if (empty($_POST['username_or_email'])) { $page['errors'][] = l10n('Invalid username or email'); return false; } $user_id = get_userid_by_email($_POST['username_or_email']); if (!is_numeric($user_id)) { $user_id = get_userid($_POST['username_or_email']); } if (!is_numeric($user_id)) { $page['errors'][] = l10n('Invalid username or email'); return false; } $userdata = getuserdata($user_id, false); // password request is not possible for guest/generic users $status = $userdata['status']; if (is_a_guest($status) or is_generic($status)) { $page['errors'][] = l10n('Password reset is not allowed for this user'); return false; } if (empty($userdata['email'])) { $page['errors'][] = l10n('User "%s" has no email address, password reset is not possible', $userdata['username']); return false; } $activation_key = generate_key(20); list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)')); single_update(USER_INFOS_TABLE, array('activation_key' => pwg_password_hash($activation_key), 'activation_key_expire' => $expire), array('user_id' => $user_id)); $userdata['activation_key'] = $activation_key; set_make_full_url(); $message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n"; $message .= l10n('Username "%s" on gallery %s', $userdata['username'], get_gallery_home_url()); $message .= "\r\n\r\n"; $message .= l10n('To reset your password, visit the following address:') . "\r\n"; $message .= get_gallery_home_url() . '/password.php?key=' . $activation_key . '-' . urlencode($userdata['email']); $message .= "\r\n\r\n"; $message .= l10n('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n"; unset_make_full_url(); $message = trigger_change('render_lost_password_mail_content', $message); $email_params = array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Password Reset'), 'content' => $message, 'email_format' => 'text/plain'); if (pwg_mail($userdata['email'], $email_params)) { $page['infos'][] = l10n('Check your email for the confirmation link'); return true; } else { $page['errors'][] = l10n('Error sending email'); return false; } }
function oauth_assign_template_vars($u_redirect = null) { global $template, $conf, $hybridauth_conf, $user; $conf['oauth']['include_common_template'] = true; if ($template->get_template_vars('OAUTH') == null) { if (!empty($user['oauth_id'])) { list($provider, $identifier) = explode('---', $user['oauth_id'], 2); if ($provider == 'Persona') { $persona_email = $identifier; } } $template->assign('OAUTH', array('conf' => $conf['oauth'], 'u_login' => get_root_url() . OAUTH_PATH . 'auth.php?provider=', 'providers' => $hybridauth_conf['providers'], 'persona_email' => @$persona_email, 'key' => get_ephemeral_key(0))); $template->assign(array('OAUTH_PATH' => OAUTH_PATH, 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/', 'ABS_ROOT_URL' => rtrim(get_gallery_home_url(), '/') . '/')); } if (isset($u_redirect)) { $template->append('OAUTH', compact('u_redirect'), true); } }
function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array()) { global $conf, $page, $env_nbm, $conf; set_make_full_url(); $check_key_treated = array(); $updated_data_count = 0; $error_on_updated_data_count = 0; if ($is_subscribe) { $msg_info = l10n('User %s [%s] was added to the subscription list.'); $msg_error = l10n('User %s [%s] was not added to the subscription list.'); } else { $msg_info = l10n('User %s [%s] was removed from the subscription list.'); $msg_error = l10n('User %s [%s] was not removed from the subscription list.'); } if (count($check_key_list) != 0) { $updates = array(); $enabled_value = boolean_to_string($is_subscribe); $data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe); // Prepare message after change language $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.'); // Begin nbm users environment begin_users_env_nbm(true); foreach ($data_users as $nbm_user) { if (check_sendmail_timeout()) { // Stop fill list on 'send', if the quota is override $page['errors'][] = $msg_break_timeout; break; } // Fill return list $check_key_treated[] = $nbm_user['check_key']; $do_update = true; if ($nbm_user['mail_address'] != '') { // set env nbm user set_user_on_env_nbm($nbm_user, true); $subject = '[' . $conf['gallery_title'] . '] ' . ($is_subscribe ? l10n('Subscribe to notification by mail') : l10n('Unsubscribe from notification by mail')); // Assign current var for nbm mail assign_vars_nbm_mail_content($nbm_user); $section_action_by = $is_subscribe ? 'subscribe_by_' : 'unsubscribe_by_'; $section_action_by .= $is_admin_request ? 'admin' : 'himself'; $env_nbm['mail_template']->assign(array($section_action_by => true, 'GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => get_gallery_home_url())); $ret = pwg_mail(array('name' => stripslashes($nbm_user['username']), 'email' => $nbm_user['mail_address']), array('from' => $env_nbm['send_as_mail_formated'], 'subject' => $subject, 'email_format' => $env_nbm['email_format'], 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 'content_format' => $env_nbm['email_format'])); if ($ret) { inc_mail_sent_success($nbm_user); } else { inc_mail_sent_failed($nbm_user); $do_update = false; } // unset env nbm user unset_user_on_env_nbm(); } if ($do_update) { $updates[] = array('check_key' => $nbm_user['check_key'], 'enabled' => $enabled_value); $updated_data_count += 1; $page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']); } else { $error_on_updated_data_count += 1; $page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']); } } // Restore nbm environment end_users_env_nbm(); display_counter_info(); mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('check_key'), 'update' => array('enabled')), $updates); } $page['infos'][] = l10n_dec('%d user was updated.', '%d users were updated.', $updated_data_count); if ($error_on_updated_data_count != 0) { $page['errors'][] = l10n_dec('%d user was not updated.', '%d users were not updated.', $error_on_updated_data_count); } unset_make_full_url(); return $check_key_treated; }
} } } } } // +-----------------------------------------------------------------------+ // | chronology | // +-----------------------------------------------------------------------+ if (isset($page['chronology_field'])) { unset($page['is_homepage']); include_once PHPWG_ROOT_PATH . 'include/functions_calendar.inc.php'; initialize_calendar(); } // title update if (isset($page['title'])) { $page['section_title'] = '<a href="' . get_gallery_home_url() . '">' . l10n('Home') . '</a>'; if (!empty($page['title'])) { $page['section_title'] .= $conf['level_separator'] . $page['title']; } else { $page['title'] = $page['section_title']; } } // add meta robots noindex, nofollow to avoid unnecesary robot crawls $page['meta_robots'] = array(); if (isset($page['chronology_field']) or isset($page['flat']) and isset($page['category']) or 'list' == $page['section'] or 'recent_pics' == $page['section']) { $page['meta_robots'] = array('noindex' => 1, 'nofollow' => 1); } elseif ('tags' == $page['section']) { if (count($page['tag_ids']) > 1) { $page['meta_robots'] = array('noindex' => 1, 'nofollow' => 1); } } elseif ('recent_cats' == $page['section']) {
if (isset($_GET['page']) and preg_match('/^[a-z_]*$/', $_GET['page']) and is_file(PHPWG_ROOT_PATH . 'admin/' . $_GET['page'] . '.php')) { $page['page'] = $_GET['page']; } else { $page['page'] = 'intro'; } $link_start = PHPWG_ROOT_PATH . 'admin.php?page='; $conf_link = $link_start . 'configuration&section='; // +-----------------------------------------------------------------------+ // | Template init | // +-----------------------------------------------------------------------+ $title = l10n('Piwigo Administration'); // for include/page_header.php $page['page_banner'] = '<h1>' . l10n('Piwigo Administration') . '</h1>'; $page['body_id'] = 'theAdminPage'; $template->set_filenames(array('admin' => 'admin.tpl')); $template->assign(array('USERNAME' => $user['username'], 'ENABLE_SYNCHRONIZATION' => $conf['enable_synchronization'], 'U_SITE_MANAGER' => $link_start . 'site_manager', 'U_HISTORY_STAT' => $link_start . 'stats', 'U_FAQ' => $link_start . 'help', 'U_SITES' => $link_start . 'remote_site', 'U_MAINTENANCE' => $link_start . 'maintenance', 'U_NOTIFICATION_BY_MAIL' => $link_start . 'notification_by_mail', 'U_CONFIG_GENERAL' => $link_start . 'configuration', 'U_CONFIG_DISPLAY' => $conf_link . 'default', 'U_CONFIG_EXTENTS' => $link_start . 'extend_for_templates', 'U_CONFIG_MENUBAR' => $link_start . 'menubar', 'U_CONFIG_LANGUAGES' => $link_start . 'languages', 'U_CONFIG_THEMES' => $link_start . 'themes', 'U_CATEGORIES' => $link_start . 'cat_list', 'U_CAT_OPTIONS' => $link_start . 'cat_options', 'U_CAT_UPDATE' => $link_start . 'site_update&site=1', 'U_RATING' => $link_start . 'rating', 'U_RECENT_SET' => $link_start . 'batch_manager&filter=prefilter-last_import', 'U_BATCH' => $link_start . 'batch_manager', 'U_TAGS' => $link_start . 'tags', 'U_USERS' => $link_start . 'user_list', 'U_GROUPS' => $link_start . 'group_list', 'U_RETURN' => get_gallery_home_url(), 'U_ADMIN' => PHPWG_ROOT_PATH . 'admin.php', 'U_LOGOUT' => PHPWG_ROOT_PATH . 'index.php?act=logout', 'U_PLUGINS' => $link_start . 'plugins', 'U_ADD_PHOTOS' => $link_start . 'photos_add', 'U_CHANGE_THEME' => $change_theme_url, 'U_UPDATES' => $link_start . 'updates')); if ($conf['activate_comments']) { $template->assign('U_COMMENTS', $link_start . 'comments'); // pending comments $query = ' SELECT COUNT(*) FROM ' . COMMENTS_TABLE . ' WHERE validated=\'false\' ;'; list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); if ($nb_comments > 0) { $template->assign('NB_PENDING_COMMENTS', $nb_comments); } } // any photo in the caddie? $query = '
// | This program is distributed in the hope that it will be useful, but | // | WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. | // +-----------------------------------------------------------------------+ // // Start output of page // $template->set_filenames(array('header' => 'header.tpl')); trigger_notify('loc_begin_page_header'); $template->assign(array('GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'PAGE_BANNER' => trigger_change('render_page_banner', str_replace('%gallery_title%', $conf['gallery_title'], isset($page['page_banner']) ? $page['page_banner'] : $conf['page_banner'])), 'BODY_ID' => isset($page['body_id']) ? $page['body_id'] : '', 'CONTENT_ENCODING' => get_pwg_charset(), 'PAGE_TITLE' => strip_tags($title), 'U_HOME' => get_gallery_home_url(), 'LEVEL_SEPARATOR' => $conf['level_separator'])); // Header notes if (!empty($header_notes)) { $template->assign('header_notes', $header_notes); } // No referencing is required if (!$conf['meta_ref']) { $page['meta_robots']['noindex'] = 1; $page['meta_robots']['nofollow'] = 1; } if (!empty($page['meta_robots'])) { $template->append('head_elements', '<meta name="robots" content="' . implode(',', array_keys($page['meta_robots'])) . '">'); } if (!isset($page['meta_robots']['noindex'])) { $template->assign('meta_ref', 1); }
set_make_full_url(); $rss = new UniversalFeedCreator(); $rss->encoding = get_pwg_charset(); $rss->title = $conf['gallery_title']; $rss->title .= ' (as ' . stripslashes($user['username']) . ')'; $rss->link = get_gallery_home_url(); // +-----------------------------------------------------------------------+ // | Feed creation | // +-----------------------------------------------------------------------+ $news = array(); if (!$image_only) { $news = news($feed_row['last_check'], $dbnow, true, true); if (count($news) > 0) { $item = new FeedItem(); $item->title = l10n('New on %s', format_date($dbnow)); $item->link = get_gallery_home_url(); // content creation $item->description = '<ul>'; foreach ($news as $line) { $item->description .= '<li>' . $line . '</li>'; } $item->description .= '</ul>'; $item->descriptionHtmlSyndicated = true; $item->date = ts_to_iso8601(datetime_to_ts($dbnow)); $item->author = $conf['rss_feed_author']; $item->guid = sprintf('%s', $dbnow); $rss->addItem($item); $query = ' UPDATE ' . USER_FEED_TABLE . ' SET last_check = \'' . $dbnow . '\' WHERE id = \'' . $feed_id . '\'
function vjs_render_media($content, $picture) { global $template, $picture, $page, $conf, $user, $refresh; //print_r( $picture['current']); // do nothing if the current picture is actually an image ! if (array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) { return $content; } // In case it is not an image but not a supported video file by the plugin if (vjs_valid_extension(get_extension($picture['current']['path'])) === false) { return $content; } // In case, we handle a large video, we define a MAX_HEIGHT // variable to limit the display size. $MAX_HEIGHT = isset($conf['vjs_conf']['max_height']) ? $conf['vjs_conf']['max_height'] : '480'; if (isset($user['maxheight']) and $user['maxheight'] != '') { $MAX_HEIGHT = $user['maxwidth']; } //print "MAX_HEIGHT=" . $MAX_HEIGHT; //print_r($user); $extension = vjs_get_mimetype_from_ext(get_extension($picture['current']['path'])); //print "extension\n"; //print_r($extension); // Video file -- Guess resolution base on height if (isset($picture['current']['width'])) { $width = $picture['current']['width']; } if (isset($picture['current']['height'])) { $height = $picture['current']['height']; } if (!isset($width) || !isset($height) || $width == 0 || $height == 0) { // If guess was unsuccessful, fallback to default 16/9 resolution 720x480 // Mostly happend when video metadata was incorrectly sync into PWG // This is the case for ogv video for example. $height = 480; $width = round(16 * 480 / 9, 0); } //print "Video height=" . $height . " width=". $width; // Resize if video is too height //print $height .">". $MAX_HEIGHT; if ($height > $MAX_HEIGHT) { $height = $MAX_HEIGHT; $width = round(16 * $MAX_HEIGHT / 9, 0); //print "MAX_HEIGHT height=" . $height . " width=". $width; } // Upscale if video is too small $upscale = isset($conf['vjs_conf']['upscale']) ? strbool($conf['vjs_conf']['upscale']) : false; if ($upscale and $height < $MAX_HEIGHT) { $height = $MAX_HEIGHT; $width = round(16 * $MAX_HEIGHT / 9, 0); //print "UPSCALE height=" . $height . " width=". $width; } // Load parameter, fallback to default if unset $skin = isset($conf['vjs_conf']['skin']) ? $conf['vjs_conf']['skin'] : 'vjs-default-skin'; $customcss = isset($conf['vjs_customcss']) ? $conf['vjs_customcss'] : ''; $preload = isset($conf['vjs_conf']['preload']) ? $conf['vjs_conf']['preload'] : 'none'; $loop = isset($conf['vjs_conf']['loop']) ? strbool($conf['vjs_conf']['loop']) : false; $controls = isset($conf['vjs_conf']['controls']) ? strbool($conf['vjs_conf']['controls']) : false; $volume = isset($conf['vjs_conf']['volume']) ? $conf['vjs_conf']['volume'] : '1'; $language = isset($conf['vjs_conf']['language']) ? $conf['vjs_conf']['language'] : 'en'; // Slideshow : The video needs to be launch automatically in // slideshow mode. The refresh of the page is set to the // duration of the video. $autoplay = isset($conf['vjs_conf']['autoplay']) ? strbool($conf['vjs_conf']['autoplay']) : false; if ($page['slideshow']) { $refresh = 20; // TODO move to separate DB to actualy get this details information $autoplay = true; $loop = false; } // Assing the CSS file according to the skin $available_skins = array('vjs-default-skin' => 'video-js.min.css', 'vjs-bluebox-skin' => 'bluebox-skin.css', 'vjs-redtube-skin' => 'redtube-skin.css'); $skincss = $available_skins[$skin]; // Guess the poster extension $file_wo_ext = pathinfo($picture['current']['path']); $file_dir = dirname($picture['current']['path']); $poster = embellish_url($picture['current']['src_image']->get_path()); //print $poster; // Try to find multiple video source $vjs_extensions = array('ogg', 'ogv', 'mp4', 'm4v', 'webm', 'webmv'); $files_ext = array_merge(array(), $vjs_extensions, array_map('strtoupper', $vjs_extensions)); // Add the current file in array $videos[] = array('src' => embellish_url($picture['current']['element_url']), 'ext' => $extension); // Add any other video source format foreach ($files_ext as $file_ext) { $file = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "." . $file_ext; if (file_exists($file)) { array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext))); } } //print_r($videos); // Sort array to have MP4 first in the source list for iOS support foreach ($videos as $key => $row) { $src[$key] = $row['src']; $ext[$key] = $row['ext']; } array_multisort($src, SORT_ASC, $ext, SORT_ASC, $videos); //print_r($videos); /* Try to find WebVTT */ $file = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . ".vtt"; $subtitles = null; if (file_exists($file)) { $subtitles = '<track kind="subtitles" src="' . embellish_url(get_gallery_home_url() . $file) . '" srclang="' . $language . '" label="English"></track>'; } /* Thumbnail videojs plugin */ $thumbnails_plugin = isset($conf['vjs_conf']['plugins']['thumbnails']) ? strbool($conf['vjs_conf']['plugins']['thumbnails']) : false; $thumbnails = array(); if ($thumbnails_plugin) { $filematch = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "-th_*"; $matches = glob($filematch); if (is_array($matches) and !empty($matches)) { $sort = array(); // A list of sort columns and their data to pass to array_multisort foreach ($matches as $filename) { $ext = explode("-th_", $filename); $second = explode(".", $ext[1]); include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; include_once PHPWG_ROOT_PATH . 'admin/include/image.class.php'; $rotate = pwg_image::get_rotation_angle_from_code($picture['current']['rotation']); // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg //echo "$filename second " . $second[0]. "\n"; $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename), 'rotate' => $rotate); $sort['second'][$second[0]] = $second[0]; } // Sort thumbnails by second ASC !empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails); } //$thumbnails = array( array('second' => 0, 'source' => $poster), array('second' => 5, 'source' => $poster)); //print_r($thumbnails); } /* ZoomRotate videojs plugin */ $zoomrotate_plugin = isset($conf['vjs_conf']['plugins']['zoomrotate']) ? strbool($conf['vjs_conf']['plugins']['zoomrotate']) : false; $zoomrotate = array(); if ($zoomrotate_plugin) { // TODO Disable if playing on iOS, as it read the metadata itself if ($picture['current']['rotation'] != null) { include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; include_once PHPWG_ROOT_PATH . 'admin/include/image.class.php'; // rotation is $picture['current']['rotation'] // zoom is witdh / height $rotate = pwg_image::get_rotation_angle_from_code($picture['current']['rotation']); $zoomrotate = array('rotate' => $rotate, 'zoom' => round($width / $height, 1, PHP_ROUND_HALF_DOWN)); // Change the video player size $tmp_width = $width; $tmp_height = $height; $width = $tmp_height; $height = $tmp_width; } } /* Watermark videojs plugin */ $watermark_plugin = isset($conf['vjs_conf']['plugins']['watermark']) ? strbool($conf['vjs_conf']['plugins']['watermark']) : false; $watermark = array(); if ($watermark_plugin) { $derivatives = unserialize($conf['derivatives']); if (is_array($derivatives) and !empty($derivatives) and $derivatives['w']->file != null) { $watermark = array('file' => embellish_url(get_gallery_home_url() . $derivatives['w']->file), 'xpos' => $derivatives['w']->xpos, 'ypos' => $derivatives['w']->ypos, 'xrepeat' => $derivatives['w']->xrepeat, 'opacity' => $derivatives['w']->opacity); } } // Generate HTML5 tags // Why the data-setup attribute does not work if only one video $options = ""; if ($controls) { $options .= "controls"; } if ($autoplay) { $options .= " autoplay "; } if ($loop) { $options .= " loop "; } $options .= ' preload="' . $preload . '"'; // Select the template $template->set_filenames(array('vjs_content' => dirname(__FILE__) . "/template/vjs-player.tpl")); // Ensure the ratio is always below 100%, there is for sure a better way! $ratio = round($height / $width * 100, 2); if ($ratio >= 100) { $ratio = round($width / $height * 100, 2); } // Assign the template variables // We use here the piwigo's get_gallery_home_url function to build // the full URL as suggested by videojs for flash fallback compatibility $template->assign(array('VIDEOJS_POSTER_URL' => embellish_url(get_gallery_home_url() . $poster), 'VIDEOJS_PATH' => embellish_url(get_gallery_home_url() . VIDEOJS_PATH), 'WIDTH' => $width, 'RATIO' => $ratio, 'OPTIONS' => $options, 'VIDEOJS_SKIN' => $skin, 'VIDEOJS_SKINCSS' => $skincss, 'VIDEOJS_CUSTOMCSS' => $customcss, 'volume' => $volume, 'subtitles' => $subtitles, 'thumbnails' => $thumbnails, 'zoomrotate' => $zoomrotate, 'watermark' => $watermark, 'videos' => $videos)); // Return the rendered html $vjs_content = $template->parse('vjs_content', true); return $vjs_content; }
function forecast_render_element_content() { global $template, $picture, $page, $conf; load_language('plugin.lang', FORECAST_PATH); if (empty($page['image_id']) and !is_numeric($page['image_id'])) { return; } // Load coordinates and date_creation from picture $query = "SELECT latitude,longitude,date FROM forecast WHERE id='" . $page['image_id'] . "';"; //FIXME LIMIT 1 ? $result = pwg_query($query); $row = pwg_db_fetch_assoc($result); if (!isset($row) or !isset($row['latitude']) or empty($row['latitude']) or !isset($row['longitude']) or empty($row['longitude']) or !isset($row['date']) or empty($row['date'])) { return; } $lat = $row['latitude']; $lon = $row['longitude']; $date = $row['date']; // Load parameter, fallback to default if unset $fc_height = isset($conf['forecast_conf']['height']) ? $conf['forecast_conf']['height'] : '200'; $fc_header = isset($conf['forecast_conf']['link']) ? $conf['forecast_conf']['link'] : 'Overcast'; $fc_header_css = isset($conf['forecast_conf']['linkcss']) ? $conf['forecast_conf']['linkcss'] : ''; $fc_show_link = isset($conf['forecast_conf']['show']) ? $conf['forecast_conf']['show'] : 'true'; $fc_api_key = isset($conf['forecast_conf']['api_key']) ? $conf['forecast_conf']['api_key'] : ''; if (strlen($fc_header_css) != 0) { $fc_css = "style='" . $fc_header_css . "'"; } $fc_link = "http://forecast.io/#/f/" . $lat . "," . $lon; // Init Forecast.io lib include 'lib/forecast.io.php'; // Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto // Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en' $fc_unit = isset($conf['forecast_conf']['unit']) ? $conf['forecast_conf']['unit'] : 'auto'; $fc_lang = isset($conf['forecast_conf']['lang']) ? $conf['forecast_conf']['lang'] : 'en'; /* Do we have a Forecast.io API key */ if (strlen($fc_api_key) != 0) { // Make a request to Forecast.io using the user supply API, proxy set to false $forecast = new ForecastIO($fc_api_key, $fc_unit, $fc_lang, false); } else { /** * Make a request to https://forecast-xbgmsharp.rhcloud.com * to non disclose the Forecast.io API key, proxy set to true * Source code at https://github.com/xbgmsharp/nodejs-forecast **/ $forecast = new ForecastIO($fc_api_key, $fc_unit, $fc_lang, true); } $condition = $forecast->getHistoricalConditions($lat, $lon, $date); if (!isset($condition) or $condition === 'false') { return; } //print_r($condition); // Parse weather condition to human readable $condition = parseCondition($condition); // Select the template $template->set_filenames(array('forecast_content' => dirname(__FILE__) . "/template/picture.tpl")); // Assign the template variables $template->assign(array('FORECAST_HEIGHT' => $fc_height, 'FORECAST_PATH' => embellish_url(get_gallery_home_url() . FORECAST_PATH), 'FORECAST_NAME' => $fc_header, 'FORECAST_NAME_CSS' => $fc_header_css, 'FORECAST_SHOW_LINK' => $fc_show_link, 'FORECAST_LINK' => $fc_link, 'FORECAST_DATA' => $condition)); // Return the rendered html $forecast_content = $template->parse('forecast_content', true); return $forecast_content; }
if (file_exists($file)) { array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext))); } } //print_r($videos); /* Try to find WebVTT */ $file = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . ".vtt"; file_exists($file) ? $subtitle = embellish_url(get_gallery_home_url() . $file) : ($subtitle = null); /* Thumbnail videojs plugin */ $filematch = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "-th_*"; $matches = glob($filematch); $thumbnails = array(); $sort = array(); // A list of sort columns and their data to pass to array_multisort if (is_array($matches) and !empty($matches)) { foreach ($matches as $filename) { $ext = explode("-th_", $filename); $second = explode(".", $ext[1]); // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg //echo "$filename second " . $second[0]. "\n"; $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename)); $sort['second'][$second[0]] = $second[0]; } } //print_r($thumbnails); // Sort thumbnails by second !empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails); $infos = array_merge(array('Poster' => $poster), array('Videos source' => count($videos)), array('videos' => $videos), array('Thumbnails' => count($thumbnails)), array('thumbnails' => $thumbnails), array('Subtitle' => $subtitle)); //print_r($infos); $template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'SYNC_URL' => $sync_url, 'DELETE_URL' => $delete_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'EXIF' => $exif, 'INFOS' => $infos)); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
function osm_render_element_content() { global $template, $picture, $page, $conf; load_language('plugin.lang', OSM_PATH); if (empty($page['image_id'])) { return; } // Load coordinates from picture $query = 'SELECT latitude,longitude FROM ' . IMAGES_TABLE . ' WHERE id = \'' . $page['image_id'] . '\' ;'; //FIXME LIMIT 1 ? $result = pwg_query($query); $row = pwg_db_fetch_assoc($result); if (!$row or !$row['latitude'] or empty($row['latitude'])) { return; } $lat = $row['latitude']; $lon = $row['longitude']; // Load parameter, fallback to default if unset $height = isset($conf['osm_conf']['right_panel']['height']) ? $conf['osm_conf']['right_panel']['height'] : '200'; $zoom = isset($conf['osm_conf']['right_panel']['zoom']) ? $conf['osm_conf']['right_panel']['zoom'] : '12'; $osmname = isset($conf['osm_conf']['right_panel']['link']) ? $conf['osm_conf']['right_panel']['link'] : 'Location'; $osmnamecss = isset($conf['osm_conf']['right_panel']['linkcss']) ? $conf['osm_conf']['right_panel']['linkcss'] : ''; $showosm = isset($conf['osm_conf']['right_panel']['showosm']) ? $conf['osm_conf']['right_panel']['showosm'] : 'true'; if (strlen($osmnamecss) != 0) { $osmnamecss = "style='" . $osmnamecss . "'"; } $osmlink = "https://openstreetmap.org/?mlat=" . $lat . "&mlon=" . $lon . "&zoom=12&layers=M"; $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = false; $local_conf['img_popup'] = false; $local_conf['popup'] = 2; $local_conf['center_lat'] = $lat; $local_conf['center_lng'] = $lon; $local_conf['zoom'] = $zoom; // TF, 20160102: pass config as parameter $js_data = osm_get_items($conf, $page); $js = osm_get_js($conf, $local_conf, $js_data); // Select the template $template->set_filenames(array('osm_content' => dirname(__FILE__) . "/template/osm-picture.tpl")); // Assign the template variables $template->assign(array('HEIGHT' => $height, 'OSMJS' => $js, 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMNAME' => $osmname, 'OSMNAMECSS' => $osmnamecss, 'SHOWOSM' => $showosm, 'OSMLINK' => $osmlink)); // Return the rendered html $osm_content = $template->parse('osm_content', true); return $osm_content; }
function osm_gen_template($conf, $js, $js_data, $tmpl, $template) { $linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : l10n('OSWorldMap'); $template->set_filename('map', dirname(__FILE__) . '/../template/' . $tmpl); $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'GALLERY_TITLE' => $linkname . ' - ' . $conf['gallery_title'], 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'TOTAL' => sprintf(l10n('ITEMS'), count($js_data)), 'OSMJS' => $js, 'MYROOT_URL' => get_absolute_root_url(), 'default_baselayer' => $conf['osm_conf']['map']['baselayer'])); if ($conf['osm_conf']['map']['baselayer'] == 'custom') { $iconbaselayer = $conf['osm_conf']['map']['custombaselayerurl']; $iconbaselayer = str_replace('{s}', 'a', $iconbaselayer); $iconbaselayer = str_replace('{z}', '5', $iconbaselayer); $iconbaselayer = str_replace('{x}', '15', $iconbaselayer); $iconbaselayer = str_replace('{y}', '11', $iconbaselayer); $template->assign(array('custombaselayer' => $conf['osm_conf']['map']['custombaselayer'], 'custombaselayerurl' => $conf['osm_conf']['map']['custombaselayerurl'], 'iconbaselayer' => $iconbaselayer)); } $template->pparse('map'); $template->p(); }
$redirect_to = urldecode($_GET['redirect']); if (is_a_guest()) { $page['errors'][] = l10n('You are not authorized to access the requested page'); } } if (isset($_POST['login'])) { if (!isset($_COOKIE[session_name()])) { $page['errors'][] = l10n('Cookies are blocked or not supported by your browser. You must enable cookies to connect.'); } else { if ($conf['insensitive_case_logon'] == true) { $_POST['username'] = search_case_username($_POST['username']); } $redirect_to = isset($_POST['redirect']) ? urldecode($_POST['redirect']) : ''; $remember_me = isset($_POST['remember_me']) and $_POST['remember_me'] == 1; if (try_log_user($_POST['username'], $_POST['password'], $remember_me)) { redirect(empty($redirect_to) ? get_gallery_home_url() : $redirect_to); } else { $page['errors'][] = l10n('Invalid password!'); } } } //----------------------------------------------------- template initialization // // Start output of page // $title = l10n('Identification'); $page['body_id'] = 'theIdentificationPage'; $template->set_filenames(array('identification' => 'identification.tpl')); $template->assign(array('U_REDIRECT' => $redirect_to, 'F_LOGIN_ACTION' => get_root_url() . 'identification.php', 'authorize_remembering' => $conf['authorize_remembering'])); if (!$conf['gallery_locked'] && $conf['allow_user_registration']) { $template->assign('U_REGISTER', get_root_url() . 'register.php');
/** * Sends an email, using Piwigo specific informations. * * @param string|array $to * @param array $args * o from: sender [default value webmaster email] * o Cc: array of carbon copy receivers of the mail. [default value empty] * o Bcc: array of blind carbon copy receivers of the mail. [default value empty] * o subject [default value 'Piwigo'] * o content: content of mail [default value ''] * o content_format: format of mail content [default value 'text/plain'] * o email_format: global mail format [default value $conf_mail['default_email_format']] * o theme: theme to use [default value $conf_mail['mail_theme']] * o mail_title: main title of the mail [default value $conf['gallery_title']] * o mail_subtitle: subtitle of the mail [default value subject] * @param array $tpl - use these options to define a custom content template file * o filename * o dirname (optional) * o assign (optional) * * @return boolean */ function pwg_mail($to, $args = array(), $tpl = array()) { global $conf, $conf_mail, $lang_info, $page; if (empty($to) and empty($args['Cc']) and empty($args['Bcc'])) { return true; } if (!isset($conf_mail)) { $conf_mail = get_mail_configuration(); } include_once PHPWG_ROOT_PATH . 'include/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); foreach (get_clean_recipients_list($to) as $recipient) { $mail->addAddress($recipient['email'], $recipient['name']); } $mail->WordWrap = 76; $mail->CharSet = 'UTF-8'; // Compute root_path in order have complete path set_make_full_url(); if (empty($args['from'])) { $from = array('email' => $conf_mail['email_webmaster'], 'name' => $conf_mail['name_webmaster']); } else { $from = unformat_email($args['from']); } $mail->setFrom($from['email'], $from['name']); $mail->addReplyTo($from['email'], $from['name']); // Subject if (empty($args['subject'])) { $args['subject'] = 'Piwigo'; } $args['subject'] = trim(preg_replace('#[\\n\\r]+#s', '', $args['subject'])); $mail->Subject = $args['subject']; // Cc if (!empty($args['Cc'])) { foreach (get_clean_recipients_list($args['Cc']) as $recipient) { $mail->addCC($recipient['email'], $recipient['name']); } } // Bcc $Bcc = get_clean_recipients_list(@$args['Bcc']); if ($conf_mail['send_bcc_mail_webmaster']) { $Bcc[] = array('email' => get_webmaster_mail_address(), 'name' => ''); } if (!empty($Bcc)) { foreach ($Bcc as $recipient) { $mail->addBCC($recipient['email'], $recipient['name']); } } // theme if (empty($args['theme']) or !in_array($args['theme'], array('clear', 'dark'))) { $args['theme'] = $conf_mail['mail_theme']; } // content if (!isset($args['content'])) { $args['content'] = ''; } // try to decompose subject like "[....] ...." if (!isset($args['mail_title']) and !isset($args['mail_subtitle'])) { if (preg_match('#^\\[(.*)\\](.*)$#', $args['subject'], $matches)) { $args['mail_title'] = $matches[1]; $args['mail_subtitle'] = $matches[2]; } } if (!isset($args['mail_title'])) { $args['mail_title'] = $conf['gallery_title']; } if (!isset($args['mail_subtitle'])) { $args['mail_subtitle'] = $args['subject']; } // content type if (empty($args['content_format'])) { $args['content_format'] = 'text/plain'; } $content_type_list = array(); if ($conf_mail['mail_allow_html'] and @$args['email_format'] != 'text/plain') { $content_type_list[] = 'text/html'; } $content_type_list[] = 'text/plain'; $contents = array(); foreach ($content_type_list as $content_type) { // key compose of indexes witch allow to cache mail data $cache_key = $content_type . '-' . $lang_info['code']; if (!isset($conf_mail[$cache_key])) { // instanciate a new Template if (!isset($conf_mail[$cache_key]['theme'])) { $conf_mail[$cache_key]['theme'] = get_mail_template($content_type); trigger_notify('before_parse_mail_template', $cache_key, $content_type); } $template =& $conf_mail[$cache_key]['theme']; $template->set_filename('mail_header', 'header.tpl'); $template->set_filename('mail_footer', 'footer.tpl'); $template->assign(array('GALLERY_URL' => get_gallery_home_url(), 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => defined('PHPWG_URL') ? PHPWG_URL : '', 'CONTENT_ENCODING' => get_pwg_charset(), 'CONTACT_MAIL' => $conf_mail['email_webmaster'])); if ($content_type == 'text/html') { if ($template->smarty->templateExists('global-mail-css.tpl')) { $template->set_filename('global-css', 'global-mail-css.tpl'); $template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global-css'); } if ($template->smarty->templateExists('mail-css-' . $args['theme'] . '.tpl')) { $template->set_filename('css', 'mail-css-' . $args['theme'] . '.tpl'); $template->assign_var_from_handle('MAIL_CSS', 'css'); } } } $template =& $conf_mail[$cache_key]['theme']; $template->assign(array('MAIL_TITLE' => $args['mail_title'], 'MAIL_SUBTITLE' => $args['mail_subtitle'])); // Header $contents[$content_type] = $template->parse('mail_header', true); // Content // Stored in a temp variable, if a content template is used it will be assigned // to the $CONTENT template variable, otherwise it will be appened to the mail if ($args['content_format'] == 'text/plain' and $content_type == 'text/html') { // convert plain text to html $mail_content = '<p>' . nl2br(preg_replace('/(https?:\\/\\/([-\\w\\.]+[-\\w])+(:\\d+)?(\\/([\\w\\/_\\.\\#-]*(\\?\\S+)?[^\\.\\s])?)?)/i', '<a href="$1">$1</a>', htmlspecialchars($args['content']))) . '</p>'; } else { if ($args['content_format'] == 'text/html' and $content_type == 'text/plain') { // convert html text to plain text $mail_content = strip_tags($args['content']); } else { $mail_content = $args['content']; } } // Runtime template if (isset($tpl['filename'])) { if (isset($tpl['dirname'])) { $template->set_template_dir($tpl['dirname'] . '/' . $content_type); } if ($template->smarty->templateExists($tpl['filename'] . '.tpl')) { $template->set_filename($tpl['filename'], $tpl['filename'] . '.tpl'); if (!empty($tpl['assign'])) { $template->assign($tpl['assign']); } $template->assign('CONTENT', $mail_content); $contents[$content_type] .= $template->parse($tpl['filename'], true); } else { $contents[$content_type] .= $mail_content; } } else { $contents[$content_type] .= $mail_content; } // Footer $contents[$content_type] .= $template->parse('mail_footer', true); } // Undo Compute root_path in order have complete path unset_make_full_url(); // Send content to PHPMailer if (isset($contents['text/html'])) { $mail->isHTML(true); $mail->Body = move_css_to_body($contents['text/html']); if (isset($contents['text/plain'])) { $mail->AltBody = $contents['text/plain']; } } else { $mail->isHTML(false); $mail->Body = $contents['text/plain']; } if ($conf_mail['use_smtp']) { // now we need to split port number if (strpos($conf_mail['smtp_host'], ':') !== false) { list($smtp_host, $smtp_port) = explode(':', $conf_mail['smtp_host']); } else { $smtp_host = $conf_mail['smtp_host']; $smtp_port = 25; } $mail->IsSMTP(); // enables SMTP debug information (for testing) 2 - debug, 0 - no message $mail->SMTPDebug = 0; $mail->Host = $smtp_host; $mail->Port = $smtp_port; if (!empty($conf_mail['smtp_secure']) and in_array($conf_mail['smtp_secure'], array('ssl', 'tls'))) { $mail->SMTPSecure = $conf_mail['smtp_secure']; } if (!empty($conf_mail['smtp_user'])) { $mail->SMTPAuth = true; $mail->Username = $conf_mail['smtp_user']; $mail->Password = $conf_mail['smtp_password']; } } $ret = true; $pre_result = trigger_change('before_send_mail', true, $to, $args, $mail); if ($pre_result) { $ret = $mail->send(); if (!$ret and (!ini_get('display_errors') or is_admin())) { trigger_error('Mailer Error: ' . $mail->ErrorInfo, E_USER_WARNING); } if ($conf['debug_mail']) { pwg_send_mail_test($ret, $mail, $args); } } return $ret; }
function render_media($content, $picture) { global $template, $picture, $page, $conf, $user, $refresh; // do nothing if the current picture is actually an image ! if (@$picture['current']['is_picture'] || array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) { return $content; } // In case, the we handle a large video, we define a MAX_WIDTH // variable to limit the display size. if (isset($user['maxwidth']) and $user['maxwidth'] != '') { $MAX_WIDTH = $user['maxwidth']; } else { $MAX_WIDTH = '720'; } // Get video infos with getID3 lib require_once dirname(__FILE__) . '/include/getid3/getid3.php'; $getID3 = new getID3(); $fileinfo = $getID3->analyze($picture['current']['path']); $extension = strtolower(get_extension($picture['current']['path'])); $basename = strtolower(get_filename_wo_extension($picture['current']['path'])); $is_video = False; // if not a media extension, do nothing if (!in_array($extension, $conf['media_ext'])) { return $content; } else { if (isset($fileinfo['video'])) { // -- video file -- $is_video = True; if ($extension == 'webm') { $extension = 'webmv'; } if ($extension == 'mp4') { $extension = 'm4v'; } // guess resolution if (isset($fileinfo['video']['resolution_x'])) { $width = $fileinfo['video']['resolution_x']; } if (isset($fileinfo['video']['resolution_y'])) { $height = $fileinfo['video']['resolution_y']; } if (!isset($width) || !isset($height)) { // If guess was unsuccessful, fallback to default 16/9 resolution // This is the case for ogv video for example. $width = $MAX_WIDTH; $height = intval(9 * ($width / 16)); } } else { // -- audio only file -- if ($extension == 'webm') { $extension = 'webma'; } if ($extension == 'mp4') { $extension = 'm4a'; } if ($extension == 'ogg') { $extension = 'oga'; } $width = '0'; $height = '0'; } } // Resize if video is too large if ($width > $MAX_WIDTH) { $height = intval($height * ($MAX_WIDTH / $width)); $width = $MAX_WIDTH; } // Slideshow : The video needs to be launch automatically in // slideshow mode. The refresh of the page is set to the // duration of the video. if (isset($conf['jplayer_autoplay']) && $conf['jplayer_autoplay']) { $AUTOPLAY = 'play'; } else { $AUTOPLAY = ''; } if ($page['slideshow']) { $refresh = $fileinfo['playtime_seconds']; $AUTOPLAY = 'play'; } // Picture representative to be used as poster image in the player $poster_url = NULL; if (isset($picture['current']['src_image']) && isset($conf['jplayer_representative_as_poster']) && $conf['jplayer_representative_as_poster']) { $poster_url = $picture['current']['src_image']->get_url(); $poster_url = embellish_url(get_gallery_home_url() . $poster_url); if (strpos($poster_url, "mimetype")) { // Ignore mimetype representatives because they're too small $poster_url = NULL; } } // Load parameter, fallback to blue monday if unset $skin = isset($conf['jplayer_skin']) ? $conf['jplayer_skin'] : 'bm'; // Select the template $template->set_filenames(array('jp_content' => dirname(__FILE__) . "/template/jp-" . $skin . ".tpl")); $alternate_media_url = ''; $alternate_type = ''; if ($extension == 'webmv') { if (file_exists($basename . '.m4v')) { $alternate_media_url = str_replace('webm', 'm4v', $picture['current']['element_url']); $alternate_type = 'm4v'; } } else { if ($extension == 'm4v') { if (file_exists($basename . '.webm')) { $alternate_media_url = str_replace('m4v', 'webm', $picture['current']['element_url']); $alternate_type = 'webmv'; } } } // Assign the template variables // We use here the piwigo's get_gallery_home_url function to build // the full URL as suggested by jplayer for flash fallback compatibility $template->assign(array('JP_MEDIA_URL' => embellish_url(get_gallery_home_url() . $picture['current']['element_url']), 'ALT_JP_MEDIA_URL' => embellish_url(get_gallery_home_url() . $alternate_media_url), 'JP_POSTER' => $poster_url, 'JPLAYER_PATH' => JPLAYER_PATH, 'JPLAYER_FULLPATH' => realpath(dirname(__FILE__)), 'WIDTH' => $width . 'px', 'HEIGHT' => $height . 'px', 'TYPE' => $extension, 'ALT_TYPE' => $alternate_type, 'AUTOPLAY' => $AUTOPLAY, 'IS_VIDEO' => $is_video)); // Return the rendered html $jp_content = $template->parse('jp_content', true); return $jp_content; }
/** * Function called from UAM_admin.php to send notification email when user registration have been manually validated by admin * * @param : user id * */ function validation_mail($id) { global $conf; $conf_UAM = unserialize($conf['UserAdvManager']); include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $custom_txt = ""; $subject = ""; // We have to get the user's language in database // ---------------------------------------------- $query = ' SELECT user_id, language FROM ' . USER_INFOS_TABLE . ' WHERE user_id = ' . $id . ' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language // ------------------------------------------------------------------------------------------------------------------------------- if (empty($data)) { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = pwg_get_session_var('lang_switch', $user['language']); switch_lang_to($language); } else { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = $data['language']; // Usefull for debugging switch_lang_to($data['language']); load_language('plugin.lang', UAM_PATH); } // Retreive users email and user name from id // ------------------------------------------ $query = ' SELECT id, username, mail_address FROM ' . USERS_TABLE . ' WHERE id = ' . $id . ' ;'; $result = pwg_db_fetch_assoc(pwg_query($query)); if (isset($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT']) and !empty($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) { // Management of Extension flags ([username], [mygallery]) // ------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; if (function_exists('get_user_language_desc')) { $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } else { $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } } if (isset($conf_UAM['ADMINVALIDATIONMAIL']) and !empty($conf_UAM['ADMINVALIDATIONMAIL'])) { // Management of Extension flags ([username], [mygallery], [myurl]) // ---------------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; $patterns[] = '#\\[myurl\\]#i'; $replacements[] = get_gallery_home_url(); if (function_exists('get_user_language_desc')) { $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } else { $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } } $infos = array(get_l10n_args('UAM_User: %s', stripslashes($result['username'])), get_l10n_args('Email: %s', $result['mail_address']), get_l10n_args('', '')); // Sending the email with subject and contents // ------------------------------------------- // Adding gallery URL at the end of the email if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true') { $content = l10n_args($infos) . "\n\n" . $custom_txt . get_absolute_root_url(); pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false') { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } else { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } // Switching back to default language // ---------------------------------- switch_lang_back(); }
function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '') { global $conf, $page, $user, $lang_info, $lang, $env_nbm; $return_list = array(); if (in_array($action, array('list_to_send', 'send'))) { list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); $is_action_send = $action == 'send'; // disabled and null mail_address are not selected in the list $data_users = get_user_notifications('send', $check_key_list); // List all if it's define on options or on timeout $is_list_all_without_test = ($env_nbm['is_sendmail_timeout'] or $conf['nbm_list_all_enabled_users_to_send']); // Check if exist news to list user or send mails if (!$is_list_all_without_test or $is_action_send) { if (count($data_users) > 0) { $datas = array(); if (!isset($customize_mail_content)) { $customize_mail_content = $conf['nbm_complementary_mail_content']; } $customize_mail_content = trigger_change('nbm_render_global_customize_mail_content', $customize_mail_content); // Prepare message after change language if ($is_action_send) { $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.'); } else { $msg_break_timeout = l10n('Prepared time for list of users to send mail is limited. Others users are not listed.'); } // Begin nbm users environment begin_users_env_nbm($is_action_send); foreach ($data_users as $nbm_user) { if (!$is_action_send and check_sendmail_timeout()) { // Stop fill list on 'list_to_send', if the quota is override $page['infos'][] = $msg_break_timeout; break; } if ($is_action_send and check_sendmail_timeout()) { // Stop fill list on 'send', if the quota is override $page['errors'][] = $msg_break_timeout; break; } // set env nbm user set_user_on_env_nbm($nbm_user, $is_action_send); if ($is_action_send) { $auth = null; $add_url_params = array(); $auth_key = create_user_auth_key($nbm_user['user_id'], $nbm_user['status']); if ($auth_key !== false) { $auth = $auth_key['auth_key']; $add_url_params['auth'] = $auth; } set_make_full_url(); // Fill return list of "treated" check_key for 'send' $return_list[] = $nbm_user['check_key']; if ($conf['nbm_send_detailed_content']) { $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail'], $auth); $exist_data = count($news) > 0; } else { $exist_data = news_exists($nbm_user['last_send'], $dbnow); } if ($exist_data) { $subject = '[' . $conf['gallery_title'] . '] ' . l10n('New photos added'); // Assign current var for nbm mail assign_vars_nbm_mail_content($nbm_user); if (!is_null($nbm_user['last_send'])) { $env_nbm['mail_template']->assign('content_new_elements_between', array('DATE_BETWEEN_1' => $nbm_user['last_send'], 'DATE_BETWEEN_2' => $dbnow)); } else { $env_nbm['mail_template']->assign('content_new_elements_single', array('DATE_SINGLE' => $dbnow)); } if ($conf['nbm_send_detailed_content']) { $env_nbm['mail_template']->assign('global_new_lines', $news); } $nbm_user_customize_mail_content = trigger_change('nbm_render_user_customize_mail_content', $customize_mail_content, $nbm_user); if (!empty($nbm_user_customize_mail_content)) { $env_nbm['mail_template']->assign('custom_mail_content', $nbm_user_customize_mail_content); } if ($conf['nbm_send_html_mail'] and $conf['nbm_send_recent_post_dates']) { $recent_post_dates = get_recent_post_dates_array($conf['recent_post_dates']['NBM']); foreach ($recent_post_dates as $date_detail) { $env_nbm['mail_template']->append('recent_posts', array('TITLE' => get_title_recent_post_date($date_detail), 'HTML_DATA' => get_html_description_recent_post_date($date_detail, $auth))); } } $env_nbm['mail_template']->assign(array('GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => add_url_params(get_gallery_home_url(), $add_url_params), 'SEND_AS_NAME' => $env_nbm['send_as_name'])); $ret = pwg_mail(array('name' => stripslashes($nbm_user['username']), 'email' => $nbm_user['mail_address']), array('from' => $env_nbm['send_as_mail_formated'], 'subject' => $subject, 'email_format' => $env_nbm['email_format'], 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 'content_format' => $env_nbm['email_format'], 'auth_key' => $auth)); if ($ret) { inc_mail_sent_success($nbm_user); $datas[] = array('user_id' => $nbm_user['user_id'], 'last_send' => $dbnow); } else { inc_mail_sent_failed($nbm_user); } unset_make_full_url(); } } else { if (news_exists($nbm_user['last_send'], $dbnow)) { // Fill return list of "selected" users for 'list_to_send' $return_list[] = $nbm_user; } } // unset env nbm user unset_user_on_env_nbm(); } // Restore nbm environment end_users_env_nbm(); if ($is_action_send) { mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('user_id'), 'update' => array('last_send')), $datas); display_counter_info(); } } else { if ($is_action_send) { $page['errors'][] = l10n('No user to send notifications by mail.'); } } } else { // Quick List, don't check news // Fill return list of "selected" users for 'list_to_send' $return_list = $data_users; } } // Return list of "selected" users for 'list_to_send' // Return list of "treated" check_key for 'send' return $return_list; }
/** * identification menu block */ function oauth_blockmanager($menu_ref_arr) { global $template, $conf, $hybridauth_conf; $menu =& $menu_ref_arr[0]; if ($hybridauth_conf['enabled'] == 0 or !$conf['oauth']['display_menubar'] or $menu->get_block('mbIdentification') == null) { return; } $u_redirect = !empty($_GET['redirect']) ? urldecode($_GET['redirect']) : get_gallery_home_url(); oauth_assign_template_vars($u_redirect); $template->set_prefilter('menubar', 'oauth_add_menubar_buttons_prefilter'); }
} } else { if (isset($_GET['init_auth'])) { $params = array(); if ($provider == 'OpenID') { $params['openid_identifier'] = $_GET['openid_identifier']; } // try to authenticate $adapter = $hybridauth->authenticate($provider, $params); } else { if (!verify_ephemeral_key(@$_GET['key'])) { throw new Exception('Forbidden', 403); } $template->assign('LOADING', '&openid_identifier=' . @$_GET['openid_identifier'] . '&init_auth=1'); } } } catch (Exception $e) { switch ($e->getCode()) { case 5: $template->assign('ERROR', l10n('Authentication canceled')); break; case 404: $template->assign('ERROR', l10n('User not found')); break; default: $template->assign('ERROR', l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>', '<span title="' . $e->getMessage() . '">' . $e->getCode() . '</span>')); } } $template->assign(array('GALLERY_TITLE' => $conf['gallery_title'], 'CONTENT_ENCODING' => get_pwg_charset(), 'U_HOME' => get_gallery_home_url(), 'OAUTH_PATH' => OAUTH_PATH, 'PROVIDER' => $hybridauth_conf['providers'][$provider]['name'], 'SELF_URL' => OAUTH_PATH . 'auth.php?provider=' . $provider)); $template->set_filename('index', realpath(OAUTH_PATH . 'template/auth.tpl')); $template->pparse('index');
// | WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. | // +-----------------------------------------------------------------------+ // by default we start with guest $user['id'] = $conf['guest_id']; if (isset($_COOKIE[session_name()])) { if (isset($_GET['act']) and $_GET['act'] == 'logout') { // logout logout_user(); redirect(get_gallery_home_url()); } elseif (!empty($_SESSION['pwg_uid'])) { $user['id'] = $_SESSION['pwg_uid']; } } // Now check the auto-login if ($user['id'] == $conf['guest_id']) { auto_login(); } // using Apache authentication override the above user search if ($conf['apache_authentication']) { $remote_user = null; foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER') as $server_key) { if (isset($_SERVER[$server_key])) { $remote_user = $_SERVER[$server_key]; break;
} } //-------------------------------------------------------------- initialization // navigation bar $page['navigation_bar'] = array(); if (count($page['items']) > $page['nb_image_page']) { $page['navigation_bar'] = create_navigation_bar(duplicate_index_url(array(), array('start')), count($page['items']), $page['start'], $page['nb_image_page'], true, 'start'); } $template->assign('thumb_navbar', $page['navigation_bar']); // caddie filling :-) if (isset($_GET['caddie'])) { fill_caddie($page['items']); redirect(duplicate_index_url()); } if (isset($page['is_homepage']) and $page['is_homepage']) { $canonical_url = get_gallery_home_url(); } else { $start = $page['nb_image_page'] * round($page['start'] / $page['nb_image_page']); if ($start > 0 && $start >= count($page['items'])) { $start -= $page['nb_image_page']; } $canonical_url = duplicate_index_url(array('start' => $start)); } $template->assign('U_CANONICAL', $canonical_url); //-------------------------------------------------------------- page title $title = $page['title']; $template_title = $page['section_title']; if (count($page['items']) > 0) { $template_title .= ' [' . count($page['items']) . ']'; } $template->assign('TITLE', $template_title);