Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Głupawe funkcje - czyli "zabawa" z php, pseudokod
.radex
post
Post #1





Grupa: Zarejestrowani
Postów: 1 657
Pomógł: 125
Dołączył: 29.04.2006

Ostrzeżenie: (0%)
-----


tak jak w nazwie tematu.... taki pseudokod... możliwe że coś takiego było... tongue.gif ja dam:

"Praca moderatora"
  1. <?php
  2. if($I['czas'] > 15*60){ //jeśli mam czasu więcej niż 15 minut
  3. login(forum.mojsite.co.uk , $I['username-mojsite'] , $I['password-mojsite']);
  4.  
  5. for($i = 0 ; $i < sizeof($NEWPOST) ; $i++){
  6.  
  7. ReadPost($NEWPOST[$i]);
  8.  
  9. if($Postauthor[$NEWPOST[$i]] == 'SPAMMING'){
  10.  
  11. BAN($postauthot[$NEWPOST[$i]]);
  12.  
  13. }
  14.  
  15. }
  16. }
  17. ?>


--------------------
blog | Tadam — minutnik do Pomodoro na Maka :)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 17)
phpion
post
Post #2





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Co to ma byc blink.gif
Go to the top of the page
+Quote Post
kwiateusz
post
Post #3


Admin Techniczny


Grupa: Administratorzy
Postów: 2 071
Pomógł: 93
Dołączył: 5.07.2005
Skąd: Olsztyn




opis pracy moderatora pseudo kodem :]
Go to the top of the page
+Quote Post
phpion
post
Post #4





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Świetne, ubaw po pachy.
Go to the top of the page
+Quote Post
Daimos
post
Post #5





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

Ostrzeżenie: (0%)
-----


  1. <?
  2. $Postauthor["radex_p"] = 'SPAMMING';
  3. ?>

winksmiley.jpg


--------------------
scriptun.com. Startup z poradnikami do gier ttp.zone i ttpzone.pl
Go to the top of the page
+Quote Post
strife
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

Ostrzeżenie: (0%)
-----


  1. <?php
  2.  
  3.  
  4. class Uzytkownik
  5. {
  6. private $Leniwy;
  7.  
  8. private $PotrafiKorzystacZGoogle;
  9.  
  10. private $JestNowy;
  11.  
  12. private $Dzieciak;
  13.  
  14. public function setLeniwy( $param = true )
  15. {
  16. $this -> Leniwy = $param;
  17. }
  18. public function setPotrafiKorzystacZGoogle( $param = true )
  19. {
  20. if ( $this -> Leniwy == true ) {
  21. $this -> PotrafiKorzystacZGoogle = false;
  22. } else {
  23. $this -> PotrafiKorzystacZGoogle = $param;
  24. }
  25.  
  26. }
  27. public function setJestNowy( $param )
  28. {
  29. $this -> JestNowy = $param;
  30. }
  31. public function setNowyTemat( $trescTematu )
  32. {
  33.  
  34. if ( $this -> PotrafiKorzystacZGoogle == true && $this -> Leniwy == false ) {
  35. return false;
  36. }
  37.  
  38. $olewamRegulamin = NULL;
  39. $dopisekDoTematu = NULL;
  40.  
  41. if ( ! $this -> PotrafiKorzystacZGoogle ) {
  42. $dopisekDoTematu .= "Tylko nie mowcie, zebym poszukal na GOOGLE, bo juz szukalem i NIC !! n";
  43. }
  44.  
  45. if ( $this -> JestNowy ) {
  46. $dopisekDoTematu .= "Jestem nowynn";
  47. } 
  48.  
  49. if ( $this -> JestNowy && $this -> Leniwy ) {
  50. $olewamRegulamin = true;
  51. }
  52.  
  53. if ( $this -> Leniwy ) {
  54. $dopisekDoTematu .= "Na forum szukalem kilka godzin i nic nie znalazlem POMOZCIE !! PLISSSSnn";
  55. }
  56.  
  57. if ( $this -> Dzieciak ) {
  58. return $this -> zmienZapisNaZiomalski( $trescTematu . "nn" .$dopisekDoTematu );
  59. } else {
  60. return ( $trescTematu . "nn" .$dopisekDoTematu );
  61. }
  62.  
  63.  
  64.  
  65. }
  66. public function zmienZapisNaZiomalski( $param ) 
  67. {
  68. $jEsTKuL = NULL;
  69. for( $i = 0; $i < strlen( $param ); $i ++ )
  70. {
  71. if ( $i % 2 ) {
  72. $jEsTKuL .= strtoupper( $param{$i} );
  73. } else {
  74. $jEsTKuL .= strtolower( $param{$i} );
  75. }
  76.  
  77. }
  78.  
  79. return "eLO eLO ZiooOoOooOmY !!!nn" . $jEsTKuL;
  80. }
  81. public function setDzieciak( $param )
  82. {
  83. $this -> Dzieciak = $param;
  84. }
  85.  
  86. }
  87.  
  88. $new = new Uzytkownik;
  89. $trescTematu = "Mam na imie Wojtek, mam 13 lat i mam problem, mam skrypt i nie dziala mi, d
    laczego!?!?!"
    ;
  90.  
  91.  
  92. $new -> setDzieciak( true );
  93. $new -> setJestNowy( true );
  94. $new -> setLeniwy( true );
  95. $new -> setPotrafiKorzystacZGoogle( false );
  96.  
  97.  
  98. echo $new -> setNowyTemat( $trescTematu );
  99.  
  100. /**
  101.  * WYNIK:
  102.  * eLO eLO ZiooOoOooOmY !!!
  103.  *
  104.  * mAm nA ImIe wOjTeK, mAm 13 LaT I MaM PrObLeM, mAm sKrYpT I NiE DzIaLa mI, dLa
    CzEgO!?!?!
  105.  * 
  106.  * TyLkO NiE MoWcIe, ZeByM PoSzUkAl nA GoOgLe, Bo jUz sZuKaLeM I NiC !! 
  107.  * JeStEm nOwY
  108.  * 
  109.  * nA FoRuM SzUkAlEm kIlKa gOdZiN I NiC NiE ZnAlAzLeM PoMoZcIe !! PlIsSsS
  110.  */
  111.  
  112. ?>


