Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MediaDBPythonScripte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BA_SI-Projekt
MediaDBPythonScripte
Commits
407d54fa
Commit
407d54fa
authored
Jan 25, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
3e996a2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
68 deletions
+69
-68
color.class.php
color.class.php
+66
-61
media.php
media.php
+3
-7
No files found.
color.class.php
View file @
407d54fa
<?php
class
Colors
{
private
$foreground_colors
=
array
();
private
$background_colors
=
array
();
public
function
__construct
()
{
// Set up shell colors
$this
->
foreground_colors
[
'black'
]
=
'0;30'
;
$this
->
foreground_colors
[
'dark_gray'
]
=
'1;30'
;
$this
->
foreground_colors
[
'blue'
]
=
'0;34'
;
$this
->
foreground_colors
[
'light_blue'
]
=
'1;34'
;
$this
->
foreground_colors
[
'green'
]
=
'0;32'
;
$this
->
foreground_colors
[
'light_green'
]
=
'1;32'
;
$this
->
foreground_colors
[
'cyan'
]
=
'0;36'
;
$this
->
foreground_colors
[
'light_cyan'
]
=
'1;36'
;
$this
->
foreground_colors
[
'red'
]
=
'0;31'
;
$this
->
foreground_colors
[
'light_red'
]
=
'1;31'
;
$this
->
foreground_colors
[
'purple'
]
=
'0;35'
;
$this
->
foreground_colors
[
'light_purple'
]
=
'1;35'
;
$this
->
foreground_colors
[
'brown'
]
=
'0;33'
;
$this
->
foreground_colors
[
'yellow'
]
=
'1;33'
;
$this
->
foreground_colors
[
'light_gray'
]
=
'0;37'
;
$this
->
foreground_colors
[
'white'
]
=
'1;37'
;
$this
->
background_colors
[
'black'
]
=
'40'
;
$this
->
background_colors
[
'red'
]
=
'41'
;
$this
->
background_colors
[
'green'
]
=
'42'
;
$this
->
background_colors
[
'yellow'
]
=
'43'
;
$this
->
background_colors
[
'blue'
]
=
'44'
;
$this
->
background_colors
[
'magenta'
]
=
'45'
;
$this
->
background_colors
[
'cyan'
]
=
'46'
;
$this
->
background_colors
[
'light_gray'
]
=
'47'
;
}
// Returns colored string
public
function
getColoredString
(
$string
,
$foreground_color
=
null
,
$background_color
=
null
)
{
$colored_string
=
""
;
// Check if given foreground color found
if
(
isset
(
$this
->
foreground_colors
[
$foreground_color
]))
{
$colored_string
.=
"
\033
["
.
$this
->
foreground_colors
[
$foreground_color
]
.
"m"
;
}
// Check if given background color found
if
(
isset
(
$this
->
background_colors
[
$background_color
]))
{
$colored_string
.=
"
\033
["
.
$this
->
background_colors
[
$background_color
]
.
"m"
;
}
// Add string and end coloring
$colored_string
.=
$string
.
"
\033
[0m"
;
return
$colored_string
;
}
// Returns all foreground color names
public
function
getForegroundColors
()
{
return
array_keys
(
$this
->
foreground_colors
);
}
// Returns all background color names
public
function
getBackgroundColors
()
{
return
array_keys
(
$this
->
background_colors
);
}
class
Console
{
private
$foreground_colors
=
array
();
private
$background_colors
=
array
();
public
function
__construct
()
{
// Set up shell colors
$this
->
foreground_colors
[
'black'
]
=
'0;30'
;
$this
->
foreground_colors
[
'dark_gray'
]
=
'1;30'
;
$this
->
foreground_colors
[
'blue'
]
=
'0;34'
;
$this
->
foreground_colors
[
'light_blue'
]
=
'1;34'
;
$this
->
foreground_colors
[
'green'
]
=
'0;32'
;
$this
->
foreground_colors
[
'light_green'
]
=
'1;32'
;
$this
->
foreground_colors
[
'cyan'
]
=
'0;36'
;
$this
->
foreground_colors
[
'light_cyan'
]
=
'1;36'
;
$this
->
foreground_colors
[
'red'
]
=
'0;31'
;
$this
->
foreground_colors
[
'light_red'
]
=
'1;31'
;
$this
->
foreground_colors
[
'purple'
]
=
'0;35'
;
$this
->
foreground_colors
[
'light_purple'
]
=
'1;35'
;
$this
->
foreground_colors
[
'brown'
]
=
'0;33'
;
$this
->
foreground_colors
[
'yellow'
]
=
'1;33'
;
$this
->
foreground_colors
[
'light_gray'
]
=
'0;37'
;
$this
->
foreground_colors
[
'white'
]
=
'1;37'
;
$this
->
background_colors
[
'black'
]
=
'40'
;
$this
->
background_colors
[
'red'
]
=
'41'
;
$this
->
background_colors
[
'green'
]
=
'42'
;
$this
->
background_colors
[
'yellow'
]
=
'43'
;
$this
->
background_colors
[
'blue'
]
=
'44'
;
$this
->
background_colors
[
'magenta'
]
=
'45'
;
$this
->
background_colors
[
'cyan'
]
=
'46'
;
$this
->
background_colors
[
'light_gray'
]
=
'47'
;
}
// Returns colored string
public
function
getColoredString
(
$string
,
$foreground_color
=
null
,
$background_color
=
null
)
{
$colored_string
=
""
;
// Check if given foreground color found
if
(
isset
(
$this
->
foreground_colors
[
$foreground_color
]))
{
$colored_string
.=
"
\033
["
.
$this
->
foreground_colors
[
$foreground_color
]
.
"m"
;
}
// Check if given background color found
if
(
isset
(
$this
->
background_colors
[
$background_color
]))
{
$colored_string
.=
"
\033
["
.
$this
->
background_colors
[
$background_color
]
.
"m"
;
}
// Add string and end coloring
$colored_string
.=
$string
.
"
\033
[0m"
;
return
$colored_string
;
}
// Returns all foreground color names
public
function
getForegroundColors
()
{
return
array_keys
(
$this
->
foreground_colors
);
}
// Returns all background color names
public
function
getBackgroundColors
()
{
return
array_keys
(
$this
->
background_colors
);
}
public
function
clearscreen
(
$out
=
TRUE
)
{
$clearscreen
=
chr
(
27
)
.
"[H"
.
chr
(
27
)
.
"[2J"
;
if
(
$out
)
print
$clearscreen
;
else
return
$clearscreen
;
}
}
?>
\ No newline at end of file
media.php
View file @
407d54fa
<?php
include
'./color.class.php'
;
$colors
=
new
Colors
();
$Console
=
new
Console
();
function
clearscreen
(
$out
=
TRUE
)
{
$clearscreen
=
chr
(
27
)
.
"[H"
.
chr
(
27
)
.
"[2J"
;
if
(
$out
)
print
$clearscreen
;
else
return
$clearscreen
;
}
//echo "md5: ".$colors->getColoredString("Fehler!", "white", "red") .PHP_EOL;
//echo "md5: ".$colors->getColoredString("Erfolgreich!", "white", "green") .PHP_EOL;
...
...
@@ -32,7 +28,7 @@ if(isset($argv[1])){
$exit
=
false
;
clearscreen
();
$Console
->
clearscreen
();
do
{
echo
"Bitte Befehl eingeben:"
;
$name
=
trim
(
fgets
(
STDIN
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment