index d7921871bec4b6ff74053fbdc5b294c326fde589..dec99bbc2122eb6c8a77f587efdf0aae06637eae 100644 (file)
*
* \param string 'class_name' The currently requested class
*/
-function __autoload($class_name) {
+function __gosa_autoload($class_name) {
global $class_mapping, $BASE_DIR;
if ($class_mapping === NULL){
exit;
}
}
+spl_autoload_register('__gosa_autoload');
/*! \brief Checks if a class is available.
/* Return plugin dir or root directory? */
if ($plugin){
if ($path == ""){
- $nf= preg_replace("!^".$BASE_DIR."/!", "", session::global_get('plugin_dir'));
+ $nf= preg_replace("!^".$BASE_DIR."/!", "", preg_replace('/^\.\.\//', '', session::global_get('plugin_dir')));
} else {
$nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
}
/* Bail out if we have login restrictions set, for security reasons
the message is the same than failed user/pw */
if (!$ui->loginAllowed()){
+ new log("security","login","",array(),"Login restriction for user \"$username\", login not permitted");
return (NULL);
}
$allowed_attributes = array("uid","mail");
$verify_attr = array();
if($config->get_cfg_value("loginAttribute") != ""){
- $tmp = split(",", $config->get_cfg_value("loginAttribute"));
+ $tmp = explode(",", $config->get_cfg_value("loginAttribute"));
foreach($tmp as $attr){
if(in_array($attr,$allowed_attributes)){
$verify_attr[] = $attr;
/* Bail out if we have login restrictions set, for security reasons
the message is the same than failed user/pw */
if (!$ui->loginAllowed()){
+ new log("security","login","",array(),"Login restriction for user \"$username\", login not permitted");
return (NULL);
}
{
if (session::global_is_set('size_limit') && session::global_get('size_limit') >= 10000000 ||
(session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
- $config= "<input type='submit' name='edit_sizelimit' value="._("Configure").">";
+ $config= "<button type='submit' name='edit_sizelimit'>"._("Configure")."</button>";
} else {
$config= "";
}
$dep= "";
- foreach (split(',', $dn) as $rdn){
+ foreach (explode(',', $dn) as $rdn){
$dep = preg_replace("/^[^=]+=/","",$rdn)."/".$dep;
}
/* Prepare and show template */
$smarty= get_smarty();
$smarty->assign("allow_readonly",$allow_readonly);
- if(is_array($dn)){
- $msg = "<pre>";
- foreach($dn as $sub_dn){
- $msg .= "\n".$sub_dn.", ";
- }
- $msg = preg_replace("/, $/","</pre>",$msg);
- }else{
- $msg = $dn;
- }
+ $msg= msgPool::buildList($dn);
$smarty->assign ("dn", $msg);
if ($remove){
} else {
$smarty->assign ("action", _("Edit anyway"));
}
- $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries %s"), "<b>".$msg."</b>", ""));
+
+ $smarty->assign ("message", _("These entries are currently locked:"). $msg);
return ($smarty->fetch (get_template_path('islocked.tpl')));
}
*/
function netmask_to_bits($netmask)
{
- list($nm0, $nm1, $nm2, $nm3)= split('\.', $netmask);
+ list($nm0, $nm1, $nm2, $nm3)= explode('.', $netmask);
$res= 0;
for ($n= 0; $n<4; $n++){
* \param int 'percentage' Value to display
* \param int 'width' width of the resulting output
* \param int 'height' height of the resulting output
- * \param boolean 'showvalue' weither to show the percentage in the progressbar or not
+ * \param boolean 'showtext' weither to show the percentage in the progressbar or not
* */
-function progressbar($percentage,$width=100,$height=15,$showvalue=false)
+function progressbar($percentage, $width= 200, $height= 14, $showText= false, $colorize= true, $id= "")
{
- return("<img src='progress.php?x=$width&y=$height&p=$percentage'>");
+ $text= "";
+ $class= "";
+ $style= "width:${width}px;height:${height}px;";
+
+ // Fix percentage range
+ $percentage= floor($percentage);
+ if ($percentage > 100) {
+ $percentage= 100;
+ }
+ if ($percentage < 0) {
+ $percentage= 0;
+ }
+
+ // Only show text if we're above 10px height
+ if ($showText && $height>10){
+ $text= $percentage."%";
+ }
+
+ // Set font size
+ $style.= "font-size:".($height-3)."px;";
+
+ // Set color
+ if ($colorize){
+ if ($percentage < 70) {
+ $class= " progress-low";
+ } elseif ($percentage < 80) {
+ $class= " progress-mid";
+ } elseif ($percentage < 90) {
+ $class= " progress-high";
+ } else {
+ $class= " progress-full";
+ }
+ }
+
+ // Apply gradients
+ $hoffset= floor($height / 2) + 4;
+ $woffset= floor(($width+5) * (100-$percentage) / 100);
+ foreach (array("-moz-box-shadow", "-webkit-box-shadow", "box-shadow") as $type) {
+ $style.="$type:
+ 0 0 2px rgba(255, 255, 255, 0.4) inset,
+ 0 4px 6px rgba(255, 255, 255, 0.4) inset,
+ 0 ".$hoffset."px 0 -2px rgba(255, 255, 255, 0.2) inset,
+ -".$woffset."px 0 0 -2px rgba(255, 255, 255, 0.2) inset,
+ -".($woffset+1)."px 0 0 -2px rgba(0, 0, 0, 0.6) inset,
+ 0pt ".($hoffset+1)."px 8px rgba(0, 0, 0, 0.3) inset,
+ 0pt 1px 0px rgba(0, 0, 0, 0.2);";
+ }
+
+ // Set ID
+ if ($id != ""){
+ $id= "id='$id'";
+ }
+
+ return "<div class='progress$class' $id style='$style'>$text</div>";
}
@@ -2807,6 +2856,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
"en_US" => "English",
"nl_NL" => "Dutch",
"pl_PL" => "Polish",
+ "pt_BR" => "Brazilian Portuguese",
#"sv_SE" => "Swedish",
"zh_CN" => "Chinese",
"vi_VN" => "Vietnamese",
@@ -2820,6 +2870,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
"en_US" => _("English"),
"nl_NL" => _("Dutch"),
"pl_PL" => _("Polish"),
+ "pt_BR" => _("Brazilian Portuguese"),
#"sv_SE" => _("Swedish"),
"zh_CN" => _("Chinese"),
"vi_VN" => _("Vietnamese"),
}
}
- list($lm,$nt)= split (":", trim($hash));
+ list($lm,$nt)= explode(":", trim($hash));
$attrs['sambaLMPassword']= $lm;
$attrs['sambaNTPassword']= $nt;
/* get the ranges */
$tmp = array('0'=> 1000);
if (preg_match('/posixAccount/', $oc) && $config->get_cfg_value("uidNumberBase") != ""){
- $tmp= split('-',$config->get_cfg_value("uidNumberBase"));
+ $tmp= explode('-',$config->get_cfg_value("uidNumberBase"));
} elseif($config->get_cfg_value("gidNumberBase") != ""){
- $tmp= split('-',$config->get_cfg_value("gidNumberBase"));
+ $tmp= explode('-',$config->get_cfg_value("gidNumberBase"));
}
/* Set hwm to max if not set - for backward compatibility */
}
+/* Mark the occurance of a string with a span */
+function mark($needle, $haystack, $ignorecase= true)
+{
+ $result= "";
+
+ while (preg_match('/^(.*)('.preg_quote($needle).')(.*)$/i', $haystack, $matches)) {
+ $result.= $matches[1]."<span class='mark'>".$matches[2]."</span>";
+ $haystack= $matches[3];
+ }
+
+ return $result.$haystack;
+}
+
+
+/* Return an image description using the path */
+function image($path, $action= "", $title= "", $align= "middle")
+{
+ global $config;
+ global $BASE_DIR;
+ $label= null;
+
+ // Bail out, if there's no style file
+ if(!session::global_is_set("img-styles")){
+
+ // Get theme
+ if (isset ($config)){
+ $theme= $config->get_cfg_value("theme", "default");
+ } else {
+ # For debuging - avoid that there's no theme set
+ die("config not set!");
+ $theme= "default";
+ }
+
+ if (!file_exists("$BASE_DIR/ihtml/themes/$theme/img.styles")){
+ die ("No img.style for this theme found!");
+ }
+
+ session::global_set('img-styles', unserialize(file_get_contents("$BASE_DIR/ihtml/themes/$theme/img.styles")));
+ }
+ $styles= session::global_get('img-styles');
+
+ /* Extract labels from path */
+ if (preg_match("/\.png\[(.*)\]$/", $path, $matches)) {
+ $label= $matches[1];
+ }
+
+ $lbl= "";
+ if ($label) {
+ if (isset($styles["images/label-".$label.".png"])) {
+ $lbl= "<div style='".$styles["images/label-".$label.".png"]."'></div>";
+ } else {
+ die("Invalid label specified: $label\n");
+ }
+
+ $path= preg_replace("/\[.*\]$/", "", $path);
+ }
+
+ // Non middle layout?
+ if ($align == "middle") {
+ $align= "";
+ } else {
+ $align= ";vertical-align:$align";
+ }
+
+ // Clickable image or not?
+ if ($title != "") {
+ $title= "title='$title'";
+ }
+ if ($action == "") {
+ return "<div class='img' $title style='".$styles[$path]."$align'>$lbl</div>";
+ } else {
+ return "<input type='submit' class='img' id='$action' value='' name='$action' $title style='".$styles[$path]."$align'>";
+ }
+}
+
+/*! \brief Encodes a complex string to be useable in HTML posts.
+ */
+function postEncode($str)
+{
+ return(preg_replace("/=/","_", base64_encode($str)));
+}
+
+/*! \brief Decodes a string encoded by postEncode
+ */
+function postDecode($str)
+{
+ return(base64_decode(preg_replace("/_/","=", $str)));
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>