/[cvs]/nfo/php/libs/org.netfrag.elib/progressive/common/hidden/inc/pm-dccl.php.inc
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.elib/progressive/common/hidden/inc/pm-dccl.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Wed Jan 23 17:40:35 2002 UTC (23 years, 3 months ago) by cvsjoko
Branch: nfo, MAIN
CVS Tags: v003, HEAD
Changes since 1.1: +0 -0 lines
initial

1 cvsjoko 1.1 <?php
2    
3     /*
4     -----------------------------------
5     *** progressive media ***
6    
7     pm-dccl.inc
8     Progressive Media:
9     Dynamic common code library.
10    
11     -----------------------------------
12    
13     $Id: pm-dccl.php.inc,v 1.4 2001/01/23 03:19:03 amo Exp $
14    
15     $Log: pm-dccl.php.inc,v $
16     Revision 1.4 2001/01/23 03:19:03 amo
17     + minor bugfix
18    
19     Revision 1.3 2000/12/11 20:55:28 amo
20     +- ?
21    
22     Revision 1.2 2000/10/29 15:52:33 amo
23     + Blöcke im VarTrace jetzt JavaScript - ein-/ausklappbar
24    
25     Revision 1.1 2000/10/27 10:36:13 amo
26     + neu
27    
28    
29     -----------------------------------
30     */
31    
32     DEFINE ('MODULE_DCCL', 1);
33    
34     // ========================================================
35     /*
36     Email-Adress / URL - Validation Functions
37     */
38     // ========================================================
39    
40     function validateEmail($email)
41     {
42     return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
43     }
44    
45     function validateURL($url)
46     {
47     return eregi("^((ht|f)tp://)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$", $url);
48     }
49    
50     function convertURLS($text)
51     {
52     $text = eregi_replace("((ht|f)tp://www\.|www\.)([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})((/|\?)[a-z0-9~#%&\\/'_\+=:\?\.-]*)*)", "http://www.\\3", $text);
53     $text = eregi_replace("((ht|f)tp://)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)", "<a href=\"\\0\">\\0</a>", $text);
54     return $text;
55     }
56    
57     function convertMail($text)
58     {
59     $text = eregi_replace("([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))", "<a href='mailto:\\0'>\\0</a>", $text);
60     return $text;
61     }
62    
63     function convertAllLinks($text)
64     {
65     $text = convertURLS($text);
66     $text = convertMail($text);
67     return $text;
68     }
69    
70     // ========================================================
71    
72    
73    
74     // ========================================================
75     /*
76     array helper functions
77     */
78     // ========================================================
79    
80    
81     function pop(&$array){
82     if (!is_array($array)){ return; }
83     $variable = $array[count($array)-1];
84     unset($array[count($array)-1]);
85     return $variable;
86     }
87    
88     function push (&$array, $variable)
89     {
90    
91     if (!is_array($array)) { print "<b>Error: </b>Given variable is not an array.<br>"; exit; }
92     $array [count ($array)] = $variable;
93     return count($array);
94    
95     }
96    
97     /*
98     function chomp(&$string, $int = 1){
99     if (!$string || $int < 1){ return; }
100     for ($x = 0; $x < $int; $x++){
101     if (ereg("\n$",$string,$ref)){
102     $string = ereg_replace("\n$","",$string);
103     }else{
104     return;
105     }
106     }
107     unset($x);
108     unset($int);
109     }
110    
111     function shift(&$array){
112     if (!is_array($array) || !is_string($variable)){ return; }
113     $variable = $array[0];
114     for ($x = 1; $x < count($array); $x++){
115     $temp[count($temp)] = $array[$x];
116     }
117     $array = $temp;
118     unset($temp);
119     return $variable;
120     }
121    
122     function unshift(&$array,$variable){
123     if (!is_array($array)){ return; }
124     if (!is_array($variable)){
125     $temp = $array;
126     unset($array);
127     $array[0] = $variable;
128     for ($x = 0; $x < count($temp); $x++){
129     $array[count($array)] = $temp[$x];
130     }
131     unset($temp);
132     unset($x);
133     }elseif(is_array($variable)){
134     $temp = $array;
135     unset($array);
136     for ($x = 0; $x < count($variable); $x++){
137     $array[count($array)] = $variable[$x];
138     }
139     for ($x = 0; $x < count($temp); $x++){
140     $array[count($array)] = $temp[$x];
141     }
142     unset($temp);
143     unset($x);
144     }
145     return count($array);
146     }
147    
148     function splice(&$array,$skip,$length,$variable){
149     if (!is_array($array) || $length == 0){ return; }
150     $replaced = array();
151     if ($skip < 0){
152     if (!is_array($variable)){
153     $array[count($array)] = $variable;
154     }elseif (is_array($variable)){
155     for ($x = 0; $x < count($variable); $x++){
156     $array[count($array)] = $variable[$x];
157     }
158     }
159     return $replaced;
160     }
161    
162     for ($x = 0; $x < count($array); $x++){
163     if ($x >= $skip){
164     if (!is_array($variable)){
165     if ($length > 1){
166    
167     }else{
168     $replaced[count($replaced)] = $array[$x];
169     $array[$x] = $variable;
170     break;
171     }
172    
173    
174     }elseif (is_array($variable)){
175     for ($y = $skip; $y <= $length; $y++){
176     $replaced[count($replaced)] = $array[$y];
177     $array[$y] = $array[($skip+$length)];
178     }
179     for ($y = (count($array)-$length); $y < count($array); $y++){
180     unset($array[$y]);
181     }
182     $temp = $array;
183     unset($array);
184     for ($y = ($skip-1); $y >= 0; $y--){
185     $array[$y] = $temp[$y];
186     }
187     for ($y = $skip; $y < count($variable); $y++){
188     $array[count($array)] = $variable[$y];
189     }
190     for ($y = $skip; $y < count($temp); $y++){
191     $array[count($array)] = $temp[$y];
192     }
193     }
194     }
195     }
196     return $replaced;
197     }
198    
199    
200     function sort_unique(&$data, $type = ""){
201     if (!is_array($data)){
202     settype($data,"array");
203     }
204     if (count($data) < 1){
205     print "Array is empty!<br>\n";
206     return;
207     }
208     if (isset($temp)){ unset($temp); }
209    
210     $count = 0;
211     for ($x = 0; $x < count($data); $x++){
212     if (is_array($data[$x])){
213     sort_unique_sub(&$data[$x], $type);
214     $count++;
215     }
216     }
217    
218     if ($count == 0){
219     sort_unique_sub(&$data, $type);
220     }
221     }
222    
223     function sort_unique_sub ($data, $type = ""){
224     if (isset($temp)){ unset($temp); }
225     if ($type == "nocase"){
226     for ($x = 0; $x < count($data); $x++){
227     $data[$x] = strtolower($data[$x]);
228     }
229     }
230     sort($data);
231     for ($x = 0; $x < count($data); $x++){
232     if ($data[$x] != $data[$x+1]){
233     $temp[sizeof($temp)] = $data[$x];
234     }
235     }
236     unset ($data);
237     for ($x = 0; $x < count($temp); $x++){
238     $data[$x] = $temp[$x];
239     }
240     }
241    
242     function truncate_array(&$data, $element){
243     if (!is_array($data)){
244     settype($data,"array");
245     }
246     if (count($data) < 1){
247     print "Array is empty!<br>\n";
248     return;
249     }
250     if (!$element){
251     print "Must specify array element!<br>\n";
252     return;
253     }
254     if (count($data) < $element){
255     $num = count($data);
256     print "Array only has $num elements!<br>\n";
257     return;
258     }
259    
260     for ($x = count($data); $x >= 1; $x--){
261     if ($x >= $element){
262     unset($data[$x-1]);
263     }
264     }
265     }
266    
267    
268     function get_array_range(&$data, $range = ""){
269     if (!is_array($data)){
270     settype($data,"array");
271     }
272     if (count($data) < 1){
273     print "Array is empty!<br>\n";
274     return;
275     }
276     if (!$range){
277     print "No range specified!<br>\n";
278     return;
279     }
280    
281     list($start,$end) = split("-",$range);
282     if ($start > $end){
283     $temp = $start;
284     $start = $end;
285     $end = $temp;
286     }
287    
288     if ($end > count($data)){
289     $num = count($data);
290     print "Array only has $num elements!<br>\n";
291     return;
292     }
293    
294     if (isset($temp)){ unset($temp); }
295    
296     for ($x = 1; $x <= count($data); $x++){
297     if ($x >= $start && $x <= $end){
298     $temp[sizeof($temp)] = $data[$x-1];
299     }
300     }
301     unset($data);
302     $data = $temp;
303     unset($temp);
304    
305     }
306    
307     */
308    
309    
310    
311    
312     // ========================================================
313    
314    
315    
316     // ========================================================
317     /*
318     ERROR-Handling
319     */
320     // ========================================================
321    
322     function errorhandling_enable() {
323    
324     global $old_error_handler;
325    
326     // set to the user defined error handler
327     // error_reporting(1024);
328     // error_reporting(0);
329     $old_error_handler = set_error_handler("ErrorHandler_PHP");
330     }
331    
332     function ErrorHandler_PHP ($errno, $errstr, $errfile, $errline, $vars) {
333    
334     $priv_error = new error($errno, $errstr, $errfile, $errline, $vars);
335    
336     if (function_exists('onerror_php')) { onerror_php($priv_error); }
337    
338     }
339    
340     function ErrorHandler_Application ($content) {
341    
342     if (function_exists('onerror_app')) { onerror_app($content); }
343    
344     }
345    
346     function get_ApplicationErrorDescription_By_ApplicationErrorCode($type) {
347    
348     // Fehler-Typ und Fehler-Nummer holen, falls übergeben
349    
350     $priv_msg = '';
351     $type = trim ($type);
352    
353     if ($type) {
354    
355     $priv_err = split ('\.', $type);
356    
357     $errtype = $priv_err[0];
358     $errno = $priv_err[1];
359    
360     switch ($errtype) {
361    
362     case 'db':
363    
364     switch ($errno) {
365    
366     case '99':
367    
368     $priv_msg = "Die Datenbank ist momentan leider ausgelastet, bitte entschuldigen Sie die St&ouml;rung.";
369    
370     break;
371    
372     }
373    
374     break;
375    
376     }
377    
378     }
379    
380     return $priv_msg;
381    
382     }
383    
384     // --------------------------------------
385     // error class
386     // --------------------------------------
387    
388     class error {
389    
390     var $number;
391     var $description;
392     var $file;
393     var $line;
394     var $vars;
395    
396    
397    
398     // define an assoc array of error string
399     // in reality the only entries we should
400     // consider are 2,8,256,512 and 1024
401     var $_errortype = array (
402     1 => "Error",
403     2 => "Warning",
404     4 => "Parsing Error",
405     8 => "Notice",
406     16 => "Core Error",
407     32 => "Core Warning",
408     64 => "Compile Error",
409     128 => "Compile Warning",
410     256 => "User Error",
411     512 => "User Warning",
412     1024=> "User Notice"
413     );
414    
415    
416    
417     function error(&$priv_number, &$priv_description, &$priv_file, &$priv_line, &$priv_vars) {
418    
419     $this->number = $priv_number;
420     $this->description = $priv_description;
421     $this->file = $priv_file;
422     $this->line = $priv_line;
423     $this->vars = $priv_vars;
424    
425     }
426    
427     function get_ErrorTypeText_By_ErrorNumber($errnumber) {
428    
429    
430     if ($errnumber && isset($this->_errortype[$errnumber])) {
431     return $this->_errortype[$errnumber];
432     }
433    
434     }
435    
436     function get_VarTrace() {
437    
438     static $callcount;
439     $callcount++;
440    
441     $result = "<br>\n";
442     $priv_varTraceHash = $this->vars;
443    
444     while (list($key, $value) = each ($priv_varTraceHash)) {
445    
446     $errdiv_domid = 'errdiv_' . $key . $callcount;
447     $result .=
448     "\n <!-- new var-trace-entry --> \n" .
449     '&nbsp;&nbsp;' .
450     "\n" .
451     '<a href="javascript:" onclick="javascript:
452     priv_domobj = document.all.' . $errdiv_domid . ';
453     if (priv_domobj.style.display == \'none\' || priv_domobj.style.visibility == \'hidden\') {
454     priv_domobj.style.display = \'\';
455     } else {
456     priv_domobj.style.display = \'none\';
457     }
458     ">' . $key . '</a>' . ': ' .
459     '<div id="' . $errdiv_domid . '" style="display:none;">' .
460     htmlentities(wddx_serialize_value($priv_varTraceHash[$key])) .
461     '</div>' .
462     "<br>\n";
463    
464     }
465    
466     return $result;
467    
468     }
469    
470     function get_ErrorOutputBlock_Plain() {
471    
472     $priv_vartrace = $this->get_VarTrace($this->vars);
473     $priv_content =
474     "<b>PHP Error Type: </b>" . $this->get_ErrorTypeText_By_ErrorNumber($this->number) . "<br>" .
475     "<b>Number: </b>" . $this->number . "<br>" .
476     "<b>Description: </b>" . $this->description . "<br>" .
477     "<b>Filename: </b>" . $this->file . "<br>" .
478     "<b>Line: </b>" . $this->line . "<br>" .
479     "<b>VarTrace: </b>" . $priv_vartrace . "<br>";
480    
481     return $priv_content;
482    
483     }
484    
485    
486     }
487    
488     // --------------------------------------
489    
490    
491    
492    
493     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed