set_title("Cron Uploader"); $page->set_heading("Cron Uploader"); if (!$config->get_bool(UserConfig::ENABLE_API_KEYS)) { $info_html .= "THIS EXTENSION REQUIRES USER API KEYS TO BE ENABLED IN BOARD ADMIN"; } $info_html .= "Information
" . ($running ? "" : "") . "
Cron upload is currently running
Directory Files Size (MB) Directory Path
Queue {$queue_dirinfo['total_files']} {$queue_dirinfo['total_mb']} {$queue_dirinfo['path']}
Uploaded {$uploaded_dirinfo['total_files']} {$uploaded_dirinfo['total_mb']} {$uploaded_dirinfo['path']}
Failed {$failed_dirinfo['total_files']} {$failed_dirinfo['total_mb']} {$failed_dirinfo['path']}
Cron Command:
Create a cron job with the command above. Read the documentation if you're not sure what to do.
URL:
"; $install_html = " This cron uploader is fairly easy to use but has to be configured first.
  1. Install & activate this plugin.
  2. Go to the Board Config and change any settings to match your preference.
  3. Copy the cron command above.
  4. Create a cron job or something else that can open a url on specified times.
    cron is a service that runs commands over and over again on a a schedule. You can set up cron (or any similar tool) to run the command above to trigger the import on whatever schedule you desire.
    If you're not sure how to do this, you can give the command to your web host and you can ask them to create the cron job for you.
    When you create the cron job, you choose when to upload new posts.
"; $max_time = intval(ini_get('max_execution_time'))*.8; $usage_html = "Upload your images you want to be uploaded to the queue directory using your FTP client or other means.
({$queue_dirinfo['path']})
  1. Any sub-folders will be turned into tags.
  2. If the file name matches \"## - tag1 tag2.png\" the tags will be used.
  3. If both are found, they will all be used.
  4. The character \";\" will be changed into \":\" in any tags.
  5. You can inherit categories by creating a folder that ends with \";\". For instance category;\\tag1 would result in the tag category:tag1. This allows creating a category folder, then creating many subfolders that will use that category.
The cron uploader works by importing files from the queue folder whenever this url is visited:
$cron_url
"; $block = new Block("Cron Uploader", $info_html, "main", 10); $block_install = new Block("Setup Guide", $install_html, "main", 30); $block_usage= new Block("Usage Guide", $usage_html, "main", 20); $page->add_block($block); $page->add_block($block_install); $page->add_block($block_usage); if (!empty($log_entries)) { $log_html = ""; foreach ($log_entries as $entry) { $log_html .= ""; } $log_html .= "
{$entry["date_sent"]}{$entry["message"]}
"; $block = new Block("Log", $log_html, "main", 40); $page->add_block($block); } } public function get_user_options(string $dir, bool $stop_on_error, int $log_level, bool $all_logs): string { $form = SHM_SIMPLE_FORM( "user_admin/cron_uploader", TABLE( ["class"=>"form"], TBODY( TR( TH("Cron Uploader") ), TR( TH("Root dir"), TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) ), TR( TH(), TD( LABEL(INPUT(["type"=>'checkbox', "name"=>'stop_on_error']), "Stop On Error") ) ), TR( TH(rawHTML("Repeat Password")), TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) ) ), TFOOT( TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Save Settings"]))) ) ) ); $html = emptyHTML($form); return (string)$html; } public function display_form(array $failed_dirs) { global $page; $link = make_http(make_link("cron_upload")); $html = "Cron uploader documentation"; $html .= make_form(make_link("admin/cron_uploader_restage")); $html .= ""; $html .= ""; $html .= ""; $html .= "
Failed dir
"; $html .= make_form(make_link("admin/cron_uploader_clear_queue"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the queue folder?');") ."
" ."
"; $html .= make_form(make_link("admin/cron_uploader_clear_uploaded"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the uploaded folder?');") ."
" ."
"; $html .= make_form(make_link("admin/cron_uploader_clear_failed"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the failed folder?');") ."
" ."
"; $html .= "\n"; $page->add_block(new Block("Cron Upload", $html)); } }