Changeset 718 for trunk


Ignore:
Timestamp:
Feb 17, 2020 11:01:55 PM (4 years ago)
Author:
anonymous
Message:

Minor fixes

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/form_template.cli.php

    r612 r718  
    209209        case 'dec' :
    210210        case 'numeric' :
    211         default :
    212211            $output[$field] = <<<E_O_F
    213212
     
    225224        case 'time' :
    226225        case 'year' :
    227         default :
    228226            $output[$field] = <<<E_O_F
    229227
  • trunk/bin/module_maker/skel/admin.php

    r664 r718  
    5656
    5757// Configure the cache object.
    58 $cache = new Cache('%NAME_PLURAL%');
     58$cache =& Cache::getInstance('%NAME_PLURAL%');
    5959$cache->setParam(array('enabled' => true, 'expires' => 60));
    6060
     
    6464$page = new PageNumbers();
    6565$page->setPerPage(getFormData('per_page'), 100);
    66 $page->setPageNumber(getFormData('page_number'));
     66$page->setPageNumber(getFormData('page_number', (getFormData('sort') ? 1 : null)));
    6767
    6868// Query parameters to retain always.
     
    9494switch (getFormData('op')) {
    9595
    96 case 'add' :
     96case 'add':
    9797    // Initialize variables for the form template.
    98     $frm =& addRecordForm();
     98    $frm = addRecordForm();
    9999    $nav->add(_("Add %ITEM_TITLE%"));
    100100    $main_template = '%ADMIN_FORM_TEMPLATE%';
    101101    break;
    102102
    103 case 'edit' :
     103case 'edit':
    104104    // Initialize variables for the form template.
    105     $frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
     105    $frm = editRecordForm(getFormData('%PRIMARY_KEY%'));
    106106    $nav->add(_("Edit %ITEM_TITLE%"));
    107107    $main_template = '%ADMIN_FORM_TEMPLATE%';
    108108    break;
    109109
    110 case 'del' :
     110case 'del':
    111111    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
    112112    if ($app->validBoomerangURL('%NAME_PLURAL%')) {
     
    118118    break;
    119119
    120 case 'insert' :
     120case 'insert':
    121121    if (getFormdata('cancel', false)) {
    122122        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
     
    129129    validateInput();
    130130    if ($fv->anyErrors()) {
    131         $frm =& addRecordForm();
     131        $frm = addRecordForm();
    132132        $frm = array_merge($frm, getFormData());
    133133        $nav->add(_("Add %ITEM_TITLE%"));
     
    147147    break;
    148148
    149 case 'update' :
     149case 'update':
    150150    if (getFormdata('reset', false)) {
    151151        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
     
    165165    validateInput();
    166166    if ($fv->anyErrors()) {
    167         $frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
     167        $frm = editRecordForm(getFormData('%PRIMARY_KEY%'));
    168168        $frm = array_merge($frm, getFormData());
    169169        $nav->add(_("Edit %ITEM_TITLE%"));
     
    216216%FORM_VALIDATION%
    217217
    218 function &addRecordForm()
     218function addRecordForm()
    219219{
    220220    // Set default values for the reset of the fields.
     
    232232}
    233233
    234 function &editRecordForm($id)
     234function editRecordForm($id)
    235235{
    236236    global $lock, $locally_carried_queries;
  • trunk/lib/Lock.inc.php

    r694 r718  
    217217            return true;
    218218        } else {
    219             $app->logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
    220219            return false;
    221220        }
  • trunk/lib/PDO.inc.php

    r698 r718  
    401401            $stmt = $this->dbh->query($query);
    402402            if (!$stmt) {
    403                 throw new Exception('PDO::query returned false');
     403                throw new \Exception('PDO::query returned false');
    404404            }
    405405        } catch (\Exception $e) {
     
    454454            $stmt = $this->dbh->prepare($query, ...$params);
    455455            if (!$stmt) {
    456                 throw new Exception('PDO::query returned false');
     456                throw new \Exception('PDO::prepare returned false');
    457457            }
    458458        } catch (\PDOException $e) {
     
    499499
    500500    /*
    501     *
    502     *
    503     * @access   public
    504     * @param
    505     * @return
     501    * Remove unsafe characters from SQL identifiers (tables, views, indexes, columns, and constraints).
     502    *
     503    * @access   public
     504    * @param    string  $idname     Identifier name.
     505    * @return   string              Clean string.
    506506    * @author   Quinn Comendant <quinn@strangecode.com>
    507507    * @since    09 Jul 2019 18:32:55
    508508    */
    509     static function sanitizeIdentifier($str)
    510     {
    511         return preg_replace('/\W/u', '', $str);
     509    static function sanitizeIdentifier($idname)
     510    {
     511        return preg_replace('/\W/u', '', $idname);
    512512    }
    513513
  • trunk/lib/Utilities.inc.php

    r715 r718  
    677677    $val = trim(ini_get($val));
    678678    if ($val != '') {
    679         $last = strtolower($val{strlen($val) - 1});
    680     } else {
    681         $last = '';
    682     }
    683     switch ($last) {
    684         // The 'G' modifier is available since PHP 5.1.0
    685         case 'g':
    686             $val *= 1024;
    687         case 'm':
    688             $val *= 1024;
    689         case 'k':
    690             $val *= 1024;
     679        $unit = strtolower($val{strlen($val) - 1});
     680        $val = preg_replace('/\D/', '', $val);
     681
     682        switch ($unit) {
     683            // No `break`, so these multiplications are cumulative.
     684            case 'g':
     685                $val *= 1024;
     686            case 'm':
     687                $val *= 1024;
     688            case 'k':
     689                $val *= 1024;
     690        }
    691691    }
    692692
     
    10631063    $app =& App::getInstance();
    10641064
    1065     if ('POST' == getenv('REQUEST_METHOD') && null === $key) {
    1066         return dispelMagicQuotes($_POST, $app->getParam('always_dispel_magicquotes'));
    1067     } else if ('GET' == getenv('REQUEST_METHOD') && null === $key) {
    1068         return dispelMagicQuotes($_GET, $app->getParam('always_dispel_magicquotes'));
     1065    if (null === $key) {
     1066        // Return entire array.
     1067        switch (strtoupper(getenv('REQUEST_METHOD'))) {
     1068        case 'POST':
     1069            return dispelMagicQuotes($_POST, $app->getParam('always_dispel_magicquotes'));
     1070
     1071        case 'GET':
     1072            return dispelMagicQuotes($_GET, $app->getParam('always_dispel_magicquotes'));
     1073
     1074        default:
     1075            return dispelMagicQuotes($_REQUEST, $app->getParam('always_dispel_magicquotes'));
     1076        }
    10691077    }
    10701078
     
    11391147        break;
    11401148    }
     1149
     1150    $_REQUEST[$key] = $val;
    11411151}
    11421152
Note: See TracChangeset for help on using the changeset viewer.