2007-10-10 19:15:47 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2009-06-04 02:44:32 +04:00
|
|
|
* This file is part of Mibew Messenger project.
|
2007-10-10 19:15:47 +04:00
|
|
|
*
|
2009-06-04 02:44:32 +04:00
|
|
|
* Copyright (c) 2005-2009 Mibew Messenger Community
|
2007-10-10 19:15:47 +04:00
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* Evgeny Gryaznov - initial API and implementation
|
|
|
|
*/
|
|
|
|
|
2008-06-05 01:36:54 +04:00
|
|
|
require_once('../libs/common.php');
|
|
|
|
require_once('../libs/operator.php');
|
2009-03-25 02:34:57 +03:00
|
|
|
require_once('../libs/groups.php');
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$operator = check_login();
|
2009-03-25 02:34:57 +03:00
|
|
|
loadsettings();
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$imageLocales = array();
|
2009-01-14 01:19:12 +03:00
|
|
|
$allLocales = get_available_locales();
|
|
|
|
foreach($allLocales as $curr) {
|
2007-10-17 15:32:50 +04:00
|
|
|
$imagesDir = "../locales/$curr/button";
|
|
|
|
if($handle = opendir($imagesDir)) {
|
|
|
|
while (false !== ($file = readdir($handle))) {
|
2008-09-30 02:41:59 +04:00
|
|
|
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
2007-10-17 15:32:50 +04:00
|
|
|
&& is_file("$imagesDir/".$matches[1]."_off.gif")) {
|
|
|
|
$image = $matches[1];
|
|
|
|
if( !isset($imageLocales[$image]) ) {
|
|
|
|
$imageLocales[$image] = array();
|
|
|
|
}
|
|
|
|
$imageLocales[$image][] = $curr;
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
}
|
2007-10-17 15:32:50 +04:00
|
|
|
closedir($handle);
|
2007-10-10 19:15:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$image = verifyparam("image","/^\w+$/", "webim");
|
|
|
|
$image_locales = $imageLocales[$image];
|
|
|
|
|
2008-11-21 19:47:03 +03:00
|
|
|
$stylelist = array("" => getlocal("page.preview.style_default"));
|
|
|
|
$stylesfolder = "../styles";
|
|
|
|
if($handle = opendir($stylesfolder)) {
|
|
|
|
while (false !== ($file = readdir($handle))) {
|
|
|
|
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
|
|
|
|
$stylelist[$file] = $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
$style = verifyparam("style","/^\w*$/", "");
|
|
|
|
if($style && !in_array($style, $stylelist)) {
|
|
|
|
$style = "";
|
|
|
|
}
|
|
|
|
|
2009-03-25 02:34:57 +03:00
|
|
|
$groupid = "";
|
|
|
|
if($settings['enablegroups'] == '1') {
|
|
|
|
$groupid = verifyparam( "group", "/^\d{0,8}$/", "");
|
|
|
|
if($groupid) {
|
|
|
|
$group = group_by_id($groupid);
|
|
|
|
if(!$group) {
|
|
|
|
$errors[] = getlocal("page.group.no_such");
|
|
|
|
$groupid = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 19:15:47 +04:00
|
|
|
$showhost = verifyparam("hostname","/^on$/", "") == "on";
|
|
|
|
$forcesecure = verifyparam("secure","/^on$/", "") == "on";
|
|
|
|
|
2007-10-17 15:32:50 +04:00
|
|
|
$lang = verifyparam("lang", "/^[\w-]{2,5}$/", "");
|
2007-10-10 19:15:47 +04:00
|
|
|
if( !$lang || !in_array($lang,$image_locales) )
|
|
|
|
$lang = in_array($current_locale,$image_locales) ? $current_locale : $image_locales[0];
|
|
|
|
|
2007-10-17 15:32:50 +04:00
|
|
|
$file = "../locales/${lang}/button/${image}_on.gif";
|
2007-10-10 19:15:47 +04:00
|
|
|
$size = get_gifimage_size($file);
|
|
|
|
|
2008-09-30 02:41:59 +04:00
|
|
|
$message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang",$size[0],$size[1]);
|
2007-10-10 19:15:47 +04:00
|
|
|
|
|
|
|
$page = array();
|
2009-03-25 02:34:57 +03:00
|
|
|
$page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure);
|
2007-10-10 19:15:47 +04:00
|
|
|
$page['availableImages'] = array_keys($imageLocales);
|
|
|
|
$page['availableLocales'] = $image_locales;
|
2008-11-21 19:47:03 +03:00
|
|
|
$page['availableStyles'] = $stylelist;
|
2007-10-10 19:15:47 +04:00
|
|
|
|
2009-03-25 02:34:57 +03:00
|
|
|
if($settings['enablegroups'] == '1') {
|
|
|
|
$allgroups = get_groups(false);
|
|
|
|
$page['groups'] = array();
|
|
|
|
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
|
|
|
foreach($allgroups as $g) {
|
|
|
|
$page['groups'][] = $g;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$page['formgroup'] = $groupid;
|
2008-11-21 19:47:03 +03:00
|
|
|
$page['formstyle'] = $style;
|
2007-10-10 19:15:47 +04:00
|
|
|
$page['formimage'] = $image;
|
|
|
|
$page['formlang'] = $lang;
|
|
|
|
$page['formhostname'] = $showhost;
|
|
|
|
$page['formsecure'] = $forcesecure;
|
|
|
|
|
2009-03-16 04:20:04 +03:00
|
|
|
prepare_menu($operator);
|
2007-10-10 19:15:47 +04:00
|
|
|
start_html_output();
|
|
|
|
require('../view/gen_button.php');
|
2007-05-10 21:31:10 +04:00
|
|
|
?>
|