Home  >  Article  >  php教程  >  PHP hack的使用技巧详解

PHP hack的使用技巧详解

WBOY
WBOYOriginal
2016-06-13 11:09:492056browse

PHP hack示例:

  1.  ?php  
  2. $tabs = array();  
  3. function tabs_header()  
  4. {  
  5. ?> 
  6. style type="text/css"> 
  7. .tab {  
  8. border-bottom: 1px solid black;  
  9. text-align: center;  
  10. font-family: arial, verdana;  
  11. }  
  12. .tab-active {   
  13. border-left: 1px solid black;   
  14. border-top: 1px solid black;   
  15. border-right: 1px solid black;   
  16. text-align: center;   
  17. font-family: arial, verdana;   
  18. font-weight: bold;  
  19. }  
  20. .tab-content {   
  21. padding: 5px;   
  22. border-left: 1px solid black;   
  23. border-right: 1px solid black;   
  24. border-bottom: 1px solid black;  
  25. }   
  26.  /style>  

<ol class="dp-xml">
<li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span> </span></span></li>
<li><span>}  </span></li>
<li class="alt"><span>function tabs_start()  </span></li>
<li><span>{   </span></li>
<li class="alt"><span>ob_start();   </span></li>
<li><span>}  </span></li>
<li class="alt"><span>function endtab()   </span></li>
<li><span>{   </span></li>
<li class="alt"><span>global $tabs;  </span></li>
<li>
<span>$</span><span class="attribute">text</span><span> = </span><span class="attribute-value">ob_get_clean</span><span>();  </span>
</li>
<li class="alt"><span>$tabs[ count( $tabs ) - 1 ][ 'text' ] = $text;  </span></li>
<li><span>ob_start();  </span></li>
<li class="alt"><span>}  </span></li>
<li><span>function tab( $title )   </span></li>
<li class="alt"><span>{  </span></li>
<li><span>global $tabs;  </span></li>
<li class="alt">
<span>if ( count( $tabs ) </span><span class="tag">></span><span> 0 )  </span>
</li>
<li><span>endtab();  </span></li>
<li class="alt"><span>$tabs []= array(  </span></li>
<li>
<span class="attribute">title</span><span> =</span><span class="tag">></span><span> $title,  </span>
</li>
<li class="alt">
<span class="attribute">text</span><span> =</span><span class="tag">></span><span> ""  </span>
</li>
<li><span>);  </span></li>
<li class="alt"><span>}  </span></li>
<li><span> </span></li>
<li class="alt"><span>function tabs_end( )  </span></li>
<li><span>{  </span></li>
<li class="alt"><span>global $tabs;  </span></li>
<li><span>endtab( );  </span></li>
<li class="alt"><span>ob_end_clean( );  </span></li>
<li>
<span>$</span><span class="attribute">index</span><span> = </span><span class="attribute-value">0</span><span>;  </span>
</li>
<li class="alt"><span>if ( $_GET['tabindex'] )  </span></li>
<li>
<span>$</span><span class="attribute">index</span><span> = $_GET['tabindex'];  </span>
</li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
<li><span class="tag"><span> </span><span class="tag-name">table</span><span> </span><span class="attribute">width</span><span>=</span><span class="attribute-value">"100%"</span><span> </span><span class="attribute">cellspacing</span><span>=</span><span class="attribute-value">"0"</span><span> </span><span class="attribute">cellpadding</span><span>=</span><span class="attribute-value">"0"</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span> </span><span class="tag-name">tr</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span> ?php  </span></span></li>
<li class="alt">
<span>$</span><span class="attribute">baseuri</span><span> = $_SERVER['REQUEST_URI'];  </span>
</li>
<li>
<span>$</span><span class="attribute">baseuri</span><span> = </span><span class="attribute-value">preg_replace</span><span>( "/?.*$/", "", $baseuri );  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute">curindex</span><span> = </span><span class="attribute-value">0</span><span>;  </span>
</li>
<li><span>foreach( $tabs as $tab )  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>$</span><span class="attribute">class</span><span> = </span><span class="attribute-value">"tab"</span><span>;  </span>
</li>
<li class="alt">
<span>if ( $</span><span class="attribute">index</span><span> == $curindex )  </span>
</li>
<li>
<span>$</span><span class="attribute">class</span><span> =</span><span class="attribute-value">"tab-active"</span><span>;  </span>
</li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
<li><span class="tag"><span> </span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">""</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span> </span><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">"<span>?</span><span class="attribute">tabindex</span><span>=</span><span class="attribute-value">".$curindex ); ?>"</span><span class="tag">></span><span> </span></span></span></li>
<li><span class="tag"><span> ?php echo( $tab['title'] ); </span><span class="tag">?></span><span> </span></span></li>
<li class="alt"><span class="tag"><span> /a</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span> /td</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span> ?php  </span></span></li>
<li><span>$curindex += 1;  </span></li>
<li class="alt"><span>}  </span></li>
<li>
<span class="tag">?></span><span> </span>
</li>
<li class="alt"><span class="tag"><span> /tr</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span> </span><span class="tag-name">tr</span><span class="tag">></span><span class="tag"><span> </span><span class="tag-name">td</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"tab-content"</span><span> </span><span class="attribute">colspan</span><span>=</span><span class="attribute-value">""</span><span class="tag">></span><span> </span></span></span></li>
<li class="alt"><span class="tag"><span> ?php echo( $tabs[$index ]['text'] ); </span><span class="tag">?></span><span> </span></span></li>
<li><span class="tag"><span> /td</span><span class="tag">></span><span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span> /table</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span> ?php  </span></span></li>
<li class="alt"><span>}  </span></li>
<li>
<span class="tag">?></span><span> </span>
</li>
</ol>

以上这一大段的代码就是有关PHP hack的具体实现方法。
 


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn