Blame view

view/palert_plus_config.html 4.65 KB
cf76164e6   Ting Chan   20190709
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  <?php 
  $open_file2 = '/home/pi/Desktop/vAlert/bin/vAlert8.cfg';
  	shell_exec("sudo chmod 777 ".$open_file2);
  
  $fp=fopen($open_file2,'r');
  $fileContent='';
  $tmpStr='';
  $hold=array();
  $insert=array();
  $size=0;
  while($mydata=fgetcsv($fp,10000,"
  "))
  {
  	if(is_array($mydata))
  	{
  		for($i=0 ;$i<count($mydata);$i++)
  		{
  
  			if(substr($mydata[$i],0)=="[BLOCK_CONFIG_BY_ONE_ITEM]")
  			{
                // $fileContent.="
  ";
                 $tmpStr.=$mydata[$i]."
  ";
                 $hold[$size]=$mydata[$i];
                 
                 $size++;
  			}
  			else{
  			  $hold[$size]=$mydata[$i];
  			  if(substr($hold[$size-1],0)=="[BLOCK_CONFIG_BY_ONE_ITEM]")
  			  {
  			  	//$fileContent.="
  ";
  			  	$tmpStr.=$mydata[$i]."
  ";
  			  }
  			  else{
  			  $fileContent.=$mydata[$i]."
  ";
  			   $tmpStr.=$mydata[$i]."
  ";
  			    }
                
                 $size++;
  		    }
  			
  		}
  	}
  	else{
  	        $hold[$size]=$mydata;
  	        
           if(strpos($mydata,'[BLOCK_CONFIG_BY_ONE_ITEM]') or strpos($hold[$size-1],'[BLOCK_CONFIG_BY_ONE_ITEM]'))
  	        {
  	        	$fileContent.="";
  	        	$tmpStr.=$mydata."
  ";
  	        }
  	        else{
  	            $fileContent.=$mydata;
  	            $tmpStr.=$mydata."
  ";
  	         }
  	        $size++;
  	    }
     }        
  
    
  
  ?>
  
  
  <main class="mn-inner">
  	<div class="row">	
  		<div class="card">
              <div class="card-content">
              	<span class="card-title"><?=parameter_settings?></span>
  				<div class="preloader-wrapper big active status" style="position:fixed;
  				  top:50%;
  				  right:50%;
  				  _position: absolute; /* position fixed for IE6 */
  				  _top:expression(documentElement.scrollTop+100);
  				  z-index:3;">
                      <div class="spinner-layer spinner-red-only">
                          <div class="circle-clipper left">
                              <div class="circle"></div>
                          </div>
  						<div class="gap-patch">
                              <div class="circle"></div>
                          </div>
  						<div class="circle-clipper right">
                              <div class="circle"></div>
                          </div>
                      </div>
  
                  </div>
  				<form id="edit_config" action="php/change_config.php" method="POST">
  				<div class="row" >
  											
                  <textarea class="materialize-textarea" length="240" name="config"><?php echo $fileContent;  ?></textarea>
                  <input type="hidden" name="source" value="<?= $tmpStr?>">			
  											
                 </div>
  				</form>
  					<!--用再增加多組value
  					<div class="input-field col s12">
  						<i class="material-icons prefix	"><a href="#">note_add</a></i>
  						<input id="icon_prefix" type="text" class="validate" value="">
  						<label class="active">aaa</label>
                      </div>
  					-->
  					<!--一般
  					<div class="input-field col s12">
  						<input type="text" class="validate" value="">
  						<label class="active">aaa</label>
  					</div>
  					-->
  			</div>
  		</div>
  	</div>
  	<div class="fixed-action-btn" style="bottom: 45px; right: 124px;">
  		<a class="waves-effect waves-light btn red m-b-xs reload">
  			Reload
  		</a>
  	</div>
  	<div class="fixed-action-btn" style="bottom: 45px; right: 24px;">
  		<a class="waves-effect waves-light btn blue m-b-xs update">
  			SAVE
  		</a>
      </div>
  </main>
  				</div>
          <div class="left-sidebar-hover"></div>
          
          <!-- Javascripts -->
          <script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script>
          <script src="assets/plugins/materialize/js/materialize.min.js"></script>
          <script src="assets/plugins/material-preloader/js/materialPreloader.min.js"></script>
          <script src="assets/plugins/jquery-blockui/jquery.blockui.js"></script>
          <script src="assets/plugins/select2/js/select2.min.js"></script>
          <script src="assets/js/alpha.min.js"></script>
          <script src="assets/js/pages/form-select2.js"></script>
          <script>
  			$('.status').hide();
  			$('.update').click(function(){
  
  				//$("#edit_config").submit();
  			$.ajax( {
  					  type: "POST",
  					  url: $('#edit_config').attr( 'action' ),
  					  data: $('#edit_config').serialize(),
  					  success: function( response ) {
  						if(response == '1'){
  							alert('Success !');
  							location.href='index.php?item=config';
  						}else{
  							alert('Success !');
  							location.href='index.php?item=config';
  						}
  					  },
  					  beforeSend:function(){
  						$('.status').show();
  					  }
  				});
  			})
  			
  			$('.reload').click(function(){
  				location.href='../php/reload.php';				
  			})
  			
  		</script>