Make WordPress Core

Ticket #13111: appointy.php

File appointy.php, 8.7 KB (added by Quinnetic, 17 years ago)

Appointy Plugin appointy.php. This is where the error pointed

Line 
1<?php
2/*
3Plugin Name: Appointy - Appointment Scheduler.
4Plugin URI: http://www.appointy.com/wordpress/
5Description: This plugin shows your free time slot on your blog and allows you to book appointments with your clients 24x7x365. Very easy Ajax interface. Easy to setup and can be controlled completely from powerful admin area.
6Version: 1.5
7Author: Appointy, Inc
8Author URI: http://www.appointy.com
9*/
10
11//define('WP_DEBUG', true);
12//error_reporting( E_ALL );
13define('APPOINTYPATH', get_option('siteurl').'/wp-content/plugins/appointy-appointment-scheduler');
14
15$appointy_installed = true;
16$appointy_calendar_privileges = 0;
17$iFrameVal = "<iframe src=http://demo.appointy.com/?isGadget=1 width=710px height=550px scrolling=auto frameborder=0></iframe>";
18
19add_action('init', 'appointy_calendar_init');
20add_action('widgets_init', 'widget_init_appointy');
21add_filter('the_content','appointy_insert');
22
23
24function appointy_insert($content)
25{
26 if (preg_match('{APPOINTY}',$content))
27 {
28 $content = str_replace('{APPOINTY}',appointy(),$content);
29 }
30 //echo $content;
31 return $content;
32}
33
34function appointy()
35{
36 global $userdata, $table_prefix, $wpdb, $appointy_installed;
37 get_currentuserinfo();
38 // $user_login = $userdata->user_login;
39 $str='';
40 if( !appointy_calendar_installed() )
41 $appointy_installed = appointy_calendar_install();
42 //echo "-->" . $appointy_installed;
43
44 if( !$appointy_installed )
45 {
46 echo "PLUGIN NOT CORRECTLY INSTALLED, PLEASE CHECK ALL INSTALL PROCEDURE!";
47 return;
48 }
49 $query = "
50 SELECT code AS code
51 FROM ".$table_prefix."appointy_calendar LIMIT 1
52 ";
53 //echo $query;
54 $code = $wpdb->get_var( $query );
55
56 //}
57 ?>
58
59 <?php
60 $str.='<div class="wrap">';
61 if( $code === null )
62 {
63 $str.= '<h4>You don\'t have appointy Calendar, please set code in Settings menu.</h4>';
64 }
65 else
66 {
67
68
69 $str.='<center>';
70
71 $str.='<div id="CalendarDiv">';
72 ?><?php
73 $str.= $code;
74 ?>
75 <?php
76 $str.='</div>';
77
78
79 $str.='</center>';
80
81 }
82 ?>
83 <?php
84 $str.='</div>';
85
86 return $str;
87
88
89}
90
91function widget_init_appointy() {
92 if (!function_exists('register_sidebar_widget'))
93 return;
94 register_sidebar_widget('Appointy','widget_calendar_appointy');
95}
96
97function widget_calendar_appointy() {
98 echo "appointy";
99 }
100
101function appointy_calendar_init()
102{
103 global $appointy_calendar_privileges, $table_prefix, $wpdb, $appointy_path, $appointy_default, $appointy_installed;
104 add_action('admin_menu', 'appointy_calendar_config_page');
105}
106
107function appointy_calendar_config_page()
108{
109
110 if ( function_exists('add_submenu_page') )
111 {
112 add_menu_page('appointy Calendar', 'Appointy Calendar', 8, __FILE__, 'appointy_calendar_main_page');
113 //add_submenu_page(__FILE__, 'Settings', 'Settings', $appointy_calendar_privileges, 'maintenance', 'appointy_calendar_manage_page');
114 //add_submenu_page(__FILE__, 'Admin Settings', 'Admin Settings', 8, 'admin_maitenance', 'appointy_calendar_admin_manage_page');
115 }
116}
117
118function appointy_calendar_main_page()
119{
120 global $appointy_default, $userdata, $table_prefix, $wpdb, $appointy_installed, $iFrameVal;
121 get_currentuserinfo();
122
123 if( !appointy_calendar_installed() )
124 $appointy_installed = appointy_calendar_install();
125
126 if( !$appointy_installed )
127 {
128 echo "PLUGIN NOT CORRECTLY INSTALLED, PLEASE CHECK ALL INSTALL PROCEDURE!";
129 return;
130 }
131 ?>
132 <div class="wrap">
133 <?php
134 $valid = true;
135
136 $queryS = "select * from ".$table_prefix."appointy_calendar limit 1";
137 $d1 = $wpdb->get_var( $queryS );
138 if( $d1 === null )
139 {
140 $query ="
141 INSERT INTO ".$table_prefix."appointy_calendar (code)
142 VALUES ('". $iFrameVal ."')
143 ";
144 $wpdb->query( $query );
145 }
146 else
147 {
148 $query = "SELECT code AS code FROM ".$table_prefix."appointy_calendar LIMIT 1";
149 $iFrameVal = $wpdb->get_var( $query );
150 }
151
152
153 if( isset($_POST["set"]) AND $_POST["set"] == "Update" )
154 {
155
156 if( !appointy_calendar_code( $_POST["code"] ) )
157 $valid = false;
158 else
159
160 {
161 $query ="Update ".$table_prefix."appointy_calendar set code = '".$_POST["code"]."'";// where calendar_id = " & $d1 ->calendar_id;
162 $wpdb->query( $query );
163 $iFrameVal = str_replace("\\", "", ($_POST["code"]));
164 }
165 }
166
167 if( isset( $_GET["ui"]) and $_GET["ui"] == "true" )
168 {
169 $query = "
170 DROP TABLE ".$table_prefix."appointy_calendar
171 ";
172 mysql_query( $query ) or die( mysql_error() );
173
174 delete_option( 'appointy_calendar_privileges' ); //Removing option from database...
175
176 $installed = appointy_calendar_installed();
177
178 if( !$installed ) {
179 echo "PLUGIN UNINSTALLED. NOW DE-ACTIVATE PLUGIN.<br />";
180 echo " <a href=plugins.php>CLICK HERE</a>";
181 return;
182 }
183 else
184 {
185 echo "PROBLEMS WITH UNINSTALL FUNCTION.";
186 }
187
188 }
189 ?>
190
191 <div style="margin-bottom:20px;"><h2>Appointy Calendar</h2></div>
192 <div>
193 <div style="float:left;">
194 <img src="<?php echo APPOINTYPATH; ?>/calendar.png" border="0" />
195 <br /><br />
196
197 <span style="float:left;width:400px;padding-left:20px;">
198 <p><b>Don't have an account on Appointy?</b></p>
199 <a href ="http://www.appointy.com/quickUserSignUp.aspx" target="_blank" class="button">&nbsp;&nbsp;Register Now. It's Free &raquo;&nbsp;&nbsp;</a><br />
200 <br />
201 </span></div>
202
203 <div style="float:left;width:400px;padding-left:20px;" >
204 <form action="<?php echo $_SERVER["PHP_SELF"]."?page=".$_GET["page"]; ?>" method="POST">
205 <p><b style="color:#000099">STEP &raquo; 1 Enter your Appointy Calendar Code</b><br />
206 <span style="font-size:11px;">Don't have appointy username? Click here to register free.</span><br />
207 <span style="font-size:11px;">Change "demo.appointy.com" to "{yourusername}.appointy.com"<br />
208 where {yourusername} is your username on Appointy.com <br />
209 </span><br />
210 <textarea type ="text" name="code" rows="5" cols="60"><?php echo $iFrameVal ?></textarea>
211 </p>
212 <p><input type="submit" name="set" value="Update" /></p>
213 </form>
214 <p><b style="color:#000099">STEP &raquo; 2 Create a new page. </b><br />
215 Goto &quot;<strong>Write</strong>&quot; --&gt; &quot;<strong>Write Page</strong>&quot;. Enter a<strong> Title</strong> e.g. &quot;Schedule an appointment&quot; (This would be shown as a link on your page. So make sure you chose the right title) and in <strong>Page Content </strong>write {APPOINTY} (including brackets). See preview. <br /><br />Note: If it overlaps your sidebar then create a new template from your theme without sidebar and use it for Appointy page. <a href=http://blog.appointy.com/tip/solution-appointy-wordpress-plugin-overlays-sidebar target=_blank >Click here</a> to see step by step instructions.</p>
216 <p><b style="color:#000099">STEP &raquo; 3 You are done. Now manage Appointments and clients from admin area easily. </b><br />
217 You are all done. Now test your blog. Appointy is easy to use and your clients would love scheduling with you. If you want to change your business hours, block days or times, add staff or service, approve appointment etc then click the link below and login to your powerful admin area on Appointy. <br />
218 <br />
219 <a href =<?php echo get_admin_url(); ?> target="_blank" class="button">&nbsp;&nbsp; Goto Admin Area &raquo;&nbsp;&nbsp;</a> </p>
220 <p><br />
221 <p>Uninstall Appointy Plugin: <a href="admin.php?page=appointy-appointment-scheduler\appointy.php&ui=true">UNINSTALL</a></p>
222 <br />
223 <br />
224
225 </p>
226 </div>
227 </div>
228 <div>
229 <div style="clear:both"></div>
230
231 <?php
232}
233
234
235function appointy_calendar_code( $code )
236{
237 if( strpos($code, "<iframe") === FALSE )
238 return false;
239 else
240 return true;
241}
242
243/*
244function get_admin_url()
245{
246 global $iFrameVal;
247 $adminURL = preg_match("/http:\/\/(.*).com/", $iFrameVal, $matches);
248 if ($adminURL = true)
249 {
250 $adminURL = htmlentities($matches['0']);
251 $adminURL = $adminURL .'/admin';
252 }
253 return $adminURL;
254}
255*/
256
257function appointy_calendar_installed()
258{
259 global $table_prefix, $wpdb;
260
261 $query = "
262 SHOW TABLES LIKE '".$table_prefix."appointy_calendar'
263 ";
264 //echo $query;
265 $install = $wpdb->get_var( $query );
266 //echo "nemesh-->>" . $install;
267
268 if( $install === NULL )
269 return false;
270 else
271 return true;
272}
273
274function appointy_calendar_install()
275{
276 global $table_prefix, $wpdb;
277
278 $query = "
279 CREATE TABLE ".$table_prefix."appointy_calendar (
280 calendar_id INT(11) NOT NULL auto_increment,
281 code TEXT NOT NULL,
282 PRIMARY KEY( calendar_id )
283 )
284 ";
285 $wpdb->query( $query );
286
287 //Using option for appointy calendar plugin!
288 add_option( "appointy_calendar_privileges", "2" );
289
290 if( !appointy_calendar_installed() )
291 return false;
292 else
293 return true;
294}
295
296
297
298?>