2011-04-07 12:09:10 +04:00
|
|
|
<?php
|
|
|
|
/*
|
2013-03-07 01:22:53 +04:00
|
|
|
* Copyright 2005-2013 the original author or authors.
|
2011-04-07 12:09:10 +04:00
|
|
|
*
|
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
|
2011-04-07 12:09:10 +04:00
|
|
|
*
|
2013-03-07 01:22:53 +04:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-07 12:09:10 +04:00
|
|
|
*
|
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-04-07 12:09:10 +04:00
|
|
|
*/
|
|
|
|
|
2011-12-14 19:50:10 +04:00
|
|
|
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity)
|
2011-04-07 12:09:10 +04:00
|
|
|
{
|
|
|
|
$link = get_app_location($showhost, $forcesecure) . "/client.php";
|
|
|
|
if ($locale)
|
|
|
|
$link = append_query($link, "locale=$locale");
|
|
|
|
if ($style)
|
|
|
|
$link = append_query($link, "style=$style");
|
|
|
|
if ($group)
|
|
|
|
$link = append_query($link, "group=$group");
|
|
|
|
|
|
|
|
$modsecfix = $modsecurity ? ".replace('http://','').replace('https://','')" : "";
|
|
|
|
$jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)");
|
|
|
|
$temp = get_popup($link, "$jslink",
|
|
|
|
$inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1");
|
2012-07-16 18:26:53 +04:00
|
|
|
if (Settings::get('enabletracking')) {
|
2011-04-07 12:34:04 +04:00
|
|
|
$temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp);
|
|
|
|
$temp .= '<div id="mibewinvitation"></div><script type="text/javascript">var mibewInviteStyle = \'@import url(';
|
|
|
|
$temp .= get_app_location($showhost, $forcesecure);
|
2011-12-14 19:50:10 +04:00
|
|
|
$temp .= '/styles/invitations/';
|
2012-07-16 18:26:53 +04:00
|
|
|
$temp .= ($invitationstyle?$invitationstyle:(Settings::get('invitationstyle')));
|
2011-12-11 22:53:49 +04:00
|
|
|
$temp .= '/invite.css);\'; var mibewRequestTimeout = ';
|
2012-07-16 18:26:53 +04:00
|
|
|
$temp .= Settings::get('updatefrequency_tracking');
|
2011-12-11 22:53:49 +04:00
|
|
|
$temp .= '*1000; var mibewRequestUrl = \'';
|
2011-04-07 12:34:04 +04:00
|
|
|
$temp .= get_app_location($showhost, $forcesecure);
|
2011-12-11 22:53:49 +04:00
|
|
|
$temp .= '/request.php?entry=\' + escape(document.referrer) + \'&lang=ru\'</script><script type="text/javascript" src="';
|
|
|
|
$temp .= get_app_location($showhost, $forcesecure);
|
|
|
|
$temp .= '/js/request.js"></script><script type="text/javascript">mibewMakeRequest();</script>';
|
2011-04-07 12:34:04 +04:00
|
|
|
}
|
2011-04-07 12:09:10 +04:00
|
|
|
return "<!-- mibew button -->" . $temp . "<!-- / mibew button -->";
|
|
|
|
}
|
|
|
|
|
|
|
|
function verifyparam_groupid($paramid)
|
|
|
|
{
|
2012-01-21 19:09:49 +04:00
|
|
|
global $errors;
|
2011-04-07 12:09:10 +04:00
|
|
|
$groupid = "";
|
2012-01-21 19:09:49 +04:00
|
|
|
$groupid = verifyparam($paramid, "/^\d{0,8}$/", "");
|
|
|
|
if ($groupid) {
|
|
|
|
$group = group_by_id($groupid);
|
|
|
|
if (!$group) {
|
|
|
|
$errors[] = getlocal("page.group.no_such");
|
|
|
|
$groupid = "";
|
2011-04-07 12:09:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $groupid;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_groups_list()
|
|
|
|
{
|
|
|
|
$result = array();
|
2012-07-13 16:56:50 +04:00
|
|
|
$allgroups = get_all_groups();
|
2012-02-24 17:52:39 +04:00
|
|
|
$result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"), 'level' => 0);
|
2012-01-21 19:09:49 +04:00
|
|
|
foreach ($allgroups as $g) {
|
|
|
|
$result[] = $g;
|
2011-04-07 12:09:10 +04:00
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_image_locales_map($localesdir)
|
|
|
|
{
|
|
|
|
$imageLocales = array();
|
|
|
|
$allLocales = get_available_locales();
|
|
|
|
foreach ($allLocales as $curr) {
|
|
|
|
$imagesDir = "$localesdir/$curr/button";
|
|
|
|
if ($handle = @opendir($imagesDir)) {
|
|
|
|
while (false !== ($file = readdir($handle))) {
|
|
|
|
if (preg_match("/^(\w+)_on.gif$/", $file, $matches)
|
|
|
|
&& is_file("$imagesDir/" . $matches[1] . "_off.gif")) {
|
|
|
|
$image = $matches[1];
|
|
|
|
if (!isset($imageLocales[$image])) {
|
|
|
|
$imageLocales[$image] = array();
|
|
|
|
}
|
|
|
|
$imageLocales[$image][] = $curr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $imageLocales;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|