winksmiley.jpg

@Hacker - winksmiley.jpg


--------------------
Go to the top of the page
+Quote Post
phpion
post
Post #7





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Lol, hahaha, to mnie zabilo biggrin.gif szczegolnie fragment:
  1. <?php $new -> setPotrafiKorzystacZGoogle( false ); ?>

oraz przykladowy post hehehe. Ale coz: to jest tylko rzeczywistosc...
Go to the top of the page
+Quote Post
.radex
post
Post #8





Grupa: Zarejestrowani
Postów: 1 657
Pomógł: 125
Dołączył: 29.04.2006

Ostrzeżenie: (0%)
-----


Cytat(my salsa @ 10.04.2007, 21:34:30 ) *
  1. <?
  2. $Postauthor["radex_p"] = 'SPAMMING';
  3. ?>

winksmiley.jpg


  1. $lastpost = '<?$Postauthor["radex_p"] = 'SPAMMING';?>';
  2.  
  3. Odpisz(Check($lastpost));


Zwraca:

Ciekawe czy wiesz co to spam:P


--------------------
blog | Tadam — minutnik do Pomodoro na Maka :)
Go to the top of the page
+Quote Post
Daimos
post
Post #9





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

Ostrzeżenie: (0%)
-----


no zapewne nie, skomplikowane slowo smile.gif


--------------------
scriptun.com. Startup z poradnikami do gier ttp.zone i ttpzone.pl
Go to the top of the page
+Quote Post
Hacker
post
Post #10





Grupa: Zarejestrowani
Postów: 225
Pomógł: 0
Dołączył: 1.11.2005

Ostrzeżenie: (0%)
-----


@strife
Zapomniałeś o zadeklarowaniu pola $Dzieciak (kurde czemu ja się czepiam poprawności kodu w takim temacie LOL). Poza tym niezły pomysł


--------------------
(\.../)This is Bunny
(O.o)Copy Bunny into your signature to help him...
(> <)...on his way to world domination
Go to the top of the page
+Quote Post
empathon
post
Post #11





Grupa: Zarejestrowani
Postów: 246
Pomógł: 31
Dołączył: 13.11.2006
Skąd: się znamy?

Ostrzeżenie: (0%)
-----


~strife: świetne biggrin.gif
btw.
http://en.wikipedia.org/wiki/Spaghetti_code


--------------------
Goldenline: Łukasz Rodziewicz
Go to the top of the page
+Quote Post
ActivePlayer
post
Post #12





Grupa: Przyjaciele php.pl
Postów: 1 224
Pomógł: 40
Dołączył: 6.07.2004
Skąd: Wuppertal

Ostrzeżenie: (0%)
-----


z calym szacunkiem ale tematy z pisaniem klas swiatecznych i bezsensownych to chyba nie najwyzszy poziom?
Go to the top of the page
+Quote Post
empathon
post
Post #13





Grupa: Zarejestrowani
Postów: 246
Pomógł: 31
Dołączył: 13.11.2006
Skąd: się znamy?

Ostrzeżenie: (0%)
-----


Cytat(ActivePlayer @ 11.04.2007, 19:01:40 ) *
z calym szacunkiem ale tematy z pisaniem klas swiatecznych i bezsensownych to chyba nie najwyzszy poziom?

W takim razie z całym szacunkiem potraktuj to jako dywagacje na temat statystycznego odwzorowania behawioralnych zachowań jednostek wyalienowanych poprzez stymulacje neuronowe oparte na logice rozproszonej w implementacji obiektowej języków skryptowych wysokiego poziomy interpretowanych po stronie serwera?
Brzmi lepiej i sensowniej ?
winksmiley.jpg


--------------------
Goldenline: Łukasz Rodziewicz
Go to the top of the page
+Quote Post
mike
post
Post #14





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


To jak to brzmi nie zmienia faktu, że takim wątkom blisko dna.
Go to the top of the page
+Quote Post
empathon
post
Post #15





Grupa: Zarejestrowani
Postów: 246
Pomógł: 31
Dołączył: 13.11.2006
Skąd: się znamy?

Ostrzeżenie: (0%)
-----


Cytat(mike_mech @ 11.04.2007, 19:57:03 ) *
To jak to brzmi nie zmienia faktu, że takim wątkom blisko dna.

Wszystko zależy od definicji szeroko pojętego "dna". Na co dzień można się spotkać z dużo większymi bezsensami a cel istnienia co drugiej rzeczy w Waszym domu nie jest czysto funkcjonalny.
Mija się z celem nazywanie takich klas jak ta strife'a bliskimi dna.
Jeśli komuś sprawia to radość ( ja uśmiechnołem się czytając ja ) to niech je pisze, zwłaszcza jeśli działają i w gruncie rzeczy oddają rzeczywistość winksmiley.jpg


--------------------
Goldenline: Łukasz Rodziewicz
Go to the top of the page
+Quote Post
mike
post
Post #16





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Cytat(mike_mech @ 11.04.2007, 19:57:03 ) *
(...) takim wątkom blisko dna.

Cytat(empathon @ 11.04.2007, 20:35:26 ) *
(...) Mija się z celem nazywanie takich klas jak ta strife'a bliskimi dna.
Tak "filozowałeś" wyżej tongue.gif a z logiką na bakier tongue.gif


Klasa strife nie była taka zła, niemniej jednak ja uważam że takie rzeczy za głupoty i pierdoły tongue.gif
Go to the top of the page
+Quote Post
Fuzja
post
Post #17





Grupa: Zarejestrowani
Postów: 216
Pomógł: 0
Dołączył: 6.11.2005

Ostrzeżenie: (0%)
-----


