/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { $file = array_key_exists('param', $map) ? $map['param'] : 'ocprocks'; require_code('textfiles'); require_lang('ocprocks'); $place = _find_text_file_path($file, ''); if (!file_exists($place)) { warn_exit(do_lang_tempcode('DIRECTORY_NOT_FOUND', escape_html($place))); } $edit_url = new ocp_tempcode(); return do_template('BLOCK_MAIN_OCPROCKS', array('FILE' => $file, 'CONTENT' => apply_emoticons($this->get_random_line($place)))); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('quotes'); $file = array_key_exists('param', $map) ? $map['param'] : 'quotes'; $title = array_key_exists('title', $map) ? $map['title'] : do_lang('QUOTES'); require_code('textfiles'); $place = _find_text_file_path($file, ''); if (!file_exists($place)) { warn_exit(do_lang_tempcode('DIRECTORY_NOT_FOUND', escape_html($place))); } $edit_url = new ocp_tempcode(); if ($file == 'quotes' && has_actual_page_access(get_member(), 'quotes', 'adminzone')) { $edit_url = build_url(array('page' => 'quotes'), 'adminzone'); } return do_template('BLOCK_MAIN_QUOTES', array('_GUID' => '7cab7422f603f7b1197c940de48b99aa', 'TITLE' => $title, 'EDIT_URL' => $edit_url, 'FILE' => $file, 'CONTENT' => comcode_to_tempcode($this->get_random_line($place), NULL, true))); }
/** * Write a text file, using the _custom system * * @param string The file name (without .txt) * @param ?LANGUAGE_NAME The language to write for (NULL: none) (blank: search) * @param string The data to write */ function write_text_file($codename, $lang, $out) { $xpath = _find_text_file_path($codename, $lang); if ($xpath == '') { $xpath = get_file_base() . '/text/' . user_lang() . '/' . $codename . '.txt'; } $path = str_replace(get_file_base() . '/text/', get_custom_file_base() . '/text_custom/', $xpath); $myfile = @fopen($path, 'wt'); if ($myfile === false) { intelligent_write_error($path); } $out = unixify_line_format($out); if (fwrite($myfile, $out) < strlen($out)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); fix_permissions($path); sync_file($path); }