function print_excerpt($length)
{
    // Max excerpt length. Length is set in characters
    global $post;
    $text = $post->post_excerpt;
    if ('' == $text) {
        $text = get_the_content('');
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
    }
    $text = strip_shortcodes($text);
    // optional, recommended
    $text = strip_tags($text);
    // use ' $text = strip_tags($text,'<p><a>'); ' if you want to keep some tags
    $text = substr($text, 0, $length);
    $excerpt = reverse_strrchr($text, '.', 1);
    if ($excerpt) {
        echo apply_filters('the_excerpt', $excerpt);
    } else {
        echo apply_filters('the_excerpt', $text);
    }
}
function saveFile($field_id)
{
    $uploaddir = UPLOAD_PATH . 'docs/';
    $ext = substr(strrchr($_FILES[$field_id]['name'], "."), 1);
    $name = reverse_strrchr($_FILES[$field_id]['name'], ".");
    $name = substr($name, 0, -1);
    if ($_SESSION['MDS_ID'] != '') {
        $name = $_SESSION['MDS_ID'] . "_" . $name;
    }
    // echo "<b>NAMEis:[$name]</b>";
    $name = ereg_replace("[ '\"]+", "_", $name);
    // strip quotes, spaces
    $new_name = $name . time() . "." . $ext;
    $uploadfile = $uploaddir . $new_name;
    //$uploaddir . $file_name;
    //echo "te,p Image is:".$_FILES[$field_id]['tmp_name']." upload file:".$uploadfile;
    if (move_uploaded_file($_FILES[$field_id]['tmp_name'], $uploadfile)) {
        //echo "File is valid, and was successfully uploaded.\n";
    } else {
        //echo "Possible file upload attack ($uploadfile)!\n";
    }
    return $new_name;
}
     delete_package($todel, htmlspecialchars($_GET['pkg']));
     delete_package_xml(htmlspecialchars($_GET['pkg']));
     update_status("Package deleted.");
     $static_output .= "\nPackage deleted.";
     update_output_window($static_output);
     break;
 case "showlog":
     $id = htmlspecialchars($_GET['pkg']);
     if (strpos($id, ".")) {
         exit;
     }
     update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
     break;
 case "reinstallpkg":
     $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
     $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
     delete_package($todel, htmlspecialchars($_GET['pkg']));
     delete_package_xml(htmlspecialchars($_GET['pkg']));
     install_package(htmlspecialchars($_GET['pkg']));
     update_status("Package reinstalled.");
     $static_output .= "\n\nPackage reinstalled.";
     start_service(htmlspecialchars($_GET['pkg']));
     update_output_window($static_output);
     break;
 case "reinstallxml":
     delete_package_xml(htmlspecialchars($_GET['pkg']));
     install_package(htmlspecialchars($_GET['pkg']));
     $static_output .= "\n\nPackage reinstalled.";
     start_service(htmlspecialchars($_GET['pkg']));
     update_output_window($static_output);
     break;
function print_excerpt_smc($title)
{
    // Max excerpt length. Length is set in characters
    global $post;
    $rem_len = "";
    //clear variable
    $title_len = strlen($title);
    //get length of title
    $excerpt_line = 25;
    if ($title_len <= 30) {
        $rem_len = $excerpt_line * 5;
        //calc space remaining for excerpt
    } elseif ($title_len <= 34) {
        $rem_len = $excerpt_line * 5;
    } elseif ($title_len <= 51) {
        $rem_len = $excerpt_line * 4;
    } elseif ($title_len <= 68) {
        $rem_len = $excerpt_line * 4;
    } elseif ($title_len <= 85) {
        $rem_len = $excerpt_line * 4;
    }
    $text = $post->post_excerpt;
    if ('' == $text) {
        $text = get_the_content('');
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
    }
    $text = strip_shortcodes($text);
    // optional, recommended
    $text = strip_tags($text, '<p>');
    // use ' $text = strip_tags($text,'<p><a>'); ' if you want to keep some tags
    $text = substr($text, 0, $rem_len);
    $excerpt = reverse_strrchr($text, ' ', 1) . "&#0133;";
    if ($excerpt) {
        echo apply_filters('the_excerpt', $excerpt);
    } else {
        echo apply_filters('the_excerpt', $text);
    }
}