Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Po zaznaczeniu checbox chce pobierać plik
amii
post
Post #1





Grupa: Zarejestrowani
Postów: 728
Pomógł: 76
Dołączył: 12.06.2009

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


Bardzo dziwna sprawa. Po pierwsze to funkcja dodaj() jest przekopiowana ze skryptu gdzie wszystko działa OK. Po drugie inne checkboxy działają OK. Problem jest taki, że jak zaznaczam checkboxy dla akcji pinguj (tej z pliku functions.php) to firefox chce mi pobierać plik admin.php a IE wyświetla: Program Internet Explorer nie może wyświetlić witryny sieci Web.

Plik admin.php
  1. echo '<form method="post" id="formularz_checkbox" name="formularz_checkbox" action="'.SITE.'admin.php?action=dodaj&amp;task=usun">';
  2. $przycisk = html_input('submit', 'usun_zaznaczone_name', 'usun_zaznaczone_id', 'Usun
  3.  
  4. zaznaczone', '', 'button', 'onclick="java script: return pop()"', '', '', '', '', '', '', '', '');
  5. $przycisk2 = html_input('submit', 'pinguj_zaznaczone_name', 'pinguj_zaznaczone_id', 'Pinguj
  6.  
  7. zaznaczone', '', 'button', '', '', '', '', '', '', '', '', '');
  8. echo '<p><input type="checkbox" name="zaznacz_all_name" id="zaznacz_all_id"
  9.  
  10. onClick="zaznacz(this, \'formularz_checkbox\')" /> Zaznacz wszystko: ' .$przycisk . $przycisk2. ' </p>';
  11.  
  12. while ($row2 = mysql_fetch_array($zapytanie3)) {
  13. $wartosc_bool = $row2['tick'];
  14.  
  15. if($wartosc_bool) $zdjecie = '<img float="left" display="inline" src="'.SITE.'images/index.png" alt="strona zaindeksowana" height="16" width="16">';
  16. else $zdjecie = '<img float="left" display="inline" src="'.SITE.'images/index_no.png" alt="strona niezaindeksowana" height="16" width="16">';
  17.  
  18. $link = '<a target="_blank" href="http://www.google.pl/#hl=pl&amp;source=hp&amp;q=site:'.$row2['url'].'&amp;aq=f">'.$row2['url'].'</a>';
  19. $podstaw = '<input type="checkbox" name="checkbox_name[]" id="checkbox_id_'.$row2['url'].'"
  20.  
  21. value="'.$row2['url'].'<:snitch.gif'.$row2['id'].'" />';
  22.  
  23. echo '<p>' . $podstaw. '&nbsp;&nbsp;&nbsp; ' .$zdjecie. ' &nbsp;&nbsp;&nbsp;<a target="_blank" href="http://www.google.pl/#hl=pl&amp;source=hp&amp;q=site:'.$row2['url'].'&amp;aq=f">'.$row2['url'].'</a>
  24.  
  25. </p>';
  26. }
  27. echo $renderPager1; //wyswietlenie paginatora
  28. echo '</form>';



Plik functions.php
  1. // Funkcja generująca przyciski formularza
  2. function html_input($type, $name, $id, $value, $label, $css, $script1, $script2, $script3, $checked, $rows, $cols, $method, $action, $legend) {
  3. $lbl = !empty($label) ? '<label for="'.$id.'">'.$label.'</label>' : '';
  4. $ID = !empty($id) ? ' id="'.$id.'"' : '';
  5. $style = !empty($css) ? ' class="'.$css.'"' : '';
  6. $js1 = !empty($script1) ? ' '.$script1 : '';
  7. $js2 = !empty($script2) ? ' '.$script2 : '';
  8. $js3 = !empty($script3) ? ' '.$script3 : '';
  9. $attribs = $ID.$style.$js1.$js2.$js3;
  10. $val = ' value="'.$value.'"';
  11. $input = '<input type="'.$type.'" name="'.$name.'"'.$attribs;
  12. switch($type) {
  13. case 'form': $output = (!empty($method) && $method != 'end') ?
  14. '<form method="'.$method.'" action="'.$action.'"'.$attribs.'>' : '</form>'; break;
  15. case 'fieldset': $output = (!empty($legend) && $legend != 'end') ?
  16. '<fieldset><legend'.$attribs.'>'.$legend.'</legend>' : '</fieldset>'; break;
  17. case 'text':
  18. case 'password': $output = '<p>'.$lbl.':<br />'.$input.$val.' /></p>'; break;
  19. case 'checkbox':
  20. case 'radio': $check = $checked == 'ok' ? ' checked="checked"' : ''; $output = '<p>'.$input.$check.' /> '.$lbl.'</p>'; break;
  21. case 'hidden':
  22. case 'submit':
  23. case 'reset':
  24. case 'button': $output = $input.$val.' />'; break;
  25. case 'textarea':
  26. $output = '<p>'.$lbl.':<br />
  27. <textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.$attribs.'>'.$value.
  28. '</textarea></p>'; break;
  29. }
  30. return $output;
  31. }
  32.  
  33.  
  34. function dodaj() {
  35. if (isset($_GET['task'])) {
  36.  
  37. switch($_GET['task']) {
  38.  
  39. case 'usun':
  40.  
  41. if (isset($_POST['pinguj_zaznaczone1_name'])) {
  42. $title = array('Alkomaty dowodowe', 'Uzdatnianie wody', 'Filtry do wody', 'Alkomaty'); //tytuły do pingowania
  43. $losowy_rekord = mt_rand(0, count($title)-1);
  44. foreach($_POST['checkbox_name1'] as $key => $value) {
  45. $value = explode('<:snitch.gif', $value);
  46. $extract = trim($value[0]);
  47. ping($title[$losowy_rekord], $extract);
  48.  
  49. }
  50. unset($_POST['pinguj_zaznaczone1_name']);
  51. }
  52.  
  53. if (isset($_POST['pinguj_zaznaczone_name'])) {
  54. $title = array('Alkomaty dowodowe', 'Uzdatnianie wody', 'Filtry do wody', 'Alkomaty'); //tytuły do pingowania
  55. $losowy_rekord = mt_rand(0, count($title)-1);
  56. foreach($_POST['checkbox_name'] as $key => $value) {
  57. $value = explode('<:snitch.gif', $value);
  58. $extract = trim($value[0]);
  59. ping($title[$losowy_rekord], $extract);
  60.  
  61. }
  62. unset($_POST['pinguj_zaznaczone_name']);
  63. }
  64. }
  65. }
  66. }


--------------------
gry flash online
Dobry hosting i tanie odnowienia domen firma: masternet.
Zarabianie bez wysiłku na domenach bez ruchu: prolink.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
wNogachSpisz
post
Post #2





Grupa: Zarejestrowani
Postów: 1 233
Pomógł: 87
Dołączył: 6.03.2009

Ostrzeżenie: (40%)
XX---


  1. html_input($type, $name, $id, $value, $label, $css, $script1, $script2, $script3, $checked, $rows, $cols, $method, $action, $legend)


omfg....

Nie lepiej dać coś w stylu

  1. $settings = array(
  2. 'type' => 'text',
  3. 'id' => 'myId',
  4. ...
  5. );
  6.  
  7. html_input($settings)


--------------------------------------------------------

Czepiania ciąg dalszy:

  1. $lbl = !empty($label) ? '<label for="'.$id.'">'.$label.'</label>' : '';
  2. $ID = !empty($id) ? ' id="'.$id.'"' : '';
  3. $style = !empty($css) ? ' class="'.$css.'"' : '';
  4. $js1 = !empty($script1) ? ' '.$script1 : '';

W ten sposób nie sprawdza się czy argument został przekazany....
Taki kod generuje mase ostrzeżeń,
nawet jeśli masz wyłączone pokazywanie błędów, to mimo wszytko PHP przejdzie procedurę jego obsługi, to pochłania mase zasobów..

Używaj isset();

--------------------------------------------------------

Pokaż jak wygląda funkcja ping()

Ten post edytował wNogachSpisz 25.02.2011, 15:05:44
Go to the top of the page
+Quote Post
amii
post
Post #3





Grupa: Zarejestrowani
Postów: 728
Pomógł: 76
Dołączył: 12.06.2009

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


Gotowy wyprodukowany HTML dla formularza wygląda tak (więc nie sądzę aby to był problem z html_input):

  1. <form method="post" id="formularz_checkbox" name="formularz_checkbox" action="http://strona.com/synonim/admin.php?action=dodaj&task=usun"><p><input type="checkbox" name="zaznacz_all_name" id="zaznacz_all_id"
  2.  
  3. onClick="zaznacz(this, 'formularz_checkbox')" /> Zaznacz wszystko: <input type="submit" name="usun_zaznaczone_name" id="usun_zaznaczone_id" class="button" onclick="java script: return pop()" value="Usun
  4. zaznaczone" /><input type="submit" name="pinguj_zaznaczone_name" id="pinguj_zaznaczone_id" class="button" value="Pinguj
  5. zaznaczone" /> </p><p><input type="checkbox" name="checkbox_name[]" id="checkbox_id_http://www.coloria12.bialowieza.pl/article/sposoby-oczyszczania-wody/"
  6.  
  7. value="http://www.coloria12.bialowieza.pl/article/sposoby-oczyszczania-wody/<:snitch.gif352" />    <img float="left" display="inline" src="http://strona.com/synonim/images/index_no.png" alt="strona niezaindeksowana" height="16" width="16">    <a target="_blank" href="http://www.google.pl/#hl=pl&source=hp&q=site:http://www.coloria12.bialowieza.pl/article/sposoby-oczyszczania-wody/&aq=f">http://www.coloria12.bialowieza.pl/article/sposoby-oczyszczania-wody/</a>
  8.  
  9.  
  10. </p><span>1</span>  <a title="Strona 2" href="?ppidPagera1=2">2</a>  <a title="Strona 3" href="?ppidPagera1=3">3</a>  <a title="Strona 4" href="?ppidPagera1=4">4</a>  <a title="Strona 5" href="?ppidPagera1=5">5</a>  <a title="Strona 6" href="?ppidPagera1=6">6</a>  <a title="Strona 7" href="?ppidPagera1=7">7</a>  <a title="Strona 8" href="?ppidPagera1=8">8</a>  <a title="Strona 9" href="?ppidPagera1=9">9</a>  <a title="Strona 10" href="?ppidPagera1=10">10</a>  <a title="Strona 11" href="?ppidPagera1=11">11</a>    <a title="Następna strona" href="?ppidPagera1=2">></a>  <a title="10 stron(y) do przodu" href="?ppidPagera1=11">>></a>  <a title="Ostatnia strona" href="?ppidPagera1=133">>|</a></form>



Ping to gotowa funkcja pobrana z Internetu słuzy do pingowania:
  1. //Funkcja pinguje wskazany adres
  2. function ping($blogTitle, $blogUrl) {
  3. // Please, edit these variables to your needs
  4.  
  5. //$blogTitle="tytuł!";
  6. //$blogUrl="http://www.adres.pl/all.html";
  7. $pingListFile="pinglist.txt";
  8. $showDebugInfo=FALSE; // Do you want verbose output?
  9.  
  10. // Stop editing here
  11.  
  12. // PingRPC.php
  13. //
  14. // 2007 by Sascha Tayefeh
  15. //
  16. // This is a PHP5-based XML-RPC ping script. It reads a one-column
  17. // fully qualified URL-list from a file ($pingListFile). Here is
  18. // an example how this file must look like:
  19. // ----------------------
  20. // ----------------------
  21.  
  22. $replacementCount=0;
  23. $userAgent="pingrpc.php by tayefeh";
  24.  
  25. // Read pinglist file. Must contain one fully qualified URL
  26. // delimiter is an ASCII-linebreak)
  27. $fp=fopen($pingListFile,"r");
  28. while ( ! feof( $fp) )
  29. {
  30. $line = trim(fgets( $fp, 4096));
  31. // get the hostname
  32. $host=$line; // Make a copy of $line
  33. $host=preg_replace('/^.*http:\/\//','',$host); // Delete anything before http://
  34. $host=preg_replace('/\/.*$/','',$host); // Delete anything after behind the hostname
  35.  
  36. // get the path
  37. $path=$line; // Make another copy of $line
  38. $path=preg_replace('/^.*http:\/\/[a-zA-Z0-9\-_\.]*\.[a-zA-Z]{1,3}\//','',$path,-1,$replacementCount); // Delete anything before the path
  39. if(!$replacementCount) $path=''; // if there was no replacement (i.e. no explicit path), act appropiately
  40. if($host) $myList[$host]=$path;
  41. }
  42. echo "<h1>Ping process started</h1>";
  43.  
  44. echo "<p>Reading URLs from file $pingListFile: ";
  45. echo count($myList)." urls read.</p>";
  46.  
  47.  
  48. // Use DOM to create the XML-File
  49. $xml= new DOMDocument('1.0');
  50. $xml->formatOutput=true;
  51. $xml->preserveWhiteSpace=false;
  52. $xml->substituteEntities=false;
  53.  
  54. // Create the xml structure
  55. $methodCall=$xml->appendChild($xml->createElement('methodCall'));
  56. $methodName=$methodCall->appendChild($xml->createElement('methodName'));
  57. $params=$methodCall->appendChild($xml->createElement('params'));
  58. $param[1]=$params->appendChild($xml->createElement('param'));
  59. $value[1]=$param[1]->appendChild($xml->createElement('value'));
  60. $param[2]=$params->appendChild($xml->createElement('param'));
  61. $value[2]=$param[2]->appendChild($xml->createElement('value'));
  62.  
  63. // Set the node values
  64. $methodName->nodeValue="weblogUpdates.ping";
  65. $value[1]->nodeValue=$blogTitle;
  66. $value[2]->nodeValue=$blogUrl;
  67.  
  68. $xmlrpcReq = $xml->saveXML(); // Write the document into a string
  69. $xmlrpcLength = strlen( $xmlrpcReq ); // Get the string length.
  70.  
  71. echo "Here&apos;s the xml-message I generated (size: $xmlrpcLength bytes):";
  72.  
  73. echo "\n<pre>\n";
  74. echo htmlentities($xmlrpcReq);
  75. echo "</pre>";
  76.  
  77.  
  78. echo "<dl>";
  79.  
  80. // Proceed every link read from file
  81. foreach ( $myList as $host => $path)
  82. {
  83. if($showDebugInfo) echo "<hr/>";
  84.  
  85. echo "<dt><strong>Pinging host: $host </strong>";
  86. $httpReq = "POST /" . $path . " HTTP/1.0\r\n";
  87. $httpReq .= "User-Agent: " . $userAgent. "\r\n";
  88. $httpReq .= "Host: " . $host . "\r\n";
  89. $httpReq .= "Content-Type: text/xml\r\n";
  90. $httpReq .= "Content-length: $xmlrpcLength\r\n\r\n";
  91. $httpReq .= "$xmlrpcReq\r\n";
  92. echo "</dt>";
  93.  
  94. if($showDebugInfo)
  95. {
  96. echo "<dd><strong>Request:</strong><pre><span style=\"color: #cc9900\">".htmlentities($httpReq)."</span></pre>";
  97. echo "<strong>Answer</strong>:<span style=\"color: #99cc00\"><pre>";
  98. }
  99.  
  100.  
  101. // Actually, send ping
  102. if ( $pinghandle = @fsockopen( $host, 80 ) )
  103. {
  104. @fputs( $pinghandle, $httpReq );
  105. while ( ! feof( $pinghandle ) )
  106. {
  107. $pingresponse = @fgets( $pinghandle, 128 );
  108. if($showDebugInfo) echo htmlentities($pingresponse);
  109. }
  110. @fclose( $pinghandle );
  111. }
  112. if($showDebugInfo) echo "</span></pre></dd>";
  113. }
  114. echo "</dl>";
  115. echo "<p>FINISHED</p>";
  116. }


Ten post edytował amii 25.02.2011, 15:25:28


--------------------
gry flash online
Dobry hosting i tanie odnowienia domen firma: masternet.
Zarabianie bez wysiłku na domenach bez ruchu: prolink.
Go to the top of the page
+Quote Post
wNogachSpisz
post
Post #4





Grupa: Zarejestrowani
Postów: 1 233
Pomógł: 87
Dołączył: 6.03.2009

Ostrzeżenie: (40%)
XX---


Cytat(amii @ 25.02.2011, 15:18:21 ) *
nie sądzę aby to był problem z html_input


Problem czy może nie problem, nie ważne.
Im szybciej nauczysz się stosować właściwe techniki, tym lepiej dla Ciebie,
w tej chwili Twój kod to totalna sieczka i ciężko się to nawet czyta..

Wracając do tematu, u mnie POST wykonuje się prawidłowo na Operze, Firefoxie i IE 7

Może wrzuć ten skrypt do sieci i podaj adres..

Ten post edytował wNogachSpisz 25.02.2011, 15:33:32
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: 19.08.2025 - 11:04