Просмотр файла system/inc/classes/form.class.php

Размер файла: 3.57Kb
  1. <?php
  2. class form {
  3. protected $form = '';
  4. protected $method;
  5. protected $act;
  6. protected $form_names;
  7. protected $legend;
  8. protected $formid;
  9. protected $hidden = array();
  10.  
  11. public function __construct($act, $method = '', $form_names = '', $formid = '', $hidden = '', $legend = '')
  12. {
  13. $this->act = $act;
  14. $this->method = $method ? $method : 'post';
  15. $this->form_names = $form_names ? $form_names : '';
  16. $this->formid = $formid ? $formid : '';
  17. $this->hidden = $hidden ? $hidden : '';
  18. $this->legend = $legend ? $legend : '';
  19. $form = '<form name="form" action="' . $this->act . '" method="' . $this->method . '" ';
  20. $form .= $this->formid ? $this->formid : '';
  21. $form .= $this->form_names ? 'name="' . $this->form_names . '">' : '>';
  22. return $this -> form = $form . PHP_EOL;
  23. }
  24.  
  25. public function input($text = '', $name, $type = 'text', $value = '', $br = false, $size = '', $max = '',$name_check = '',$accept = '')
  26. {
  27. $form = '';
  28. $form.= $text ? $text . '<br/>' : '';
  29. $form.= '<input '.$accept.' type="' . $type . '" name="' . $name . '" value="' . $value . '" size="' . $size . '" ';
  30. $form.= $max ? 'maxlength="' . $max . '" />'.($br ? '<br />' : null).'' : '/> '.$name_check.''.($br ? '<br />' : null).'';
  31. return $this->form .= PHP_EOL . $form . PHP_EOL;
  32. }
  33.  
  34. public function textarea($text = false, $name, $value = '',$bb_code = false)
  35. {
  36. global $text_list;
  37. $form = '';
  38. $form.= $text ? $text . '<br/>' : '';
  39. if($bb_code == true) {
  40. $form.= $text_list->text_lister();}
  41. $form.= '<textarea id="text" name="' . $name . '">';
  42. $form.= $value ? $value : '';
  43. $form.= '</textarea><br/>';
  44. return $this->form .= PHP_EOL . $form . PHP_EOL;
  45. }
  46.  
  47. public function select($text, $name, $form_value, $selected = 1)
  48. {
  49. $form = ($text ? $text . '<br/>' : null) . '<select name="' . $name . '">' . PHP_EOL;
  50. $for_number = 1;
  51. foreach ($form_value as $form_z => $form_num)
  52. {
  53. $form .= '<option value="' . $form_num . '" ' . ($for_number==$selected ? 'selected="selected"' : '') . '>' . $form_z . '</option>' . PHP_EOL;
  54. $for_number ++; }
  55. $form .= '</select><br/>';
  56. return $this->form .= $form . PHP_EOL;
  57. }
  58.  
  59. public function submit ($submitname = '', $submitvalue = '', $br = false) {
  60. $form = '<input type="submit" name="' . $submitvalue . '" value="' . $submitname . '" />' .($br ? '<br />' : null);
  61. return $this->form .= $form . PHP_EOL;
  62.  
  63. }
  64. public function form_link($link_http = '',$link_title = '')
  65. {
  66. $form = '<a href="http://'.$_SERVER['HTTP_HOST'].''.$link_http.'">'.$link_title.'</a>';
  67. return $this->form .= $form . PHP_EOL;
  68. }
  69. public function captcha($name_funct) {
  70. global $settings_shcms;
  71. if($settings_shcms[$name_funct] == 1)
  72. {
  73. $form = '<script type="text/javascript">
  74. src="/shcms/antibot.php?r=rand(1000,9999)";
  75. function reload(){
  76. document.captcha.src="/shcms/antibot.php?r=rand(1000,9999)";
  77. document.captcha.src=src+"?rand="+Math.random(); } </script>
  78. <img name="captcha" class="midside" alt="Код безопастности" src="'.DIR_SHCMS.'antibot.php?r='.rand(1000, 9999) .'"/><br />
  79. <a href="javascript:void(0)" onclick="reload()">обновить, если не виден код</a><br/>
  80. <input type="text" style="width:115px" size="5" maxlength="5" name="kod"/><br/>';
  81. }
  82. return $this->form .= $form . PHP_EOL;
  83. }
  84. public function finish() {
  85. echo $this->form . '</form>';
  86. }
  87. }
  88.