mibew/src/messenger/webim/libs/getcode.php

115 lines
3.4 KiB
PHP
Raw Normal View History

<?php
/*
2013-03-07 01:22:53 +04:00
* Copyright 2005-2013 the original author or authors.
*
2013-03-07 01:22:53 +04:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
2013-03-07 01:22:53 +04:00
* http://www.apache.org/licenses/LICENSE-2.0
*
2013-03-07 01:22:53 +04:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2011-02-27 01:48:41 +03:00
function setup_getcode_tabs($active)
{
global $page, $webimroot;
$page['tabselected'] = $active;
$page['tabs'] = array(
2011-02-27 01:48:41 +03:00
array('title' => getlocal("page_getcode.tab.image"), 'link' => "$webimroot/operator/getcode.php"),
array('title' => getlocal("page_getcode.tab.text"), 'link' => "$webimroot/operator/gettextcode.php"),
);
}
2011-02-27 01:48:41 +03:00
function generate_button($title, $locale, $style, $group, $inner, $showhost, $forcesecure, $modsecurity)
{
$link = get_app_location($showhost, $forcesecure) . "/client.php";
if ($locale)
$link = append_query($link, "locale=$locale");
2011-02-27 01:48:41 +03:00
if ($style)
$link = append_query($link, "style=$style");
2011-02-27 01:48:41 +03:00
if ($group)
$link = append_query($link, "group=$group");
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
2011-02-27 01:48:41 +03:00
$jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&amp;referrer='+escape(document.referrer$modsecfix)");
$temp = get_popup($link, "$jslink",
2011-02-27 01:48:41 +03:00
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1");
return "<!-- mibew button -->" . $temp . "<!-- / mibew button -->";
}
2011-02-27 01:48:41 +03:00
function get_style_list($stylesfolder)
{
$stylelist = array("" => getlocal("page.preview.style_default"));
2011-02-27 01:48:41 +03:00
if ($handle = opendir($stylesfolder)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/^\w+$/", $file) && is_dir("$stylesfolder/$file")) {
$stylelist[$file] = $file;
}
}
closedir($handle);
}
return $stylelist;
}
2011-02-27 01:48:41 +03:00
function verifyparam_groupid($paramid)
{
global $settings, $errors;
$groupid = "";
2011-02-27 01:48:41 +03:00
if ($settings['enablegroups'] == '1') {
$groupid = verifyparam($paramid, "/^\d{0,8}$/", "");
2011-02-27 01:48:41 +03:00
if ($groupid) {
$group = group_by_id($groupid);
2011-02-27 01:48:41 +03:00
if (!$group) {
$errors[] = getlocal("page.group.no_such");
$groupid = "";
}
}
}
return $groupid;
}
2011-02-27 01:48:41 +03:00
function get_groups_list()
{
global $settings;
$result = array();
2011-02-27 01:48:41 +03:00
if ($settings['enablegroups'] == '1') {
$link = connect();
$allgroups = get_all_groups($link);
mysql_close($link);
$result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
2011-02-27 01:48:41 +03:00
foreach ($allgroups as $g) {
$result[] = $g;
}
}
2011-02-27 01:48:41 +03:00
return $result;
}
2011-02-27 01:48:41 +03:00
function get_image_locales_map($localesdir)
{
$imageLocales = array();
$allLocales = get_available_locales();
2011-02-27 01:48:41 +03:00
foreach ($allLocales as $curr) {
$imagesDir = "$localesdir/$curr/button";
2011-02-27 01:48:41 +03:00
if ($handle = @opendir($imagesDir)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
2011-02-27 01:48:41 +03:00
&& is_file("$imagesDir/" . $matches[1] . "_off.gif")) {
$image = $matches[1];
2011-02-27 01:48:41 +03:00
if (!isset($imageLocales[$image])) {
$imageLocales[$image] = array();
}
$imageLocales[$image][] = $curr;
}
}
closedir($handle);
}
}
return $imageLocales;
}
?>