Cały mike_mech winksmiley.jpg wszystko musi mieć określony cel, nie wolno tracić czasu na pierdoły, albo się pracuje albo się bawi smile.gif
Go to the top of the page
+Quote Post
mike
post
Post #18





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Cytat(Fuzja @ 11.04.2007, 21:07:46 ) *
Cały mike_mech winksmiley.jpg wszystko musi mieć określony cel, nie wolno tracić czasu na pierdoły, albo się pracuje albo się bawi smile.gif
Hehe, nie jest ze mną tak źle tongue.gif
Rzucę wam kodem (pewnie powszechnie znanym) i już nie przeszkadzam winksmiley.jpg

  1. <?php
  2. /********************************************************************
  3. Model-View-Controller implementation according to POSA
  4. (Pattern-Oriented Software Architecture
  5.   <a href="http://www.hillside.net/patterns/books/Siemens/book.html)" target="_blank">http://www.hillside.net/patterns/books/Siemens/book.html)</a>
  6. ********************************************************************/
  7.  
  8. class HelloWorldController {
  9. private $model;
  10. function __construct($model) {
  11. $this->model = $model;
  12. }
  13.  
  14. function handleEvent($args) {
  15. $this->model->setStrategy($args[2]);
  16. $this->model->addText($args[1]);
  17. }
  18. }
  19.  
  20.  
  21. class HelloWorldModel {
  22. private $text;
  23. private $observers = array();
  24. private $strategy;
  25.  
  26. function attach($observer) {
  27. $this->observers[] = $observer;
  28. }
  29.  
  30. function getData() {
  31. $facade = new HelloWorldFacade($this->strategy);
  32. return $facade->getHelloWorld().$this->text."n";
  33. }
  34.  
  35. function addText($text='') {
  36. $this->text = $text;
  37. $this->notify();
  38. }
  39.  
  40. function setStrategy($strategy) {
  41. $this->strategy = $strategy;
  42. }
  43.  
  44. function notify() {
  45. foreach ($this->observers as $observer) {
  46. $observer->update();
  47. }
  48. }
  49. }
  50.  
  51. class HelloWorldView {
  52. private $model;
  53.  
  54. function initialize($model) {
  55. $this->model = $model;
  56. $model->attach($this);
  57. return $this->makeController();
  58. }
  59.  
  60. function makeController() {
  61. return new HelloWorldController($this->model);
  62. }
  63.  
  64. function update() {
  65. $this->display();
  66. }
  67.  
  68. function display() {
  69. echo $this->model->getData();
  70. }
  71. }
  72.  
  73.  
  74. /*********************************************************************
  75. "Business logic"
  76. ********************************************************************/
  77.  
  78. class HelloWorld {
  79.  function execute() {
  80.  return "Hello world";
  81.  }
  82. }
  83.  
  84. class HelloWorldDecorator {
  85.  private $helloworld;
  86.  function __construct($helloworld) {
  87.  $this->helloworld = $helloworld;
  88.  }
  89.  
  90.  function execute() {
  91.  return $this->helloworld->execute();
  92.  }
  93. }
  94.  
  95. abstract class HelloWorldEmphasisStrategy {
  96. abstract function emphasize($string);
  97. }
  98.  
  99. class HelloWorldBangEmphasisStrategy extends HelloWorldEmphasisStrategy {
  100. function emphasize($string) {
  101.  return $string."!";
  102. }
  103. }
  104.  
  105. class HelloWorldRepetitionEmphasisStrategy extends HelloWorldEmphasisStrategy {
  106. function emphasize($string) {
  107.  return $string." and ".$string." again";
  108. }
  109. }
  110.  
  111. class HelloWorldEmphasizer extends HelloWorldDecorator {
  112.  private $strategy;
  113.  function HelloWorldEmphasizer($helloworld,$strategy) {
  114.  $this->strategy = $strategy;
  115.  parent::__construct($helloworld);
  116.  }
  117.  
  118.  function execute() {
  119.  $string = parent::execute();
  120.  return $this->strategy->emphasize($string);
  121.  }
  122. }
  123.  
  124. class HelloWorldStrategyFactory {
  125. static function make($type) {
  126. if ($type == 'repetition') return self::makeRepetitionStrategy();
  127. return self::makeBangStrategy();
  128. }
  129.  
  130. static function makeBangStrategy() {
  131. return new HelloWorldBangEmphasisStrategy;
  132. }
  133. static function makeRepetitionStrategy() {
  134. return new HelloWorldRepetitionEmphasisStrategy;
  135. }
  136. }
  137.  
  138. class HelloWorldFormatter extends HelloWorldDecorator {
  139.  function execute() {
  140.  $string = parent::execute();
  141.  return $string."n";
  142.  }
  143. }
  144.  
  145. class HelloWorldFacade {
  146. private $strategy;
  147. function __construct($strategyType) {
  148. $this->strategy = HelloWorldStrategyFactory::make($strategyType);
  149. }
  150.  
  151. function getHelloWorld() {
  152. $formatter = new HelloWorldFormatter(
  153. new HelloWorldEmphasizer(
  154. new HelloWorld,$this->strategy));
  155. return $formatter->execute();
  156. }
  157. }
  158.  
  159. $model = new HelloWorldModel;
  160. $view = new HelloWorldView;
  161. $controller = $view->initialize($model);
  162. $controller->handleEvent($_SERVER['argv']);
  163.  
  164. ?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 08:17