PageRenderTime 50ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/ticker_v2_notfinished/ticker_example_script.php

http://flaimo-php.googlecode.com/
PHP | 239 lines | 159 code | 20 blank | 60 comment | 14 complexity | 817125f5883287715b34152678a56fb4 MD5 | raw file
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. //+----------------------------------------------------------------------+
  4. //| WAMP (XP-SP1/1.3.24/4.0.12/4.3.0) |
  5. //+----------------------------------------------------------------------+
  6. //| Copyright (c) 1992-2003 Michael Wimmer |
  7. //+----------------------------------------------------------------------+
  8. //| I don't have the time to read through all the licences to find out |
  9. //| what the exactly say. But it's simple. It's free for non commercial |
  10. //| projects, but as soon as you make money with it, i want my share :-) |
  11. //+----------------------------------------------------------------------+
  12. //| Authors: Michael Wimmer <flaimo@gmx.net> |
  13. //+----------------------------------------------------------------------+
  14. //
  15. // $Id$
  16. /**
  17. * @package Ticker
  18. * @category FLP
  19. * @filesource
  20. */
  21. ob_start();
  22. session_start();
  23. include_once 'class.Ticker.inc.php';
  24. $t = new Ticker(20);
  25. $list = $t->getMessageList();
  26. echo '<?xml version="1.0" encoding="iso-8859-1"?>'; ?>
  27. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <title>SMS/E-Mail Ticker</title>
  31. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  32. <link href="doc.css" rel="stylesheet" type="text/css" />
  33. <script language="javascript" type="text/javascript">
  34. <!--
  35. /*
  36. The contents of this file are subject to the Netscape Public
  37. License Version 1.1 (the "License"); you may not use this file
  38. except in compliance with the License. You may obtain a copy of
  39. the License at http://www.mozilla.org/NPL/
  40. Software distributed under the License is distributed on an "AS
  41. IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  42. implied. See the License for the specific language governing
  43. rights and limitations under the License.
  44. The Initial Developer of the Original Code is Doron Rosenberg
  45. Alternatively, the contents of this file may be used under the
  46. terms of the GNU Public License (the "GPL"), in which case the
  47. provisions of the GPL are applicable instead of those above.
  48. If you wish to allow use of your version of this file only
  49. under the terms of the GPL and not to allow others to use your
  50. version of this file under the NPL, indicate your decision by
  51. deleting the provisions above and replace them with the notice
  52. and other provisions required by the GPL. If you do not delete
  53. the provisions above, a recipient may use your version of this
  54. file under either the NPL or the GPL.
  55. Contributor(s): Doron Rosenberg, doronr@gmx.net
  56. Bob Clary, Netscape Communications, Copyright 2001
  57. */
  58. /*
  59. stock-ticker.js Version 0.2
  60. this script animates a ticker consisting of a div containing a sequence of
  61. spans. the div is shifted to the left by shiftBy pixels every interval ms.
  62. As the second visible span reaches the left of the screen, the first is appended to
  63. the end of the div's children.
  64. See http://devedge.netscape.com/toolbox/examples/2001/stock-ticker/
  65. */
  66. function Ticker(name, id, shiftBy, interval) {
  67. this.name = name;
  68. this.id = id;
  69. this.shiftBy = shiftBy ? shiftBy : 1;
  70. this.interval = interval ? interval : 100;
  71. this.runId = null;
  72. this.div = document.getElementById(id);
  73. var node = this.div.firstChild;
  74. var next;
  75. while (node) {
  76. next = node.nextSibling;
  77. if (node.nodeType == 3)
  78. this.div.removeChild(node);
  79. node = next;
  80. }
  81. this.left = 0;
  82. this.shiftLeftAt = this.div.firstChild.offsetWidth;
  83. this.div.style.height = this.div.firstChild.offsetHeight;
  84. this.div.style.width = 2 * screen.availWidth;
  85. this.div.style.visibility = 'visible';
  86. }
  87. function startTicker() {
  88. this.stop();
  89. this.left -= this.shiftBy;
  90. if (this.left <= -this.shiftLeftAt) {
  91. this.left = 0;
  92. this.div.appendChild(this.div.firstChild);
  93. this.shiftLeftAt = this.div.firstChild.offsetWidth;
  94. }
  95. this.div.style.left = (this.left + 'px');
  96. this.runId = setTimeout(this.name + '.start()', this.interval);
  97. }
  98. function stopTicker() {
  99. if (this.runId)
  100. clearTimeout(this.runId);
  101. this.runId = null;
  102. }
  103. function changeTickerInterval(newinterval) {
  104. if (typeof(newinterval) == 'string')
  105. newinterval = parseInt('0' + newinterval, 10);
  106. if (typeof(newinterval) == 'number' && newinterval > 0)
  107. this.interval = newinterval;
  108. this.stop();
  109. this.start();
  110. }
  111. /* Prototypes for Ticker */
  112. Ticker.prototype.start = startTicker;
  113. Ticker.prototype.stop = stopTicker;
  114. Ticker.prototype.changeInterval = changeTickerInterval;
  115. var ticker = null;
  116. function setTickerSpeed() {
  117. ticker.changeInterval(document.forms.frmTickerSpeed.speed.value);
  118. }
  119. function startticker() {
  120. ticker = new Ticker('ticker', 'tickerID', 1, document.forms.frmTickerSpeed.speed.value);
  121. ticker.start();
  122. }
  123. // -->
  124. </script>
  125. <style type="text/css">
  126. <!--
  127. .ticker {
  128. padding: 2px 0px;
  129. background-color: white;
  130. position: relative;
  131. visibility: hidden;
  132. left: 0px;
  133. top: 0px;
  134. border-width: 1px;
  135. border-style: solid;
  136. font-size: 12px;
  137. font-weight: bold;
  138. width: 100%;
  139. }
  140. -->
  141. </style>
  142. </head>
  143. <body>
  144. <h1><a href="http://sourceforge.net/projects/php-flp/">SMS/E-Mail Ticker</a> <small>(V1.002)</small></h1>
  145. <p>To test the script, send a <acronym title="Short Message Service" lang="en" xml:lang="en">SMS</acronym> (cell phone text message) or mail to ticker@flaimo.com. The message body has to start with "<?php echo $t->getStartString(); ?>" and end with "<?php echo $t->getEndString(); ?>". Only the first 160 characters are displayed. Guidelines for a couple of cell phone companies on how to send a SMS to an e-mail can be found <a href="sms2mail.htm">here</a>.</p>
  146. <p>Some download servers at sourceforge.net seem to be down. Be sure to try all mirror servers that are listed there.</p>
  147. <h2>Last <?php echo $t->getListSize(); ?> Messages</h2>
  148. <?php
  149. // to add a message though a form for example use this method.
  150. if ($t->hasMessageWritten() === FALSE && isset($_POST['Submit'])) {
  151. $t->addTickerMessage($_POST['t_message'],$_POST['t_name']);
  152. } // end if
  153. $singlestring = '';
  154. foreach ($list as $id) {
  155. $m = $t->getMessage($id);
  156. echo '<p style="font-size:0.6em;border-bottom: 1px solid #333;"><b>ID:</b> ' , $m->getID() , '<br />';
  157. echo '<b>Date:</b> ' , date('Y-m-d H:i:s',$m->getTimestamp()) , '<br />';
  158. echo '<b>Message:</b> ' , htmlentities(strip_tags($m->getText())) , '</p>';
  159. $singlestring .= '<span>' , htmlentities(strip_tags($m->getText())) , ' <span style="color:red">+++</span> </span>' , "\n";
  160. } // end foreach
  161. ?>
  162. <h2>Sample Ticker</h2>
  163. <p>You can use the messages to create a ticker, guestbook, shoutbox,&#8230;whatever.</p>
  164. <div style="position: relative; height: 18px; width: 100%; overflow: hidden;">
  165. <div name="tickerspace" id="tickerID" class="ticker">
  166. <?php echo $singlestring; ?>
  167. </div>
  168. </div>
  169. <form name="frmTickerSpeed">
  170. <input type="hidden" id="speed" name="speed" value="20" size="4" />
  171. <!--Ticker Speed <input type="text" id="speed" name="speed" value="20" size="4" /> ms&nbsp;
  172. <button type="button" onclick="ticker.stop();" style="color:red; font-weight:bold">Stop</button>
  173. <button type="button" onclick="setTickerSpeed();ticker.start();" style="color:green; font-weight:bold">Play</button>
  174. <button type="button" onclick="setTickerSpeed()">Set Ticker Speed</button>-->
  175. </form>
  176. <hr />
  177. <p>
  178. Besides Mail and SMS you can use a plain HTML form to add a Ticker message
  179. (maximum 160 characters). Please be patient. It could take some time until
  180. the message shows up.
  181. </p>
  182. <?php if ($t->hasMessageWritten() === FALSE) { ?>
  183. <form name="ticker" id="ticker" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  184. <p>
  185. <fieldset>
  186. <legend>Add Ticker message</legend>
  187. <label for="t_message">Message:</label><br />
  188. <textarea name="t_message" id="t_message" cols="40" rows="3"></textarea>
  189. <br />
  190. <label for="t_name">Name</label>
  191. <input type="text" name="t_name" id="t_name" />
  192. <br />
  193. <input type="submit" name="Submit" id="Submit" value="Add Message" />
  194. </fieldset>&nbsp;
  195. </p>
  196. </form>
  197. <?php } ?>
  198. <hr />
  199. <p> <strong>Author:</strong> <a href="mailto:flaimo@gmx.net">Flaimo</a><br />
  200. <strong>Date:</strong> 2003-05-30<br />
  201. <strong>URLs:</strong><br />
  202. <a href="http://sourceforge.net/projects/php-flp/">Project homepage</a><br />
  203. <a href="http://www.flaimo.com/">Sample-Script</a></p>
  204. <script language="javascript" type="text/javascript">
  205. <!--
  206. startticker();
  207. // -->
  208. </script>
  209. </body>
  210. </html>
  211. <?php
  212. ob_end_flush();
  213. ?>