IFACRUD (Create, Read, Update, Delete) ====================================== Modifications to this set of IFACRUD ------------------------------------ //29/09/18 ---------- Added $dateformat property to ifa_dbgrid class. Formats date columns if > 0. 1 = DD/MM/YYYY, 2 = DD/MM/YY, 3 = e.g. 1st Oct 2018. Changes to: ajax_get_tbl.php, ifa_ajax_classes.js & ifa_ajax_classes.php IFA CRUD Documentation: updated. //30/09/18 ---------- Implemented inherited $attrstr property in ifa_button class. Changes to: ifa_ajax_classes.php IFA CRUD Documentation: Already documented in ifa_data_inputs class //08/10/18 ---------- Removed hard-coded "document_base_url :" parameter from tinymce.init() and replaced it with the base domain taken from $this->app->href. Changes to: ifa_ajax_classes.php IFA CRUD Documentation: N/A //09/10/18 ---------- Added ajax_get_file.php which can be called from ifa_ajax_to_tinymce_content() to file the tinyMCE editor from a server based file. Changes to: N/A IFA CRUD Documentation: Added file. Added ajax_set_file.php which can be called from ifa_save_htmltxt_to_file() to save the contents of a tinyMCE editor to a server based file. Changes to: N/A IFA CRUD Documentation: Added file. Minor update to ifa_ajax_to_tinymce_content() to ensure display is updated after programatically changing the editor's contents Changes to: ifa_ajax_classes.js IFA CRUD Documentation: N/A Added ifa_save_htmltxt_to_file() which saves the contents of an ifa_htmlmemo (tinyMCE editor) to a server based file. Changes to: ifa_ajax_classes.js IFA CRUD Documentation: Added function. //11/10/18 ---------- Setting ifa_textinput's autocomplete to false now sets the text input's autocomplete attribute to "off" rather than just not setting the attribute at all Changes to: ifa_ajax_classes.php IFA CRUD Documentation: updated. Added ajax_insert_joined.php which can be called from ifa_ajax_insert() to add records to a couple of tables which can then be linked in a join using the ufv of one in a nominated column of the other. Changes to: N/A IFA CRUD Documentation: Added file. //25/10/18 ---------- Added the ifa_time class. Creates an input in which the user can enter 24hr clock format times with or without seconds (e.g. HH:MM or HH:MM:SS). ajax_get_value.php now looks for $_POST['maxlen'] and, if set, truncates the length of the (string) value it returns accordingly. Changes to: ifa_ajax_classes.php & ajax_get_value.php IFA CRUD Documentation: Added class. //31/10/18 ---------- Added the ifa_currency class. Creates an input which inherits from ifa_textinput and adds an onchange attribute that converts any number entered to a float with 2 decimal places and adds a patern attribute to detect any non-number Changes to: ifa_ajax_classes.php IFA CRUD Documentation: Added class. //04/11/18 ---------- Changed ifa_checkboxes() class, which was broken, to ifa_radio_checkboxes(). Added updatesql property and deleted multiple property (now never multiple) Changes to: ifa_ajax_classes.php & ifa_ajax_classes.js IFA CRUD Documentation: Added class & function. //05/11/18 ---------- Made ifa_date() respect readonly Changes to: ifa_ajax_classes.php IFA CRUD Documentation: N/A //09/11/18 ---------- Only add the onblur() event handler to an ifa_select() if $this->updatesql is set. Changes to: ifa_ajax_classes.php IFA CRUD Documentation: Updated. //16/11/18 ---------- Write up the new $_SESSION regime. Added ifa_sessions.php with the SessionManager class and the ifa_session_start(), ifa_using_db_sessions() & ifa_get_defs() functions. ifa.php which should be required at the top of each "app" file //20/11/18 ---------- Made ifa_date_input_blur() trigger a DB update if the values of all three date parts concatenated have changed when leaving the ifa_date collection of elements. Was being done individually which could lead to the date not being recorded if the last element blurred hadn't changed. Changes to: ifa_ajax_classes.js IFA CRUD Documentation: N/A //19/06/19 ---------- Tested for existing $_SESSION before starting a new one in ifa_session_start() to avoid the generation of "Notice: session_start(): A session had already been started - ignoring in ..." messages. Changes to: ifa_sessions.php IFA CRUD Documentation: N/A Added $readonly property to ifa_range class. Changes to ifa_ajax_classes.php IFA CRUD Documentation: Done Used empty() to test if there's a sort column set for a DBGrid instead of "!= ''" to avoid "Notice: Undefined index:" message when one hasn't been set. Changes to ifa_ajax_classes.php IFA CRUD Documentation: N/A Used empty() to test if there's a filter string set for a DBGrid to avoid "Notice: Undefined index:" message when one hasn't been set. Changes to ifa_ajax_classes.php IFA CRUD Documentation: N/A Initialised $ordstr & $str to avoid "Notice: Undefined variable:" messages. Changes to ajax_get_tbl.php IFA CRUD Documentation: N/A Used empty() to test if there's a page number set for a paginated DBGrid to avoid "Notice: Undefined index:" message when one hasn't been set. Changes to ifa_ajax_classes.php IFA CRUD Documentation: N/A Used empty() to test if $_GET['ufv'] has been set for a ifa_view_page to avoid "Notice: Undefined index:" message if one hasn't been set. Changes to ifa_page_classes.php IFA CRUD Documentation: N/A Removed old code which attempted to add a string version of the input's value to classes descended from the ifa_data_input class as the value is now automatically converted to an array. Changes to ifa_ajax_classes.php IFA CRUD Documentation: N/A Removed code assigning a value to $addposts which didn't seem to be being used to avoid "Notice: Undefined variable:" message. Changes to ifa_ajax_classes.php IFA CRUD Documentation: N/A //20/06/19 ---------- Various tweaks to get ifa_listview working Changes to ifa_ajax_classes.php & ifa_ajax_classes.js IFA CRUD Documentation: N/A Updated ifa_sql_to_value($sql) to return an empty string if the supplied $sql returns an empty result set Changes to ifa_func.php IFA CRUD Documentation: N/A //19/08/19 ---------- Added $destdir property to ifa_fileinput class to allow a destination directory on the server to be specified Changes to ifa_ajax_classes.php, ifa_ajax_classes.js & ajax_upload_file.php IFA CRUD Documentation: Updated. //22/01/20 ---------- Added $forcehttps property to ifa_page class. If true triggers a redirect to an HTTPS if connection is HTTP when the page is loaded Changes to ifa_page_classes.php. IFA CRUD Documentation: Updated. =================================================================================================================== Description ----------- A collection of .php & .js scripts that combine to enable the basic DB tasks of creating, reading, updating & deleting data PLUS listing records in a tabular format (DBGrid). A number of .css files control the appearance of the displays. There are various rules and dependancies that apply when using these files: Configuration ------------- All the IFACRUD files (ajax_*.php, ifa_ajax_*.*, ifa_*.php, reset.css) should be in their own directory - usually, but not necessarily, a sub-directory of the site or app specific files. The site or app specific files should include a menu.php, ifa.php & an ifa.ini. The paths and URLs to the two directory paths (IFACRIUD and site or app specific) need to be set in the ifa.ini file along with a few other app-wide default settings: Example: Demo app (and full documentation) at https://localhost/ifacruddocs/menu.php ifa_login.php ------------- ifa_login.php (or menu.php if logging in is not required) should start with the following lines: // Reset the session if page was opened with a ?reset query if (isset($_GET['reset'])): $_SESSION = array(); endif; //< if (!isset($_SESSION['ifa_code_dir'])): $_SESSION['app_config'] = dirname(__FILE__).'/ifa.ini'; $_SESSION['ifa_code_dir'] = $configarr['ifa_dir']; $_SESSION['defs'] = $configarr['defs']; endif; require_once($_SESSION['ifa_code_dir'].'ifa_page_classes.php'); $loginPage = new ifa_page(); // You don't need to be logged in to access this page! $loginPage->accesslevel = 0; ... IFACRUD files: -------------- ajax_delete.php ajax_get_combolist.php ajax_get_file.php ajax_get_list.php ajax_get_options.php ajax_get_session_value.php ajax_get_tbl.php ajax_get_value.php ajax_insert.php ajax_insert_joined.php ajax_query.php ajax_save_ifa_downs.php ajax_save_multi_sel.php ajax_set_file.php ajax_set_session_value.php ajax_set_value.php ajax_upload_file.php ifa_ajax_classes.css ifa_ajax_classes.js ifa_ajax_classes.php ifa_func.php ifa_page_classes.php ifa_sessions.php reset.css Stored in the application directory: ifa.ini ifa.php ifa_login.php ifa_loginproc.php ifa_logout.php menu.php Stored and named as set in ifa.ini. Examples css = ifacrud.css - App/Site specific css file. (Optional) spinner_url = bikewheel.png - Loader "Wait" image, displayed while pages load. (Optional) defs = /data01/c1234567/ifa/ifacruddocs_config.php - Definitions file for DB access. Should not be stored in a public dirtectory To Do: ------ General ======= * Investigate improving the security of the log-in password hashing. * Catch AJAX Network Errors e.g. try { xmlhttp.send(posts); } catch(exception) { if(exception.name == 'NetworkError') { console.log('There was a network error.'); } } Could prompt user to retry? * Investigate the security of the $_SESSION. * Investigate adding transactions to the PDO stuff *? Add a "query" object to build and allow the editing of an SQL query. See old ifa_mysql* stuff for how to divi SQL into sections. Use arrays to store the column expressions, where conditions, etc. ->build() to construct the sql str to be sent to the DB. *? Add an ifa_ajax_from_session() JS function and a PHP script to go with it to retrieve $_SESSION variables to be used in JS. May have to be a synchronous xmlhttp request? *? Get ifa_data_inputs->form working. * ifa_db_connect() - Needed anymore? * Need to be able to distinguish the correct $_SESSION when switching between two IFACRUD sites open at the same time. At the moment CSS and goodness knows what else gets confused.