From d4303ecfda4c98bdfab375fb0921eb617bee4774 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 14 Oct 2007 10:37:37 +0000 Subject: [PATCH] locking mechanismen hinuzgefuegt...so gut wies eben geht --- TODO | 1 + ajax+json_home/ajax.php | 104 ++++++++++++++++---------------------- ajax+json_home/test1.html | 2 +- libs/errException.php | 4 +- libs/mutualExclusion.php | 58 +++++++++++++++++++++ pvtest.php | 90 +++------------------------------ 6 files changed, 111 insertions(+), 148 deletions(-) create mode 100644 libs/mutualExclusion.php diff --git a/TODO b/TODO index ec56ba0..3a0cefe 100644 --- a/TODO +++ b/TODO @@ -17,3 +17,4 @@ http://www.php-faq.de/search.php?q=Locking&l=20 web developer http://de.wikipedia.org/wiki/Semaphor_%28Informatik%29 -djikstra PV- + http://www.kreissl.info/diggs/bs_04.php diff --git a/ajax+json_home/ajax.php b/ajax+json_home/ajax.php index fc18151..a0572c1 100644 --- a/ajax+json_home/ajax.php +++ b/ajax+json_home/ajax.php @@ -1,67 +1,49 @@ BabelFish("en_de",$english); - $french = $trans->BabelFish("en_fr",$english); - } - catch(SoapFault $e) - { - $english = "not found"; - $german = "not found"; - $french = "not found"; - } -*/ - class dummy +class dummy +{ + // nur public member werden via json verschickt. + public $german; + public $english; + public $french; + + function __construct ($english, $german, $french) { - // nur public member werden via json verschickt. - public $german; - public $english; - public $french; - - function __construct ($english, $german, $french) - { - $this->german = $german; - $this->english = $english; - $this->french["val1"] = $french; - $this->french["val2"] = "jokus"; - } - } - - $encoding = FALSE; - if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && - strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== FALSE) - $encoding = "x-gzip"; - if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && - strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) - $encoding = "gzip"; - - header ('Content-type: text/plain'); - - $result = FALSE; - if ($encoding !== FALSE) - $result = gzcompress (json_encode (new dummy ( - 'doing gzip', 'gezipedte Daten', 'la zippo'))); - - if ($result !== FALSE) - { - header ('Content-Encoding: ' . $encoding); - - print ("\x1f\x8b\x08\x00\x00\x00\x00\x00"); - print ($result); - } - else - { - $result = json_encode (new dummy ( - 'doing no gzip', 'nicht gezipedte Daten', 'no la zippo')); - - print ($result); + $this->german = $german; + $this->english = $english; + $this->french["val1"] = $french; + $this->french["val2"] = "jokus"; } +} + +$encoding = FALSE; +if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && + strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== FALSE) +$encoding = "x-gzip"; +if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && + strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) +$encoding = "gzip"; + +header ('Content-type: text/plain'); + +$result = FALSE; +if ($encoding !== FALSE) + $result = gzcompress (json_encode (new dummy ( + 'doing gzip', 'gezipedte Daten', 'la zippo'))); + +if ($result !== FALSE) +{ + header ('Content-Encoding: ' . $encoding); + + print ("\x1f\x8b\x08\x00\x00\x00\x00\x00"); + print ($result); +} +else +{ + $result = json_encode (new dummy ( + 'doing no gzip', 'nicht gezipedte Daten', 'no la zippo')); + + print ($result); +} ?> diff --git a/ajax+json_home/test1.html b/ajax+json_home/test1.html index 3bf7f8f..8d0f104 100644 --- a/ajax+json_home/test1.html +++ b/ajax+json_home/test1.html @@ -67,7 +67,7 @@ // anfrage erstellen (GET, url ist localhost, // request ist asynchron - var url = 'http://muedv031/~georg/bilder/ajax+json/ajax.php' + + var url = 'http://localhost/~georg/bilder/ajax+json_home/ajax.php' + '?translate=' + document.getElementById ('myword').value; req.open("GET", url, true); diff --git a/libs/errException.php b/libs/errException.php index 7c11dda..10fec7a 100644 --- a/libs/errException.php +++ b/libs/errException.php @@ -49,7 +49,7 @@ function setErrExceptionMapping () { global $oldErrHandler; - if ($oldErrHandler == NULL) + if ($oldErrHandler === NULL) $oldErrHandler = set_error_handler ('mapErrToExc'); } @@ -57,7 +57,7 @@ function resetErrExceptionMapping () { global $oldErrHandler; - if ($oldErrHandler != NULL) + if ($oldErrHandler !== NULL) { set_error_handler ($oldErrHandler); $oldErrHandler = NULL; diff --git a/libs/mutualExclusion.php b/libs/mutualExclusion.php new file mode 100644 index 0000000..413e867 --- /dev/null +++ b/libs/mutualExclusion.php @@ -0,0 +1,58 @@ + diff --git a/pvtest.php b/pvtest.php index a2172c6..ebb04f0 100644 --- a/pvtest.php +++ b/pvtest.php @@ -1,93 +1,15 @@