/[scire]/webgli/webgliUtility.php
Gentoo

Contents of /webgli/webgliUtility.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 55 - (show annotations) (download)
Sun May 7 19:57:58 2006 UTC (11 years, 9 months ago) by codeman
File size: 7924 byte(s)
adding a lot of webgli screens, some of which are done
the details of the status of webgli is in /webgli/TODO

1 <?php
2 #Utility functions for WebGLI
3
4 ##
5 # Will take a password and return it hashed in md5 format
6 # @param password the password to be hashed
7 function hash_password($password)
8 {
9 $salt = "$1$";
10 $chars = "./abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
11 for($i=0;$i<=8;$i++) { # in range(0, 8):
12 $salt .= $chars[rand(0,strlen($chars)-1)]; #chars[random.randint(0, len(chars)-1)]
13 }
14 $salt .= "$";
15 $passwd_hash = crypt($password, $salt);
16
17 return $passwd_hash;
18 }
19
20 function get_eth_devices()
21 {
22 $eth_devices = system("/sbin/ifconfig -a | grep -e '^[A-Za-z]'| cut -d ' ' -f 1");
23 return split(' ',$eth_devices);
24 }
25
26 function list_modules()
27 {
28 exec("lsmod | grep -v ^Module | cut -d ' ' -f 1 ", $modules);
29 return $modules;
30 }
31
32 function generate_keymap_list()
33 {
34 $keymap_list = array();
35 $path = "/usr/share/keymaps";
36
37 # find /usr/share/keymaps -iname *.map.gz -printf "%f \n"
38 exec("find ".$path." -iname *.map.gz -printf \"%f \n\"",$output);
39 foreach ($output as $keymap) {
40 # strip the last 9 chars ( .map.gz\n )
41 $keymap = trim($keymap);
42 $keymap = substr($keymap,0,-7);
43 array_push($keymap_list, $keymap);
44 }
45 # sort the keymap list
46 sort($keymap_list);
47
48 return $keymap_list;
49 }
50
51 function generate_consolefont_list()
52 {
53 $consolefont_list = array();
54 $path = "/usr/share/consolefonts";
55
56 # find /usr/share/consolefonts -iname *.gz -printf "%f \n"
57 exec("find ".$path." -iname *.gz -printf \"%f \n\"", $output);
58 foreach ($output as $consolefont) {
59 # strip the last 5 chars ( .gz\n )
60 $consolefont = trim($consolefont);
61 $consolefont = substr($consolefont,0,-3);
62
63 # test if its psfu or psf or fnt
64 # and remove it if necessary
65 if (substr($consolefont,-4) == "psfu") {
66 $consolefont = substr($consolefont,0,-5);
67 }
68 if (substr($consolefont,-3) == "psf") {
69 $consolefont = substr($consolefont,0,-4);
70 }
71 if (substr($consolefont,-3) =="fnt") {
72 $consolefont = substr($consolefont,0,-4);
73 }
74 array_push($consolefont_list, $consolefont);
75 }
76 # sort the keymap list
77 sort($consolefont_list);
78
79 return $consolefont_list;
80 }
81 /* We gave up on this feature I think
82 function generate_consoletranslation_list()
83 {
84 $consoletranslation_list = array();
85 $path = "/usr/share/consoletrans";
86
87 # find /usr/share/keymaps -iname *.trans -printf "%f \n"
88 exec("find ".$path." -iname *.trans -printf \"%f \n\"", $output);
89 foreach ($output as $consoletran) {
90 # strip the last 8 chars ( .trans\n )
91 $consoletran = trim($consoletran);
92 $consoletran = substr($consoletran,0,-8);
93 array_push($consoletranslation_list, $consoletran);
94 }
95 sort($consoletranslation_list);
96
97 return $consoletranslation_list;
98 }
99 */
100
101 function get_install_package_list()
102 {
103 $install_package_list = array(
104 'Desktop' => array("Popular Desktop Applications",
105 array("bittorrent"=> "tool for distributing files via a distributed network of nodes",
106 "evolution" => "A GNOME groupware application, a Microsoft Outlook workalike",
107 "gaim" => "GTK Instant Messenger client",
108 "gftp" => "Gnome based FTP Client",
109 "gimp" => "GNU Image Manipulation Program",
110 "inkscape" => "A SVG based generic vector-drawing program",
111 "koffice" => "An integrated office suite for KDE, the K Desktop Environment",
112 "mozilla" => "The Mozilla Web Browser",
113 "mozilla-firefox" => "The Mozilla Firefox Web Browser",
114 "mozilla-thunderbird" => "Thunderbird Mail Client",
115 "mplayer" => "Media Player for Linux",
116 "openoffice" => "OpenOffice.org, a full office productivity suite.",
117 "openoffice-bin" => "Same as OpenOffice but a binary package (no compiling!)",
118 "rhythmbox" => "Music management and playback software for GNOME",
119 "vlc" => "VLC media player - Video player and streamer",
120 "xchat" => "Graphical IRC Client",
121 "xine-ui" => "Xine movie player",
122 "xmms" => "X MultiMedia System" )),
123 'Servers' => array("Applications often found on servers.",
124 array("apache" => "Apache Web Server",
125 "cups" => "The Common Unix Printing System",
126 "exim" => "A highly configurable, drop-in replacement for sendmail",
127 "iptables" => "Linux kernel (2.4+) firewall, NAT and packet mangling tools",
128 "mod_php" => "Apache module for PHP",
129 "mysql" => "A fast, multi-threaded, multi-user SQL database server",
130 "postfix" => "A fast and secure drop-in replacement for sendmail",
131 "postgresql" => "sophisticated Object-Relational DBMS",
132 "proftpd" => "ProFTP Server",
133 "samba" => "SAMBA client/server programs for UNIX",
134 "sendmail" => "Widely-used Mail Transport Agent (MTA)",
135 "traceroute" => "Utility to trace the route of IP packets" )),
136 'X11' => array("Window managers and X selection.",
137 array("xorg-x11" => "An X11 implementation maintained by the X.Org Foundation",
138 "gnome" => "The Gnome Desktop Environment",
139 "kde" => "The K Desktop Environment",
140 "blackbox" => "A small, fast, full-featured window manager for X",
141 "enlightenment" => "Enlightenment Window Manager",
142 "fluxbox" => "Fluxbox is an X11 window manager featuring tabs and an iconbar",
143 "xfce4" => "XFCE Desktop Environment" )),
144 'Misc' => array("Miscellaneous Applications you may want.",
145 array("emacs" => "An incredibly powerful, extensible text editor",
146 "ethereal" => "A commercial-quality network protocol analyzer",
147 "gkrellm" => "Single process stack of various system monitors",
148 "gvim" => "GUI version of the Vim text editor",
149 "keychain" => "ssh-agent manager",
150 "logrotate" => "Rotates, compresses, and mails system logs",
151 "ntp" => "Network Time Protocol suite/programs",
152 "rdesktop" => "A Remote Desktop Protocol Client",
153 "slocate" => "Secure way to index and quickly search for files on your system",
154 "ufed" => "Gentoo Linux USE flags editor",
155 "vim" => "Vim, an improved vi-style text editor" )),
156 'Recommended' => array("Applications recommended by the GLI Team.",
157 array("anjuta" => "A versatile IDE for GNOME",
158 "chkrootkit" => "a tool to locally check for signs of a rootkit",
159 "crack-attack" => "Addictive OpenGL-based block game",
160 "gnupg" => "The GNU Privacy Guard, a GPL pgp replacement",
161 "net-snmp" => "Software for generating and retrieving SNMP data",
162 "netcat" => "the network swiss army knife",
163 "nmap" => "A utility for network exploration or security auditing",
164 "screen" => "full-screen window manager that multiplexes between several processes",
165 "xpdf" => "An X Viewer for PDF Files" ))
166 );
167 return $install_package_list;
168 }
169
170 function get_grp_pkgs_from_cd() {
171 if (!is_file("/usr/livecd/grppkgs.txt")) {
172 return "";
173 }
174 exec('cat /usr/livecd/grppkgs.txt',$output);
175 $output_arr = explode($output);
176 #remove the first part before a / for comparision
177 $results = array();
178 foreach ($output_arr as $pkg) {
179 array_push($results, substr($pkg, int(strpos($pkg,'/'))+1 )); #.append(pkg[(pkg.find('/')+1):])
180 }
181 return $results;
182 }
183
184 function get_global_use_flags() {
185 $fh = fopen("/usr/portage/profiles/use.desc", "r");
186 while (!feof($fh)) {
187 $line = trim(fgets($fh));
188 if ( (!$line) or $line[0] == '#') {
189 continue;
190 }
191 $dash_pos = strpos($line, " - ");
192 if ($dash_pos == -1) {
193 continue;
194 }
195 $flagname = substr($line,0,$dash_pos);
196 $desc = substr($line,$dash_pos+3);
197 $use_desc[$flagname] = $desc;
198 }
199 fclose($fh);
200 return $use_desc;
201 }
202
203 function get_local_use_flags() {
204 $fh = fopen("/usr/portage/profiles/use.local.desc", "r");
205 while (!feof($fh)) {
206 $line = trim(fgets($fh));
207 if ( (!$line) or $line[0] == '#') {
208 continue;
209 }
210 $dash_pos = strpos($line, " - ");
211 if ($dash_pos == -1) {
212 continue;
213 }
214 $colon_pos = strpos($line,":");#, 0, dash_pos);
215 $pkg = substr($line,0,$colon_pos);
216 $flagname = substr($line,$colon_pos+1,$dash_pos); #line[colon_pos+1:dash_pos] or line[colon_pos+1]
217 $flagname = substr($line,$colon_pos+1, ($dash_pos-$colon_pos));
218 $desc = "(" . $pkg . ") " . substr($line,$dash_pos+3);
219 $use_local_desc[$flagname] = $desc;
220 }
221 fclose($fh);
222 return $use_local_desc;
223 }
224 ?>

  ViewVC Help
Powered by ViewVC 1.1.20