Exemple #1
0
 private function show_profile_form($profile)
 {
     $this->output->add_javascript("banshee/" . PASSWORD_HASH . ".js");
     $this->output->add_javascript("profile.js");
     $this->output->run_javascript("hash = window['" . PASSWORD_HASH . "'];");
     $this->output->open_tag("edit");
     $this->output->add_tag("username", $this->user->username);
     $this->output->add_tag("email", $profile["email"]);
     $this->output->add_tag("notification_key", $profile["notification_key"]);
     $this->output->add_tag("notification_method", $profile["notification_method"]);
     $this->output->add_tag("daily_report", show_boolean($profile["daily_report"]));
     if ($this->user->status == USER_STATUS_CHANGEPWD) {
         $this->output->add_tag("cancel", "Logout", array("page" => LOGOUT_MODULE));
     } else {
         $this->output->add_tag("cancel", "Back", array("page" => $this->settings->start_page));
     }
     $notification_methods = config_array(NOTIFICATION_METHODS);
     $this->output->open_tag("notification");
     foreach ($notification_methods as $method => $label) {
         $this->output->add_tag("method", $method, array("label" => $label));
     }
     $this->output->close_tag();
     /* Action log
      */
     if (($actionlog = $this->model->last_account_logs()) !== false) {
         $this->output->open_tag("actionlog");
         foreach ($actionlog as $log) {
             $this->output->record($log, "log");
         }
         $this->output->close_tag();
     }
     $this->output->close_tag();
 }
Exemple #2
0
 public function __construct($db, $page, $output)
 {
     $this->db = $db;
     $this->page = $page;
     $this->output = $output;
     $this->supported = config_array(SUPPORTED_LANGUAGES);
     $this->global_texts = $this->load_texts("*");
     $this->page_texts = $this->load_texts($this->page->page);
 }
Exemple #3
0
 public function __construct()
 {
     $flags = config_array(MODULE_FLAGS);
     foreach ($flags as $key => $value) {
         $this->module_flags[$key] = explode(",", $value);
     }
     $arguments = func_get_args();
     call_user_func_array(array("parent", "__construct"), $arguments);
     $modules = array_keys($this->module_flags);
     sort($modules);
     foreach ($modules as $module) {
         $this->elements["module"]["options"][$module] = $module;
     }
 }
Exemple #4
0
 public function save_oke($page)
 {
     $result = true;
     if (valid_input(trim($page["url"]), VALIDATE_URL, VALIDATE_NONEMPTY) == false) {
         $this->output->add_message("URL is empty or contains invalid characters.");
         $result = false;
     } else {
         if (strpos($page["url"], "//") !== false || $page["url"][0] !== "/") {
             $this->output->add_message("Invalid URL.");
             $result = false;
         }
     }
     if (in_array($page["language"], array_keys(config_array(SUPPORTED_LANGUAGES))) == false) {
         $this->output->add_message("Language not supported.");
         $result = false;
     }
     if (($layouts = $this->get_layouts()) != false) {
         if (in_array($page["layout"], $layouts) == false) {
             $this->output->add_message("Invalid layout.");
             $result = false;
         }
     }
     if (trim($page["title"]) == "") {
         $this->output->add_message("Empty title not allowed.");
         $result = false;
     }
     if (valid_input($page["language"], VALIDATE_NONCAPITALS, 2) == false) {
         $this->output->add_message("Invalid language code.");
         $result = false;
     }
     $module = ltrim($page["url"], "/");
     $public_pages = page_to_module(config_file("public_pages"));
     $private_pages = page_to_module(config_file("private_pages"));
     if (in_array($module, $public_pages) || in_array($module, $private_pages)) {
         $this->output->add_message("URL belongs to a module.");
         $result = false;
     } else {
         $query = "select * from pages where id!=%d and url=%s limit 1";
         if (($page = $this->db->execute($query, $page["id"], $page["url"])) != false) {
             if (count($page) > 0) {
                 $this->output->add_message("URL belongs to another page.");
                 $result = false;
             }
         }
     }
     return $result;
 }
Exemple #5
0
 private function show_page_form($page)
 {
     $this->output->set_xslt_parameter("admin_role_id", ADMIN_ROLE_ID);
     $page["private"] = show_boolean($page["private"]);
     $page["visible"] = show_boolean($page["visible"]);
     $page["back"] = show_boolean($page["back"]);
     $args = array();
     if (isset($page["id"])) {
         $args["id"] = $page["id"];
     }
     $this->output->add_javascript("cms/page.js");
     $this->output->add_javascript("ckeditor/ckeditor.js");
     $this->output->add_javascript("banshee/start_ckeditor.js");
     $this->output->open_tag("edit");
     /* Languages
      */
     $this->output->open_tag("languages");
     foreach (config_array(SUPPORTED_LANGUAGES) as $code => $lang) {
         $this->output->add_tag("language", $lang, array("code" => $code));
     }
     $this->output->close_tag();
     /* Layouts
      */
     $this->output->open_tag("layouts", array("current" => $page["layout"]));
     if (($layouts = $this->model->get_layouts()) != false) {
         foreach ($layouts as $layout) {
             $this->output->add_tag("layout", $layout);
         }
     }
     $this->output->close_tag();
     /* Roles
      */
     $this->output->open_tag("roles");
     if (($roles = $this->model->get_roles()) != false) {
         foreach ($roles as $role) {
             $this->output->add_tag("role", $role["name"], array("id" => $role["id"], "checked" => show_boolean($page["roles"][$role["id"]])));
         }
     }
     $this->output->close_tag();
     /* Page data
      */
     $this->output->record($page, "page", $args);
     $this->output->close_tag();
 }
Exemple #6
0
 public function upload_oke($file, $directory)
 {
     if ($file["error"] !== 0) {
         $this->output->add_message("Error while uploading file.");
         return false;
     }
     if ($this->filename_oke($directory . "/" . $file["name"]) == false) {
         $this->output->add_message("Invalid filename.");
         return false;
     }
     if (($ext = strrchr($file["name"], ".")) === false) {
         $this->output->add_message("File has no extension.");
         return false;
     }
     if (in_array(substr($ext, 1), config_array(ALLOWED_UPLOADS)) == false) {
         $this->output->add_message("Invalid file extension.");
         return false;
     }
     if (file_exists($directory . "/" . $file["name"])) {
         $this->output->add_message("File already exists.");
         return false;
     }
     return true;
 }
Exemple #7
0
 public function execute()
 {
     $months_of_year = config_array(MONTHS_OF_YEAR);
     $this->output->title = "Weblog";
     $this->output->description = "Weblog";
     $this->output->keywords = "weblog";
     $this->output->add_alternate("Weblog", "application/rss+xml", "/weblog.xml");
     $this->url = array("url" => $this->page->page);
     /* Sidebar
      */
     $this->output->open_tag("sidebar");
     /* Tags
      */
     if (($tags = $this->model->get_all_tags()) != false) {
         $this->output->open_tag("tags");
         foreach ($tags as $tag) {
             $this->output->add_tag("tag", $tag["tag"], array("id" => $tag["id"]));
         }
         $this->output->close_tag();
     }
     /* Years
      */
     if (($years = $this->model->get_years()) != false) {
         $this->output->open_tag("years");
         foreach ($years as $year) {
             $this->output->add_tag("year", $year["year"]);
         }
         $this->output->close_tag();
     }
     /* Periods
      */
     if (($periods = $this->model->get_periods()) != false) {
         $this->output->open_tag("periods");
         foreach ($periods as $period) {
             $link = array("link" => $period["year"] . "/" . $period["month"]);
             $text = $months_of_year[$period["month"] - 1] . " " . $period["year"];
             $this->output->add_tag("period", $text, $link);
         }
         $this->output->close_tag();
     }
     $this->output->close_tag();
     if ($this->page->type == "xml") {
         /* RSS feed
          */
         $rss = new RSS($this->output);
         if ($rss->fetch_from_cache("weblog_rss") == false) {
             $rss->title = $this->settings->head_title . " weblog";
             $rss->description = $this->settings->head_description;
             if (($weblogs = $this->model->get_last_weblogs($this->settings->weblog_rss_page_size)) != false) {
                 foreach ($weblogs as $weblog) {
                     $link = "/weblog/" . $weblog["id"];
                     $rss->add_item($weblog["title"], $weblog["content"], $link, $weblog["timestamp"]);
                 }
             }
             $rss->to_output();
         }
     } else {
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
             /* Comment submits
              */
             if ($this->model->comment_oke($_POST) == false) {
                 $this->show_weblog($_POST["weblog_id"]);
                 $this->show_comment($_POST);
             } else {
                 if ($this->model->add_comment($_POST) == false) {
                     $this->output->add_message("Error while adding comment.");
                     $this->show_weblog($_POST["weblog_id"]);
                     $this->show_comment($_POST);
                 } else {
                     $this->output->add_tag("result", "Comment has been added.", array("url" => $this->page->page . "/" . $_POST["weblog_id"]));
                 }
             }
         } else {
             if ($this->page->pathinfo[1] == "tag" && valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
                 /* Tagged weblogs
                  */
                 if (($tag = $this->model->get_tag($this->page->pathinfo[2])) == false) {
                     $this->output->add_tag("result", "Unknown tag", $this->url);
                 } else {
                     if (($weblogs = $this->model->get_tagged_weblogs($this->page->pathinfo[2])) === false) {
                         $this->output->add_tag("result", "Error fetching tags", $this->url);
                     } else {
                         $this->output->title = "Tag " . $tag . " - Weblog";
                         $this->output->open_tag("list", array("label" => "Weblogs with '" . $tag . "' tag"));
                         foreach ($weblogs as $weblog) {
                             $this->output->record($weblog, "weblog");
                         }
                         $this->output->close_tag();
                     }
                 }
             } else {
                 if ($this->page->pathinfo[1] == "period" && valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) && valid_input($this->page->pathinfo[3], VALIDATE_NUMBERS)) {
                     /* Weblogs of certain period
                      */
                     if (($weblogs = $this->model->get_weblogs_of_period($this->page->pathinfo[2], $this->page->pathinfo[3])) === false) {
                         $this->output->add_tag("result", "Error fetching weblogs", $this->url);
                     } else {
                         if ($this->page->pathinfo[3] == null) {
                             $this->output->title = "Year " . $this->page->pathinfo[2] . " - Weblog";
                         } else {
                             $month = $months_of_year[$this->page->pathinfo[3] - 1];
                             $this->output->title = $month . " " . $this->page->pathinfo[2] . " - Weblog";
                         }
                         $month = 0;
                         $count = count($weblogs);
                         for ($i = 0; $i < $count; $i++) {
                             if ((int) $weblogs[$i]["month"] != $month) {
                                 if ($month != 0) {
                                     $this->output->close_tag();
                                 }
                                 if ($i < $count) {
                                     $label = $months_of_year[$weblogs[$i]["month"] - 1] . " " . $this->page->pathinfo[2];
                                     $this->output->open_tag("list", array("label" => $label));
                                 }
                             }
                             $this->output->record($weblogs[$i], "weblog");
                             $month = (int) $weblogs[$i]["month"];
                         }
                         if ($month != 0) {
                             $this->output->close_tag();
                         }
                     }
                 } else {
                     if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
                         /* Show weblog
                          */
                         $this->show_weblog($this->page->pathinfo[1]);
                         if ($this->user->logged_in) {
                             $this->show_comment(array("author" => $this->user->fullname));
                         }
                     } else {
                         /* Show last weblogs
                          */
                         $this->show_last_weblogs();
                     }
                 }
             }
         }
     }
 }
Exemple #8
0
function date_string($format, $timestamp = null)
{
    if ($timestamp === null) {
        $timestamp = time();
    }
    $days_of_week = config_array(DAYS_OF_WEEK);
    $months_of_year = config_array(MONTHS_OF_YEAR);
    $format = strtr($format, "lDFM", "#\$%&");
    $result = date($format, $timestamp);
    $day = $days_of_week[(int) date("N", $timestamp) - 1];
    $result = str_replace("#", $day, $result);
    $day = substr($days_of_week[(int) date("N", $timestamp) - 1], 0, 3);
    $result = str_replace("\$", $day, $result);
    $month = $months_of_year[(int) date("n", $timestamp) - 1];
    $result = str_replace("%", $month, $result);
    $month = substr($months_of_year[(int) date("n", $timestamp) - 1], 0, 3);
    $result = str_replace("&", $month, $result);
    return $result;
}
Exemple #9
0
     }
     $uploads_size = isset($VARS['uploads_size']) ? (int) $VARS['uploads_size'] : 0;
     $uploads_active = (int) isset($VARS["uploads_active"]);
     $uploads_extensions = isset($VARS['uploads_ext']) ? $VARS['uploads_ext'] : '';
     if (!preg_match('/^[A-Za-z0-9_\\|]+$/', $uploads_extensions)) {
         trigger_error($ind295, E_USER_WARNING);
     }
     $exts = explode('|', $uploads_extensions);
     $good_exts = array();
     for ($i = 0, $num_exts = sizeof($exts); $i < $num_exts; ++$i) {
         if ($exts[$i] && !in_array($exts[$i], $good_exts)) {
             $good_exts[] = $exts[$i];
         }
     }
     $uploads_extensions = implode('|', $good_exts);
     $configs = config_array();
     $configs['uploads_size'] = $uploads_size;
     $configs['uploads_active'] = $uploads_active;
     $configs['uploads_ext'] = $uploads_extensions;
     save_config($configs);
     $title = $ind21;
     echo make_redirect($ind22, '?id=uploads', $ind338);
 } else {
     if ($id == 'help') {
         /*id Help*/
         if (!has_access(NEWS_REPORTER)) {
             trigger_error($ind19, E_USER_WARNING);
         }
         $message = '';
         $version = '';
         $title = $ind152;
Exemple #10
0
 private function show_month($month, $year)
 {
     if (($appointments = $this->model->get_appointments_for_month($month, $year)) === false) {
         $this->output->add_tag("result", "Database error.");
         return;
     }
     $day = $this->model->monday_before($month, $year);
     $last_day = $this->model->sunday_after($month, $year);
     $today = strtotime("today 00:00:00");
     $months_of_year = config_array(MONTHS_OF_YEAR);
     $this->output->open_tag("month", array("title" => $months_of_year[$month - 1] . " " . $year));
     /* Links
      */
     $y = $year;
     if (($m = $month - 1) == 0) {
         $m = 12;
         $y--;
     }
     $this->output->add_tag("prev", $y . "/" . $m);
     $y = $year;
     if (($m = $month + 1) == 13) {
         $m = 1;
         $y++;
     }
     $this->output->add_tag("next", $y . "/" . $m);
     /* Days of week
      */
     $days_of_week = config_array(DAYS_OF_WEEK);
     $this->output->open_tag("days_of_week");
     foreach ($days_of_week as $dow) {
         if ($this->output->mobile) {
             $dow = substr($dow, 0, 3);
         }
         $this->output->add_tag("day", $dow);
     }
     $this->output->close_tag();
     /* Weeks
      */
     while ($day < $last_day) {
         $this->output->open_tag("week");
         for ($dow = 1; $dow <= 7; $dow++) {
             $params = array("nr" => date("j", $day), "dow" => $dow);
             if ($day == $today) {
                 $params["today"] = " today";
             }
             $this->output->open_tag("day", $params);
             foreach ($appointments as $appointment) {
                 if ($appointment["begin"] >= $day && $appointment["begin"] < $day + DAY) {
                     $this->output->add_tag("appointment", $appointment["title"], array("id" => $appointment["id"]));
                 } else {
                     if ($appointment["begin"] < $day && $appointment["end"] >= $day) {
                         $this->output->add_tag("appointment", "... " . $appointment["title"], array("id" => $appointment["id"]));
                     }
                 }
             }
             $this->output->close_tag();
             $day = strtotime(date("d-m-Y", $day) . " +1 day");
         }
         $this->output->close_tag();
     }
     $this->output->close_tag();
 }