Develop and Download Open Source Software

Browse CVS Repository

Annotation of /xoonips/AL/xnpal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.21 - (hide annotations) (download) (as text)
Wed Jan 12 11:39:52 2005 UTC (19 years, 3 months ago) by youi
Branch: MAIN
Changes since 1.20: +202 -202 lines
File MIME type: text/x-c++src
xnpal.hのインクルード.
関数名のPrefixをvpからxnpに変更.

1 aga 1.1 /*
2 youi 1.21 $Revision: 1.20 $
3     XNPAL: XooNiPs Platform Abstract Layer
4 aga 1.1
5     zend_parse_parameters??hp4.1.0??綽?荀?
6     .so???<?ゃ?????????荀????????贋????舟??鴻????
7     C++?с????extern "C"{}, BEGIN/END_EXTERN_C()??綽?荀???
8     */
9    
10    
11     #include <stdio.h>
12 aga 1.2 #include "criteria.h"
13     #include "common.h"
14     #include "commonal.h"
15     #include "session.h"
16     #include "group.h"
17     #include "account.h"
18 youi 1.21 #include "xnpal.h"
19 aga 1.1
20 aga 1.2 // for inet_aton
21     #include <sys/socket.h>
22     #include <netinet/in.h>
23     #include <arpa/inet.h>
24    
25 aga 1.1 // global variables
26    
27 youi 1.21 PHP_MSHUTDOWN_FUNCTION(xnpalmod)
28 aga 1.18 {
29     uninitializeDB();
30     return SUCCESS;
31     }
32 aga 1.1
33     /* declaration of functions to be exported */
34     extern "C" {
35 aga 1.2 ZEND_FUNCTION(first_module );
36 youi 1.21 ZEND_FUNCTION(xnp_initialize_db );
37     ZEND_FUNCTION(xnp_login_user );
38     ZEND_FUNCTION(xnp_logout_user );
39     ZEND_FUNCTION(xnp_create_session );
40     ZEND_FUNCTION(xnp_get_session );
41     ZEND_FUNCTION(xnp_is_activated );
42     ZEND_FUNCTION(xnp_activate );
43     ZEND_FUNCTION(xnp_get_account_count );
44     ZEND_FUNCTION(xnp_delete_account );
45     ZEND_FUNCTION(xnp_get_account );
46     ZEND_FUNCTION(xnp_get_accounts );
47     ZEND_FUNCTION(xnp_insert_account );
48     ZEND_FUNCTION(xnp_update_account );
49     ZEND_FUNCTION(xnp_dump_uids );
50     ZEND_FUNCTION(xnp_get_group_count );
51     ZEND_FUNCTION(xnp_get_groups_by_uid );
52     ZEND_FUNCTION(xnp_is_group_admin );
53     ZEND_FUNCTION(xnp_dump_gids );
54     ZEND_FUNCTION(xnp_dump_group_admins );
55     ZEND_FUNCTION(xnp_delete_member );
56     ZEND_FUNCTION(xnp_insert_member );
57     ZEND_FUNCTION(xnp_get_members );
58     ZEND_FUNCTION(xnp_delete_group );
59     ZEND_FUNCTION(xnp_insert_group );
60     ZEND_FUNCTION(xnp_update_group );
61     ZEND_FUNCTION(xnp_get_group );
62     ZEND_FUNCTION(xnp_get_groups );
63     ZEND_FUNCTION(xnp_is_moderator );
64     ZEND_FUNCTION(xnp_get_uid );
65 aga 1.2
66 youi 1.21 ZEND_FUNCTION(xnp_is_valid_session_id );
67     ZEND_FUNCTION(xnp_get_last_error_string );
68 aga 1.9
69 youi 1.21 ZEND_FUNCTION(xnp_test_criteria );
70     ZEND_FUNCTION(xnp_test_uids );
71 aga 1.1 };
72     /* compiled function list so Zend knows what's in this module */
73 youi 1.21 zend_function_entry xnpalmod_functions[] =
74 aga 1.1 {
75 aga 1.2 ZEND_FE(first_module ,NULL)
76 youi 1.21 ZEND_FE(xnp_initialize_db ,NULL)
77     ZEND_FE(xnp_login_user ,NULL)
78     ZEND_FE(xnp_logout_user ,NULL)
79     ZEND_FE(xnp_create_session ,NULL)
80     ZEND_FE(xnp_get_session ,NULL)
81     ZEND_FE(xnp_is_activated ,NULL)
82     ZEND_FE(xnp_activate ,NULL)
83     ZEND_FE(xnp_get_account_count ,NULL)
84     ZEND_FE(xnp_delete_account ,NULL)
85     ZEND_FE(xnp_get_account ,NULL)
86     ZEND_FE(xnp_get_accounts ,NULL)
87     ZEND_FE(xnp_insert_account ,NULL)
88     ZEND_FE(xnp_update_account ,NULL)
89     ZEND_FE(xnp_dump_uids ,NULL)
90     ZEND_FE(xnp_get_group_count ,NULL)
91     ZEND_FE(xnp_get_groups_by_uid ,NULL)
92     ZEND_FE(xnp_is_group_admin ,NULL)
93     ZEND_FE(xnp_dump_gids ,NULL)
94     ZEND_FE(xnp_dump_group_admins ,NULL)
95     ZEND_FE(xnp_delete_member ,NULL)
96     ZEND_FE(xnp_insert_member ,NULL)
97     ZEND_FE(xnp_get_members ,NULL)
98     ZEND_FE(xnp_delete_group ,NULL)
99     ZEND_FE(xnp_insert_group ,NULL)
100     ZEND_FE(xnp_update_group ,NULL)
101     ZEND_FE(xnp_get_group ,NULL)
102     ZEND_FE(xnp_get_groups ,NULL)
103     ZEND_FE(xnp_is_moderator ,NULL)
104     ZEND_FE(xnp_get_uid ,NULL)
105     ZEND_FE(xnp_is_valid_session_id ,NULL)
106     ZEND_FE(xnp_get_last_error_string ,NULL)
107     ZEND_FE(xnp_test_criteria ,NULL)
108     ZEND_FE(xnp_test_uids ,NULL)
109 aga 1.1 {NULL, NULL, NULL}
110     };
111    
112     /* compiled module information */
113 youi 1.21 zend_module_entry xnpalmod_module_entry =
114 aga 1.1 {
115     STANDARD_MODULE_HEADER,
116     "Visiome Platform Abstract Layer",
117 youi 1.21 xnpalmod_functions,
118 aga 1.1 NULL,
119 youi 1.21 PHP_MSHUTDOWN(xnpalmod),
120 aga 1.1 NULL,
121     NULL,
122 aga 1.16 NULL,
123 aga 1.1 NO_VERSION_YET,
124     STANDARD_MODULE_PROPERTIES
125     };
126    
127     /* implement standard "stub" routine to introduce ourselves to Zend */
128     #if COMPILE_DL_FIRST_MODULE
129     BEGIN_EXTERN_C()
130 youi 1.21 ZEND_GET_MODULE(xnpalmod)
131 aga 1.1 END_EXTERN_C()
132     #endif
133    
134 aga 1.16
135 aga 1.1 /* implement function that is meant to be made available to PHP */
136     ZEND_FUNCTION(first_module)
137     {
138     long parameter;
139     // if(ZEND_NUM_ARGS() != 2) WRONG_PARAM_COUNT;
140     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &parameter) == FAILURE) {
141     return;
142     }
143     parameter++;
144     RETURN_LONG(parameter);
145     }
146     /** zval????C????絖?????緇?????
147     */
148     char *getZvalString( zval **p ){
149     convert_to_string_ex(p);
150     return Z_STRVAL_PP(p); //(**p).value.str.val;
151     }
152    
153     /** zval????int??緇?????
154     */
155     int getZvalInt( zval **p ){
156     convert_to_long_ex(p);
157     return Z_LVAL_PP(p); // (int)(**p).value.lval;
158     }
159    
160 aga 1.2 // keylen????鮎??0????????
161     static void print_hash_key( int res, const char *key, uint keyLen, ulong index ){
162     zend_printf( "print_hash_key : key=0x%08x keylen=%08d index=%08d<br> ", key, keyLen, index );
163     if ( res == HASH_KEY_IS_STRING ){
164     char *p = new char[keyLen+1];
165     memcpy( p, key, keyLen );
166     p[keyLen] = 0;
167     zend_printf( " key is string[%s]<br>\n", p );
168     }
169     else {
170     zend_printf( " key is integer[%d]<br>\n", index );
171     }
172     }
173    
174    
175 aga 1.16 /** zval*????criteria_t?????????????????????鴻??????紊掩??????getResult()!=RES_OK <br>
176     criteria :
177 aga 1.2 array( 'start'=>0, 'rows'=>10,
178     'orders'=>array(
179     array('name'=>'id','order'=>'0'),
180     array('name'=>'timestamp','name'=>'1'), ...)
181     ); ??????就???f?渇????
182     */
183     class zCriteria_t : public criteria {
184     private:
185     result_t result;
186 aga 1.16
187 aga 1.2 // pz: array('name'=>'timestamp','name'=>'1')
188     // ????????orderby??篏???????申????
189     void setOrder( zval *pz ){
190     char *column = 0;
191     order_t order = (order_t)0;
192    
193     HashPosition pos;
194     zval **ppzTmp = 0;
195     int res2;
196     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
197     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
198     char *key = 0;
199     uint keyLen = 0;
200     ulong index = 0;
201     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
202     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
203 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
204     if ( strncasecmp( key, "name", keyLen ) == 0 && keyLen == 5 ){
205 aga 1.2 SEPARATE_ZVAL(ppzTmp);
206     column = getZvalString(ppzTmp);
207     // zend_printf( "column=%s<br>\n", column );
208     }
209     else if ( strncasecmp( key, "order", keyLen ) == 0 && keyLen == 6 ){
210     SEPARATE_ZVAL(ppzTmp);
211     order = (order_t)getZvalInt(ppzTmp);
212     // zend_printf( "order=%d<br>\n", order );
213     }
214     }
215    
216     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
217     }
218     if ( column ){
219     orderby *o = new orderby( column, order );
220     addOrderBy( o );
221     }
222    
223     result = RES_OK;
224     }
225    
226     // pz: array( array('column'=>'hoge','order'=>'1'), array('column'=>'huga','order'=>'2'), ...)
227     void setOrders( zval *pz ){
228     HashPosition pos;
229    
230     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
231    
232     zval **ppzTmp = 0;
233     int res2;
234     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
235     char *key = 0;
236     uint keyLen = 0;
237     ulong index = 0;
238     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
239     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
240 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
241 aga 1.2 setOrder( *ppzTmp );
242     }
243     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
244     }
245     result = RES_OK;
246     }
247    
248     void initialize( zval *pz ){
249     HashPosition pos;
250     zval **ppzTmp = 0;
251     int res2;
252     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pz), &pos);
253     while ( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(pz), (void **)&ppzTmp, &pos)) == SUCCESS ) {
254     char *key = 0;
255     uint keyLen = 0;
256     ulong index = 0;
257     int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos );
258     if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){
259 aga 1.14 //print_hash_key( keyType, key, keyLen, index );
260 aga 1.2 if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){
261     SEPARATE_ZVAL(ppzTmp);
262     int tmp = getZvalInt(ppzTmp);
263     // zend_printf( "start=%d<br>\n", tmp );
264     setLimit( tmp, getLimitRows() );
265     }
266     else if ( strncasecmp( key, "rows", keyLen ) == 0 && keyLen == 5 ){
267     SEPARATE_ZVAL(ppzTmp);
268     int tmp = getZvalInt(ppzTmp);
269     // zend_printf( "rows=%d<br>\n", tmp );
270     setLimit( getLimitStart(), tmp );
271     }
272     else if ( strncasecmp( key, "orders", keyLen ) == 0 && keyLen == 7 ){
273     setOrders( *ppzTmp );
274     }
275     else
276     ; // ignore unknown key
277     }
278     else
279     ; // ignore bad key
280     zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos);
281     }
282     result = RES_OK;
283     }
284 aga 1.16
285     public:
286 aga 1.2 zCriteria_t() : criteria(){ result = RES_ERROR; }
287     zCriteria_t( zval *pz ) : criteria(){ initialize(pz); }
288     zCriteria_t( zval **ppz ) : criteria() { initialize(*ppz); }
289     result_t getResult(){ return result; };
290    
291     void dump(){
292     zend_printf( "dumping zCriteria...<br>\n" );
293     zend_printf( "result=%d<br>\n", (int)result );
294     zend_printf( "start=%d, rows=%d<br>\n", getLimitStart(), getLimitRows() );
295     const orderby *p = headOrderBy();
296     while ( p ){
297     zend_printf( "column=%s, order=%d<br>\n", p->getColumn(), p->getOrder() );
298     p = nextOrderBy();
299     }
300     }
301     };
302    
303 aga 1.16
304     /** ?f?渇???????≪???祉?鴻????ong?ゃ??緇?????
305     @param ht ?f?渇????
306     @param key ????/span>
307     @param val long?ゃ?????????????ゃ?潟??/span>
308     @return ????????true
309     */
310     static bool hashGetLong( HashTable *ht, const char *key, long *val ){
311 aga 1.14 zval **tmp;
312     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
313     convert_to_long_ex( tmp );
314     *val = Z_LVAL_PP(tmp);
315     return true;
316     }
317     return false;
318     }
319    
320 aga 1.16 /** ?f?渇???????≪???祉?鴻??????絖?????緇?????
321     @param ht ?f?渇????
322     @param key ????/span>
323     @param val ??絖????????????????ゃ?潟??/span>
324     @return ????????true
325     */
326     static bool hashGetString( HashTable *ht, const char *key, char **val ){
327 aga 1.14 zval **tmp;
328     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
329     convert_to_string_ex( tmp );
330     *val = Z_STRVAL_PP(tmp);
331     return true;
332     }
333     return false;
334     }
335    
336 aga 1.16 /** ?f?渇???????≪???祉?鴻????ouble?ゃ??緇?????
337     @param ht ?f?渇????
338     @param key ????/span>
339     @param val double?ゃ?????????????ゃ?潟??/span>
340     @return ????????true
341     */
342     static bool hashGetDouble( HashTable *ht, const char *key, double *val ){
343 aga 1.14 zval **tmp;
344     if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
345     convert_to_double_ex( tmp );
346     *val = Z_DVAL_PP(tmp);
347     return true;
348     }
349     return false;
350     }
351 aga 1.2
352 aga 1.16 /** zval*????account?????????????????????鴻?? <br>
353     ????紊掩??????getResult()!=RES_OK <br>
354     */
355 aga 1.2 class zAccount_t : public account {
356     private:
357     result_t result;
358     void initialize(zval *pz){
359 aga 1.14 HashTable *ht = Z_ARRVAL_P(pz);
360     long l;
361     char *p;
362     double d;
363     if ( hashGetLong ( ht, "uid" , &l ) ) setUID ( l );
364     if ( hashGetString( ht, "uname" , &p ) ) setUname ( p );
365     if ( hashGetString( ht, "name" , &p ) ) setName ( p );
366     if ( hashGetString( ht, "email" , &p ) ) setEmail ( p );
367     if ( hashGetString( ht, "url" , &p ) ) setURL ( p );
368     if ( hashGetString( ht, "user_avatar" , &p ) ) setUserAvatar ( p );
369     if ( hashGetString( ht, "user_icq" , &p ) ) setUserIcq ( p );
370     if ( hashGetString( ht, "user_from" , &p ) ) setUserFrom ( p );
371     if ( hashGetString( ht, "user_sig" , &p ) ) setUserSig ( p );
372     if ( hashGetString( ht, "actkey" , &p ) ) setActkey ( p );
373     if ( hashGetString( ht, "user_aim" , &p ) ) setUserAim ( p );
374     if ( hashGetString( ht, "user_yim" , &p ) ) setUserYim ( p );
375     if ( hashGetString( ht, "user_msnm" , &p ) ) setUserMsnm ( p );
376     if ( hashGetString( ht, "pass" , &p ) ) setPass ( p );
377     if ( hashGetString( ht, "theme" , &p ) ) setTheme ( p );
378     if ( hashGetString( ht, "umode" , &p ) ) setUmode ( p );
379     if ( hashGetString( ht, "user_occ" , &p ) ) setUserOcc ( p );
380     if ( hashGetString( ht, "bio" , &p ) ) setBio ( p );
381     if ( hashGetString( ht, "user_intrest" , &p ) ) setUserIntrest ( p );
382     if ( hashGetDouble( ht, "timezone_offset" , &d ) ) setTimezoneOffset ( d );
383     if ( hashGetLong ( ht, "attachsig" , &l ) ) setAttachsig ( l );
384     if ( hashGetLong ( ht, "last_login" , &l ) ) setLastLogin ( l );
385     if ( hashGetLong ( ht, "level" , &l ) ) setLevel ( l );
386     if ( hashGetLong ( ht, "notify_method" , &l ) ) setNotifyMethod ( l );
387     if ( hashGetLong ( ht, "notify_mode" , &l ) ) setNotifyMode ( l );
388     if ( hashGetLong ( ht, "posts" , &l ) ) setPosts ( l );
389     if ( hashGetLong ( ht, "rank" , &l ) ) setRank ( l );
390     if ( hashGetLong ( ht, "uorder" , &l ) ) setUorder ( l );
391     if ( hashGetLong ( ht, "user_mailok" , &l ) ) setUserMailok ( l );
392     if ( hashGetLong ( ht, "user_regdate" , &l ) ) setUserRegdate ( l );
393     if ( hashGetLong ( ht, "user_viewemail" , &l ) ) setUserViewemail ( l );
394     if ( hashGetLong ( ht, "activate" , &l ) ) setActivate ( l );
395     if ( hashGetString( ht, "address" , &p ) ) setAddress ( p );
396 aga 1.16 if ( hashGetString( ht, "division" , &p ) ) setDivision ( p );
397 aga 1.14 if ( hashGetString( ht, "tel" , &p ) ) setTel ( p );
398 aga 1.16 if ( hashGetString( ht, "company_name" , &p ) ) setCompanyName ( p );
399 aga 1.14 if ( hashGetString( ht, "country" , &p ) ) setCountry ( p );
400     if ( hashGetString( ht, "zipcode" , &p ) ) setZipcode ( p );
401     if ( hashGetString( ht, "fax" , &p ) ) setFax ( p );
402     if ( hashGetString( ht, "base_url" , &p ) ) setBaseURL ( p );
403     if ( hashGetLong ( ht, "notice_mail" , &l ) ) setNoticeMail ( l );
404     if ( hashGetLong ( ht, "notice_mail_since" , &l ) ) setNoticeMailSince ( l );
405    
406     result = RES_OK;
407 aga 1.2 }
408 aga 1.16 public:
409 aga 1.2 zAccount_t() : account(){ result = RES_ERROR; }
410 aga 1.16
411     /** ?潟?潟?鴻????????/span>
412     @param pz array( 'uid'=>1, 'uname'=>'root', ... ); ??????就???f?渇???? */
413 aga 1.2 zAccount_t( zval *pz ) : account(){ initialize(pz); }
414     zAccount_t( zval **ppz ) : account() { initialize(*ppz); }
415     result_t getResult(){ return result; };
416     };
417    
418 aga 1.16 /** zval*????(userid_t *puid,int uidLen)?????????????????????鴻?? <br>
419     ????紊掩??????getResult()!=RES_OK <br>
420 aga 1.2 */
421     class zUIDs_t {
422     private:
423     result_t result;
424     userid_t *pUID;
425     int len;
426     public:
427     zUIDs_t(){
428     pUID = 0;
429     len = 0;
430     result = RES_ERROR;
431     }
432    
433 aga 1.16 /** ?潟?潟?鴻????????/span>
434     @param pza array( '1', '3', '4', '6', ... ); ??????就?????? */
435 aga 1.2 zUIDs_t( zval *pza ){
436     pUID = 0;
437     len = 0;
438     result = RES_ERROR;
439    
440     if ( Z_TYPE_P(pza) != IS_ARRAY ){
441     result = RES_ERROR;
442     }
443     else {
444     len = zend_hash_num_elements(Z_ARRVAL_P(pza));
445     if(len == 0) {
446     pUID = new userid_t[1];
447     result = RES_OK;
448     }
449     else {
450     /* php/ext/standard/string.c ? implode??????????????????
451     zend_hash_*???????ャ?<?潟???c????????????????鐚?
452     */
453     zval **tmp;
454     HashPosition pos;
455     int i = 0;
456     pUID = new userid_t[len];
457    
458     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pza), &pos);
459     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pza), (void **) &tmp, &pos) == SUCCESS ) {
460     SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html ????/span>
461     convert_to_long_ex(tmp);
462     if ( i < len )
463     pUID[i++] = Z_LVAL_PP(tmp);
464     zend_hash_move_forward_ex(Z_ARRVAL_P(pza), &pos);
465     }
466     len = i;
467     result = RES_OK;
468     }
469     }
470     }
471    
472     ~zUIDs_t(){
473     if ( pUID ) delete[] pUID;
474     }
475     result_t getResult(){ return result; }
476     userid_t *getPUID(){ return pUID; }
477     int getLen(){ return len; }
478     void dump(){
479     zend_printf( "dumping zUIDs...<br>\n" );
480     zend_printf( "result=%d<br>\n", (int)result );
481     zend_printf( "len=%d<br>\n", len );
482     for ( int i = 0; i < len; i++ ){
483     zend_printf( "pUID[%d] = %d<br>\n", i, pUID[i] );
484     }
485     }
486     };
487    
488 aga 1.8 /**
489     *
490     * uids_t????????PHP???????????????
491     *
492 aga 1.16 * @param pUID 紊???????serid_t??????
493 aga 1.8 * @param len pUID?????????激??
494     * @param pz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
495     * @return RES_OK
496     *
497     */
498 aga 1.4 result_t uidsToZval( userid_t *pUID, int len, zval **ppz )
499     {
500 aga 1.8 zend_hash_clean( Z_ARRVAL_PP(ppz) );
501 aga 1.2
502     // add UIDs
503     for ( int i = 0; i < len; i++ ){
504 aga 1.8 add_next_index_long(*ppz, (long)(pUID[i]) );
505 aga 1.2 }
506    
507     return RES_OK;
508     }
509 aga 1.16 /**
510     *
511     * groupid_t????????PHP???????????????
512     * @param pGID 紊???????roupid_t??????
513     * @param len pGID?????????激??
514     * @param ppz 紊???腟??????吾??莨若??????(??????羝??帥?с????????
515     * @return RES_OK
516     *
517     */
518 aga 1.4 result_t gidsToZval( groupid_t *pGID, int len, zval **ppz )
519     {
520 aga 1.8 zend_hash_clean( Z_ARRVAL_PP(ppz) );
521 aga 1.2
522     // add GIDs
523     for ( int i = 0; i < len; i++ ){
524 aga 1.8 add_next_index_long(*ppz, (long)(pGID[i]) );
525 aga 1.2 }
526    
527     return RES_OK;
528     }
529    
530 aga 1.16
531     /**
532     *
533     * account_t????絎鴻??PHP???????????????
534     * @param pAccount 紊???????ccount_t*
535     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
536     * @return RES_OK
537     *
538     */
539 youi 1.6 result_t accountToZval( const account_t *pAccount, zval *z )
540     {
541     zend_hash_clean( z -> value.ht );
542    
543 youi 1.7 add_assoc_long( z, "uid", pAccount -> getUID( ) );
544 youi 1.6 add_assoc_string( z, "uname", ( char* )pAccount -> getUname( ), 1 );
545     add_assoc_string( z, "name", ( char* )pAccount -> getName( ), 1 );
546     add_assoc_string( z, "email", ( char* )pAccount -> getEmail( ), 1 );
547     add_assoc_string( z, "url", ( char* )pAccount -> getURL( ), 1 );
548     add_assoc_string( z, "user_avatar", ( char* )pAccount -> getUserAvatar( ), 1 );
549     add_assoc_string( z, "user_icq", ( char* )pAccount -> getUserIcq( ), 1 );
550     add_assoc_string( z, "user_from", ( char* )pAccount -> getUserFrom( ), 1 );
551     add_assoc_string( z, "user_sig", ( char* )pAccount -> getUserSig( ), 1 );
552     add_assoc_string( z, "actkey", ( char* )pAccount -> getActkey( ), 1 );
553     add_assoc_string( z, "user_aim", ( char* )pAccount -> getUserAim( ), 1 );
554     add_assoc_string( z, "user_yim", ( char* )pAccount -> getUserYim( ), 1 );
555     add_assoc_string( z, "user_msnm", ( char* )pAccount -> getUserMsnm( ), 1 );
556     add_assoc_string( z, "pass", ( char* )pAccount -> getPass( ), 1 );
557     add_assoc_string( z, "theme", ( char* )pAccount -> getTheme( ), 1 );
558     add_assoc_string( z, "umode", ( char* )pAccount -> getUmode( ), 1 );
559     add_assoc_string( z, "user_occ", ( char* )pAccount -> getUserOcc( ), 1 );
560     add_assoc_string( z, "bio", ( char* )pAccount -> getBio( ), 1 );
561     add_assoc_string( z, "user_intrest", ( char* )pAccount -> getUserIntrest( ), 1 );
562     add_assoc_double( z, "timezone_offset", pAccount -> getTimezoneOffset( ) );
563     add_assoc_long( z, "attachsig", pAccount -> getAttachsig( ) );
564     add_assoc_long( z, "last_login", pAccount -> getLastLogin( ) );
565     add_assoc_long( z, "level", pAccount -> getLevel( ) );
566     add_assoc_long( z, "notify_method", pAccount -> getNotifyMethod( ) );
567     add_assoc_long( z, "notify_mode", pAccount -> getNotifyMode( ) );
568     add_assoc_long( z, "posts", pAccount -> getPosts( ) );
569     add_assoc_long( z, "rank", pAccount -> getRank( ) );
570     add_assoc_long( z, "uorder", pAccount -> getUorder( ) );
571     add_assoc_long( z, "user_mailok", pAccount -> getUserMailok( ) );
572     add_assoc_long( z, "user_regdate", pAccount -> getUserRegdate( ) );
573     add_assoc_long( z, "user_viewemail", pAccount -> getUserViewemail( ) );
574    
575     add_assoc_long( z, "activate", pAccount -> getActivate( ) );
576     add_assoc_string( z, "address", ( char* )pAccount -> getAddress( ), 1 );
577 youi 1.15 add_assoc_string( z, "division", ( char* )pAccount -> getDivision( ), 1 );
578 youi 1.6 add_assoc_string( z, "tel", ( char* )pAccount -> getTel( ), 1 );
579 youi 1.15 add_assoc_string( z, "company_name", ( char* )pAccount -> getCompanyName( ), 1 );
580 youi 1.6 add_assoc_string( z, "country", ( char* )pAccount -> getCountry( ), 1 );
581     add_assoc_string( z, "zipcode", ( char* )pAccount -> getZipcode( ), 1 );
582     add_assoc_string( z, "fax", ( char* )pAccount -> getFax( ), 1 );
583     add_assoc_string( z, "base_url", ( char* )pAccount -> getBaseURL( ), 1 );
584     add_assoc_long( z, "notice_mail", pAccount -> getNoticeMail( ) );
585     add_assoc_long( z, "notice_mail_since", pAccount -> getNoticeMailSince( ) );
586     return RES_OK;
587     }
588 aga 1.16 /**
589     *
590     * 茲??違??ccount_t????絎鴻??PHP?????????????????????
591     * @param pAccounts 紊???????ccount_t*
592     * @param accountsLen pAccounts?????????激??
593     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
594     * @return RES_OK
595     *
596     z: ?????????????????????????? <br>
597 aga 1.2 array(
598     array(
599     'uid'=>100,
600     'activate'=>1,
601 youi 1.15 'division'=>'foo',
602 aga 1.2 'tel'=>'123-456-789',
603     ...
604     ),
605     ...
606     )
607 aga 1.16 */
608 youi 1.6 result_t accountsToZval( const account_t *pAccounts, int accountsLen, zval *z )
609 aga 1.4 {
610 youi 1.6 zend_hash_clean( z -> value.ht );
611     for( int i = 0; i < accountsLen; i++ ){
612     zval *new_array;
613     MAKE_STD_ZVAL(new_array);
614     if(array_init(new_array) != SUCCESS){
615     return RES_ERROR;
616     }
617     add_index_zval( z, i, new_array );
618     accountToZval( &pAccounts[ i ], new_array );
619     }
620     return RES_OK;
621 aga 1.2 }
622    
623 aga 1.16 /**
624     *
625     * 茲??違??roup_t????絎鴻??PHP?????????????????????
626     * @param pGroups 紊???????roup_t*
627     * @param groupsLen pGroups?????????激??
628     * @param z 紊???腟??????吾??莨若??????(??????羝??帥?с????????
629     * @return RES_OK
630     *
631     z: ?????????????????????????? <br>
632     array(
633     array(
634     'gid'=>1,
635     'gname'=>'foo group',
636     'gdesc'=>'group of foo'
637     ),
638     ...
639     )
640     */
641 youi 1.6 result_t groupsToZval( const group_t *pGroups, int groupsLen, zval *z )
642 aga 1.4 {
643 youi 1.6 zend_hash_clean( z -> value.ht );
644     for( int i = 0; i < groupsLen; i++ ){
645     zval *new_array;
646     MAKE_STD_ZVAL(new_array);
647     if(array_init(new_array) != SUCCESS){
648     return RES_ERROR;
649     }
650     add_index_zval( z, i, new_array );
651     add_assoc_long( new_array, "gid", pGroups[ i ].getGID( ) );
652     add_assoc_string( new_array, "gname", ( char* )pGroups[ i ].getGname( ), 1 );
653     add_assoc_string( new_array, "gdesc", ( char* )pGroups[ i ].getDesc( ), 1 );
654     }
655     return RES_OK;
656 aga 1.2 }
657    
658 youi 1.7 /**
659     *
660     * group_t????絎鴻??PHP???f?渇?????????????
661     *
662 aga 1.16 * @param pGroup 紊????????違???若??????/span>
663 youi 1.7 * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
664     * @return RES_OK
665     *
666     */
667     result_t groupToZval( const group_t *pGroup, zval *z )
668 youi 1.6 {
669     zend_hash_clean( z -> value.ht );
670     add_assoc_long( z, "gid", pGroup -> getGID( ) );
671     add_assoc_string( z, "gname", ( char* )pGroup -> getGname( ), 1 );
672     add_assoc_string( z, "gdesc", ( char* )pGroup -> getDesc( ), 1 );
673     return RES_OK;
674     }
675    
676 aga 1.16 /**
677     *
678     * PHP???f?渇????????絎鴻??group_t?????????
679     *
680     * @param z 紊????????f?渇????
681     * @param pGroup 紊???腟??????吾??莨若???違???若??
682     * @return RES_OK
683     *
684     */
685 youi 1.7 result_t zvalToGroup( zval *z, group_t *pGroup )
686     {
687     zval **tmp;
688     HashPosition pos;
689     int i = 0;
690     char* key = 0;
691    
692     key = "gid";
693 youi 1.12 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
694     convert_to_long_ex( tmp ) ;
695     pGroup -> setGID( (*tmp) -> value.lval );
696     }
697 youi 1.7 key = "gname";
698 youi 1.12 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
699     convert_to_string_ex( tmp ) ;
700     pGroup -> setGname( (*tmp) -> value.str.val );
701     }
702 youi 1.7 key = "gdesc";
703 youi 1.12 if( zend_hash_find( z -> value.ht, key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){
704     convert_to_string_ex( tmp ) ;
705     pGroup -> setDesc( (*tmp) -> value.str.val );
706     }
707 youi 1.7 return RES_OK;
708     }
709    
710 aga 1.16 /**
711     *
712     * session_t????絎鴻??PHP???f?渇?????????????
713     *
714     * @param pSession 紊???????ession_t
715     * @param z 紊???腟??????吾??莨若???f?渇????(??????羝??帥?с????????
716     * @return RES_OK
717     *
718     */
719     result_t sessionToZval( const session_t *pSession, zval *z )
720     {
721     string sessionID(unsignedIntToString(pSession->getSessionID()));
722     add_assoc_string(z, "session_id", (char *)sessionID.c_str(), 1);
723    
724     string date(unsignedIntToString((unsigned int)pSession->getDate()));
725     add_assoc_string(z, "date", (char *)date.c_str(), 1);
726    
727 aga 1.20 string userID(unsignedIntToString((unsigned int)pSession->getUID()));
728 aga 1.16 add_assoc_string(z, "user_id", (char *)userID.c_str(), 1);
729    
730     return RES_OK;
731     }
732    
733 youi 1.7
734 aga 1.16
735     /** ??絎??????違???若???????宴??緇???<br>
736 youi 1.21 int xnp_get_group( int sid, int gid, array group );
737     @param sid XNP???祉???激?с??D
738     @param gid XNP ? group_id
739 aga 1.16 @param group 腟?????????????????
740     @return 0 success <br>
741     */
742 youi 1.21 ZEND_FUNCTION(xnp_get_group)
743 aga 1.4 {
744 youi 1.6 long sid, gid;
745     zval *zgroup;
746    
747     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
748     &sid, &gid, &zgroup) == FAILURE) {
749     return;
750     }
751    
752     const group_t *pgroup;
753     result_t result = getGroup( (sessionid_t)sid, (groupid_t)gid, &pgroup );
754     if ( RES_OK == result ){
755 youi 1.7 groupToZval( pgroup, zgroup );
756 youi 1.19 freeGroup( pgroup );
757 youi 1.6 }
758    
759     RETURN_LONG(result);
760     }
761    
762 aga 1.2
763 aga 1.16 /** ??絎??????違???若??(茲????????宴??緇???<br>
764 youi 1.21 xnp_get_groups( int sid, array gids, array criteria, array groups );
765     @param sid XNP???祉???激?с??D
766     @param gids XNP ? group_id ??????
767 aga 1.16 @param criteria ?>散
768     @param groups 腟???????????????????????
769     @return 0 success <br>
770     */
771 youi 1.21 ZEND_FUNCTION(xnp_get_groups)
772 youi 1.6 {
773     result_t result;
774     long sid, uid;
775     zval *zcriteria;
776     zval *zgids;
777     zval *zgroups;
778     zval **ppzTmp = 0;
779     HashPosition pos;
780     int res2;
781     int gidsLen;
782     const group_t* groups;
783     int groupsLen;
784    
785     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
786     &sid, &zgids, &zcriteria, &zgroups) == FAILURE) {
787     return;
788     }
789    
790     //gids???違???若??ID???潟???若????
791     gidsLen = zend_hash_num_elements(Z_ARRVAL_P(zgids));
792     groupid_t *gids = new groupid_t[ gidsLen ];
793     zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zgids), &pos);
794     for( int i = 0; i < gidsLen; i++ ){
795     if( (res2=zend_hash_get_current_data_ex(Z_ARRVAL_P(zgids), (void **)&ppzTmp, &pos)) == SUCCESS ){
796     SEPARATE_ZVAL(ppzTmp);
797     convert_to_long_ex(ppzTmp);
798     gids[ i ] = Z_LVAL_PP(ppzTmp);
799     }
800     zend_hash_move_forward_ex(Z_ARRVAL_P(zgids), &pos);
801     }
802    
803     zCriteria_t zcri(zcriteria);
804     result = zcri.getResult();
805     if ( RES_OK == result ){
806     result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen );
807     if ( RES_OK == result ){
808 aga 1.14 groupsToZval( groups, groupsLen, zgroups );
809 youi 1.6 delete[] gids;
810 youi 1.19 freeGroup( groups );
811 youi 1.6 }
812     }
813     RETURN_LONG(result);
814     }
815    
816    
817 aga 1.16 /** ??絎????????若?吟???≪?????若?帥??????????茯帥?鴻??<br>
818 youi 1.21 int xnp_is_moderator(int sid, int uid)
819     @param sid XNP???祉???激?с??D
820 aga 1.16 @param uid xoops ? uid (xoops_users.uid)
821     @return true ?≪?????若?帥?с???? <br>
822     */
823 youi 1.21 ZEND_FUNCTION(xnp_is_moderator)
824 youi 1.6 {
825 youi 1.21 long xnpSessionID;
826 youi 1.6 userid_t uid;
827    
828     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
829 youi 1.21 &xnpSessionID, &uid) == FAILURE) {
830 youi 1.6 return;
831     }
832    
833 youi 1.21 bool result = isModerator( (sessionid_t)xnpSessionID, uid );
834 youi 1.6 RETURN_BOOL(result)
835     }
836    
837 aga 1.16 /** ???若?九??????uid??茯帥?鴻??<br>
838 youi 1.21 int xnp_get_uid(string uname,int &uid)
839     @param sid XNP???祉???激?с??D
840 aga 1.16 @param uname xoops ? uname (xoops_users.uname)
841     @param uid xoops ? uid (xoops_users.uid) ??????????紊???/span>
842     @return 0 success
843     */
844 youi 1.21 ZEND_FUNCTION(xnp_get_uid)
845 youi 1.6 {
846     char *uname;
847     int unameLen;
848 aga 1.14 zval *zuid;
849 youi 1.6 userid_t uid;
850    
851 aga 1.14 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
852     &uname, &unameLen, &zuid) == FAILURE) {
853 youi 1.6 return;
854     }
855    
856 aga 1.14 if (!PZVAL_IS_REF(zuid)) {
857     zend_error(E_WARNING, "2nd parameter wasn't passed by reference");
858     RETURN_LONG(RES_PHP_NONREF);
859     }
860    
861 youi 1.6 string strUname( uname, unameLen );
862     result_t result = getUid( strUname.c_str(), &uid );
863 aga 1.14 ZVAL_LONG(zuid, (long)uid);
864     RETURN_LONG((long)result);
865 aga 1.2 }
866    
867 youi 1.21 ZEND_FUNCTION(xnp_test_criteria)
868 aga 1.2 {
869     zval *z;
870    
871     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
872     &z) == FAILURE) {
873     return;
874     }
875     zend_printf("zend_printf...<br>\n");
876     zCriteria_t zcri(z);
877     zcri.dump();
878     RETURN_FALSE
879     }
880    
881 youi 1.21 ZEND_FUNCTION(xnp_test_uids)
882 aga 1.2 {
883     zval *z;
884    
885     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a",
886     &z) == FAILURE) {
887     return;
888     }
889     zend_printf("zend_printf...<br>\n");
890     zUIDs_t zuids(z);
891     zuids.dump();
892     RETURN_FALSE
893     }
894    
895    
896    
897 aga 1.4 /** DB??・膓????????≪??・膓?筝???・膓???????????????<br>
898     int initialize_db( string host[, string user[, string password[, string dbname[, string prefix]]]] );
899 aga 1.2 @param host ?ョ????????ユ????ULL
900 aga 1.1 @param user DB?ョ????????若?九???????ユ????ULL
901     @param password DB?ョ????????鴻???若???????ユ????ULL
902 aga 1.2 @param dbname DB?ョ?????B???????ユ????quot;"
903     @param prefix XOOPS DB ??refix??
904 aga 1.1 @return 0 success <br>
905     */
906 youi 1.21 ZEND_FUNCTION(xnp_initialize_db)
907 aga 1.1 {
908     zval **parameters[5];
909     char *host;
910     char *user;
911 aga 1.2 char *password;
912     char *dbname;
913     char *prefix;
914 aga 1.1
915     /* get the number of arguments */
916     int argNum = ZEND_NUM_ARGS();
917     if (argNum > 5)
918     WRONG_PARAM_COUNT;
919    
920     /* argument count is correct, now retrieve arguments */
921     if(zend_get_parameters_array_ex(argNum, parameters) != SUCCESS)
922     WRONG_PARAM_COUNT;
923    
924 aga 1.2 if (argNum < 1) host = NULL;
925 aga 1.1 else host = getZvalString( parameters[0] );
926    
927     if (argNum < 2) user = NULL;
928     else user = getZvalString( parameters[1] );
929    
930 aga 1.2 if (argNum < 3) password = NULL;
931     else password = getZvalString( parameters[2] );
932 aga 1.1
933 aga 1.2 if (argNum < 4) dbname = "";
934     else dbname = getZvalString( parameters[3] );
935 aga 1.1
936 aga 1.2 if (argNum < 5) prefix = "";
937     else prefix = getZvalString( parameters[4] );
938 aga 1.1
939 aga 1.2 result_t result = initializeDB( host, user, password, dbname, prefix );
940 aga 1.1
941 aga 1.2 RETURN_LONG(result);
942 aga 1.1 }
943    
944 aga 1.4 /** ???違?ゃ?潟??????<br>
945 youi 1.21 int xnp_login_user(string uname, string password, int &session_id)
946 aga 1.4 @param uname ???若?九??(xoops_users.uname)
947     @param password ???鴻???若??(md5(password)=xoops_users.pass)
948     @return 0 success
949     */
950 youi 1.21 ZEND_FUNCTION(xnp_login_user)
951 aga 1.1 {
952     char *uname;
953     int unameLen;
954     char *passwd;
955     int passwdLen;
956 youi 1.21 zval *zXNPSessionID;
957 aga 1.1
958 aga 1.14 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssz",
959 youi 1.21 &uname, &unameLen, &passwd, &passwdLen, &zXNPSessionID) == FAILURE) {
960 aga 1.1 return;
961     }
962    
963 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
964 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
965     RETURN_LONG(RES_PHP_NONREF);
966     }
967    
968 youi 1.21 sessionid_t xnpSessionID;
969     result_t result = loginUser( uname, passwd, &xnpSessionID );
970 aga 1.14 if ( result == RES_OK )
971 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
972 aga 1.14 RETURN_LONG((long)result);
973 aga 1.1 }
974    
975 aga 1.4 /** ???違?≪??????????<br>
976 youi 1.21 void xnp_logout_user(int xnp_session_id)
977     @param xnp_session_id XNP???祉???激?с??D
978 aga 1.4 @return ????
979     */
980 youi 1.21 ZEND_FUNCTION(xnp_logout_user)
981 aga 1.1 {
982 youi 1.21 long xnpSessionID;
983 aga 1.1
984 youi 1.21 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &xnpSessionID) == FAILURE) {
985 aga 1.1 return;
986     }
987 youi 1.21 logoutUser( (sessionid_t)xnpSessionID );
988 aga 1.1
989     RETURN_NULL();
990     }
991    
992 youi 1.21 /** XNP???祉???激?с??D 篏???<br>
993     int xnp_create_session( string xoops_sess_id, int uid, int &session )
994 aga 1.16 @param xoops_sess_id xoops???祉???激?с??D
995 aga 1.4 @param uid xoops ? uid (xoops_users.uid)
996 youi 1.21 @param session 篏???????XNP??ession??????????紊???/span>
997 aga 1.14 @return 0 ????
998 aga 1.4 */
999 youi 1.21 ZEND_FUNCTION(xnp_create_session)
1000 aga 1.2 {
1001     char *xoopsSessionID;
1002     int xoopsSessionIDLen;
1003 aga 1.5 long uid;
1004 youi 1.21 zval *zXNPSessionID;
1005 aga 1.2
1006 aga 1.14 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slz",
1007 youi 1.21 &xoopsSessionID, &xoopsSessionIDLen, &uid, &zXNPSessionID) == FAILURE) {
1008 aga 1.2 return;
1009     }
1010    
1011 youi 1.21 if (!PZVAL_IS_REF(zXNPSessionID)) {
1012 aga 1.14 zend_error(E_WARNING, "3rd parameter wasn't passed by reference");
1013     RETURN_LONG(RES_PHP_NONREF);
1014     }
1015    
1016 youi 1.21 sessionid_t xnpSessionID = 0;
1017     result_t result = createSession( xoopsSessionID, (userid_t)uid, &xnpSessionID );
1018 aga 1.14 if ( result == RES_OK )
1019 youi 1.21 ZVAL_LONG(zXNPSessionID, (long)xnpSessionID);
1020 aga 1.14 RETURN_LONG((long)result);
1021 aga 1.4 }
1022    
1023 youi 1.21 /** XNP ? session ???膣井???宴??緇???<br>
1024     int xnp_get_session( int xnp_session_id, array session_info )
1025     @param xnp_session_id XNP???祉???激?с??D
1026 aga 1.4 @param session_info 腟?????????????????
1027     @return 0 success
1028     */
1029 youi 1.21 ZEND_FUNCTION(xnp_get_session)
1030 aga 1.4 {
1031 youi 1.21 long xnpSessionID;
1032 aga 1.4 zval *sessionInfo;
1033     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1034 youi 1.21 &xnpSessionID, &sessionInfo) == FAILURE) {
1035 aga 1.4 return;
1036     }
1037     const session_t *session = 0;
1038 youi 1.21 result_t result = getSession( (sessionid_t)xnpSessionID, &session );
1039 aga 1.4 if ( result == RES_OK ){
1040     sessionToZval( session, sessionInfo );
1041 youi 1.19 freeSession( session );
1042 aga 1.4 }
1043 aga 1.2
1044 aga 1.4 RETURN_LONG((long)result);
1045 aga 1.2 }
1046 aga 1.1
1047 aga 1.16 /** ???若?吟??ctivate?倶??????緇?????<br>
1048 youi 1.21 bool xnp_is_activated( int xnp_session_id, int user_id )
1049     @param xnp_session_id XNP???祉???激?с??D
1050 aga 1.5 @param user_id xoops_users.uid
1051     @return 0 success
1052     */
1053 youi 1.21 ZEND_FUNCTION(xnp_is_activated)
1054 aga 1.2 {
1055     long sid, uid;
1056    
1057 aga 1.5 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &sid, &uid) == FAILURE) {
1058 aga 1.2 return;
1059     }
1060    
1061     bool result = isActivated( (sessionid_t)sid, (userid_t)uid );
1062    
1063     RETURN_BOOL(result);
1064     }
1065 aga 1.1
1066 youi 1.17 /** activate??????<br>
1067 youi 1.21 bool xnp_activate( int xnp_session_id, int user_id, bool activated )
1068     @param xnp_session_id xnp ? session id
1069 aga 1.5 @param user_id xoops_users.uid
1070     @param activated true:activate, false:inactivate
1071     @return 0 success
1072     */
1073 youi 1.21 ZEND_FUNCTION(xnp_activate)
1074 aga 1.2 {
1075     long sid, uid;
1076     bool activated;
1077    
1078     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llb",
1079     &sid, &uid, &activated) == FAILURE) {
1080     return;
1081     }
1082    
1083     result_t result = activate( (sessionid_t)sid, (userid_t)uid, activated );
1084    
1085     RETURN_LONG(result);
1086     }
1087 aga 1.1
1088 youi 1.21 /** XNP???≪?????潟???違??緇?????<br>
1089     int xnp_get_account_count( int xnp_session_id )
1090     @param xnp_session_id XNP???祉???激?с??D
1091 aga 1.5 @return 0 success
1092     */
1093 youi 1.21 ZEND_FUNCTION(xnp_get_account_count)
1094 aga 1.2 {
1095     long sid;
1096    
1097     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1098     &sid) == FAILURE) {
1099     return;
1100     }
1101    
1102     long count = getAccountCount( (sessionid_t)sid );
1103     RETURN_LONG(count);
1104     }
1105 aga 1.1
1106 aga 1.5 /** ?≪?????潟???????ゃ??????<br>
1107 youi 1.21 bool xnp_delete_account( int xnp_session_id, int user_id )
1108     @param xnp_session_id XNP???祉???激?с??D
1109 aga 1.5 @param user_id xoops_users.uid
1110     @return 0 success
1111     */
1112 youi 1.21 ZEND_FUNCTION(xnp_delete_account)
1113 aga 1.2 {
1114     long sid, uid;
1115    
1116     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1117     &sid, &uid) == FAILURE) {
1118     return;
1119     }
1120    
1121     result_t result = deleteAccount( (sessionid_t)sid, (userid_t)uid );
1122    
1123     RETURN_LONG(result);
1124     }
1125 aga 1.1
1126 aga 1.5 /** ?≪?????潟?????宴??緇?????<br>
1127 youi 1.21 int xnp_get_account( int xnp_session_id, int user_id, array account_info )
1128     @param xnp_session_id XNP???祉???激?с??D
1129 aga 1.5 @param user_id xoops_users.uid
1130     @param account_info ?≪?????潟?????宴???????????f?渇????
1131     @return 0 success
1132     */
1133 youi 1.21 ZEND_FUNCTION(xnp_get_account)
1134 aga 1.2 {
1135     long sid, uid;
1136     zval *zaccount;
1137    
1138     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lla",
1139     &sid, &uid, &zaccount) == FAILURE) {
1140 youi 1.6 fprintf( stderr, "error occured " );
1141 aga 1.2 return;
1142     }
1143    
1144     const account_t *paccount;
1145     result_t result = getAccount( (sessionid_t)sid, (userid_t)uid, &paccount );
1146     if ( RES_OK == result ){
1147     accountToZval( paccount, zaccount );
1148 youi 1.19 freeAccount( paccount );
1149 aga 1.2 }
1150    
1151     RETURN_LONG(result);
1152     }
1153 aga 1.1
1154 aga 1.5 /** ?>散????眼?????≪?????潟???????宴??緇?????<br>
1155 youi 1.21 int xnp_get_accoutns( int sid, array uids, array criteria, array accounts );
1156     @param xnp_session_id XNP???祉???激?с??D
1157 aga 1.5 @param user_id xoops_users.uid
1158     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1159     @param account_info ?≪?????潟?????宴???????????f?渇????
1160     @return 0 success
1161     */
1162 youi 1.21 ZEND_FUNCTION(xnp_get_accounts)
1163 aga 1.2 {
1164     result_t result;
1165     long sid;
1166     zval *zuids;
1167     zval *zcriteria;
1168     zval *zaccount;
1169    
1170     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laaa",
1171     &sid, &zuids, &zcriteria, &zaccount) == FAILURE) {
1172     return;
1173     }
1174    
1175     zCriteria_t zcri(zcriteria);
1176     result = zcri.getResult();
1177     if ( RES_OK == result ){
1178     zUIDs_t zUIDs(zuids);
1179     result = zUIDs.getResult();
1180     if ( RES_OK == result ){
1181     const account_t *paccounts;
1182     int accountLen;
1183     result = getAccounts( (sessionid_t)sid,
1184     zUIDs.getPUID(), zUIDs.getLen(),
1185     &zcri, &paccounts, &accountLen );
1186     if ( RES_OK == result ){
1187     accountsToZval( paccounts, accountLen, zaccount );
1188 youi 1.19 freeAccount( paccounts );
1189 aga 1.2 }
1190     }
1191     }
1192    
1193     RETURN_LONG(result);
1194     }
1195 aga 1.1
1196 youi 1.17 /** ?≪?????潟?????宴??荐??蚊??????<br>
1197 youi 1.21 int xnp_insert_account( int sid, array account_info, int &user_id );
1198     @param xnp_session_id xnp ? session id
1199 youi 1.17 @param account_info 荐??蚊???????≪?????潟????????/span>
1200     @param user_id ???若??D(xoops_users.uid)???吾??莨若???????<???潟??/span>
1201 aga 1.5 @return 0 success
1202     */
1203 youi 1.21 ZEND_FUNCTION(xnp_insert_account)
1204 aga 1.2 {
1205     result_t result;
1206     long sid;
1207     zval *zaccount;
1208 youi 1.17 zval *zuid;
1209     userid_t uid;
1210 aga 1.2
1211 youi 1.17 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
1212     &sid, &zaccount, &zuid) == FAILURE) {
1213 aga 1.2 return;
1214     }
1215    
1216     zAccount_t zacc(zaccount);
1217     result = zacc.getResult();
1218     if ( RES_OK == result ){
1219 youi 1.17 result = insertAccount( (sessionid_t)sid, &zacc, &uid );
1220 aga 1.2 }
1221 youi 1.17 zuid -> type = IS_LONG;
1222     zuid -> value.lval = uid;
1223 aga 1.2 RETURN_LONG(result);
1224     }
1225 aga 1.1
1226 aga 1.5 /** ?≪?????潟?????宴???贋?違??????<br>
1227 youi 1.21 int xnp_update_account( int sid, array account );
1228     @param xnp_session_id XNP???祉???激?с??D
1229 aga 1.5 @param account_info ?吾??莨若???鴻???≪?????潟?????宴??茵????f?渇????
1230     @return 0 success
1231     */
1232 youi 1.21 ZEND_FUNCTION(xnp_update_account)
1233 aga 1.2 {
1234     result_t result;
1235     long sid;
1236     zval *zaccount;
1237    
1238     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1239     &sid, &zaccount) == FAILURE) {
1240     return;
1241     }
1242    
1243     zAccount_t zacc(zaccount);
1244     result = zacc.getResult();
1245     if ( RES_OK == result ){
1246     result = updateAccount( (sessionid_t)sid, &zacc );
1247     }
1248    
1249     RETURN_LONG(result);
1250     }
1251 aga 1.1
1252 aga 1.5 /** ?>散???????≪?????潟????id???荀с??緇?????<br>
1253 youi 1.21 int xnp_dump_uids( int xnp_session_id, array criteria, array uids );
1254     @param xnp_session_id XNP???祉???激?с??D
1255 aga 1.5 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1256     @param uids uid??????????????
1257     @return 0 success
1258     */
1259 youi 1.21 ZEND_FUNCTION(xnp_dump_uids)
1260 aga 1.2 {
1261     result_t result;
1262     long sid;
1263     zval *zcriteria;
1264     zval *zuids;
1265    
1266     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1267     &sid, &zcriteria, &zuids) == FAILURE) {
1268     return;
1269     }
1270    
1271     zCriteria_t zcri(zcriteria);
1272     result = zcri.getResult();
1273     if ( RES_OK == result ){
1274     userid_t *puid;
1275     int uidLen;
1276     result = dumpUids( (sessionid_t)sid, &zcri, &puid, &uidLen );
1277     if ( RES_OK == result ){
1278     uidsToZval( puid, uidLen, &zuids );
1279 youi 1.19 freeUID( puid );
1280 aga 1.2 }
1281     }
1282    
1283     RETURN_LONG(result);
1284     }
1285 aga 1.1
1286 youi 1.21 /** XNP???違???若?????違??緇???<br>
1287     int xnp_get_group_count( int xnp_session_id );
1288     @param xnp_session_id XNP???祉???激?с??D
1289 aga 1.5 @return ?違???若????/span>
1290     */
1291 youi 1.21 ZEND_FUNCTION(xnp_get_group_count)
1292 aga 1.1 {
1293 aga 1.2 result_t result;
1294     long sid;
1295    
1296     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
1297     &sid) == FAILURE) {
1298     return;
1299     }
1300    
1301     int count = getGroupCount( (sessionid_t)sid );
1302    
1303     RETURN_LONG(count);
1304     }
1305 aga 1.1
1306 aga 1.5 /** uid?ф??絎????????若?吟??絮????違???若???с?????ゆ?>散????眼?????違???若????id??緇???<br>
1307 youi 1.21 int xnp_get_group_by_uid( int xnp_session_id, int uid, array criteria, array gids );
1308     @param xnp_session_id XNP???祉???激?с??D
1309 aga 1.5 @param user_id xoops_users.uid
1310     @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1311     @param gids gid??????????????
1312     @return 0 success
1313     */
1314 youi 1.21 ZEND_FUNCTION(xnp_get_groups_by_uid)
1315 aga 1.2 {
1316     result_t result;
1317     long sid, uid;
1318     zval *zcriteria;
1319     zval *zgids;
1320    
1321     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1322     &sid, &uid, &zcriteria, &zgids) == FAILURE) {
1323     return;
1324 aga 1.1 }
1325    
1326 aga 1.2 zCriteria_t zcri(zcriteria);
1327     result = zcri.getResult();
1328     if ( RES_OK == result ){
1329     groupid_t *pgids;
1330     int gidLen;
1331     result = getGroupsByUid( (sessionid_t)sid, (userid_t)uid, &zcri, &pgids, &gidLen );
1332     if ( RES_OK == result ){
1333     gidsToZval( pgids, gidLen, &zgids );
1334 youi 1.19 freeGID( pgids );
1335 aga 1.2 }
1336 aga 1.1 }
1337    
1338 aga 1.2 RETURN_LONG(result);
1339     }
1340    
1341    
1342 aga 1.5
1343     /** uid?ф??絎????????若?吟??gid?ф??絎??????違???若?????違???若??膊∞??????????????緇???<br>
1344 youi 1.21 int xnp_is_group_admin( int sid, int gid, int uid );
1345     @param xnp_session_id XNP???祉???激?с??D
1346     @param group_id XNP???違???若??ID
1347 aga 1.5 @param user_id xoops_users.uid
1348     @return true: ?違???若??膊∞?????с??????
1349     @return false: ?違???若??膊∞?????с???????????????????若?с??????
1350     */
1351 youi 1.21 ZEND_FUNCTION(xnp_is_group_admin)
1352 aga 1.2 {
1353     result_t result;
1354     long sid, gid, uid;
1355    
1356     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1357     &sid, &gid, &uid) == FAILURE) {
1358     return;
1359 aga 1.1 }
1360    
1361 aga 1.2 bool b = isGroupAdmin( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1362 aga 1.1
1363 aga 1.2 RETURN_BOOL(b);
1364     }
1365    
1366 aga 1.5 /** ?>散????眼?????違???若????id???荀с??緇?????<br>
1367 youi 1.21 int xnp_dump_gids( int sid, array criteria, array gids );
1368     @param xnp_session_id XNP???祉???激?с??D
1369 aga 1.5 @param criteria ??緇?膀??蚊?祉?純?若??????茵???????
1370     @param gids gid??????????????
1371     @return 0 success
1372     */
1373 youi 1.21 ZEND_FUNCTION(xnp_dump_gids)
1374 aga 1.2 {
1375     result_t result;
1376     long sid;
1377     zval *zcriteria;
1378     zval *zgids;
1379    
1380     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laa",
1381     &sid, &zcriteria, &zgids) == FAILURE) {
1382     return;
1383     }
1384 aga 1.1
1385 aga 1.2 zCriteria_t zcri(zcriteria);
1386     result = zcri.getResult();
1387     if ( RES_OK == result ){
1388     groupid_t *pgid;
1389     int gidLen;
1390     result = dumpGids( (sessionid_t)sid, &zcri, &pgid, &gidLen );
1391     if ( RES_OK == result ){
1392     gidsToZval( pgid, gidLen, &zgids );
1393 youi 1.19 freeGID( pgid );
1394 aga 1.1 }
1395     }
1396    
1397 aga 1.2 RETURN_LONG(result);
1398 aga 1.1 }
1399 aga 1.8
1400     /** gid?ф??絎??????違???若??????????с?????ゆ?>散????眼?????違???若??膊∞??????id???荀с??緇?????<br>
1401 youi 1.21 int xnp_dump_group_admins(int sid, int group_id, array criteria, array uids )
1402     @param sid XNP???祉???激?с??D
1403     @param group_id XNP???違???若??ID
1404 aga 1.8 @param criteria ?>散
1405     @param uids uid???荀с??????????????
1406     @return 0 success
1407     */
1408    
1409 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
1410 aga 1.8 {
1411     long sid, gid;
1412     zval *zcriteria;
1413     zval *zuids;
1414    
1415     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1416     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1417     return;
1418     }
1419    
1420     zCriteria_t zcri(zcriteria);
1421     result_t result = zcri.getResult();
1422     if ( result == RES_OK ){
1423     userid_t *uids;
1424     int uidsLen;
1425     result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1426     if ( result == RES_OK ){
1427     uidsToZval( uids, uidsLen, &zuids );
1428 youi 1.19 freeUID( uids );
1429 aga 1.8 }
1430     }
1431     RETURN_LONG( result );
1432     }
1433    
1434 aga 1.11 /** ?違???若???????<?潟???若?????ゃ??????<br>
1435 youi 1.21 int xnp_delete_member(int sid, int group_id, int user_id )
1436     @param sid XNP???祉???激?с??D
1437     @param group_id XNP???違???若??ID
1438 aga 1.11 @param user_id ???若??D
1439     @return 0 success
1440     */
1441    
1442 youi 1.21 ZEND_FUNCTION(xnp_delete_member)
1443 aga 1.11 {
1444     long sid, gid, uid;
1445    
1446     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
1447     &sid, &gid, &uid) == FAILURE) {
1448     return;
1449     }
1450    
1451     result_t result = deleteMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid );
1452     RETURN_LONG( result );
1453     }
1454    
1455     /** ?違???若?????<?潟???若??菴遵??????<br>
1456 youi 1.21 int xnp_insert_member(int sid, int group_id, int user_id, bool admin )
1457     @param sid XNP???祉???激?с??D
1458     @param group_id XNP???違???若??ID
1459 aga 1.11 @param user_id ???若??D
1460     @param admin ?違???若??膊∞????????true
1461     @return 0 success
1462     */
1463    
1464 youi 1.21 ZEND_FUNCTION(xnp_insert_member)
1465 aga 1.11 {
1466     long sid, gid, uid;
1467     zend_bool admin;
1468    
1469     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllb",
1470     &sid, &gid, &uid, &admin) == FAILURE) {
1471     return;
1472     }
1473    
1474     result_t result = insertMember( (sessionid_t)sid, (groupid_t)gid, (userid_t)uid, (bool)admin );
1475     RETURN_LONG( result );
1476     }
1477    
1478     /** gid?ф??絎??????違???若?????<?潟???若??id???荀с??緇???<br>
1479 youi 1.21 int xnp_get_members(int sid, int group_id, array criteria, array uids )
1480     @param sid XNP???祉???激?с??D
1481     @param group_id XNP???違???若??ID
1482 aga 1.11 @param criteria ?>散
1483     @param uids uid???荀с??????????????
1484     @return 0 success
1485     */
1486    
1487 youi 1.21 ZEND_FUNCTION(xnp_get_members)
1488 aga 1.11 {
1489     long sid, gid;
1490     zval *zcriteria;
1491     zval *zuids;
1492    
1493     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1494     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1495     return;
1496     }
1497    
1498     zCriteria_t zcri(zcriteria);
1499     result_t result = zcri.getResult();
1500     if ( result == RES_OK ){
1501     userid_t *uids;
1502     int uidsLen;
1503     result = getMembers( (sessionid_t)sid, (groupid_t)gid, &zcri, &uids, &uidsLen );
1504     if ( result == RES_OK ){
1505     uidsToZval( uids, uidsLen, &zuids );
1506 youi 1.19 freeUID( uids );
1507 aga 1.11 }
1508     }
1509     RETURN_LONG( result );
1510     }
1511 youi 1.7
1512     /** ?違???若?????宴??紊??眼??????<br>
1513 youi 1.21 int xnp_update_group(int sid, array group )
1514     @param sid XNP???祉???激?с??D
1515 youi 1.7 @param group ?違???若?????宴???f?渇????
1516     @return 0 success
1517     */
1518 youi 1.21 ZEND_FUNCTION(xnp_update_group)
1519 youi 1.7 {
1520     long sid;
1521     zval *zgroup;
1522     group_t group;
1523    
1524     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la",
1525     &sid, &zgroup) == FAILURE) {
1526     return;
1527     }
1528    
1529     zvalToGroup( zgroup, &group );
1530     result_t result = updateGroup( sid, &group );
1531     RETURN_LONG( result );
1532 aga 1.10 }
1533    
1534 youi 1.12 /** ?違???若?????宴??菴遵????????<br>
1535 youi 1.21 int xnp_insert_group( int sid, array group, int &gid )
1536 youi 1.17 @param sid ?祉???激?с??D
1537 youi 1.12 @param group ?違???若?????宴???f?渇????
1538 youi 1.17 @param gid 絲上??????違???若??ID???吾??莨若???????<???潟??/span>
1539 youi 1.12 @return RES_OK
1540     @return RES_DB_NOT_INITIALIZED
1541     @return RES_NO_SUCH_SESSION
1542     @return RES_DB_QUERY_ERROR
1543     */
1544 youi 1.21 ZEND_FUNCTION(xnp_insert_group)
1545 youi 1.12 {
1546     long sid;
1547     zval *zgroup;
1548 youi 1.17 zval *zgid;
1549 youi 1.12 group_t group;
1550 youi 1.17 groupid_t gid;
1551 youi 1.12
1552 youi 1.17 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "laz",
1553     &sid, &zgroup, &zgid ) == FAILURE) {
1554 youi 1.12 return;
1555     }
1556    
1557     zvalToGroup( zgroup, &group );
1558 youi 1.17 result_t result = insertGroup( sid, &group, &gid );
1559     zgid -> type = IS_LONG;
1560     zgid -> value.lval = gid;
1561 youi 1.12 RETURN_LONG( result );
1562     }
1563    
1564    
1565     /** ?違???若?????宴?????ゃ??????<br>
1566 youi 1.21 int xnp_delete_group( int sid, int gid )
1567     @param sid XNP???祉???激?с??D
1568 youi 1.12 @param gid ???ゃ???????違???若????D
1569     @return RES_OK
1570     @return RES_DB_QUERY_ERROR
1571     @return RES_NO_SUCH_SESSION
1572     @return RES_DB_NOT_INITIALIZED
1573     */
1574 youi 1.21 ZEND_FUNCTION(xnp_delete_group)
1575 youi 1.12 {
1576     long sid;
1577     long gid;
1578    
1579     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
1580     &sid, &gid) == FAILURE) {
1581     return;
1582     }
1583     RETURN_LONG( deleteGroup( sid, gid ) );
1584     }
1585    
1586     /** ?違???若?????????????緇???<br>
1587 youi 1.21 int xnp_dump_group_admins( int sid, int gid, array criteria, array uids )
1588     @param sid XNP???祉???激?с??D
1589     @param gid XNP?違???若????D
1590 youi 1.12 @param criteria uids???吾??莨若?????????純?若???>散鐚?膀??蚊????絎?
1591     @param uids 膊∞??????ID???吾??莨若??????
1592     @return RES_OK
1593     @return RES_DB_QUERY_ERROR
1594     @return RES_NO_SUCH_SESSION
1595     @return RES_DB_NOT_INITIALIZED
1596     */
1597     /*
1598 youi 1.21 ZEND_FUNCTION(xnp_dump_group_admins)
1599 youi 1.12 {
1600     long sid;
1601     long gid;
1602     zval *zcriteria;
1603     zval *zuids;
1604    
1605     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llaa",
1606     &sid, &gid, &zcriteria, &zuids) == FAILURE) {
1607     return;
1608     }
1609     zCriteria_t zcri(zcriteria);
1610     result_t result = zcri.getResult();
1611     if ( RES_OK == result ){
1612     userid_t* uids;
1613     int uidsLen;
1614     result_t result = dumpGroupAdmins( sid, gid, &zcri, &uids, &uidsLen );
1615     if( result != RES_OK ) RETURN_LONG( result );
1616     uidsToZval( uids, uidsLen, &zuids );
1617     fprintf( stderr, "uidsLen=%d\n", uidsLen );
1618     for( int i = 0; i < uidsLen; i++ ){
1619     fprintf( stderr, "%d, \n", uids[ i ] );
1620     }
1621 youi 1.19 freeUID( uids );
1622 youi 1.12 RETURN_LONG( result );
1623     }
1624     RETURN_LONG( result );
1625     }
1626     */
1627    
1628 youi 1.21 /** XNP??ession_id???綵??с???с????lt;br>
1629     bool xnp_is_valid_session_id( int xnp_session_id)
1630     @return true ???鴻??NP??ession_id?с????<br>
1631 aga 1.10 @return false ?≦?鴻??ession_id?障??????????/span>
1632     */
1633 youi 1.21 ZEND_FUNCTION(xnp_is_valid_session_id)
1634 aga 1.10 {
1635     long sid;
1636     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sid ) == FAILURE) {
1637     return;
1638     }
1639    
1640     RETURN_BOOL(isValidSessionID((sessionid_t)sid));
1641 aga 1.9 }
1642    
1643     /** ?????惹??絖?????緇???<br>
1644 youi 1.21 string xnp_get_last_error_string()
1645 aga 1.9 @return 0 success
1646     */
1647 youi 1.21 ZEND_FUNCTION(xnp_get_last_error_string)
1648 aga 1.9 {
1649     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "" ) == FAILURE) {
1650     return;
1651     }
1652    
1653     string str( getLastErrorString() );
1654     RETURN_STRING((char *)str.c_str(), 1);
1655 youi 1.7 }
1656    

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26