PluginProbe
User Submitted Posts – Enable Users to Submit Posts from the Front End / 20251210
User Submitted Posts – Enable Users to Submit Posts from the Front End v20251210
20260916 20260810 20260608 20230806 20230809 20230811 20230901 20230902 20230914 20231102 20240319 20240516 20240703 20241026 20250327 20250329 20251121 20251210 20260110 20260113 20260207 20260217 20260407 20260422 trunk All 59 releases
user-submitted-posts / recaptcha / autoload.php

autoload.php in User Submitted Posts – Enable Users to Submit Posts from the Front End 20251210, at recaptcha/autoload.php

70 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /* An autoloader for ReCaptcha\Foo classes. This should be required()
4 * by the user before attempting to instantiate any of the ReCaptcha
5 * classes.
6 *
7 * BSD 3-Clause License
8 * @copyright (c) 2019, Google Inc.
9 * @link https://www.google.com/recaptcha
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * 1. Redistributions of source code must retain the above copyright notice, this
15 * list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3. Neither the name of the copyright holder nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 spl_autoload_register(function ($class) {
38 if (substr($class, 0, 10) !== 'ReCaptcha\\') {
39 /* If the class does not lie under the "ReCaptcha" namespace,
40 * then we can exit immediately.
41 */
42 return;
43 }
44
45 /* All of the classes have names like "ReCaptcha\Foo", so we need
46 * to replace the backslashes with frontslashes if we want the
47 * name to map directly to a location in the filesystem.
48 */
49 $class = str_replace('\\', '/', $class);
50
51 /* First, check under the current directory. It is important that
52 * we look here first, so that we don't waste time searching for
53 * test classes in the common case.
54 */
55 $path = dirname(__FILE__).'/'.$class.'.php';
56 if (is_readable($path)) {
57 require_once $path;
58
59 return;
60 }
61
62 /* If we didn't find what we're looking for already, maybe it's
63 * a test class?
64 */
65 $path = dirname(__FILE__).'/../tests/'.$class.'.php';
66 if (is_readable($path)) {
67 require_once $path;
68 }
69 });
70