|
|
| version 1.1.1.1, 2012/02/21 23:47:54 | version 1.1.1.2, 2012/05/29 12:34:37 |
|---|---|
| Line 50 | Line 50 |
| #include "php_flatfile.h" | #include "php_flatfile.h" |
| #include "php_inifile.h" | #include "php_inifile.h" |
| #include "php_qdbm.h" | #include "php_qdbm.h" |
| #include "php_tcadb.h" | |
| /* {{{ arginfo */ | /* {{{ arginfo */ |
| ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2) | ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2) |
| Line 337 static dba_handler handler[] = { | Line 338 static dba_handler handler[] = { |
| #if DBA_QDBM | #if DBA_QDBM |
| DBA_HND(qdbm, DBA_LOCK_EXT) | DBA_HND(qdbm, DBA_LOCK_EXT) |
| #endif | #endif |
| #if DBA_TCADB | |
| DBA_HND(tcadb, DBA_LOCK_ALL) | |
| #endif | |
| { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } | { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } |
| }; | }; |
| Line 358 static dba_handler handler[] = { | Line 362 static dba_handler handler[] = { |
| #define DBA_DEFAULT "dbm" | #define DBA_DEFAULT "dbm" |
| #elif DBA_QDBM | #elif DBA_QDBM |
| #define DBA_DEFAULT "qdbm" | #define DBA_DEFAULT "qdbm" |
| #elif DBA_TCADB | |
| #define DBA_DEFAULT "tcadb" | |
| #else | #else |
| #define DBA_DEFAULT "" | #define DBA_DEFAULT "" |
| #endif | #endif |
| Line 554 static void php_dba_update(INTERNAL_FUNCTION_PARAMETER | Line 560 static void php_dba_update(INTERNAL_FUNCTION_PARAMETER |
| DBA_WRITE_CHECK; | DBA_WRITE_CHECK; |
| if (PG(magic_quotes_runtime)) { | if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) { |
| v = estrndup(val, val_len); | DBA_ID_DONE; |
| php_stripslashes(v, &val_len TSRMLS_CC); | RETURN_TRUE; |
| if (info->hnd->update(info, key_str, key_len, v, val_len, mode TSRMLS_CC) == SUCCESS) { | |
| efree(v); | |
| DBA_ID_DONE; | |
| RETURN_TRUE; | |
| } | |
| efree(v); | |
| } else { | |
| if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) { | |
| DBA_ID_DONE; | |
| RETURN_TRUE; | |
| } | |
| } | } |
| DBA_ID_DONE; | DBA_ID_DONE; |
| Line 832 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, | Line 827 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, |
| /* when in read only mode try to use existing .lck file first */ | /* when in read only mode try to use existing .lck file first */ |
| /* do not log errors for .lck file while in read ony mode on .lck file */ | /* do not log errors for .lck file while in read ony mode on .lck file */ |
| lock_file_mode = "rb"; | lock_file_mode = "rb"; |
| info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, &opened_path); | info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, &opened_path); |
| } | } |
| if (!info->lock.fp) { | if (!info->lock.fp) { |
| /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ | /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ |
| Line 847 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, | Line 842 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, |
| } | } |
| } | } |
| if (!info->lock.fp) { | if (!info->lock.fp) { |
| info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, &opened_path); | info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path); |
| if (info->lock.fp) { | if (info->lock.fp) { |
| if (lock_dbf) { | if (lock_dbf) { |
| /* replace the path info with the real path of the opened file */ | /* replace the path info with the real path of the opened file */ |
| Line 885 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, | Line 880 static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, |
| if (info->lock.fp && lock_dbf) { | if (info->lock.fp && lock_dbf) { |
| info->fp = info->lock.fp; /* use the same stream for locking and database access */ | info->fp = info->lock.fp; /* use the same stream for locking and database access */ |
| } else { | } else { |
| info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL); | info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, NULL); |
| } | } |
| if (!info->fp) { | if (!info->fp) { |
| dba_close(info TSRMLS_CC); | dba_close(info TSRMLS_CC); |
| Line 1023 PHP_FUNCTION(dba_fetch) | Line 1018 PHP_FUNCTION(dba_fetch) |
| skip = 0; | skip = 0; |
| } | } |
| if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) { | if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) { |
| if (val && PG(magic_quotes_runtime)) { | |
| val = php_addslashes(val, len, &len, 1 TSRMLS_CC); | |
| } | |
| DBA_ID_DONE; | DBA_ID_DONE; |
| RETURN_STRINGL(val, len, 0); | RETURN_STRINGL(val, len, 0); |
| } | } |