| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- /*
- *
- * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
- *
- * http://www.opengamepanel.org/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
- function print_failure($text)
- {
- echo '<p class="failure">'.$text.'</p>';
- }
- function print_success($text)
- {
- echo '<p class="success">'.$text.'</p>';
- }
- function create_back_button($module,$subpage = "")
- {
- $retval = "<p><a href='?m=$module";
- if ( !empty($subpage) )
- {
- $retval .= "&p=$subpage";
- }
- $retval .= "'><< ".get_lang('back')."</a></p>\n";
- return $retval;
- }
- /// Creates HTML drop box from given array with the given listname, custom for Rsync sites
- function create_drop_box_from_array_rsync($input_array,$listname,$current_value = "", $use_only_values = true)
- {
- $retval = "<select id=\"$listname\" name=\"$listname\">\n";
- foreach($input_array as $key => $value)
- {
- $value = trim($value);
- list($rsync_site,$location) = explode("|", $value);
- // We want to print lines with zeros, but not empty lines.
- if ( $value !== "0" && empty($value) )
- {
- continue;
- }
- if ( $use_only_values === true )
- {
- # $key = $value;
- }
- if ( $key == $current_value )
- {
- $retval .= "<option value='$rsync_site' selected='selected'>$rsync_site - $location</option>\n";
- }
- else
- {
- $retval .= "<option value='$rsync_site'>$rsync_site - $location</option>\n";
- }
- }
- $retval .= "</select>\n";
- return $retval;
- }
- /// Creates HTML drop box from given array with the given listname.
- function create_drop_box_from_array($input_array,$listname,$current_value = "", $use_only_values = true)
- {
- $retval = "<select id=\"$listname\" name=\"$listname\" style=\"max-width:330px;\">\n";
- foreach($input_array as $key => $value)
- {
- // Make sure we don't allow HTML or script
- $key = trim(strip_tags($key));
- $value = trim(strip_tags($value));
-
- // We want to print lines with zeros, but not empty lines.
- if ( empty($value) and $value !="0" )
- {
- continue;
- }
- if ( $use_only_values === true )
- {
- $key = $value;
- }
- $sel = "";
-
- if ( $key == $current_value )
- {
- $sel .= "selected='selected'";
- }
- $retval .= "<option value='$key' $sel>$value</option>\n";
- }
- $retval .= "</select>\n";
- return $retval;
- }
- /// Creates HTML drop box from given array with the given listname.
- /// Used to create a list of users/groups. Remote_readfile is used to read in /etc/passwd and /etc/group
- function create_drop_box_from_passwd($input_array,$listname)
- {
- $retval = "<select name=\"$listname\">\n";
- foreach($input_array as $line)
- {
- $line = trim($line);
- if ( empty($line) ) continue;
- list($username, $junk, $uid, $gid, $comment, $home_dir, $shell) = explode(':', $line);
- if ( $uid < 500 ) continue; #this will filter out system id's, typically under 500
- $retval .= "<option value='$uid:$gid'>$username (uid=$uid gid=$gid home=$home_dir)</option>\n";
- }
- $retval .= "</select>\n";
- return $retval;
- }
- function get_user_uid_gid_from_passwd($input_array,$name)
- {
- foreach($input_array as $line)
- {
- $line = trim($line);
- if ( empty($line) ) continue;
- list($username, $junk, $uid, $gid, $comment, $home_dir, $shell) = explode(':', $line);
- if ( $username === $name )
- {
- $retval = "$uid:$gid";
- return $retval;
- }
- }
- }
- function check_theme_image($base_image_path)
- {
- $base_image_path = ltrim($base_image_path, "/");
- global $settings;
- return file_exists( 'themes/' . $settings['theme'] . "/" . $base_image_path ) ?
- 'themes/'.$settings['theme'] . "/" . $base_image_path :
- $base_image_path;
- }
- ?>
|