Jump to content

logansama

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by logansama

  1. Thanks for the input. Already started googling the apache bench you mentioned. What i have done as an attempt to "think out the php box" so to speak, is to write a linux script which will manage the starting of many individual "sessions" (each with unique PID) which will each then run the script, providing their independent details. Doing further testing to see if it will work, but like i said, will read up on the apache bench. Thank you.
  2. Good day, Never dealt with creating automated bots (in php or in any other language) and i dont have experience in stress testing php. But my boss says i must work it out. I have a script which plays a game in itself and stores data in a table. I require to run about 1milion games to check if the maths work out the way they should (gambling maths etc). Php is not that capable to run multiple instances/threads of the script without having grave issues with data access from the tables etc. Was told to look into building a script (php) which would create large volumes of "bot" players which would individually (separate from any other bot created) run the script (thus run a game each). The final result will be many "simultaneous" games played which will result in reaching (hopefully) the 1milion mark rather quickly! Like i said i have no experience in this, but i have a few ideas i am starting on. Any input or tips on where to start looking into this matter would be greatly appreciated. Any experience you wish to share as well! Thank you.
  3. hehe, yes i will be given pre-written c++ to turn into an extension this way. My level of skill with C and C++ is entry-level at best. But yes, since php extensions should be written in C i fully agree with you.
  4. Last night i managed to get something going. Its basic, maybe not exactly 100% correct, but it works and is a good starting point. Please note that i still created the extension using Swig. Also note that the C++ i used was based on tutorial examples i could find, i am not a c++ programmer. To provide the data and steps: 1.) The Input file :: test4.i %module test4 %{ #include "test4.cpp" %} %include "test4.cpp" This file describes what you want to include. I always had the file.h descriptions here, but that caused a fault when a function was called from the php. The reason was that the function is listed in the extension but the implementation does not exist. By listing the cpp file (implementation) the function calls result correctly in the php. 2.) test4.h #ifndef __TEST4_H__ #define __TEST4_H__ int test4_showNumber(); #endif 3.) test4.cpp #include <iostream> #include "test4.h" using namespace std; int test4_showNumber() { int num = 8 +12; return num; } Please note this is VERY simple, the point was just to test actual implementation. I did everything in Ubuntu 8.10. In order to use swig you need to have it installed. View their website for more details on everything they do. http://www.swig.org. You also need a working PHP installed. I used XAMPP for linux (lampp) as well as a version compiled from source. v5.2.8 PHP in both cases. And lastly a working gcc/g++ installation. I used version 4.3.2. In the directory where the three above files are located i ran the following commands: 1.) swig -php5 -c++ test4.i this builds a few files. Their uses can be read about on their site. 2.) g++ 'php-config --includes' -fpic -c test4_wrap.cpp Please note that i did not type 'php-config --includes' as part of the command. What i mean by it is that the output you get from the command 'php-config --includes' should be added in the command above in its place. The lampp installation did not have the needed include directories and files, so i used those from the source built php. 3.) g++ -shared test4_wrap.o -o test4.so Then copy the .so file to where your extensions are stored. In my case with lampp it was in ../lampp/lib/php/extension/no-debug-non-zts-20060613/. Then edit your php.ini file: Add the following under "Dynamic Extensions": extension=test4.so Then restart your apache so that the new settings of the php.ini is loaded. The test php file i created was as follows: <?PHP if( extension_loaded("test4") ) { echo "<br><br><br>LOADED TEST 4 !! <br>"; } else { echo "NOTHING!! <br>"; } if (function_exists('test4_showNumber')) { echo "test4_showNumber is available.<br />\n"; } else { echo "test2_testNumber not available.<br />\n"; } echo "<br>The number is ....<br>"; $val1= test4_showNumber(); echo $val1; the output is then: LOADED TEST 4 !! test4_showNumber is available. The number is .... 20 Like i said a very simple implementation, but still an implementation and a start. Thank you for all the help everybody and hope someone finds this helpful/interesting.
  5. Some additional findings: (and with these i find myself in waters i have not swam in before. ) ran "php --re test" ('test' being the name of the extension i created using the Swig environment): Extension [ <persistent> extension #55 test version <no_version> ] { - Functions { Function [ <internal:test> function new_test ] { } Function [ <internal:test> function test_calc ] { } Function [ <internal:test> function test_getnumber ] { } } } test_calc is implemented in the original cpp file to receive two int parameters. so when i call itin a php file as follows: <?PHP test_calc(10,10); i get the following: Warning: Wrong parameter count for test_getnumber() in /opt/lampp/htdocs/extension/calculate.php on line 6 the test_getnumber() is supposed to receive no parameters but when i call test_getnumber() i get the same warning as above. At this point i am not even sure what to ask help for? hehe I think i will settle for ANY input or opinions etc. Thank you.
  6. Swig does the 'wrapping' of your source/implementation code before you proceed to compile it into a shared object. Normal extensions are in C so you need some extra conversion if you are using C++. Swig apparently does all the needed changes for you. I just need to figure out exactly how so i can actually use the extension. A link if you want more detail http://www.swig.org/Doc1.3/Php.html#Php_nn2_6 it also deals with many other langiages, not just php and c++.
  7. by all means i am sure that the extension has not been configured as part of php. I am not sure if the extension shared-object does contain a fault. Is there a means to test it? The shared object is created by compiling a wrapped .cpp file. This wrapped .cpp file is created by Swig using a normal .cpp file with c++ code. This wrapped cpp file contains the needed php/zend/cpp/c converted code used by php to understand extension. The original cpp file has the function foo(), the wrapped cpp file (before compiling) has the function as _wrap_foo() and the EXAMPLE php file the Swig created (to test the shared object extension) has a call to _foo(). In my test php file i have made a call to foo(), _wrap_foo() and _foo() and all of them result in "call to undefined function". I am now trying to figure out what the extension contains, wonder if there is a standard way to view the content of a loaded extension?
  8. Good day, Attempting the way of dynamically loading a created extension (.so) via the php.ini on linux. The extension is a c++ based extension created using Swig framework. I understand the php.ini way being: (for explaining purposes 'extension.so' represents the extension file/s ) 1. copy the extension.so file to be used, to the extensions dir/location specified by the the php.ini file 2. add to the php.ini file (under Dynamic Extensions) the line "extension=extension.so" 3. Restart the apache to reload the new settings of the php.ini. 4. Call the functions in a php file to test. unfortunately i receive errors when calling the function: "Fatal error: Call to undefined function foo() in /file_location/file.php on line #" when testing by adding the following code to top of php file....: (please note that enable_dl is On in the php.ini) if( dl('extension.so') ) { echo "could load all good! <br>"; } ..i recieve the output: ""Warning: Module 'extension' already loaded in Unknown on line 0"" i understand the above to mean that dl is trying to load something that is already loaded. i also did a command line check 'php -m' to check that the 'test' extension i am dynamically loading has not been compiled in with php. And it has not been. I am not sure if this all means the extension has loaded correctly but its been created incorrectly, or if the shared object has just not been loaded correctly. If anyone knows that my php.ini implementation is flawed, please tell me and if possible also on how to do it correctly. If you know of another way to do dynamically add extension library files, please help me out. I thank you in advance.
  9. If you get the .cpp and header file's structure correct and specify correct php include files then the Swig framework compiles correctly without error. Seems to do all correctly. Now i just need to work out how the hell to correctly load the generated .so file for use in php!
  10. An engine for a project has already been created using c++ and it would be the death of the developer if he would be told to redo it in C. what exactly has been done in the c++ code i am not wholly aware of. I have been given a link to a script called Swig which does allow you to create a suitable wrapper of your cpp code. Does most of the code adapting and macro replacing stuff for you. Then you just compile the wrapped code into a library (.so) and use that in php. Problem is that this script requires a list of includes from php and i cannot figure out how to provide the includes. Swig tut: http://www.swig.org/Doc1.3/Php.html#Php_nn2_6
  11. Ok, i have just been informed that i must focus my attention on how to build a PHP extension in linux using external libraries (.so). Thus using the PHP_ARG_WITH in the config.m4 file. My linux box is estimated to arrive in 1 hour. Will try and test then. Any input about the external library version would be greatly appreciated.
  12. 1st: From teh sticky it seems people are strict about what is allowed here, but from what i can define this is best place to have this post - if not, indicate where and i will move the post. I have not personally built php extensions but i have studied the process it goes through. I was instructed to determine (for a project i have just been thrown into) if it is at all possible to build php extensions using either external .so (built form c++ files) or actually using c++ (cpp) files as implementation(s) instead of C files? So far from all the "well explained" tutorials i have found that the default files generated by calling the ext_skel is basically for C code. But like i said we have c++ code we would like to build the extension implementations with. What i have determined so far: 1) One can apparently use PHP_ARG_WITH in the config.m4 which will allow you to specify an external .so file when calling 'configure'. But how this would effect other files in the skel setup i am not aware of. For example: does that mean the default C implementation file is left as is? 2) through online examples i have found that apparently cpp files may be used: http://www.mail-archive.com/internals@lists.php.net/msg24298.html resolved on last reply http://cvs.php.net/viewvc.cgi/pecl/rar/config.m4?revision=1.6&view=markup For all purposes i hope to test out the above to points today, but i must wait for my station to be loaded with linux later this morning before i can try. All i ask for is some input from those who have knowledge in this area, and perhaps a nudge into the right direction of testing/research. Thank you.
  13. Good day gents and gentets! I just wanted to ask the opinion of others on the following: When recieveing values, usually through $_POST or $_GET one would determain if a value was actually received by doing a isset(..) on the value element or just the whole array. But would you aggree or disagree that it would be good practice to also have a empty(..) check on the same value? I have had incidents where the value/variable etc received was set but happened to be empty. I wonder if i should make it a required practice to always do both a isset() and empty()? your input will be values!
  14. It appears there is some serious problems with IE7 and it handling of sessions, cookies etc. Even Microsoft isn't giving much info on how to work around the issue but seem to kind-off indicate they are aware of it! So now i develop in-house for FF and the other browsers, no longer will i bother to make the code IE compatible! YAY!!
  15. <damned my inability to get on forums enough!! - cant for the life of me remember how to edit original post - if even possible> Did some additional testing on sessions in the page. There are basically three key areas where data is passed to and fro between php and interface. I decided to use session_id() to view the id of the session at each of these three "steps". In firefox all three the session_id's echoed was the same. No difference. And code works fine! In IE7 each of the three echoed session id's are different!! I do not have in depth knowledge of php SESSIONS etc but i do believe my problem will be solved by getting IE NOT to 'reset' the session at every step (even though i am not sure why it resets as i don't use new windows/tabs??). Now to try this, but please if this additional info helps, please provide any help where you can! Thank You, David
  16. Good day, To start off, i have traced other posts concerning similar problems with SESSION variable sand IE7, but those issues are slightly different and the threads have ended. The application: In the interface page one enters a name in textfield. This is sent to php file which uses sql to determine if the given name is in database. If it is, then code generates some response code to user and also store the selected persons 'employeeNumber' to a $_SESSION[''] variable so called. User sees person exists in list and can then select from a dropdown list (created upon successful retrieval of person) whether to view that persons address data, contact details etc etc. Making selection then tells another php file to use the stored $_SESSION['employeeNumber'] as PrimaryKey in retrieving the needed data. The problem: I did this in the same way i have for some time, worked in IE6, works fine in FF and opera etc, but doesnt work in IE7, well not completely. By echo'ing the SESSION value at each step i have found that when the initial search of the person takes place and is found. The session variable is populated with the employeeNumber. Cool IE7 shows session when echoed. But when i select from dropdown other data to view something goes wrong. With echo of returned data i find that the session variable is empty all of a sudden. The variable still exists but the value given to it is no more. Tested by opening same page in both IE7 and FF2.0 at same time. FF works fine, IE7 no working! Tested in both separately, same results. Majority of the problems and solution i have found both in Google and here in this forum is cookies specific or that session is just not created at all. So it confuses me to madness that the session variable is created and working but then, without opening new tabs or windows or pop-ups the value just goes empty?! I have even found possible solutions of not having JS includes in the <head> of the file but the in the <body>. This unfortunately made no difference. I considered the idea that the session times-out in IE7 after few seconds if not set, but if i stick to the part of only searching for the person over and testing with that data alone it doesn't seem to time-out? I have reached a dead end. Any help or redirecting to worthy pool of information will be greatly appreciated! And thank you, David [EDIT] I have also looked in the possibility of ob_start() or session_start() possibly having some influence, but with what i know of them i tested and did not manage to determine whether they made any difference whats o ever?! <ponders if insurance covers purposely destroying PC>
  17. I must agree with fenway, i am not sure what it is your trying to do ??? Perhaps a CASE would work. [code=php:0]sum($a+$b+$c) as $total [/code] then.. [code=php:0] switch($total) { case  $total<15 :     $newtotal= 10; break; ....etc } [/code] I guess its the same thing that fenway said? Perhaps this will help in some way.
  18. Cool!! Now comes the research part!  ;D At least i know now there is an alternative way to do it. Thank you for your help!
  19. Forgive the lack of understanding of term but do you mean DB abstraction layers? After reading your reply i googled a tad, and found that there are basically four types of abstraction layers:   1.  A software library to connect to a database server and issue queries, fetch results etc.   2. A software library to present a common API to different database servers.   3. A software library to automatically generate portable SQL queries.   4. A software library to map Object-Oriented Programming to a relational database (Object-Relational Mapping, or ORM) Is this what you meant? I assume you have worked with these layers before. If so could you perhaps give me a starting point from where to work from? Some pointer or where you would start or website to read?  ??? ;D Will continue the google search for now. And thank you for this nudge in a direction. Much appreciated!
  20. Yeah have been thinking about it allot thus far. Will actually implement it that way! I have run out of any other option, beside hardcoding relations in the php, but that is just nasty and wrong!  :P But (just in case) is there a special "structure"/"communication" (lack of terminology) that could be made between the table with the data and the table with corresponding 'descriptions'? I am not all that sure that a Primary-key/Foreign-key application could be used?!  ??? I am not yet all that expert with the building of database relations. Thank you for assistance.
  21. Yeah i know. Am doing something similar at present. I just wanted to do it, because i really do not want to make extra tables or unnecessary code just to get two- or three worded descriptions! I usually try to do things a tad differently!  Thanks for the input though!! ;D
  22. This is not me pushing the posts. Just adding extra discovery. I have tried additional uses of mysql_fetch_field. By attempting to access the the value of "default" field. As is the example found on [URL=http://'http://www.php.net/manual/en/function.mysql-fetch-field.php']php.net - mysql_fetch_field[/URL] Unfortunately i get ALL the info back from the result set concerning all the colums i use, EXCEPT the default's value. So now ia m officially stumped!!
  23. I use Xampp for my development. I get that error every time when i update to a newer version. I also have no idea what the hell causes it. The only way i manage to get it working is by uninstalling any related Xampp programs (itself) and delete all files it leaves behind (making copies of anything i really need to keep) because it always leaves the mysql folders untouched for some reason. Then re-install then BANG works fine. Not the most technical solution! :P But hey it seems to work! ;)
  24. First off, i am still new with the forum thing so if this should be under a different section please tell me! Without the throwing of fruit and veg!  ;D I am making a html based personnel management system. Nothing big. I am using a combination of OOP based JS and PHP as well as some Ajax structures. The idea is user selects an employee then does a search of data concerning set employee. The call for data is sent from html via JS and Ajax to php, where data is retrieved, structured and sent back to JS classes that automatically builds a display interface showing the retrieved data. <u>My problem is this:</u> I would like to be able to retrieve a "description/comments" (for lack of better term) of a given column. At present i need to hard code a <b>SWITCH</b> or <b>IF</b> or whatever to define a description for a column. By this i mean that IF column: fname is selected then the description is set to "First Name", IF column: telnum then set to "Contact Number" etc etc. I would like to know if there is a way to make a description in the table on the column itself so that if i retrieve the value of column fname, then i can also get the "description" of the column? <b>EXAMPLE CONCEPT:</b> SELECT the value of column fname: "David" from table and SELECT the "description" of column fname: "First Name" from same table. Then i can pass both back to JS and bobs-your-uncle i can build generic interface class to display "First Name: David"  8) The closest i have been able to find is mysql_fetch_field, but as far as i have tried i cannot get it to assist me in this matter. Other ideas included making a sister-table witch has the "description" of each column, but doing this with ALL the tables is useless redundancy! If you have an idea of what i should do, functions to use or a website to go to, any help will be much appreciated! PS I am not the best at describing what is in my head and its latish! :P So if you don't understand what i mean, please feel free to ask any questions! :)
  25. Good day, I have searched for a solution or help on the following but it seems that my descriptions in the searches are not good enough to result in sufficient information! I have found that php has some built in functions which can be used in generating images (or editing blank images) that i can use. I would like to add one of those images to my "contact us" page, where some mis-shapen numbes or letters appear in the image. Then the user must type these numbers/letters to "verify" authenticity! In other word to avoid spam! :) "A CURSE ON THE HOUSE OF SPAM!!!........sorry." :) I ask if anyone can perhaps point me in the direction of a person or site where i can get some Tutorial or decription on doing it correctly and according to any known standards and in a secure way! Greately thank all in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.