PluginProbe
Insert Html Snippet / 1.3.4
Insert Html Snippet v1.3.4
1.4.6 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 All 27 releases
insert-html-snippet / admin / snippet-edit.php

snippet-edit.php in Insert Html Snippet 1.3.4, at admin/snippet-edit.php

202 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) )
3 exit;
4
5 global $wpdb;
6 $goback=1;
7 $xyz_ips_snippetId = intval($_GET['snippetId']);
8 $xyz_ips_message='';
9 if(isset($_GET['xyz_ips_msg'])){
10 $xyz_ips_message = intval($_GET['xyz_ips_msg']);
11 }
12 if($xyz_ips_message == 1){
13 ?>
14 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
15 PHP Snippet updated successfully. &nbsp;&nbsp;&nbsp;
16 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
17 </div>
18 <?php
19 }
20 if(isset($_GET['goback']))
21 $goback= intval($_GET['goback']);
22 if(isset($_POST) && isset($_POST['updateSubmit'])){
23
24 if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-pedit_'.$xyz_ips_snippetId )) {
25 wp_nonce_ays( 'ips-pedit_'.$xyz_ips_snippetId );
26 exit;
27 }
28 $goback=intval($_POST['goback']);
29 $goback++;
30 $_POST = stripslashes_deep($_POST);
31 $_POST = xyz_trim_deep($_POST);
32 $xyz_ips_snippetId = intval($_GET['snippetId']);
33 $temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
34 $temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
35 $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
36 $xyz_ips_content = $_POST['snippetContent'];
37
38 if(get_option('xyz_ips_auto_insert')==1){
39 $xyz_ips_content_start='<?php';
40 $new_line="\r\n";
41 $xyz_ips_content_end='?>';
42
43 if (stripos($xyz_ips_content, '<?php') !== false)
44 $tag_start_position=stripos($xyz_ips_content,'<?php');
45 else
46 $tag_start_position="-1";
47
48 if (stripos($xyz_ips_content, '?>') !== false)
49 $tag_end_position=stripos($xyz_ips_content,'?>');
50 else
51 $tag_end_position="-1";
52
53
54 if(stripos($xyz_ips_content, '<?php') === false && stripos($xyz_ips_content, '?>') === false)
55 {
56 $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
57 }
58 else if(stripos($xyz_ips_content, '<?php') !== false)
59 {
60 if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
61 {
62 $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
63 }
64 }
65 else if(stripos($xyz_ips_content, '<?php') === false)
66 {
67 if (stripos($xyz_ips_content, '?>') !== false)
68 {
69 $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
70 }
71 }
72 }
73
74 if($xyz_ips_title != "" && $xyz_ips_content != ""){
75 if(ctype_alnum($temp_xyz_ips_title)){
76 $snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id!=%d AND title=%s LIMIT 0,1',$xyz_ips_snippetId,$xyz_ips_title)) ;
77 if($snippet_count == 0){
78 $xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
79 $wpdb->update($wpdb->prefix.'xyz_ips_short_code', array('title'=>$xyz_ips_title,'content'=>$xyz_ips_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ips_snippetId));
80 header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$xyz_ips_snippetId.'&xyz_ips_msg=1'.'&goback='.$goback));
81 }
82 else{
83 ?>
84 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
85 PHP Snippet already exists. &nbsp;&nbsp;&nbsp;
86 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
87 </div>
88 <?php
89 }
90 }
91 else{
92 ?>
93 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
94 PHP Snippet title can have only alphabets,numbers or hyphen. &nbsp;&nbsp;&nbsp;
95 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
96 </div>
97 <?php
98 }
99 }
100 else{
101 ?>
102 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
103 Fill all mandatory fields. &nbsp;&nbsp;&nbsp;
104 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
105 </div>
106 <?php
107 }
108 }
109 global $wpdb;
110 $snippetDetails = $wpdb->get_results($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id=%d LIMIT 0,1',$xyz_ips_snippetId )) ;
111 $snippetDetails = $snippetDetails[0];
112 ?>
113 <div >
114 <fieldset
115 style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
116 <legend>
117 <b>
118 Edit PHP Snippet
119 </b>
120 </legend>
121 <form name="frmmainForm" id="frmmainForm" method="post">
122 <?php wp_nonce_field( 'ips-pedit_'.$xyz_ips_snippetId ); ?>
123 <input type="hidden" id="snippetId" name="snippetId"
124 value="
125 <?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
126 <div>
127 <input type="hidden" name="goback" value= <?php echo $goback;?>>
128
129 <table
130 style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
131 <tr>
132 <td>
133 <br/>
134 <div id="shortCode">
135 </div>
136 <br/>
137 </td>
138 </tr>
139 <tr valign="top">
140 <td style="border-bottom: none;width:20%;">
141 &nbsp;&nbsp;&nbsp;Tracking Name&nbsp;
142 <font color="red">
143 *
144 </font>
145 </td>
146 <td style="border-bottom: none;width:1px;">
147 &nbsp;:&nbsp;
148 </td>
149 <td>
150 <input style="width:80%;"
151 type="text" name="snippetTitle" id="snippetTitle"
152 value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>">
153 </td>
154 </tr>
155 <tr>
156 <td style="border-bottom: none;width:20%; ">
157 <?php
158 if(get_option('xyz_ips_auto_insert')==1){
159 ?>
160 &nbsp;&nbsp;&nbsp;PHP code
161 <?php
162 }
163 else{
164 ?>
165 &nbsp;&nbsp;&nbsp;PHP code (without &lt;?php ?&gt;)&nbsp;
166 <?php
167 }
168 ?>
169 <font color="red">
170 *
171 </font>
172 </td>
173 <td style="border-bottom: none;width:1px;">
174 &nbsp;:&nbsp;
175 </td>
176 <td >
177 <textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}else{ echo esc_textarea($snippetDetails->content); }?></textarea>
178 </td>
179 </tr>
180 <tr>
181 <td>
182 </td>
183 <td>
184 <input class="button-primary" style="cursor: pointer;"
185 type="button" name="back" onclick=" window.history.go(-<?php echo $goback;?>);" value="back" >
186 </td>
187 <td>
188 <input class="button-primary" style="cursor: pointer;"
189 type="submit" name="updateSubmit" value="Update">
190 </td>
191 </tr>
192 <tr>
193 <td>
194 <br/>
195 </td>
196 </tr>
197 </table>
198 </div>
199 </form>
200 </fieldset>
201 </div>
202