| 194 |
ulong index = 0; |
ulong index = 0; |
| 195 |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
| 196 |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
| 197 |
print_hash_key( keyType, key, keyLen, index ); |
//print_hash_key( keyType, key, keyLen, index ); |
| 198 |
if ( strncasecmp( key, "column", keyLen ) == 0 && keyLen == 7 ){ |
if ( strncasecmp( key, "name", keyLen ) == 0 && keyLen == 5 ){ |
| 199 |
SEPARATE_ZVAL(ppzTmp); |
SEPARATE_ZVAL(ppzTmp); |
| 200 |
column = getZvalString(ppzTmp); |
column = getZvalString(ppzTmp); |
| 201 |
// zend_printf( "column=%s<br>\n", column ); |
// zend_printf( "column=%s<br>\n", column ); |
| 231 |
ulong index = 0; |
ulong index = 0; |
| 232 |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
| 233 |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
| 234 |
print_hash_key( keyType, key, keyLen, index ); |
//print_hash_key( keyType, key, keyLen, index ); |
| 235 |
setOrder( *ppzTmp ); |
setOrder( *ppzTmp ); |
| 236 |
} |
} |
| 237 |
zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos); |
zend_hash_move_forward_ex(Z_ARRVAL_P(pz), &pos); |
| 250 |
ulong index = 0; |
ulong index = 0; |
| 251 |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
int keyType = zend_hash_get_current_key_ex(Z_ARRVAL_P(pz), &key, &keyLen, &index, false/*duplicate flag*/, &pos ); |
| 252 |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
if ( keyType == HASH_KEY_IS_STRING/*1*/ || keyType == HASH_KEY_IS_LONG/*2*/ ){ |
| 253 |
print_hash_key( keyType, key, keyLen, index ); |
//print_hash_key( keyType, key, keyLen, index ); |
| 254 |
if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){ |
if ( strncasecmp( key, "start", keyLen ) == 0 && keyLen == 6 ){ |
| 255 |
SEPARATE_ZVAL(ppzTmp); |
SEPARATE_ZVAL(ppzTmp); |
| 256 |
int tmp = getZvalInt(ppzTmp); |
int tmp = getZvalInt(ppzTmp); |
| 292 |
} |
} |
| 293 |
}; |
}; |
| 294 |
|
|
| 295 |
|
bool hashGetLong( HashTable *ht, const char *key, long *val ){ |
| 296 |
|
zval **tmp; |
| 297 |
|
if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){ |
| 298 |
|
convert_to_long_ex( tmp ); |
| 299 |
|
*val = Z_LVAL_PP(tmp); |
| 300 |
|
return true; |
| 301 |
|
} |
| 302 |
|
return false; |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
bool hashGetString( HashTable *ht, const char *key, char **val ){ |
| 306 |
|
zval **tmp; |
| 307 |
|
if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){ |
| 308 |
|
convert_to_string_ex( tmp ); |
| 309 |
|
*val = Z_STRVAL_PP(tmp); |
| 310 |
|
return true; |
| 311 |
|
} |
| 312 |
|
return false; |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
bool hashGetDouble( HashTable *ht, const char *key, double *val ){ |
| 316 |
|
zval **tmp; |
| 317 |
|
if( zend_hash_find( ht, (char *)key, strlen( key ) + 1, ( void** )&tmp ) == SUCCESS ){ |
| 318 |
|
convert_to_double_ex( tmp ); |
| 319 |
|
*val = Z_DVAL_PP(tmp); |
| 320 |
|
return true; |
| 321 |
|
} |
| 322 |
|
return false; |
| 323 |
|
} |
| 324 |
|
|
| 325 |
class zAccount_t : public account { |
class zAccount_t : public account { |
| 326 |
private: |
private: |
| 327 |
result_t result; |
result_t result; |
| 328 |
public: |
public: |
| 329 |
void initialize(zval *pz){ |
void initialize(zval *pz){ |
| 330 |
; // todo |
HashTable *ht = Z_ARRVAL_P(pz); |
| 331 |
|
long l; |
| 332 |
|
char *p; |
| 333 |
|
double d; |
| 334 |
|
if ( hashGetLong ( ht, "uid" , &l ) ) setUID ( l ); |
| 335 |
|
if ( hashGetString( ht, "uname" , &p ) ) setUname ( p ); |
| 336 |
|
if ( hashGetString( ht, "name" , &p ) ) setName ( p ); |
| 337 |
|
if ( hashGetString( ht, "email" , &p ) ) setEmail ( p ); |
| 338 |
|
if ( hashGetString( ht, "url" , &p ) ) setURL ( p ); |
| 339 |
|
if ( hashGetString( ht, "user_avatar" , &p ) ) setUserAvatar ( p ); |
| 340 |
|
if ( hashGetString( ht, "user_icq" , &p ) ) setUserIcq ( p ); |
| 341 |
|
if ( hashGetString( ht, "user_from" , &p ) ) setUserFrom ( p ); |
| 342 |
|
if ( hashGetString( ht, "user_sig" , &p ) ) setUserSig ( p ); |
| 343 |
|
if ( hashGetString( ht, "actkey" , &p ) ) setActkey ( p ); |
| 344 |
|
if ( hashGetString( ht, "user_aim" , &p ) ) setUserAim ( p ); |
| 345 |
|
if ( hashGetString( ht, "user_yim" , &p ) ) setUserYim ( p ); |
| 346 |
|
if ( hashGetString( ht, "user_msnm" , &p ) ) setUserMsnm ( p ); |
| 347 |
|
if ( hashGetString( ht, "pass" , &p ) ) setPass ( p ); |
| 348 |
|
if ( hashGetString( ht, "theme" , &p ) ) setTheme ( p ); |
| 349 |
|
if ( hashGetString( ht, "umode" , &p ) ) setUmode ( p ); |
| 350 |
|
if ( hashGetString( ht, "user_occ" , &p ) ) setUserOcc ( p ); |
| 351 |
|
if ( hashGetString( ht, "bio" , &p ) ) setBio ( p ); |
| 352 |
|
if ( hashGetString( ht, "user_intrest" , &p ) ) setUserIntrest ( p ); |
| 353 |
|
if ( hashGetDouble( ht, "timezone_offset" , &d ) ) setTimezoneOffset ( d ); |
| 354 |
|
if ( hashGetLong ( ht, "attachsig" , &l ) ) setAttachsig ( l ); |
| 355 |
|
if ( hashGetLong ( ht, "last_login" , &l ) ) setLastLogin ( l ); |
| 356 |
|
if ( hashGetLong ( ht, "level" , &l ) ) setLevel ( l ); |
| 357 |
|
if ( hashGetLong ( ht, "notify_method" , &l ) ) setNotifyMethod ( l ); |
| 358 |
|
if ( hashGetLong ( ht, "notify_mode" , &l ) ) setNotifyMode ( l ); |
| 359 |
|
if ( hashGetLong ( ht, "posts" , &l ) ) setPosts ( l ); |
| 360 |
|
if ( hashGetLong ( ht, "rank" , &l ) ) setRank ( l ); |
| 361 |
|
if ( hashGetLong ( ht, "uorder" , &l ) ) setUorder ( l ); |
| 362 |
|
if ( hashGetLong ( ht, "user_mailok" , &l ) ) setUserMailok ( l ); |
| 363 |
|
if ( hashGetLong ( ht, "user_regdate" , &l ) ) setUserRegdate ( l ); |
| 364 |
|
if ( hashGetLong ( ht, "user_viewemail" , &l ) ) setUserViewemail ( l ); |
| 365 |
|
if ( hashGetLong ( ht, "activate" , &l ) ) setActivate ( l ); |
| 366 |
|
if ( hashGetString( ht, "address" , &p ) ) setAddress ( p ); |
| 367 |
|
if ( hashGetString( ht, "institute" , &p ) ) setInstitute ( p ); |
| 368 |
|
if ( hashGetString( ht, "tel" , &p ) ) setTel ( p ); |
| 369 |
|
if ( hashGetString( ht, "organization" , &p ) ) setOrganization ( p ); |
| 370 |
|
if ( hashGetString( ht, "country" , &p ) ) setCountry ( p ); |
| 371 |
|
if ( hashGetString( ht, "zipcode" , &p ) ) setZipcode ( p ); |
| 372 |
|
if ( hashGetString( ht, "fax" , &p ) ) setFax ( p ); |
| 373 |
|
if ( hashGetString( ht, "base_url" , &p ) ) setBaseURL ( p ); |
| 374 |
|
if ( hashGetLong ( ht, "notice_mail" , &l ) ) setNoticeMail ( l ); |
| 375 |
|
if ( hashGetLong ( ht, "notice_mail_since" , &l ) ) setNoticeMailSince ( l ); |
| 376 |
|
|
| 377 |
|
result = RES_OK; |
| 378 |
} |
} |
| 379 |
zAccount_t() : account(){ result = RES_ERROR; } |
zAccount_t() : account(){ result = RES_ERROR; } |
| 380 |
zAccount_t( zval *pz ) : account(){ initialize(pz); } |
zAccount_t( zval *pz ) : account(){ initialize(pz); } |
| 688 |
if ( RES_OK == result ){ |
if ( RES_OK == result ){ |
| 689 |
result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen ); |
result = getGroups( (sessionid_t)sid, gids, gidsLen, &zcri, &groups, &groupsLen ); |
| 690 |
if ( RES_OK == result ){ |
if ( RES_OK == result ){ |
| 691 |
|
groupsToZval( groups, groupsLen, zgroups ); |
| 692 |
delete[] gids; |
delete[] gids; |
| 693 |
freeResult( groups ); |
freeResult( groups ); |
| 694 |
} |
} |
| 695 |
} |
} |
|
groupsToZval( groups, groupsLen, zgroups ); |
|
| 696 |
RETURN_LONG(result); |
RETURN_LONG(result); |
| 697 |
} |
} |
| 698 |
|
|
| 699 |
|
|
| 700 |
// int vp_is_moderator(string uname) |
// int vp_is_moderator(int sid, int uid) |
| 701 |
ZEND_FUNCTION(vp_is_moderator) |
ZEND_FUNCTION(vp_is_moderator) |
| 702 |
{ |
{ |
| 703 |
long vpSessionID; |
long vpSessionID; |
| 712 |
RETURN_BOOL(result) |
RETURN_BOOL(result) |
| 713 |
} |
} |
| 714 |
|
|
| 715 |
// int vp_get_uid(string uname) |
// int vp_get_uid(string uname,int &uid) |
| 716 |
ZEND_FUNCTION(vp_get_uid) |
ZEND_FUNCTION(vp_get_uid) |
| 717 |
{ |
{ |
| 718 |
char *uname; |
char *uname; |
| 719 |
int unameLen; |
int unameLen; |
| 720 |
|
zval *zuid; |
| 721 |
userid_t uid; |
userid_t uid; |
| 722 |
|
|
| 723 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", |
| 724 |
&uname, &unameLen) == FAILURE) { |
&uname, &unameLen, &zuid) == FAILURE) { |
| 725 |
return; |
return; |
| 726 |
} |
} |
| 727 |
|
|
| 728 |
|
if (!PZVAL_IS_REF(zuid)) { |
| 729 |
|
zend_error(E_WARNING, "2nd parameter wasn't passed by reference"); |
| 730 |
|
RETURN_LONG(RES_PHP_NONREF); |
| 731 |
|
} |
| 732 |
|
|
| 733 |
string strUname( uname, unameLen ); |
string strUname( uname, unameLen ); |
| 734 |
result_t result = getUid( strUname.c_str(), &uid ); |
result_t result = getUid( strUname.c_str(), &uid ); |
| 735 |
if ( result == RES_OK ){ |
ZVAL_LONG(zuid, (long)uid); |
| 736 |
RETURN_LONG((long)uid); |
RETURN_LONG((long)result); |
|
} |
|
|
else { |
|
|
//zend_printf( "vpal_debug: vp_get_uid(%s): result=%d<br>\n", strUname.c_str(),(int)result ); |
|
|
RETURN_FALSE |
|
|
} |
|
| 737 |
} |
} |
| 738 |
|
|
| 739 |
/** session → zval |
/** session → zval |
| 830 |
} |
} |
| 831 |
|
|
| 832 |
/** ログインする。<br> |
/** ログインする。<br> |
| 833 |
int vp_login_user(string uname, string password) |
int vp_login_user(string uname, string password, int &session_id) |
| 834 |
@param uname ユーザ名(xoops_users.uname) |
@param uname ユーザ名(xoops_users.uname) |
| 835 |
@param password パスワード(md5(password)=xoops_users.pass) |
@param password パスワード(md5(password)=xoops_users.pass) |
| 836 |
@return 0 success |
@return 0 success |
| 841 |
int unameLen; |
int unameLen; |
| 842 |
char *passwd; |
char *passwd; |
| 843 |
int passwdLen; |
int passwdLen; |
| 844 |
|
zval *zVPSessionID; |
| 845 |
|
|
| 846 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssz", |
| 847 |
&uname, &unameLen, &passwd, &passwdLen) == FAILURE) { |
&uname, &unameLen, &passwd, &passwdLen, &zVPSessionID) == FAILURE) { |
| 848 |
return; |
return; |
| 849 |
} |
} |
| 850 |
|
|
| 851 |
|
if (!PZVAL_IS_REF(zVPSessionID)) { |
| 852 |
|
zend_error(E_WARNING, "3rd parameter wasn't passed by reference"); |
| 853 |
|
RETURN_LONG(RES_PHP_NONREF); |
| 854 |
|
} |
| 855 |
|
|
| 856 |
sessionid_t vpSessionID; |
sessionid_t vpSessionID; |
| 857 |
result_t result = loginUser( uname, passwd, &vpSessionID ); |
result_t result = loginUser( uname, passwd, &vpSessionID ); |
| 858 |
if ( result == RES_OK ){ |
if ( result == RES_OK ) |
| 859 |
RETURN_LONG((long)vpSessionID); |
ZVAL_LONG(zVPSessionID, (long)vpSessionID); |
| 860 |
} |
RETURN_LONG((long)result); |
|
else { |
|
|
//zend_printf( "vpal_debug: vp_login_user(%s, %s): cannot login. result=%d<br>\n", strUname.c_str(), strPasswd.c_str(), (int)result ); |
|
|
RETURN_FALSE |
|
|
} |
|
| 861 |
} |
} |
| 862 |
|
|
| 863 |
/** ログアウトする。<br> |
/** ログアウトする。<br> |
| 878 |
} |
} |
| 879 |
|
|
| 880 |
/** vp の session id 作成<br> |
/** vp の session id 作成<br> |
| 881 |
int vp_create_session( string xoops_sess_id, int uid, string remote_host ) |
int vp_create_session( string xoops_sess_id, int uid, int &session ) |
| 882 |
@param xoops_sess_id xoopsのsession id |
@param xoops_sess_id xoopsのsession id |
| 883 |
@param uid xoops の uid (xoops_users.uid) |
@param uid xoops の uid (xoops_users.uid) |
| 884 |
@return FALSE以外: vp の session id |
@return 0 成功 |
|
@return FALSE: 失敗 |
|
| 885 |
*/ |
*/ |
| 886 |
ZEND_FUNCTION(vp_create_session) |
ZEND_FUNCTION(vp_create_session) |
| 887 |
{ |
{ |
| 888 |
char *xoopsSessionID; |
char *xoopsSessionID; |
| 889 |
int xoopsSessionIDLen; |
int xoopsSessionIDLen; |
| 890 |
long uid; |
long uid; |
| 891 |
|
zval *zVPSessionID; |
| 892 |
|
|
| 893 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "slz", |
| 894 |
&xoopsSessionID, &xoopsSessionIDLen, &uid) == FAILURE) { |
&xoopsSessionID, &xoopsSessionIDLen, &uid, &zVPSessionID) == FAILURE) { |
| 895 |
return; |
return; |
| 896 |
} |
} |
| 897 |
|
|
| 898 |
|
if (!PZVAL_IS_REF(zVPSessionID)) { |
| 899 |
|
zend_error(E_WARNING, "3rd parameter wasn't passed by reference"); |
| 900 |
|
RETURN_LONG(RES_PHP_NONREF); |
| 901 |
|
} |
| 902 |
|
|
| 903 |
sessionid_t vpSessionID = 0; |
sessionid_t vpSessionID = 0; |
| 904 |
result_t result = createSession( xoopsSessionID, (userid_t)uid, &vpSessionID ); |
result_t result = createSession( xoopsSessionID, (userid_t)uid, &vpSessionID ); |
| 905 |
if ( result == RES_OK ){ |
if ( result == RES_OK ) |
| 906 |
RETURN_LONG((long)vpSessionID); |
ZVAL_LONG(zVPSessionID, (long)vpSessionID); |
| 907 |
} |
RETURN_LONG((long)result); |
|
else { |
|
|
RETURN_FALSE; |
|
|
} |
|
| 908 |
} |
} |
| 909 |
|
|
| 910 |
/** vp の session の詳細情報を得る<br> |
/** vp の session の詳細情報を得る<br> |
| 987 |
} |
} |
| 988 |
|
|
| 989 |
long count = getAccountCount( (sessionid_t)sid ); |
long count = getAccountCount( (sessionid_t)sid ); |
|
|
|
| 990 |
RETURN_LONG(count); |
RETURN_LONG(count); |
| 991 |
} |
} |
| 992 |
|
|