cvs: pecl /uploadprogress .cvsignore EXPERIMENTAL README config.m4 config.w32 package2.xml php_uploadprogress.h uploadprogress.c uploadprogress.dsp
| From: | Christian Stocker | Date: | Tue, 05 Dec 2006 12:00:12 +0000 |
| Subject: | cvs: pecl /uploadprogress .cvsignore EXPERIMENTAL README config.m4 config.w32 package2.xml php_uploadprogress.h uploadprogress.c uploadprogress.dsp | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-6732@lists.php.net to get a copy of this message | ||
chregu Tue Dec 5 12:00:12 2006 UTC
Added files:
/pecl/uploadprogress .cvsignore EXPERIMENTAL README config.m4
config.w32 package2.xml php_uploadprogress.h
uploadprogress.c uploadprogress.dsp
Log:
Initial commit on PECL
http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/.cvsignore?view=markup&rev=1.1 Index: pecl/uploadprogress/.cvsignore +++ pecl/uploadprogress/.cvsignore *.lo *.la..deps..libs Makefile Makefile.fragments Makefile.global Makefile.objects acinclude.m4 aclocal.m4 autom4te.cache build config.cache config.guess config.h config.h.in config.log config.nice config.status config.sub configure configure.in conftest conftest.c include install-sh libtool ltmain.sh missing mkinstalldirs modules scan_makefile_in.awk *.dsw *.plg *.opt *.ncb Release Release_inline Debug Release_TS Release_TSDbg Release_TS_inline Debug_TS *.tgz *~ #*#..#* http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/config.m4?view=markup&rev=1.1 Index: pecl/uploadprogress/config.m4 +++ pecl/uploadprogress/config.m4 dnl dnl $ Id: $ dnl PHP_ARG_ENABLE(uploadprogress, whether to enable uploadprogress functions, [ --enable-uploadprogress Disable uploadprogress support]) if test "$PHP_UPLOADPROGRESS" != "no"; then PHP_SUBST(UPLOADPROGRESS_SHARED_LIBADD) AC_DEFINE(HAVE_UPLOADPROGRESS, 1, [ ]) PHP_NEW_EXTENSION(uploadprogress, uploadprogress.c , $ext_shared) fi http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/config.w32?view=markup&rev=1.1 Index: pecl/uploadprogress/config.w32 +++ pecl/uploadprogress/config.w32 // $ Id: $ // vim:ft=javascript ARG_ENABLE('uploadprogress' , 'The unknown extension', 'no'); if (PHP_UPLOADPROGRESS) { EXTENSION('uploadprogress", "uploadprogress.c"); AC_DEFINE('HAVE_UPLOADPROGRESS', 1, 'The unknown extension'); } http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/package2.xml?view=markup&rev=1.1 Index: pecl/uploadprogress/package2.xml +++ pecl/uploadprogress/package2.xml <?xml version="1.0" encoding="UTF-8"?> <package packagerversion="1.4.11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>uploadprogress</name> <channel>pecl.php.net</channel> <summary>An extension to track progress of a file upload.</summary> <description>PHP 5.2 is needed </description> <lead> <name>Christian Stocker</name> <user>chregu</user> <email>chregu@php.net</email> <active>yes</active> </lead> <date>2006-12-05</date> <time>12:00:07</time> <version> <release>0.3.0</release> <api>0.3.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <license uri="http://www.php.net/license">PHP License</license> <notes>Initial release </notes> <contents> <dir name="/"> <file name="config.m4" role="src" /> <file name="EXPERIMENTAL" role="doc" /> <file name="php_uploadprogress.h" role="src" /> <file name="uploadprogress.c" role="src" /> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>5.2.0</min> </php> <pearinstaller> <min>1.4.0b1</min> </pearinstaller> </required> </dependencies> <providesextension>uploadprogress</providesextension> <extsrcrelease /> </package> http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/php_uploadprogress.h?view=markup&rev=1.1 Index: pecl/uploadprogress/php_uploadprogress.h +++ pecl/uploadprogress/php_uploadprogress.h /* +----------------------------------------------------------------------+ | unknown license: | +----------------------------------------------------------------------+ +----------------------------------------------------------------------+ */ /* $ Id: $ */ #ifndef PHP_UPLOADPROGRESS_H #define PHP_UPLOADPROGRESS_H #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <php.h> #ifdef HAVE_UPLOADPROGRESS #include <php_ini.h> #include <SAPI.h> #include <ext/standard/info.h> #ifdef __cplusplus } // extern "C" #endif #ifdef __cplusplus extern "C" { #endif extern zend_module_entry uploadprogress_module_entry; #define phpext_uploadprogress_ptr &uploadprogress_module_entry #ifdef PHP_WIN32 #define PHP_UPLOADPROGRESS_API __declspec(dllexport) #else #define PHP_UPLOADPROGRESS_API #endif typedef struct _uploadprogress_data { char * identifier; /* full filename, or just the identifier, depending on method */ char * identifier_tmp; /* full filename, or just the identifier, depending on method */ time_t time_start; time_t time_last; unsigned int speed_average; unsigned int speed_last; unsigned long bytes_uploaded; unsigned long bytes_total; unsigned int files_uploaded; int est_sec; } uploadprogress_data; static char * uploadprogress_mk_filename(char * identifier, char * template); static void uploadprogress_file_php_get_info(char *, zval * ); PHP_MINIT_FUNCTION(uploadprogress); PHP_MSHUTDOWN_FUNCTION(uploadprogress); PHP_RINIT_FUNCTION(uploadprogress); PHP_RSHUTDOWN_FUNCTION(uploadprogress); PHP_MINFO_FUNCTION(uploadprogress); #ifdef ZTS #include "TSRM.h" #endif PHP_FUNCTION(uploadprogress_get_info); #ifdef __cplusplus } // extern "C" #endif #endif /* PHP_HAVE_UPLOADPROGRESS */ #endif /* PHP_UPLOADPROGRESS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/uploadprogress.c?view=markup&rev=1.1 Index: pecl/uploadprogress/uploadprogress.c +++ pecl/uploadprogress/uploadprogress.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Christian Stocker (chregu@bitflux.ch) | | Derived from: Doru Petrescu (pdoru-php-upm@kappa.ro) Â Â | | http://pdoru.from.ro/upload-progress-meter/ | +----------------------------------------------------------------------+ $Id: uploadprogress.c,v 1.1 2006/12/05 12:00:12 chregu Exp $ */ /* $ Id: $ */ #include "php_uploadprogress.h" #include "rfc1867.h" #if HAVE_UPLOADPROGRESS /* {{{ uploadprogress_functions[] */ function_entry uploadprogress_functions[] = { PHP_FE(uploadprogress_get_info, NULL) { NULL, NULL, NULL } }; /* }}} */ PHP_INI_BEGIN() PHP_INI_ENTRY("uploadprogress.file.filename_template", "/tmp/upt_%s.txt", PHP_INI_ALL, NULL) PHP_INI_END() /* {{{ uploadprogress_module_entry */ zend_module_entry uploadprogress_module_entry = { STANDARD_MODULE_HEADER, "uploadprogress", uploadprogress_functions, PHP_MINIT(uploadprogress), /* Replace with NULL if there is nothing to do at php startup */ PHP_MSHUTDOWN(uploadprogress), /* Replace with NULL if there is nothing to do at php shutdown */ PHP_RINIT(uploadprogress), /* Replace with NULL if there is nothing to do at request start */ PHP_RSHUTDOWN(uploadprogress), /* Replace with NULL if there is nothing to do at request end */ PHP_MINFO(uploadprogress), "0.0.1", STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_UPLOADPROGRESS ZEND_GET_MODULE(uploadprogress) #endif extern int (*php_rfc1867_callback)(unsigned int , void *, void ** TSRMLS_DC); static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data, void **data TSRMLS_DC) { zval handler; char *callable = NULL; uploadprogress_data * progress; int read_bytes; progress = *data; if (event == MULTIPART_EVENT_START) { multipart_event_start *e_data; e_data = (multipart_event_start*) event_data; progress = emalloc( sizeof(uploadprogress_data) ); progress->bytes_total = e_data->content_length; progress->identifier = NULL; progress->identifier_tmp = NULL; progress->time_start = time(NULL); *data = progress; } else if (event == MULTIPART_EVENT_FORMDATA) { multipart_event_formdata *e_data; e_data = (multipart_event_formdata*) event_data; read_bytes = e_data->post_bytes_processed; if (e_data->newlength) { *e_data->newlength = e_data->length; } if (strcmp(e_data->name, "UPLOAD_IDENTIFIER") == 0) { char * template = INI_STR("uploadprogress.file.filename_template"); if (strcmp(template, "") == 0) { return 0; } progress->time_last = time(NULL); progress->speed_average = 0; progress->speed_last = 0; progress->bytes_uploaded = read_bytes; progress->files_uploaded = 0; progress->est_sec = 0; progress->identifier = uploadprogress_mk_filename(*e_data->value, template); progress->identifier_tmp = emalloc(strlen( progress->identifier) + 4); sprintf( progress->identifier_tmp, "%s.wr", progress->identifier ); } } if (progress->identifier) { if (event == MULTIPART_EVENT_FILE_START) { multipart_event_file_start *e_data; e_data = (multipart_event_file_start*) event_data; read_bytes = e_data->post_bytes_processed; } else if (event == MULTIPART_EVENT_FILE_DATA) { multipart_event_file_data *e_data; e_data = (multipart_event_file_data*) event_data; read_bytes = e_data->post_bytes_processed; } else if (event == MULTIPART_EVENT_FILE_END) { multipart_event_file_end *e_data; e_data = (multipart_event_file_end*) event_data; read_bytes = e_data->post_bytes_processed; progress->files_uploaded++; } else if ( event == MULTIPART_EVENT_END ) { VCWD_UNLINK( progress->identifier ); efree( progress->identifier ); efree( progress->identifier_tmp ); efree( progress ); return 0; } time_t crtime = time(NULL); int d,dt,ds; if (progress->time_last > crtime) { /* just in case we encounter a fracture in time */ progress->time_start = progress->time_last = crtime; } dt = crtime - progress->time_last; ds = crtime - progress->time_start; d = read_bytes - progress->bytes_uploaded; if (dt) { progress->speed_last = d/dt; progress->time_last = crtime; progress->bytes_uploaded = read_bytes; progress->speed_average = ds ? read_bytes / ds : 0; progress->est_sec = progress->speed_average ? (progress->bytes_total - read_bytes) / progress->speed_average : -1; } if (dt || event >= MULTIPART_EVENT_FILE_END) { FILE *F; F = VCWD_FOPEN(progress->identifier_tmp, "wb"); if (F) { fprintf(F, "time_start=%d\ntime_last=%d\nspeed_average=%d\nspeed_last=%d\nbytes_uploaded=%d\nbytes_total=%d\nfiles_uploaded=%d\nest_sec=%d\n", progress->time_start, progress->time_last, progress->speed_average, progress->speed_last, progress->bytes_uploaded, progress->bytes_total, progress->files_uploaded, progress->est_sec ); fclose(F); VCWD_RENAME(progress->identifier_tmp,progress->identifier); } } } if (event == MULTIPART_EVENT_END ) { if (progress->identifier) { efree( progress->identifier ); } if (progress->identifier_tmp) { efree( progress->identifier_tmp ); } efree( progress ); } } /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(uploadprogress) { REGISTER_INI_ENTRIES(); php_rfc1867_callback = uploadprogress_php_rfc1867_file; /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(uploadprogress) { UNREGISTER_INI_ENTRIES(); php_rfc1867_callback = NULL; /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(uploadprogress) { /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(uploadprogress) { /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(uploadprogress) { char buffer[ 512 ] ; php_info_print_table_start() ; php_info_print_table_header( 2, "uploadprogress support", "enabled" ) ; snprintf( buffer, 512, "0.3.0-beta"); php_info_print_table_row( 2, "Version", buffer ) ; php_info_print_box_end(); /* add your stuff here */ } /* }}} */ /* {{{ proto bool uploadprogress_register(callback callback) */ PHP_FUNCTION(uploadprogress_get_info) { char * id; int id_lg; char method; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_lg) == FAILURE) { return; } return uploadprogress_file_php_get_info( id, return_value ); RETURN_FALSE; } static char * uploadprogress_mk_filename(char * identifier, char * template) { char * x; char * filename; filename = emalloc( strlen(template) + strlen(identifier) + 3 ); x = strstr( template, "%s" ); if (x==NULL) { sprintf( filename, "%s/%s", template, identifier ); }else{ strcpy( filename, template ); strcpy( filename + (x - template), identifier ); strcat( filename, x+2 ); } return filename; } static void uploadprogress_file_php_get_info(char * id, zval * return_value) { char s[1024]; char * filename; FILE *F; TSRMLS_FETCH(); char * template = INI_STR("uploadprogress.file.filename_template"); if (strcmp(template, "") == 0) { return; } else { filename = uploadprogress_mk_filename( id, template ); if (!filename) return; F = VCWD_FOPEN(filename, "rb"); if (F) { array_init(return_value); while ( fgets(s, 1000, F) ) { char *k, *v, *e; e = strchr(s,'='); if (!e) continue; *e = 0; /* break the line into 2 parts */ v = e+1; k = s; /* trim spaces in front and after the name/value */ while (*k && *k <= 32) v++; while (*v && *v <= 32) v++; for (e=k; *e; e++) if (*e <= 32) { *e = 0; break; } for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; } add_assoc_string( return_value, k, v, 1 ); } fclose(F); } if (filename) efree(filename); return; } } #endif /* HAVE_UPLOADPROGRESS */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/uploadprogress.dsp?view=markup&rev=1.1 Index: pecl/uploadprogress/uploadprogress.dsp +++ pecl/uploadprogress/uploadprogress.dsp # Microsoft Developer Studio Project File - Name="uploadprogress" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=uploadprogress - Win32 Debug_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "uploadprogress.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "uploadprogress.mak" CFG="uploadprogress - Win32 Debug_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "uploadprogress - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "uploadprogress - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "uploadprogress - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release_TS" # PROP BASE Intermediate_Dir "Release_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release_TS" # PROP Intermediate_Dir "Release_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPLOADPROGRESS_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_UPLOADPROGRESS" /D ZTS=1 /D HAVE_UPLOADPROGRESS=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS\php_uploadprogress.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" !ELSEIF "$(CFG)" == "uploadprogress - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug_TS" # PROP BASE Intermediate_Dir "Debug_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug_TS" # PROP Intermediate_Dir "Debug_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPLOADPROGRESS_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_UPLOADPROGRESS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_UPLOADPROGRESS=1 /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS\php_uploadprogress.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "uploadprogress - Win32 Release_TS" # Name "uploadprogress - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=./uploadprogress.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\php_uploadprogress.h # End Source File # End Group # End Target # End Project
http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/.cvsignore?view=markup&rev=1.1 Index: pecl/uploadprogress/.cvsignore +++ pecl/uploadprogress/.cvsignore *.lo *.la..deps..libs Makefile Makefile.fragments Makefile.global Makefile.objects acinclude.m4 aclocal.m4 autom4te.cache build config.cache config.guess config.h config.h.in config.log config.nice config.status config.sub configure configure.in conftest conftest.c include install-sh libtool ltmain.sh missing mkinstalldirs modules scan_makefile_in.awk *.dsw *.plg *.opt *.ncb Release Release_inline Debug Release_TS Release_TSDbg Release_TS_inline Debug_TS *.tgz *~ #*#..#* http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/config.m4?view=markup&rev=1.1 Index: pecl/uploadprogress/config.m4 +++ pecl/uploadprogress/config.m4 dnl dnl $ Id: $ dnl PHP_ARG_ENABLE(uploadprogress, whether to enable uploadprogress functions, [ --enable-uploadprogress Disable uploadprogress support]) if test "$PHP_UPLOADPROGRESS" != "no"; then PHP_SUBST(UPLOADPROGRESS_SHARED_LIBADD) AC_DEFINE(HAVE_UPLOADPROGRESS, 1, [ ]) PHP_NEW_EXTENSION(uploadprogress, uploadprogress.c , $ext_shared) fi http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/config.w32?view=markup&rev=1.1 Index: pecl/uploadprogress/config.w32 +++ pecl/uploadprogress/config.w32 // $ Id: $ // vim:ft=javascript ARG_ENABLE('uploadprogress' , 'The unknown extension', 'no'); if (PHP_UPLOADPROGRESS) { EXTENSION('uploadprogress", "uploadprogress.c"); AC_DEFINE('HAVE_UPLOADPROGRESS', 1, 'The unknown extension'); } http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/package2.xml?view=markup&rev=1.1 Index: pecl/uploadprogress/package2.xml +++ pecl/uploadprogress/package2.xml <?xml version="1.0" encoding="UTF-8"?> <package packagerversion="1.4.11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>uploadprogress</name> <channel>pecl.php.net</channel> <summary>An extension to track progress of a file upload.</summary> <description>PHP 5.2 is needed </description> <lead> <name>Christian Stocker</name> <user>chregu</user> <email>chregu@php.net</email> <active>yes</active> </lead> <date>2006-12-05</date> <time>12:00:07</time> <version> <release>0.3.0</release> <api>0.3.0</api> </version> <stability> <release>beta</release> <api>beta</api> </stability> <license uri="http://www.php.net/license">PHP License</license> <notes>Initial release </notes> <contents> <dir name="/"> <file name="config.m4" role="src" /> <file name="EXPERIMENTAL" role="doc" /> <file name="php_uploadprogress.h" role="src" /> <file name="uploadprogress.c" role="src" /> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>5.2.0</min> </php> <pearinstaller> <min>1.4.0b1</min> </pearinstaller> </required> </dependencies> <providesextension>uploadprogress</providesextension> <extsrcrelease /> </package> http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/php_uploadprogress.h?view=markup&rev=1.1 Index: pecl/uploadprogress/php_uploadprogress.h +++ pecl/uploadprogress/php_uploadprogress.h /* +----------------------------------------------------------------------+ | unknown license: | +----------------------------------------------------------------------+ +----------------------------------------------------------------------+ */ /* $ Id: $ */ #ifndef PHP_UPLOADPROGRESS_H #define PHP_UPLOADPROGRESS_H #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <php.h> #ifdef HAVE_UPLOADPROGRESS #include <php_ini.h> #include <SAPI.h> #include <ext/standard/info.h> #ifdef __cplusplus } // extern "C" #endif #ifdef __cplusplus extern "C" { #endif extern zend_module_entry uploadprogress_module_entry; #define phpext_uploadprogress_ptr &uploadprogress_module_entry #ifdef PHP_WIN32 #define PHP_UPLOADPROGRESS_API __declspec(dllexport) #else #define PHP_UPLOADPROGRESS_API #endif typedef struct _uploadprogress_data { char * identifier; /* full filename, or just the identifier, depending on method */ char * identifier_tmp; /* full filename, or just the identifier, depending on method */ time_t time_start; time_t time_last; unsigned int speed_average; unsigned int speed_last; unsigned long bytes_uploaded; unsigned long bytes_total; unsigned int files_uploaded; int est_sec; } uploadprogress_data; static char * uploadprogress_mk_filename(char * identifier, char * template); static void uploadprogress_file_php_get_info(char *, zval * ); PHP_MINIT_FUNCTION(uploadprogress); PHP_MSHUTDOWN_FUNCTION(uploadprogress); PHP_RINIT_FUNCTION(uploadprogress); PHP_RSHUTDOWN_FUNCTION(uploadprogress); PHP_MINFO_FUNCTION(uploadprogress); #ifdef ZTS #include "TSRM.h" #endif PHP_FUNCTION(uploadprogress_get_info); #ifdef __cplusplus } // extern "C" #endif #endif /* PHP_HAVE_UPLOADPROGRESS */ #endif /* PHP_UPLOADPROGRESS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/uploadprogress.c?view=markup&rev=1.1 Index: pecl/uploadprogress/uploadprogress.c +++ pecl/uploadprogress/uploadprogress.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Christian Stocker (chregu@bitflux.ch) | | Derived from: Doru Petrescu (pdoru-php-upm@kappa.ro) Â Â | | http://pdoru.from.ro/upload-progress-meter/ | +----------------------------------------------------------------------+ $Id: uploadprogress.c,v 1.1 2006/12/05 12:00:12 chregu Exp $ */ /* $ Id: $ */ #include "php_uploadprogress.h" #include "rfc1867.h" #if HAVE_UPLOADPROGRESS /* {{{ uploadprogress_functions[] */ function_entry uploadprogress_functions[] = { PHP_FE(uploadprogress_get_info, NULL) { NULL, NULL, NULL } }; /* }}} */ PHP_INI_BEGIN() PHP_INI_ENTRY("uploadprogress.file.filename_template", "/tmp/upt_%s.txt", PHP_INI_ALL, NULL) PHP_INI_END() /* {{{ uploadprogress_module_entry */ zend_module_entry uploadprogress_module_entry = { STANDARD_MODULE_HEADER, "uploadprogress", uploadprogress_functions, PHP_MINIT(uploadprogress), /* Replace with NULL if there is nothing to do at php startup */ PHP_MSHUTDOWN(uploadprogress), /* Replace with NULL if there is nothing to do at php shutdown */ PHP_RINIT(uploadprogress), /* Replace with NULL if there is nothing to do at request start */ PHP_RSHUTDOWN(uploadprogress), /* Replace with NULL if there is nothing to do at request end */ PHP_MINFO(uploadprogress), "0.0.1", STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_UPLOADPROGRESS ZEND_GET_MODULE(uploadprogress) #endif extern int (*php_rfc1867_callback)(unsigned int , void *, void ** TSRMLS_DC); static int uploadprogress_php_rfc1867_file(unsigned int event, void *event_data, void **data TSRMLS_DC) { zval handler; char *callable = NULL; uploadprogress_data * progress; int read_bytes; progress = *data; if (event == MULTIPART_EVENT_START) { multipart_event_start *e_data; e_data = (multipart_event_start*) event_data; progress = emalloc( sizeof(uploadprogress_data) ); progress->bytes_total = e_data->content_length; progress->identifier = NULL; progress->identifier_tmp = NULL; progress->time_start = time(NULL); *data = progress; } else if (event == MULTIPART_EVENT_FORMDATA) { multipart_event_formdata *e_data; e_data = (multipart_event_formdata*) event_data; read_bytes = e_data->post_bytes_processed; if (e_data->newlength) { *e_data->newlength = e_data->length; } if (strcmp(e_data->name, "UPLOAD_IDENTIFIER") == 0) { char * template = INI_STR("uploadprogress.file.filename_template"); if (strcmp(template, "") == 0) { return 0; } progress->time_last = time(NULL); progress->speed_average = 0; progress->speed_last = 0; progress->bytes_uploaded = read_bytes; progress->files_uploaded = 0; progress->est_sec = 0; progress->identifier = uploadprogress_mk_filename(*e_data->value, template); progress->identifier_tmp = emalloc(strlen( progress->identifier) + 4); sprintf( progress->identifier_tmp, "%s.wr", progress->identifier ); } } if (progress->identifier) { if (event == MULTIPART_EVENT_FILE_START) { multipart_event_file_start *e_data; e_data = (multipart_event_file_start*) event_data; read_bytes = e_data->post_bytes_processed; } else if (event == MULTIPART_EVENT_FILE_DATA) { multipart_event_file_data *e_data; e_data = (multipart_event_file_data*) event_data; read_bytes = e_data->post_bytes_processed; } else if (event == MULTIPART_EVENT_FILE_END) { multipart_event_file_end *e_data; e_data = (multipart_event_file_end*) event_data; read_bytes = e_data->post_bytes_processed; progress->files_uploaded++; } else if ( event == MULTIPART_EVENT_END ) { VCWD_UNLINK( progress->identifier ); efree( progress->identifier ); efree( progress->identifier_tmp ); efree( progress ); return 0; } time_t crtime = time(NULL); int d,dt,ds; if (progress->time_last > crtime) { /* just in case we encounter a fracture in time */ progress->time_start = progress->time_last = crtime; } dt = crtime - progress->time_last; ds = crtime - progress->time_start; d = read_bytes - progress->bytes_uploaded; if (dt) { progress->speed_last = d/dt; progress->time_last = crtime; progress->bytes_uploaded = read_bytes; progress->speed_average = ds ? read_bytes / ds : 0; progress->est_sec = progress->speed_average ? (progress->bytes_total - read_bytes) / progress->speed_average : -1; } if (dt || event >= MULTIPART_EVENT_FILE_END) { FILE *F; F = VCWD_FOPEN(progress->identifier_tmp, "wb"); if (F) { fprintf(F, "time_start=%d\ntime_last=%d\nspeed_average=%d\nspeed_last=%d\nbytes_uploaded=%d\nbytes_total=%d\nfiles_uploaded=%d\nest_sec=%d\n", progress->time_start, progress->time_last, progress->speed_average, progress->speed_last, progress->bytes_uploaded, progress->bytes_total, progress->files_uploaded, progress->est_sec ); fclose(F); VCWD_RENAME(progress->identifier_tmp,progress->identifier); } } } if (event == MULTIPART_EVENT_END ) { if (progress->identifier) { efree( progress->identifier ); } if (progress->identifier_tmp) { efree( progress->identifier_tmp ); } efree( progress ); } } /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(uploadprogress) { REGISTER_INI_ENTRIES(); php_rfc1867_callback = uploadprogress_php_rfc1867_file; /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(uploadprogress) { UNREGISTER_INI_ENTRIES(); php_rfc1867_callback = NULL; /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(uploadprogress) { /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(uploadprogress) { /* add your stuff here */ return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(uploadprogress) { char buffer[ 512 ] ; php_info_print_table_start() ; php_info_print_table_header( 2, "uploadprogress support", "enabled" ) ; snprintf( buffer, 512, "0.3.0-beta"); php_info_print_table_row( 2, "Version", buffer ) ; php_info_print_box_end(); /* add your stuff here */ } /* }}} */ /* {{{ proto bool uploadprogress_register(callback callback) */ PHP_FUNCTION(uploadprogress_get_info) { char * id; int id_lg; char method; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_lg) == FAILURE) { return; } return uploadprogress_file_php_get_info( id, return_value ); RETURN_FALSE; } static char * uploadprogress_mk_filename(char * identifier, char * template) { char * x; char * filename; filename = emalloc( strlen(template) + strlen(identifier) + 3 ); x = strstr( template, "%s" ); if (x==NULL) { sprintf( filename, "%s/%s", template, identifier ); }else{ strcpy( filename, template ); strcpy( filename + (x - template), identifier ); strcat( filename, x+2 ); } return filename; } static void uploadprogress_file_php_get_info(char * id, zval * return_value) { char s[1024]; char * filename; FILE *F; TSRMLS_FETCH(); char * template = INI_STR("uploadprogress.file.filename_template"); if (strcmp(template, "") == 0) { return; } else { filename = uploadprogress_mk_filename( id, template ); if (!filename) return; F = VCWD_FOPEN(filename, "rb"); if (F) { array_init(return_value); while ( fgets(s, 1000, F) ) { char *k, *v, *e; e = strchr(s,'='); if (!e) continue; *e = 0; /* break the line into 2 parts */ v = e+1; k = s; /* trim spaces in front and after the name/value */ while (*k && *k <= 32) v++; while (*v && *v <= 32) v++; for (e=k; *e; e++) if (*e <= 32) { *e = 0; break; } for (e=v; *e; e++) if (*e <= 32) { *e = 0; break; } add_assoc_string( return_value, k, v, 1 ); } fclose(F); } if (filename) efree(filename); return; } } #endif /* HAVE_UPLOADPROGRESS */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/uploadprogress.dsp?view=markup&rev=1.1 Index: pecl/uploadprogress/uploadprogress.dsp +++ pecl/uploadprogress/uploadprogress.dsp # Microsoft Developer Studio Project File - Name="uploadprogress" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=uploadprogress - Win32 Debug_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "uploadprogress.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "uploadprogress.mak" CFG="uploadprogress - Win32 Debug_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "uploadprogress - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "uploadprogress - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "uploadprogress - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release_TS" # PROP BASE Intermediate_Dir "Release_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release_TS" # PROP Intermediate_Dir "Release_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPLOADPROGRESS_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_UPLOADPROGRESS" /D ZTS=1 /D HAVE_UPLOADPROGRESS=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS\php_uploadprogress.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" !ELSEIF "$(CFG)" == "uploadprogress - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug_TS" # PROP BASE Intermediate_Dir "Debug_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug_TS" # PROP Intermediate_Dir "Debug_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UPLOADPROGRESS_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_UPLOADPROGRESS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_UPLOADPROGRESS=1 /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS\php_uploadprogress.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "uploadprogress - Win32 Release_TS" # Name "uploadprogress - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=./uploadprogress.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\php_uploadprogress.h # End Source File # End Group # End Target # End Project