PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.17.2 4.17.1 4.17.0 4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / third-party / vendor / thecodingmachine / safe / deprecated / mssql.php
wp-user-avatar / third-party / vendor / thecodingmachine / safe / deprecated Last commit date
Exceptions 4 days ago apc.php 4 days ago functionsList.php 4 days ago libevent.php 4 days ago mssql.php 4 days ago stats.php 4 days ago
mssql.php
400 lines
1 <?php
2
3 namespace ProfilePressVendor\Safe;
4
5 use ProfilePressVendor\Safe\Exceptions\MssqlException;
6 /**
7 * Binds a parameter to a stored procedure or a remote stored procedure.
8 *
9 * @param resource $stmt Statement resource, obtained with mssql_init.
10 * @param string $param_name The parameter name, as a string.
11 *
12 * You have to include the @ character, like in the
13 * T-SQL syntax. See the explanation included in
14 * mssql_execute.
15 * @param mixed $var The PHP variable you'll bind the MSSQL parameter to. It is passed by
16 * reference, to retrieve OUTPUT and RETVAL values after
17 * the procedure execution.
18 * @param int $type One of: SQLTEXT,
19 * SQLVARCHAR, SQLCHAR,
20 * SQLINT1, SQLINT2,
21 * SQLINT4, SQLBIT,
22 * SQLFLT4, SQLFLT8,
23 * SQLFLTN.
24 * @param bool $is_output Whether the value is an OUTPUT parameter or not. If it's an OUTPUT
25 * parameter and you don't mention it, it will be treated as a normal
26 * input parameter and no error will be thrown.
27 * @param bool $is_null Whether the parameter is NULL or not. Passing the NULL value as
28 * var will not do the job.
29 * @param int $maxlen Used with char/varchar values. You have to indicate the length of the
30 * data so if the parameter is a varchar(50), the type must be
31 * SQLVARCHAR and this value 50.
32 * @throws MssqlException
33 *
34 */
35 function mssql_bind($stmt, string $param_name, &$var, int $type, bool $is_output = \false, bool $is_null = \false, int $maxlen = -1): void
36 {
37 error_clear_last();
38 $result = \mssql_bind($stmt, $param_name, $var, $type, $is_output, $is_null, $maxlen);
39 if ($result === \false) {
40 throw MssqlException::createFromPhpError();
41 }
42 }
43 /**
44 * Closes the link to a MS SQL Server database that's associated with the
45 * specified link identifier. If the link identifier isn't specified, the
46 * last opened link is assumed.
47 *
48 * Note that this isn't usually necessary, as non-persistent open
49 * links are automatically closed at the end of the script's
50 * execution.
51 *
52 * @param resource $link_identifier A MS SQL link identifier, returned by
53 * mssql_connect.
54 *
55 * This function will not close persistent links generated by
56 * mssql_pconnect.
57 * @throws MssqlException
58 *
59 */
60 function mssql_close($link_identifier = null): void
61 {
62 error_clear_last();
63 if ($link_identifier !== null) {
64 $result = \mssql_close($link_identifier);
65 } else {
66 $result = \mssql_close();
67 }
68 if ($result === \false) {
69 throw MssqlException::createFromPhpError();
70 }
71 }
72 /**
73 * mssql_connect establishes a connection to a
74 * MS SQL server.
75 *
76 * The link to the server will be closed as soon as the execution of
77 * the script ends, unless it's closed earlier by explicitly calling
78 * mssql_close.
79 *
80 * @param string $servername The MS SQL server. It can also include a port number, e.g.
81 * hostname:port (Linux), or
82 * hostname,port (Windows).
83 * @param string $username The username.
84 * @param string $password The password.
85 * @param bool $new_link If a second call is made to mssql_connect with the
86 * same arguments, no new link will be established, but instead, the link
87 * identifier of the already opened link will be returned. This parameter
88 * modifies this behavior and makes mssql_connect
89 * always open a new link, even if mssql_connect was
90 * called before with the same parameters.
91 * @return resource Returns a MS SQL link identifier on success.
92 * @throws MssqlException
93 *
94 */
95 function mssql_connect(string $servername = null, string $username = null, string $password = null, bool $new_link = \false)
96 {
97 error_clear_last();
98 if ($new_link !== \false) {
99 $result = \mssql_connect($servername, $username, $password, $new_link);
100 } elseif ($password !== null) {
101 $result = \mssql_connect($servername, $username, $password);
102 } elseif ($username !== null) {
103 $result = \mssql_connect($servername, $username);
104 } elseif ($servername !== null) {
105 $result = \mssql_connect($servername);
106 } else {
107 $result = \mssql_connect();
108 }
109 if ($result === \false) {
110 throw MssqlException::createFromPhpError();
111 }
112 return $result;
113 }
114 /**
115 * mssql_data_seek moves the internal row
116 * pointer of the MS SQL result associated with the specified result
117 * identifier to point to the specified row number, first row being
118 * number 0. The next call to mssql_fetch_row
119 * would return that row.
120 *
121 * @param resource $result_identifier The result resource that is being evaluated.
122 * @param int $row_number The desired row number of the new result pointer.
123 * @throws MssqlException
124 *
125 */
126 function mssql_data_seek($result_identifier, int $row_number): void
127 {
128 error_clear_last();
129 $result = \mssql_data_seek($result_identifier, $row_number);
130 if ($result === \false) {
131 throw MssqlException::createFromPhpError();
132 }
133 }
134 /**
135 * Returns the length of field no. offset in
136 * result.
137 *
138 * @param resource $result The result resource that is being evaluated. This result comes from a
139 * call to mssql_query.
140 * @param int $offset The field offset, starts at 0. If omitted, the current field is used.
141 * @return int The length of the specified field index on success.
142 * @throws MssqlException
143 *
144 */
145 function mssql_field_length($result, int $offset = -1): int
146 {
147 error_clear_last();
148 $result = \mssql_field_length($result, $offset);
149 if ($result === \false) {
150 throw MssqlException::createFromPhpError();
151 }
152 return $result;
153 }
154 /**
155 * Returns the name of field no. offset in
156 * result.
157 *
158 * @param resource $result The result resource that is being evaluated. This result comes from a
159 * call to mssql_query.
160 * @param int $offset The field offset, starts at 0. If omitted, the current field is used.
161 * @return string The name of the specified field index on success.
162 * @throws MssqlException
163 *
164 */
165 function mssql_field_name($result, int $offset = -1): string
166 {
167 error_clear_last();
168 $result = \mssql_field_name($result, $offset);
169 if ($result === \false) {
170 throw MssqlException::createFromPhpError();
171 }
172 return $result;
173 }
174 /**
175 * Seeks to the specified field offset. If the next call to
176 * mssql_fetch_field won't include a field
177 * offset, this field would be returned.
178 *
179 * @param resource $result The result resource that is being evaluated. This result comes from a
180 * call to mssql_query.
181 * @param int $field_offset The field offset, starts at 0.
182 * @throws MssqlException
183 *
184 */
185 function mssql_field_seek($result, int $field_offset): void
186 {
187 error_clear_last();
188 $result = \mssql_field_seek($result, $field_offset);
189 if ($result === \false) {
190 throw MssqlException::createFromPhpError();
191 }
192 }
193 /**
194 * Returns the type of field no. offset in
195 * result.
196 *
197 * @param resource $result The result resource that is being evaluated. This result comes from a
198 * call to mssql_query.
199 * @param int $offset The field offset, starts at 0. If omitted, the current field is used.
200 * @return string The type of the specified field index on success.
201 * @throws MssqlException
202 *
203 */
204 function mssql_field_type($result, int $offset = -1): string
205 {
206 error_clear_last();
207 $result = \mssql_field_type($result, $offset);
208 if ($result === \false) {
209 throw MssqlException::createFromPhpError();
210 }
211 return $result;
212 }
213 /**
214 * mssql_free_result only needs to be called
215 * if you are worried about using too much memory while your script
216 * is running. All result memory will automatically be freed when
217 * the script ends. You may call mssql_free_result
218 * with the result identifier as an argument and the associated
219 * result memory will be freed.
220 *
221 * @param resource $result The result resource that is being freed. This result comes from a
222 * call to mssql_query.
223 * @throws MssqlException
224 *
225 */
226 function mssql_free_result($result): void
227 {
228 error_clear_last();
229 $result = \mssql_free_result($result);
230 if ($result === \false) {
231 throw MssqlException::createFromPhpError();
232 }
233 }
234 /**
235 * mssql_free_statement only needs to be called
236 * if you are worried about using too much memory while your script
237 * is running. All statement memory will automatically be freed when
238 * the script ends. You may call mssql_free_statement
239 * with the statement identifier as an argument and the associated
240 * statement memory will be freed.
241 *
242 * @param resource $stmt Statement resource, obtained with mssql_init.
243 * @throws MssqlException
244 *
245 */
246 function mssql_free_statement($stmt): void
247 {
248 error_clear_last();
249 $result = \mssql_free_statement($stmt);
250 if ($result === \false) {
251 throw MssqlException::createFromPhpError();
252 }
253 }
254 /**
255 * Initializes a stored procedure or a remote stored procedure.
256 *
257 * @param string $sp_name Stored procedure name, like ownew.sp_name or
258 * otherdb.owner.sp_name.
259 * @param resource $link_identifier A MS SQL link identifier, returned by
260 * mssql_connect.
261 * @return resource Returns a resource identifier "statement", used in subsequent calls to
262 * mssql_bind and mssql_executes.
263 * @throws MssqlException
264 *
265 */
266 function mssql_init(string $sp_name, $link_identifier = null)
267 {
268 error_clear_last();
269 if ($link_identifier !== null) {
270 $result = \mssql_init($sp_name, $link_identifier);
271 } else {
272 $result = \mssql_init($sp_name);
273 }
274 if ($result === \false) {
275 throw MssqlException::createFromPhpError();
276 }
277 return $result;
278 }
279 /**
280 * mssql_pconnect acts very much like
281 * mssql_connect with two major differences.
282 *
283 * First, when connecting, the function would first try to find a
284 * (persistent) link that's already open with the same host,
285 * username and password. If one is found, an identifier for it
286 * will be returned instead of opening a new connection.
287 *
288 * Second, the connection to the SQL server will not be closed when
289 * the execution of the script ends. Instead, the link will remain
290 * open for future use (mssql_close will not
291 * close links established by mssql_pconnect).
292 *
293 * This type of links is therefore called 'persistent'.
294 *
295 * @param string $servername The MS SQL server. It can also include a port number. e.g.
296 * hostname:port.
297 * @param string $username The username.
298 * @param string $password The password.
299 * @param bool $new_link If a second call is made to mssql_pconnect with
300 * the same arguments, no new link will be established, but instead, the
301 * link identifier of the already opened link will be returned. This
302 * parameter modifies this behavior and makes
303 * mssql_pconnect always open a new link, even if
304 * mssql_pconnect was called before with the same
305 * parameters.
306 * @return resource Returns a positive MS SQL persistent link identifier on success.
307 * @throws MssqlException
308 *
309 */
310 function mssql_pconnect(string $servername = null, string $username = null, string $password = null, bool $new_link = \false)
311 {
312 error_clear_last();
313 if ($new_link !== \false) {
314 $result = \mssql_pconnect($servername, $username, $password, $new_link);
315 } elseif ($password !== null) {
316 $result = \mssql_pconnect($servername, $username, $password);
317 } elseif ($username !== null) {
318 $result = \mssql_pconnect($servername, $username);
319 } elseif ($servername !== null) {
320 $result = \mssql_pconnect($servername);
321 } else {
322 $result = \mssql_pconnect();
323 }
324 if ($result === \false) {
325 throw MssqlException::createFromPhpError();
326 }
327 return $result;
328 }
329 /**
330 * mssql_query sends a query to the currently active
331 * database on the server that's associated with the specified link
332 * identifier.
333 *
334 * @param string $query An SQL query.
335 * @param resource $link_identifier A MS SQL link identifier, returned by
336 * mssql_connect or
337 * mssql_pconnect.
338 *
339 * If the link identifier isn't specified, the last opened link is
340 * assumed. If no link is open, the function tries to establish a link
341 * as if mssql_connect was called, and use it.
342 * @param int $batch_size The number of records to batch in the buffer.
343 * @return mixed Returns a MS SQL result resource on success, TRUE if no rows were
344 * returned.
345 * @throws MssqlException
346 *
347 */
348 function mssql_query(string $query, $link_identifier = null, int $batch_size = 0)
349 {
350 error_clear_last();
351 if ($batch_size !== 0) {
352 $result = \mssql_query($query, $link_identifier, $batch_size);
353 } elseif ($link_identifier !== null) {
354 $result = \mssql_query($query, $link_identifier);
355 } else {
356 $result = \mssql_query($query);
357 }
358 if ($result === \false) {
359 throw MssqlException::createFromPhpError();
360 }
361 return $result;
362 }
363 /**
364 * mssql_select_db sets the current active
365 * database on the server that's associated with the specified link
366 * identifier.
367 *
368 * Every subsequent call to mssql_query will be
369 * made on the active database.
370 *
371 * @param string $database_name The database name.
372 *
373 * To escape the name of a database that contains spaces, hyphens ("-"),
374 * or any other exceptional characters, the database name must be
375 * enclosed in brackets, as is shown in the example, below. This
376 * technique must also be applied when selecting a database name that is
377 * also a reserved word (such as primary).
378 * @param resource $link_identifier A MS SQL link identifier, returned by
379 * mssql_connect or
380 * mssql_pconnect.
381 *
382 * If no link identifier is specified, the last opened link is assumed.
383 * If no link is open, the function will try to establish a link as if
384 * mssql_connect was called, and use it.
385 * @throws MssqlException
386 *
387 */
388 function mssql_select_db(string $database_name, $link_identifier = null): void
389 {
390 error_clear_last();
391 if ($link_identifier !== null) {
392 $result = \mssql_select_db($database_name, $link_identifier);
393 } else {
394 $result = \mssql_select_db($database_name);
395 }
396 if ($result === \false) {
397 throw MssqlException::createFromPhpError();
398 }
399 }
400