root/modules/branches/2.4/irc/page.irc.php

Revision 4991, 6.8 kB (checked in by p_lindheimer, 5 years ago)

change Dcoumentation left nav to Online Resource and fix url

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php 
2 /* $Id$ */
3 // Module for offering IRC Support using PJIRC.
4 //
5 // Original Release using PJIRC 2.2.0 on 17th Feb, 2006 by
6 // xrobau@gmail.com
7 //
8 //This program is free software; you can redistribute it and/or
9 //modify it under the terms of version 2 of the GNU General Public
10 //License as published by the Free Software Foundation.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //GNU General Public License for more details.
16
17 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action = '';
18 $display='irc';
19 $type = 'tool';
20
21 ?>
22
23 </div>
24 <script type="text/javascript">
25 /**
26  * Sets a Cookie with the given name and value.
27  *
28  * name       Name of the cookie
29  * value      Value of the cookie
30  * [expires]  Expiration date of the cookie (default: end of current session)
31  * [path]     Path where the cookie is valid (default: path of calling document)
32  * [domain]   Domain where the cookie is valid
33  *              (default: domain of calling document)
34  * [secure]   Boolean value indicating if the cookie transmission requires a
35  *              secure transmission
36  */
37 function setCookie(name, value, expires, path, domain, secure) {
38     document.cookie= name + "=" + escape(value) +
39         ((expires) ? "; expires=" + expires.toGMTString() : "") +
40         ((path) ? "; path=" + path : "") +
41         ((domain) ? "; domain=" + domain : "") +
42         ((secure) ? "; secure" : "");
43 }
44
45 /**
46  * Gets the value of the specified cookie.
47  *
48  * name  Name of the desired cookie.
49  *
50  * Returns a string containing value of specified cookie,
51  *   or null if cookie does not exist.
52  */
53 function getCookie(name) {
54     var dc = document.cookie;
55     var prefix = name + "=";
56     var begin = dc.indexOf("; " + prefix);
57     if (begin == -1) {
58         begin = dc.indexOf(prefix);
59         if (begin != 0) return null;
60     } else {
61         begin += 2;
62     }
63     var end = document.cookie.indexOf(";", begin);
64     if (end == -1) {
65         end = dc.length;
66     }
67     return unescape(dc.substring(begin + prefix.length, end));
68 }
69
70 /**
71  * Deletes the specified cookie.
72  *
73  * name      name of the cookie
74  * [path]    path of the cookie (must be same as path used to create cookie)
75  * [domain]  domain of the cookie (must be same as domain used to create cookie)
76  */
77 function deleteCookie(name, path, domain) {
78     if (getCookie(name)) {
79         document.cookie = name + "=" +
80             ((path) ? "; path=" + path : "") +
81             ((domain) ? "; domain=" + domain : "") +
82             "; expires=Thu, 01-Jan-70 00:00:01 GMT";
83     }
84 }
85
86 function startirc(element) {
87   var nick = null;
88   nick = getCookie('ircnick');
89   if (nick == null) nick = '';
90   nick = prompt("What nickname would you like to use? If you leave this blank, a nick will be automatically generated for you.", nick);
91   if ((nick == null) || (nick == '')) {
92     win = window.open("config.php?type=tool&display=<?php echo urlencode($display)?>&action=startreal&quietmode=yes", "IRC Support", "width=660, height=480, location=no, menubar=no, status=no, toolbar=no, scrollbars=no");
93     win.resizeTo(660, 480);
94     win.focus();
95     return true;
96   } else {
97     var expiry = new Date();
98     expiry.setTime(expiry.getTime() + 60 * 60 * 24 * 30); // 30 days
99     setCookie('ircnick', nick, expiry);
100     element.href += '&nick='+nick;
101     win = window.open("config.php?type=tool&display=<?php echo urlencode($display)?>&action=startreal&quietmode=yes&nick="+nick, "IRC Support", "width=660, height=480, location=no, menubar=no, status=no, toolbar=no, scrollbars=no");
102     win.resizeTo(660, 480);
103     win.focus();
104     return true;
105   }
106 }
107 </script>
108 <?php
109 if (isset($_GET['nick'])) {
110   // prevent XSS and other issues
111   $nick = preg_replace('/[^a-zA-Z0-9_\-!]/','',$_GET['nick']);
112 } else {
113   $nick = '';
114 }
115
116 // Supress all this when the IRC window pops out.
117 if (!$quietmode) {
118 ?>
119
120 <div class="rnav"><ul>
121     <li><a href="config.php?type=tool&display=<?php echo urlencode($display)?>&action=start" onclick="startirc(this);"><?php echo _("Start IRC")?></a></li>
122     <li><a href="http://www.freepbx.org" target="_docs"><?php echo _("Online Resources")?></a></li>
123 </ul></div>
124
125 <div class="content">
126
127 <h2>
128 <?php echo _("Online Support")?>
129 </h2>
130
131 <?php
132 } // End header supression
133 switch ($action) {
134   case "start":
135 ?>
136 <p>
137 <?php 
138 if (empty($nick)) echo _("When you connect, you will be automatically be named 'FreePBX' and a random 4 digit number, eg, FreePBX3486.");
139 echo _("If you wish to change this to your normal nickname, you can type '<b>/nick yournickname</b>', and your nick will change. This is an ENGLISH ONLY support channel. Sorry.");
140
141   break;
142   case "startreal":
143 ?>
144 </p>
145
146 <applet name="PJirc" codebase="modules/irc/pjirc/" code="IRCApplet.class" archive="irc.jar,pixx.jar" width="640" height="400">
147 <param name="CABINETS" value="irc.cab,securedirc.cab,pixx.cab">
148 <param name="nick" value="<?php echo (!empty($nick) ? $nick : 'FreePBX????') ?>">
149 <param name="alternatenick" value="<?php echo (!empty($nick) ? $nick.'_' : 'FreePBXU????') ?>">
150 <param name="host" value="irc.freenode.net">
151 <param name="gui" value="pixx">
152 <param name="command1" value="/join #freepbx">
153 <param name="command2" value="/notice #freepbx I am using freePBX <?php echo getversion()." on ".irc_getversioninfo(); ?> ">
154 <param name="command3" value="/notice #freepbx My kernel is: <?php echo exec('uname -a'); ?> ">
155 </applet>
156
157 <script type="text/javascript">
158 function promptBeforeExiting (oldLink) {
159   if (confirm("If you leave this page, you will be disconnected from IRC. Are you sure you want to continue?")) {
160     window.location = oldLink;
161   }
162 }
163
164 function switchLinks(d) {
165   var oldLink="";
166   for (var i=0; i < d.links.length; i++) {
167     if (d.links[i].target == '') {
168       oldLink = d.links[i].href;
169       d.links[i].href = "javascript: promptBeforeExiting('"+ oldLink + "')";
170     }
171   }
172 }
173 switchLinks(document);
174 </script>
175 <?php
176     // Do IRC stuff
177   break;
178   case "":
179 ?>
180
181 <?php echo _("This allows you to contact the FreePBX channel on IRC."); ?>
182
183 <?php echo _("As IRC is an un-moderated international medium, AMP, FreePBX, Coalescent Systems, or any other party can not be held responsible for the actions or behaviour of other people on the network"); ?>
184
185 <?php echo _("When you connect to IRC, to assist in support, the IRC client will automatically send the following information to everyone in the #freePBX channel:"); ?>
186
187 <ul>
188 <li> <?php echo _("Your Linux Distribution:");
189            $ver=irc_getversioninfo();
190            echo " ($ver)"; ?>
191 <li> <?php echo _("Your FreePBX version:");
192            $ver=getversion();
193            echo " (".$ver.")"; ?>
194 <li> <?php echo _("Your Kernel version:");
195            $ver=exec('uname -a');
196            echo " ($ver)"; ?>
197 </ul>
198 <?php echo _("If you do not want this information to be made public, please use another IRC client, or contact a commercial support provider");
199 break;
200 }
201 ?>
Note: See TracBrowser for help on using the browser.