Ετήσια αρχεία: 2021


A trick into using rsync with a custom port

As rsync will not accept to be given a custom port on the destination address, a way around it is to initiate an ssh connection that will handle it for you:

rsync -e 'ssh -p 2222' $SOURCE_DIR $DEST_DIR;


Simple PHP script that lists all files in a directory, sorts them by modification date, and creates hyperlinks for each

<?php

echo '<html>';

$ignore = array('.', '..', 'index.php');
$files = array();

foreach (scandir($dir) as $file) {
  if (in_array($file, $ignore)) {
    continue;
  }
  $files[$file] = filemtime($dir . '/' . $file);
}

arsort($files);

$keys = array_keys($files);

foreach ($files as $key => $value) {
  echo date('r', $value), ' <a href="', $dir, '/', $key, '">', $key, '</a><br/>';
}

echo 'Done';

echo '</html>';
?>

Gravity Forms: How to Restrict a DatePicker Date Range and Datepicker 1 becomes minDate for datepicker 2

Create an html block in your form and add the following code:

<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    if ( formId == 10 && (fieldId == 30 || fieldId == 32) ) {
        var ranges = [
            { start: new Date('10/01/2021'), end: new Date('10/11/2021') }
        ];
        optionsObj.beforeShowDay = function(date) {
            for ( var i=0; i<ranges.length; i++ ) {
                if ( date >= ranges[i].start && date <= ranges[i].end ) return [true, ''];
            }
            return [false, ''];
        };
        optionsObj.minDate = ranges[0].start;
        optionsObj.maxDate = ranges[ranges.length -1].end;
    }
    if ( formId == 10 && fieldId == 30 ) {
        optionsObj.onClose = function (dateText, inst) {
            jQuery('#input_10_32').datepicker('option', 'minDate', dateText).datepicker('setDate', dateText);
        };
    }
    return optionsObj;
});
</script>

Be sure to change the dates, the form ID and field ID for the two fields.