PluginProbe
Crowdsignal Dashboard – Polls, Surveys & more / 1.0
Crowdsignal Dashboard – Polls, Surveys & more v1.0
3.1.8 3.1.7 trunk 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 All 97 releases
polldaddy / polldaddy-client.php

polldaddy-client.php in Crowdsignal Dashboard – Polls, Surveys & more 1.0, at polldaddy-client.php

741 lines 19.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
4
5 // TODO: polls->poll should always be an array and similar bad typing
6 class PollDaddy_Client {
7 var $polldaddy_url = 'http://api.polldaddy.com/';
8 var $partnerGUID;
9 var $userCode;
10
11 var $request = null;
12 var $response = null;
13 var $request_xml = '';
14 var $response_xml = '';
15
16 var $errors = array();
17
18 function PollDaddy_Client( $partnerGUID = '', $userCode = null ) {
19 $this->partnerGUID = $partnerGUID;
20 $this->userCode = $userCode;
21 }
22
23 function send_request() {
24 $this->request_xml = "<?xml version='1.0' encoding='utf-8' ?>\n";
25 $this->request_xml .= $this->request->xml( 'all' );
26
27 if ( function_exists( 'wp_remote_post' ) ) {
28 $response = wp_remote_post( $this->polldaddy_url, array(
29 'headers' => array( 'Content-Type' => 'text/xml; charset=utf-8', 'Content-Length' => strlen( $this->request_xml ) ),
30 'user-agent' => 'PollDaddy PHP Client/0.1',
31 'body' => $this->request_xml
32 ) );
33 if ( !$response || is_wp_error( $response ) ) {
34 $errors[-1] = "Can't connect";
35 return false;
36 }
37 $this->response_xml = wp_remote_retrieve_body( $response );
38 } else {
39 $parsed = parse_url( $this->polldaddy_url );
40
41 $fp = fsockopen(
42 $parsed['host'],
43 $parsed['scheme'] == 'ssl' || $parsed['scheme'] == 'https' && extension_loaded('openssl') ? 443 : 80,
44 $err_num,
45 $err_str,
46 3
47 );
48
49 if ( !$fp ) {
50 $errors[-1] = "Can't connect";
51 return false;
52 }
53
54 if ( function_exists( 'stream_set_timeout' ) )
55 stream_set_timeout( $fp, 3 );
56
57 if ( !$path = $parsed['path'] . ( isset($parsed['query']) ? '?' . $parsed['query'] : '' ) )
58 $path = '/';
59
60 $request = "POST $path HTTP/1.0\r\n";
61 $request .= "Host: {$parsed['host']}\r\n";
62 $request .= "User-agent: PollDaddy PHP Client/0.1\r\n";
63 $request .= "Content-Type: text/xml; charset=utf-8\r\n";
64 $request .= 'Content-Length: ' . strlen( $this->request_xml ) . "\r\n";
65
66 fwrite( $fp, "$request\r\n$this->request_xml" );
67
68 $response = '';
69 while ( !feof( $fp ) )
70 $response .= fread( $fp, 4096 );
71 fclose( $fp );
72
73
74 if ( !$response ) {
75 $errors[-2] = 'No Data';
76 }
77
78 list($headers, $this->response_xml) = explode( "\r\n\r\n", $response, 2 );
79 }
80
81 $parser = new PollDaddy_XML_Parser( $this->response_xml );
82 $this->response =& $parser->objects[0];
83 if ( isset( $this->response->errors->error ) ) {
84 if ( !is_array( $this->response->errors->error ) )
85 $this->response->errors->error = array( $this->response->errors->error );
86 foreach ( $this->response->errors->error as $error )
87 $this->errors[$error->_id] = $error->___content;
88 }
89 }
90
91 function response_part( $pos ) {
92 if ( !isset( $this->response->demands->demand ) )
93 return false;
94
95 if ( is_array( $this->response->demands->demand ) ) {
96 if ( isset( $this->response->demands->demand[$pos] ) )
97 return $this->response->demands->demand[$pos];
98 return false;
99 }
100
101 if ( 0 === $pos )
102 return $this->response->demands->demand;
103
104 return false;
105 }
106
107 function add_request( $demand, $object = null ) {
108 if ( !is_a( $this->request, 'PollDaddy_Request' ) )
109 $this->request = new PollDaddy_Request( array(
110 'userCode' => $this->userCode,
111 'demands' => new PollDaddy_Demands( array( 'demand' => array() ) )
112 ), array(
113 'partnerGUID' => $this->partnerGUID
114 ) );
115
116 if ( is_a( $object, 'Ghetto_XML_Object' ) )
117 $args = array( $object->___name => &$object );
118 elseif ( is_array( $object ) )
119 $args =& $object;
120 else
121 $args = null;
122
123 $this->request->demands->demand[] = new PollDaddy_Demand( $args, array( 'id' => $demand ) );
124
125 return count( $this->request->demands->demand ) - 1;
126 }
127
128 function reset() {
129 $this->request = null;
130 $this->response = null;
131 $this->request_xml = '';
132 $this->response_xml = '';
133 $this->errors = array();
134 }
135
136 /* pdInitiate: Initiate API "connection" */
137
138 /**
139 * @param string $Email
140 * @param string $Password
141 * @param int $partnerUserID
142 * @return string|false PollDaddy userCode or false on failure
143 */
144 function Initiate( $Email, $Password, $partnerUserID ) {
145 $this->request = new PollDaddy_Initiate( compact( 'Email', 'Password' ), array( 'partnerGUID' => $this->partnerGUID, 'partnerUserID' => $partnerUserID ) );
146 $this->send_request();
147 if ( isset( $this->response->userCode ) )
148 return $this->response->userCode;
149 return false;
150 }
151
152
153 /* pdAccess: API Access Control */
154
155 /**
156 * @param string $partnerUserID
157 * @return string|false PollDaddy userCode or false on failure
158 */
159 function GetUserCode( $partnerUserID ) {
160 $this->request = new PollDaddy_Access( array(
161 // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => __FUNCTION__ ) ) ) )
162 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => 'GetUserCode' ) ) ) )
163 ), array(
164 'partnerGUID' => $this->partnerGUID,
165 'partnerUserID' => $partnerUserID
166 ) );
167 $this->send_request();
168 if ( isset( $this->response->userCode ) )
169 return $this->response->userCode;
170 return false;
171 }
172
173 // Not Implemented
174 function RemoveUserCode() {
175 return false;
176 }
177
178 /**
179 * @see polldaddy_account()
180 * @param int $partnerUserID
181 * @param array $args polldaddy_account() args
182 * @return string|false PollDaddy userCode or false on failure
183 */
184 function CreateAccount( $partnerUserID, $args ) {
185 if ( !$account = polldaddy_account( $args ) )
186 return false;
187
188 $this->request = new PollDaddy_Access( array(
189 // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => __FUNCTION__ ) ) ) )
190 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => 'CreateAccount' ) ) ) )
191 ), array(
192 'partnerGUID' => $this->partnerGUID,
193 'partnerUserID' => $partnerUserID
194 ) );
195 $this->send_request();
196 if ( isset( $this->response->userCode ) )
197 return $this->response->userCode;
198 return false;
199 }
200
201
202 /* pdRequest: Request API Objects */
203
204 /* Accounts */
205 /**
206 * @return object|false PollDaddy Account or false on failure
207 */
208 function GetAccount() {
209 // $pos = $this->add_request( __FUNCTION__ );
210 $pos = $this->add_request( 'GetAccount' );
211 $this->send_request();
212 $r = $this->response_part( $pos );
213 if ( isset( $r->account ) && !is_null( $r->account->email ) )
214 return $r->account;
215 return false;
216 }
217
218 /**
219 * @see polldaddy_account()
220 * @param array $args polldaddy_account() args
221 * @return string|false PollDaddy userCode or false on failure
222 */
223 function UpdateAccount( $args ) {
224 if ( !$account = polldaddy_account( $args ) )
225 return false;
226
227 // $this->add_request( __FUNCTION__, $account );
228 $this->add_request( 'UpdateAccount', $account );
229 $this->send_request();
230 if ( isset( $this->response->userCode ) )
231 return $this->response->userCode;
232 return false;
233 }
234
235 /* Polls */
236 /**
237 * @return array|false Array of PollDaddy Polls or false on failure
238 */
239 function ListPolls( $start = 0, $end = 0 ) {
240 $start = (int) $start;
241 $end = (int) $end;
242 if ( !$start && !$end )
243 // $pos = $this->add_request( __FUNCTION__ );
244 $pos = $this->add_request( 'ListPolls' );
245 else
246 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end' ) ) );
247 $pos = $this->add_request( 'ListPolls', new PollDaddy_List( null, compact( 'start', 'end' ) ) );
248 $this->send_request();
249 $r = $this->response_part( $pos );
250 if ( isset( $r->polls ) ) {
251 if ( isset( $r->polls->poll ) ) {
252 if ( !is_array( $r->polls->poll ) )
253 $r->polls->poll = array( $r->polls->poll );
254 }
255 return $r->polls;
256 }
257 return false;
258 }
259
260 /**
261 * @return array|false Array of PollDaddy Polls or false on failure
262 */
263 function listPollsByBlog( $start = 0, $end = 0, $id = null ) {
264 $start = (int) $start;
265 $end = (int) $end;
266 if ( !is_numeric( $id ) )
267 $id = $GLOBALS['blog_id'];
268
269 if ( !$start && !$end )
270 // $pos = $this->add_request( __FUNCTION__ );
271 $pos = $this->add_request( 'listPollsByBlog', compact( 'id' ) );
272 else
273 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end' ) ) );
274 $pos = $this->add_request( 'listPollsByBlog', new PollDaddy_List( null, compact( 'start', 'end', 'id' ) ) );
275 $this->send_request();
276 $r = $this->response_part( $pos );
277 if ( isset( $r->polls ) ) {
278 if ( isset( $r->polls->poll ) ) {
279 if ( !is_array( $r->polls->poll ) )
280 $r->polls->poll = array( $r->polls->poll );
281 }
282 return $r->polls;
283 }
284 return false;
285 }
286
287 /**
288 * @param int $id PollDaddy Poll ID
289 * @return array|false PollDaddy Poll or false on failure
290 */
291 function GetPoll( $id ) {
292 if ( !$id = (int) $id )
293 return false;
294
295 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
296 $pos = $this->add_request( 'GetPoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
297 $this->send_request();
298
299 $demand = $this->response_part( $pos );
300 if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->poll ) && !is_null( $demand->poll->question ) ) {
301 if ( isset( $demand->poll->answers->answer ) && !is_array( $demand->poll->answers->answer ) ) {
302 if ( $demand->poll->answers->answer )
303 $demand->poll->answers->answer = array( $demand->poll->answers->answer );
304 else
305 $demand->poll->answers->answer = array();
306 }
307 return $demand->poll;
308 }
309 return false;
310 }
311
312 /**
313 * @param int $id PollDaddy Poll ID
314 * @return bool success
315 */
316 function DeletePoll( $id ) {
317 if ( !$id = (int) $id )
318 return false;
319
320 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
321 $pos = $this->add_request( 'DeletePoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
322 $this->send_request();
323
324 return empty( $this->errors );
325 }
326
327 /**
328 * @see polldaddy_poll()
329 * @param array $args polldaddy_poll() args
330 * @return array|false PollDaddy Poll or false on failure
331 */
332 function CreatePoll( $args = null ) {
333 if ( !$poll = polldaddy_poll( $args ) )
334 return false;
335 // $pos = $this->add_request( __FUNCTION__, $poll );
336 $pos = $this->add_request( 'CreatePoll', $poll );
337 $this->send_request();
338 if ( !$demand = $this->response_part( $pos ) )
339 return $demand;
340 if ( !isset( $demand->poll ) )
341 return false;
342 return $demand->poll;
343
344 }
345
346 /**
347 * @see polldaddy_poll()
348 * @param int $id PollDaddy Poll ID
349 * @param array $args polldaddy_poll() args
350 * @return array|false PollDaddy Poll or false on failure
351 */
352 function UpdatePoll( $id, $args = null ) {
353 if ( !$id = (int) $id )
354 return false;
355
356 if ( !$poll = polldaddy_poll( $args, $id ) )
357 return false;
358
359 // $pos = $this->add_request( __FUNCTION__, $poll );
360 $pos = $this->add_request( 'UpdatePoll', $poll );
361 $this->send_request();
362 return $this->response_part( $pos );
363 }
364
365 function SearchPolls( $search ) {
366 // $pos = $this->add_request( __FUNCTION__, compact( 'search' ) );
367 $pos = $this->add_request( 'SearchPolls', compact( 'search' ) );
368 $this->send_request();
369
370 $r = $this->response_part( $pos );
371 if ( isset( $r->search ) ) {
372 if ( isset( $r->search->poll ) ) {
373 if ( is_array( $r->search->poll ) )
374 return $r->search->poll;
375 else
376 return array( $r->search->poll );
377 }
378 return array();
379 }
380 return false;
381 }
382
383 // Not Implemented
384 function ListSurveys() {
385 return false;
386 }
387
388 /* Poll Results */
389 /**
390 * @param int $id PollDaddy Poll ID
391 * @return object|false PollDaddy Result or false on failure
392 */
393 function GetPollResults( $id ) {
394 if ( !$id = (int) $id )
395 return false;
396
397 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
398 $pos = $this->add_request( 'GetPollResults', new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
399 $this->send_request();
400
401 $demand = $this->response_part( $pos );
402
403 if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->result ) ) {
404 $answers = $others = array();
405 if ( isset( $demand->result->answers ) ) {
406 if ( isset( $demand->result->answers->answer ) ) {
407 if ( is_array( $demand->result->answers->answer ) )
408 $answers = $demand->result->answers->answer;
409 else
410 $answers = array( $demand->result->answers->answer );
411 }
412 }
413 if ( isset( $demand->result->otherAnswers ) ) {
414 if ( isset( $demand->result->otherAnswers->otherAnswer ) ) {
415 if ( is_array( $demand->result->otherAnswers->otherAnswer ) )
416 $others = $demand->result->otherAnswers->otherAnswer;
417 else
418 $others = array( $demand->result->otherAnswers->othernswer );
419 }
420 }
421 return (object) compact( 'answers', 'others' );
422 }
423 return false;
424 }
425
426 /**
427 * @param int $id PollDaddy Poll ID
428 * @return object|false PollDaddy Result or false on failure
429 */
430 function ResetPollResults( $id ) {
431 if ( !$id = (int) $id )
432 return false;
433
434 // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
435 $pos = $this->add_request( 'ResetPollResults', new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
436 $this->send_request();
437
438 return empty( $this->errors );
439 }
440
441 /* Poll Comments */
442 // Not Implemented
443 function GetPollComments() {
444 return false;
445 }
446
447 // Not Implemented
448 function ModerateComment() {
449 return false;
450 }
451
452 /* Extensions */
453
454 // Not Implemented
455 function GetAllExtensions() {
456 return false;
457 }
458
459 // Not Implemented
460 function GetLanguages() {
461 return false;
462 }
463
464 /* Language Packs */
465 // Not Implemented
466 function GetPacks() {
467 return false;
468 }
469
470 // Not Implemented
471 function GetPack() {
472 return false;
473 }
474
475 // Not Implemented
476 function DeletePack() {
477 return false;
478 }
479
480 // Not Implemented
481 function CreatePack() {
482 return false;
483 }
484
485 // Not Implemented
486 function UpdatePack() {
487 return false;
488 }
489
490 /* Styles */
491 // Not Implemented
492 function GetStyles() {
493 return false;
494 }
495
496 // Not Implemented
497 function GetStyle() {
498 return false;
499 }
500
501 // Not Implemented
502 function DeleteStyle() {
503 return false;
504 }
505
506 // Not Implemented
507 function CreateStyle() {
508 return false;
509 }
510
511 // Not Implemented
512 function UpdateStyle() {
513 return false;
514 }
515
516 /* Folders */
517 // Not Implemented
518 function GetFolders() {
519 return false;
520 }
521
522 /* Account Activities */
523 // Not Implemented
524 function GetActivity() {
525 return false;
526 }
527
528 // Not Implemented
529 function SetActivity() {
530 return false;
531 }
532 }
533
534 /**
535 * @param string $partnerUserID
536 * @param string $userName
537 * @param string $email
538 * @param string $password
539 * @param string $firstName
540 * @param string $lastName
541 * @param string $countryCode
542 * @param string $gender
543 * @param string $yearOfBirth
544 * @param string $websiteURL
545 * @param string $avatarURL
546 * @param string $bio
547 */
548 function &polldaddy_account( $args = null ) {
549 $false = false;
550 if ( is_a( $args, 'PollDaddy_Account' ) )
551 return $args;
552
553 $defaults = _polldaddy_account_defaults();
554
555 $args = wp_parse_args( $args, $defaults );
556
557 foreach ( array( 'userName', 'email' ) as $required )
558 if ( !is_string( $args[$required] ) || !$args[$required] )
559 return $false;
560
561 return new PollDaddy_Account( $args );
562 }
563
564 function _polldaddy_account_defaults() {
565 return array(
566 'userName' => false,
567 'email' => false,
568 'password' => false,
569 'firstName' => false,
570 'lastName' => false,
571 'countryCode' => 'nn',
572 'gender' => 'male',
573 'yearOfBirth' => 1901,
574 'websiteURL' => false,
575 'avatarURL' => false,
576 'bio' => false
577 );
578 }
579
580 function &polldaddy_poll( $args = null, $id = null, $_require_data = true ) {
581 $false = false;
582 if ( is_a( $args, 'PollDaddy_Poll' ) ) {
583 if ( is_null( $id ) )
584 return $args;
585 if ( !$id = (int) $id )
586 return $false;
587 $args->_id = $id;
588 return $args;
589 }
590
591 $defaults = _polldaddy_poll_defaults();
592
593 if ( !is_null( $args ) ) {
594 $args = wp_parse_args( $args, $defaults );
595 $args['parentID'] = (int) $args['parentID'];
596
597 if ( $_require_data ) {
598 if ( !is_string( $args['question'] ) || !$args['question'] )
599 return $false;
600
601 if ( !is_array($args['answers']) || !$args['answers'] )
602 return $false;
603 }
604
605 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'makePublic', 'closePoll', 'closePollNow' ) as $bool ) {
606 if ( 'no' !== $args[$bool] && 'yes' !== $args[$bool] )
607 $args[$bool] = $defaults[$bool];
608 }
609
610 foreach ( array( 'styleID', 'packID', 'folderID', 'languageID' ) as $int )
611 if ( !is_numeric( $args[$int] ) )
612 $args[$bool] = $defaults[$int];
613
614 if ( !in_array( $args['resultsType'], array( 'show', 'percent', 'hide' ) ) )
615 $args['resultsType'] = $defaults['resultsType'];
616
617 if ( !in_array( $args['blockRepeatVotersType'], array( 'off', 'cookie', 'cookieIP' ) ) )
618 $args['blockRepeatVotersType'] = $defaults['blockRepeatVotersType'];
619
620 if ( !in_array( $args['comments'], array( 'off', 'allow', 'moderate' ) ) )
621 $args['comments'] = $defaults['comments'];
622
623 if ( is_numeric( $args['closeDate'] ) )
624 $args['closeDate'] = gmdate( 'Y-m-d\TH:i:s', $args['closeDate'] ) . 'Z';
625 if ( !$args['closeDate'] )
626 $args['closeDate'] = gmdate( 'Y-m-d\TH:i:s' ) . 'Z';
627
628 $args['answers'] = new PollDaddy_Poll_Answers( array( 'answer' => $args['answers'] ) );
629
630 if ( is_null( $id ) )
631 $id = $args['id'];
632 unset( $args['id'] );
633 }
634
635 return new PollDaddy_Poll( $args, compact( 'id' ) );
636 }
637
638 function _polldaddy_poll_defaults() {
639 return array(
640 'id' => null,
641 'question' => false,
642 'multipleChoice' => 'no',
643 'randomiseAnswers' => 'no',
644 'otherAnswer' => 'no',
645 'resultsType' => 'show',
646 'blockRepeatVotersType' => 'cookie',
647 'comments' => 'off',
648 'makePublic' => 'yes',
649 'closePoll' => 'no',
650 'closePollNow' => 'no',
651 'closeDate' => null,
652 'styleID' => 0,
653 'packID' => 0,
654 'folderID' => 0,
655 'languageID' => _polldaddy_poll_default_language_id(),
656 'parentID' => (int) $GLOBALS['blog_id'],
657 'answers' => array()
658 );
659 }
660
661 if ( !function_exists( '_polldaddy_poll_default_language_id' ) ) :
662 function _polldaddy_poll_default_language_id() {
663 return 1;
664 }
665 endif;
666
667 function &polldaddy_poll_answer( $answer, $id = null ) {
668 if ( !is_string( $answer ) || !$answer )
669 return false;
670
671 return new PollDaddy_Poll_Answer( $answer, compact( 'id' ) );
672 }
673
674 if ( !function_exists( 'wp_parse_args' ) ) :
675 /**
676 * Merge user defined arguments into defaults array.
677 *
678 * This function is used throughout WordPress to allow for both string or array
679 * to be merged into another array.
680 *
681 * @since 2.2.0
682 *
683 * @param string|array $args Value to merge with $defaults
684 * @param array $defaults Array that serves as the defaults.
685 * @return array Merged user defined values with defaults.
686 */
687 function wp_parse_args( $args, $defaults = '' ) {
688 if ( is_object( $args ) )
689 $r = get_object_vars( $args );
690 elseif ( is_array( $args ) )
691 $r =& $args;
692 else
693 wp_parse_str( $args, $r );
694
695 if ( is_array( $defaults ) )
696 return array_merge( $defaults, $r );
697 return $r;
698 }
699 endif;
700
701 if ( !function_exists( 'wp_parse_str' ) ) :
702 /**
703 * Parses a string into variables to be stored in an array.
704 *
705 * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if
706 * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.
707 *
708 * @since 2.2.1
709 * @uses apply_filters() for the 'wp_parse_str' filter.
710 *
711 * @param string $string The string to be parsed.
712 * @param array $array Variables will be stored in this array.
713 */
714 function wp_parse_str( $string, &$array ) {
715 parse_str( $string, $array );
716 if ( get_magic_quotes_gpc() )
717 $array = stripslashes_deep( $array );
718 return $array;
719
720 $array = apply_filters( 'wp_parse_str', $array );
721 }
722 endif;
723
724 if ( !function_exists( 'stripslashes_deep' ) ) :
725 /**
726 * Navigates through an array and removes slashes from the values.
727 *
728 * If an array is passed, the array_map() function causes a callback to pass the
729 * value back to the function. The slashes from this value will removed.
730 *
731 * @since 2.0.0
732 *
733 * @param array|string $value The array or string to be striped.
734 * @return array|string Stripped array (or string in the callback).
735 */
736 function stripslashes_deep($value) {
737 $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
738 return $value;
739 }
740 endif;
741