/** * Implementation of hook_page. */ function ft_db_page($act) { global $ft; $str = ''; if ($act == 'db' && isset($ft['plugins']['db']['settings']['flushtables']) && $ft['plugins']['db']['settings']['flushtables'] === TRUE) { // Show all DB tables. $str .= "<h2>" . t('Database tables') . "</h2>"; // Other users. if (is_array($ft['db']) && is_array($ft['db']['tables']) && count($ft['db']['tables']) > 0) { $str .= '<table><tr><th>' . t('Table name') . '</th><th>' . t('Delete?') . '</th></tr>'; foreach ($ft['db']['tables'] as $name) { $str .= '<tr><td>' . $name . '</td><td>' . ft_make_link(t('delete'), 'act=db_delete&value=' . $name) . '</td></tr>'; } $str .= '</table>'; } else { $str .= '<p>' . t('No tables present in database.') . '</p>'; } } elseif ($act == 'db_delete') { $display_value = htmlentities($_GET['value']); $str = "<h2>" . t('Delete database table: !table', array('!table' => $display_value)) . "</h2>"; $str .= "<p>" . t('Are you sure you want to continue? This will delete the table from the database.') . "</p>"; $str .= '<form action="' . ft_get_self() . '" method="post">'; $str .= '<div>'; $str .= '<input type="hidden" name="value" value="' . $display_value . '">'; $str .= '<input type="hidden" name="act" value="db_delete_submit">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Yes, delete this table') . '">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '"> </div> </form>'; } return $str; }
/** * Implementation of hook_add_js_call. */ function ft_fckeditor_add_js_call() { global $ft; $return = ''; // Only add JS when we're on an edit page. if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit' && file_exists($ft['plugins']['fckeditor']['settings']['path'])) { $list = explode(" ", $ft['plugins']['fckeditor']['settings']['list']); if (in_array(ft_get_ext(strtolower($_REQUEST['file'])), $list)) { $return .= 'var oFCKeditor = new FCKeditor("filecontent") ; oFCKeditor.BasePath = "' . $ft['plugins']['fckeditor']['settings']['BasePath'] . '" ; oFCKeditor.ReplaceTextarea() ;'; // Unbind save action and rebind with a fckeditor specific version. $return .= '$("#save").unbind();$("#save").click(function(){ $("#savestatus").empty().append("<p class=\\"ok\\">' . t('Saving file…') . '</p>"); // Get file content from fckeditor. oEditor = FCKeditorAPI.GetInstance("filecontent"); filecontent = oEditor.GetHTML(); $.post("' . ft_get_self() . '", {method:\'ajax\', act:\'saveedit\', file: $(\'#file\').val(), dir: $(\'#dir\').val(), filecontent: filecontent, convertspaces: $(\'#convertspaces\').val()}, function(data){ $("#savestatus").empty().append(data); }); });'; } } return $return; }
/** * Implementation of hook_add_js_call. */ function ft_editorck_add_js_call() { global $ft; $return = ''; // Only add JS when we're on an edit page. if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit' && file_exists($ft['plugins']['editorck']['settings']['path'])) { $list = explode(" ", $ft['plugins']['editorck']['settings']['list']); if (in_array(ft_get_ext(strtolower($_REQUEST['file'])), $list)) { // Unbind save action and rebind with a ckeditor specific version. $return .= '$("#save").unbind();$("#save").click(function(){ $("#savestatus").empty().append("<p class=\\"ok\\">' . t('Saving file…') . '</p>"); // Get file content from ckeditor. filecontent = CKEDITOR.instances.filecontent.getData();; $.post("' . ft_get_self() . '", {method:\'ajax\', act:\'saveedit\', file: $(\'#file\').val(), dir: $(\'#dir\').val(), filecontent: filecontent, convertspaces: $(\'#convertspaces\').val()}, function(data){ $("#savestatus").empty().append(data); }); });'; } } return $return; }
/** * Create HTML for sidebar. */ function ft_make_sidebar() { $str = '<div id="sidebar">'; // $status = ''; // if (ft_check_upload() === TRUE && is_writeable(ft_get_dir()) && (LIMIT > 0 && LIMIT < ROOTDIRSIZE)) { // $status = '<p class="alarm">' . t('Upload disabled. Total disk space use of !size exceeds the limit of !limit.', array('!limit' => ft_get_nice_filesize(LIMIT), '!size' => ft_get_nice_filesize(ROOTDIRSIZE))) . '</p>'; // } // $status .= ft_make_messages(); // if (empty($status)) { // $str .= "<div id='status' class='hidden'></div>"; // } else { // $str .= "<div id='status' class='section'><h2>".t('Results')."</h2>{$status}</div>"; // } if (ft_check_upload() === TRUE && is_writeable(ft_get_dir())) { if (LIMIT <= 0 || LIMIT > ROOTDIRSIZE) { $str .= ' <div class="section" id="create"> <h2>' . t('Upload files') . '</h2> <form action="' . ft_get_self() . '" method="post" enctype="multipart/form-data"> <div id="uploadsection"> <input type="hidden" name="MAX_FILE_SIZE" value="' . MAXSIZE . '" /> <input type="file" class="upload" name="localfile" id="localfile-0" size="12" /> <input type="hidden" name="act" value="upload" /> <input type="hidden" name="dir" value="' . $_REQUEST['dir'] . '" /> </div> <div id="uploadbutton"> <input type="submit" name="submit" value="' . t('Upload') . '" /> </div> <div class="info">' . t('Max:') . ' <strong>' . ft_get_max_upload() . ' / ' . ft_get_nice_filesize(ft_get_bytes(ini_get('upload_max_filesize')) < ft_get_bytes(ini_get('post_max_size')) ? ft_get_bytes(ini_get('upload_max_filesize')) : ft_get_bytes(ini_get('post_max_size'))) . '</strong></div> <div style="clear:both;"></div> </form> </div>'; } } if (CREATE) { $str .= ' <div class="section" id="new"> <h2>' . t('Create folder') . '</h2> <form action="' . ft_get_self() . '" method="post"> <div> <input type="radio" name="type" value="folder" id="type-folder" checked="checked" /> <label for="type-folder" class="label_highlight">' . t('Folder') . '</label> <input type="radio" name="type" value="file" id="type-file" /> <label for="type-file">' . t('File') . '</label> <input type="radio" name="type" value="url" id="type-url" /> <label for="type-url">' . t('From URL') . '</label> </div> <div> <input type="text" name="newdir" id="newdir" size="16" /> <input type="hidden" name="act" value="createdir" /> <input type="hidden" name="dir" value="' . $_REQUEST['dir'] . '" /> <input type="submit" id="mkdirsubmit" name="submit" value="' . t('Ok') . '" /> </div> </form> </div>'; } $sidebar = array(); $result = ft_invoke_hook('sidebar'); $sidebar = array_merge($sidebar, $result); if (is_array($sidebar)) { foreach ($sidebar as $c) { $str .= $c['content']; } } $str .= '</div>'; return $str; }
/** * Implementation of hook_add_js_call. */ function ft_edit_add_js_call() { $return = ''; // Save via ajax (opposed to save & exit) if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'edit') { $return .= '$("#save").click(function(){ $("#savestatus").empty().append("<p class=\\"ok\\">' . t('Saving file…') . '</p>"); $.post("' . ft_get_self() . '", {method:\'ajax\', act:\'saveedit\', file: $(\'#file\').val(), dir: $(\'#dir\').val(), filecontent: $(\'#filecontent\').val(), convertspaces: $(\'#convertspaces\').val()}, function(data){ $("#savestatus").empty().append(data); }); });'; // Heartbeat to keep file locked. $return .= 'ft.edit_beat = function(){ $.post("' . ft_get_self() . '", {method:\'ajax\', act:\'edit_get_lock\', file: $(\'#file\').val(), dir: $(\'#dir\').val()}, function(data){ }); }; ft.edit_heartbeat = setInterval(function() { // Make ajax call to make sure file stays locked. ft.edit_beat(); }, 30000);'; } else { $return = 'ft.fileactions.edit = {type: "sendoff", link: "' . t('Edit') . '", text: "' . t('Do you want to edit this file?') . '", button: "' . t('Yes, edit file') . '"};'; } return $return; }
/** * Implementation of hook_add_js_call. */ function ft_search_add_js_call() { $return = ''; $return .= "\$('#searchform').ft_search({\r\n"; if (!empty($_REQUEST['dir'])) { $return .= "\tdirectory: '{$_REQUEST['dir']}',\r\n"; } else { $return .= "\tdirectory: '',\r\n"; } $return .= "\tformpost: '" . ft_get_self() . "',\r\n"; $return .= "\theader: '" . t('Results') . "',\r\n"; $return .= "\tloading: '" . t('Fetching results…') . "'\r\n"; $return .= '});'; return $return; }
/** * Implementation of hook_page. */ function ft_log_page($act) { global $ft; $str = ''; if ($act == 'log' && isset($ft['plugins']['log']['settings']['viewlogs']) && $ft['plugins']['log']['settings']['viewlogs'] === TRUE) { $types = ft_log_get_types(); $boundaries = ft_log_get_boundaries(); $month_min = date('m', strtotime($boundaries['oldest'])); $month_max = date('m', strtotime($boundaries['newest'])); $year_min = date('Y', strtotime($boundaries['oldest'])); $year_max = date('Y', strtotime($boundaries['newest'])); $str = "<h2>" . t('Log') . "</h2>"; $str .= '<div>'; // Filters. $str .= '<form action="' . ft_get_self() . '?act=log" method="get">'; $str .= '<div>'; $str .= ' <label for="type">' . t('Show') . ' </label>'; $str .= '<select id="type" name="type">'; $str .= '<option value="">All types</option>'; foreach ($types as $type) { $str .= '<option value="' . $type . '" ' . ($type == $_GET['type'] ? 'selected="selected"' : '') . '>' . $type . '</option>'; } $str .= '</select> '; $str .= '<label for="from">' . t('from:') . ' </label>'; $str .= '<select id="from_day" name="from_day">'; $str .= '<option value="">--</option>'; $str .= ft_log_get_date_options('from_day'); $str .= '</select> '; $str .= '<select id="from" name="from">'; $str .= '<option value="">Any month</option>'; $str .= ft_log_get_month_options($month_min, $month_max, $year_min, $year_max, 'from'); $str .= '</select>'; $str .= ' <label for="to">' . t('to:') . ' </label>'; $str .= '<select id="to_day" name="to_day">'; $str .= '<option value="">--</option>'; $str .= ft_log_get_date_options('to_day'); $str .= '</select> '; $str .= '<select id="to" name="to">'; $str .= '<option value="">Any month</option>'; $str .= ft_log_get_month_options($month_min, $month_max, $year_min, $year_max, 'to'); $str .= '</select> '; $str .= '<input type="submit" name="ft_submit" value="' . t('Show') . '">'; $str .= '<input type="hidden" name="act" value="log">'; $str .= '</div>'; $str .= '</form>'; $str .= '<table id="log_table" class="tablesorter"><thead><tr><th>' . t('Type') . '</th><th>' . t('Message') . '</th><th>' . t('Location') . '<th>' . t('Timestamp') . '</th></tr></thead><tbody>'; $items = ft_log_do_query($_GET['type'], $_GET['from_day'], $_GET['from'], $_GET['to_day'], $_GET['to']); foreach ($items as $row) { $str .= '<tr><td>' . $row['type'] . '</td><td>' . htmlentities($row['message']) . '</td><td>' . htmlentities($row['location']) . '</td><td>' . $row['timestamp'] . '</td></tr>'; } $str .= '</tbody></table>'; $str .= '<form action="' . ft_get_self() . '" method="post" accept-charset="utf-8" style="margin-left:300px;"><div><input type="submit" value="' . t('Delete records older than 7 months') . '"><input type="hidden" name="act" value="log_prune" /> '; $query = 'act=log_csv&type=' . $_GET['type'] . '&from_day=' . $_GET['from_day'] . '&from=' . $_GET['from'] . '&to_day=' . $_GET['to_day'] . '&to=' . $_GET['to']; $str .= ft_make_link(t('Download CSV report'), $query, t("Download CSV report of current view")); $str .= '</div></form>'; $str .= '</div>'; } return $str; }
/** * Implementation of hook_page. */ function ft_config_page($act) { global $ft; $str = ''; if ($act == 'config') { // Default settings. $str .= '<div style="float:left;">'; $str .= "<h2>" . t('Default settings') . "</h2>"; $str .= "<p>" . ft_make_link(t('Edit default settings'), 'act=config_default') . "</p>"; // Show a list of users. $str .= "<h2>" . t('Users') . "</h2>"; $str .= "<p>" . ft_make_link(t('Add new user'), 'act=user_add') . "</p>"; $str .= '<table><tr><th>' . t('Username') . '</th><th>' . t('Group') . '</th><th>' . t('Delete?') . '</th></tr>'; // Default user. Cannot be deleted or edited. if (USERNAME != '') { $str .= '<tr><td>' . USERNAME . '</td><td></td></tr>'; } // Other users. if (is_array($ft['users'])) { foreach ($ft['users'] as $k => $v) { if (empty($v['group'])) { $v['group'] = ''; } $str .= '<tr><td>' . ft_make_link($k, 'act=user_edit&user='******'Edit !user', array('!user' => $k))) . '</td><td>' . $v['group'] . '</td><td>' . ft_make_link(t('delete'), 'act=user_delete&value=' . $k) . '</td></tr>'; } } $str .= '</table>'; // Show groups $str .= "<h2>" . t('Groups') . "</h2>"; $str .= "<p>" . ft_make_link(t('Add new group'), 'act=user_add_group') . "</p>"; // Other users. if (is_array($ft['groups'])) { $str .= '<table><tr><th>' . t('Group') . '</th><th>' . t('Users') . '</th><th>' . t('Delete?') . '</th></tr>'; foreach ($ft['groups'] as $k => $v) { $str .= '<tr><td>' . ft_make_link($k, 'act=user_edit_group&group=' . $k, t('Edit !user', array('!user' => $k))) . '</td><td>'; // Get users in this group. $c_users = ft_get_users_by_group($k); $str .= implode('<br>', $c_users); $str .= '</td><td>' . ft_make_link(t('delete'), 'act=user_delete_group&value=' . $k) . '</td></tr>'; } } $str .= '</table>'; $str .= '</div>'; } elseif ($act == 'config_default') { // Edit default settings and plugins. $str .= '<div style="float:left;">'; $str .= "<h2>" . t('Default settings and plugins') . "</h2>"; $str .= "<p>" . t('Settings and plugins on this page will be used unless a group overrides the setting or disables the plugin.') . "</p>"; $str .= '<form action="' . ft_get_self() . '" method="post" id="ft_group_form">'; $ext = ft_settings_external_load(); $str .= ft_config_make_settings('default', $ext['settings']); $str .= ft_config_make_plugins($ext['plugins']); $str .= '<div class="submit_group">'; $str .= '<input type="hidden" name="act" value="config_default_submit">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Save settings') . '">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '"> </div> </form>'; $str .= '</div>'; } elseif ($act == 'user_add_group' || $act == 'user_edit_group') { // Add a new group. $group = ''; $str .= '<div style="float:left;">'; $str .= "<h2>" . t('Add group') . "</h2>"; if ($act == 'user_edit_group') { $group = ft_settings_external_clean($_GET['group']); $str .= "<h2>" . t('Edit user:'******'<form action="' . ft_get_self() . '" method="post" id="ft_group_form"> <fieldset id="group_name"><legend>' . t('Group name') . '</legend><table><tr><td class="setting"> <label for="user_group">' . t('Group name:') . '</label></td><td> <input type="text" name="user_group" value="' . $group . '" id="user_user"></td></tr></table> </fieldset>'; // Show default settings. if ($act == 'user_edit_group') { $str .= ft_config_make_settings('group', $ft['groups'][$group]); $str .= ft_config_make_plugins($ft['groups'][$group]['plugins']); } else { $str .= ft_config_make_settings('group', array()); $str .= ft_config_make_plugins(array()); } $str .= '</fieldset>'; $str .= '<div class="submit_group">'; if ($act == 'user_edit_group') { $str .= '<input type="hidden" name="group_old" value="' . $group . '">'; $str .= '<input type="hidden" name="act" value="user_edit_submit_group">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Edit group') . '">'; } else { $str .= '<input type="hidden" name="act" value="user_add_submit_group">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Add group') . '">'; } $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '"> </div> </form>'; $str .= '</div>'; } elseif ($act == 'user_add' || $act == 'user_edit') { $user = ''; $group = NULL; $str .= '<div style="float:left;">'; $str .= "<h2>" . t('Add user') . "</h2>"; if (!empty($_GET['user'])) { $user = ft_settings_external_clean($_GET['user']); if (is_array($ft['users']) && is_array($ft['users'][$user]) && !empty($ft['users'][$user]['group'])) { $group = $ft['users'][$user]['group']; } $str .= "<h2>" . t('Edit user:'******'<form id="ft_user_form" action="' . ft_get_self() . '" method="post"><table> <tr><td> <label for="user_user">' . t('Username:'******'</label></td><td> <input type="text" name="user_user" value="' . $user . '" id="user_user"> </td></tr> <tr><td> <label for="user_pass">' . t('Password:'******'</label></td><td> <input type="password" name="user_pass" value="" id="user_pass"> </td></tr> <tr><td> <label for="user_pass2">' . t('Confirm:') . '</label></td><td> <input type="password" name="user_pass2" value="" id="user_pass2"> </td></tr> <tr><td> <label for="user_group">' . t('Group:') . '</label></td><td> <select name="user_group" id="user_group"> <option value="">' . htmlentities(t('<none> (default settings)')) . '</option>'; // Get list of groups. if (is_array($ft['groups'])) { foreach ($ft['groups'] as $k => $v) { if ($act == 'user_edit' && $k === $group) { $str .= '<option selected="selected">' . $k . '</option>'; } else { $str .= '<option>' . $k . '</option>'; } } } $str .= '</select></td></tr></table> <div class="submit_group">'; if ($act == 'user_edit') { $str .= '<input type="hidden" name="user_old" value="' . $user . '">'; $str .= '<input type="hidden" name="act" value="user_edit_submit">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Edit user') . '">'; } else { $str .= '<input type="hidden" name="act" value="user_add_submit">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Add user') . '">'; } $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '"> </div> </form>'; $str .= '</div>'; } elseif ($act == 'user_delete' || $act == 'user_delete_group') { $value = ft_settings_external_clean($_GET['value']); $str .= '<div style="float:left;">'; $str .= "<h2>" . t('Delete user: !user', array('!user' => $value)) . "</h2>"; $str .= "<p>" . t('Are you sure you want to continue? This will delete the user from the system.') . "</p>"; $type = 'user'; if ($act == 'user_delete_group') { $str = "<h2>" . t('Delete group: !group', array('!group' => $value)) . "</h2>"; $userlist = ft_get_users_by_group($value); if (count($userlist) > 0) { $userlist = '<ul><li>' . implode('</li><li>', $userlist) . '</li></ul>'; } else { $userlist = '<ul><li class="error">' . t('This group has no users to delete.') . '</li></ul>'; } $str .= "<p>" . t('Are you sure you want to continue? This will delete the group and all users in this group.') . "{$userlist}</p>"; $type = 'group'; } $str .= '<form action="' . ft_get_self() . '" method="post">'; $str .= '<div>'; $str .= '<input type="hidden" name="value" value="' . $value . '">'; $str .= '<input type="hidden" name="act" value="user_delete_submit">'; if ($act == 'user_delete') { $str .= '<input type="hidden" name="type" value="user">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Yes, delete this user') . '">'; } else { $str .= '<input type="hidden" name="type" value="group">'; $str .= '<input type="submit" name="ft_submit" value="' . t('Yes, delete this group and all users in it') . '">'; } $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '"> </div> </form>'; $str .= '</div>'; } return $str; }