static function getItemChanges($args = NULL) { global $auth; $prefix = confGet('DB_TABLE_PREFIX'); ### default params ### $item = NULL; $date_min = NULL; $date_max = NULL; $person = NULL; $field = NULL; $project = NULL; $order_by = 'modified'; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $str_project = $project ? "AND c.project= " . intval($project) : ''; $str_item = $item ? "AND c.item=" . intval($item) : ''; $str_date_min = $date_min ? "AND c.modified >= '" . asCleanString($date_min) . "'" : ''; $str_date_max = $date_max ? "AND c.modified <= '" . asCleanString($date_max) . "'" : ''; $str_field = $field ? "AND c.field ='" . asCleanString($field) . "'" : ''; $str_person = $person ? "AND c.modified_by = " . intval($person) : ''; ### show all ### $str_query = "SELECT c.* from {$prefix}itemchange c\r\n WHERE 1\r\n {$str_project}\r\n {$str_item}\r\n {$str_person}\r\n {$str_field}\r\n {$str_date_max}\r\n {$str_date_min}\r\n " . getOrderByString($order_by); $dbh = new DB_Mysql(); $sth = $dbh->prepare($str_query); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $item_changes = array(); foreach ($tmp as $t) { $c = new ItemChange($t); $item_changes[] = $c; } return $item_changes; }
/** * get list of items from database * * This function is used for getting changed items for projects or by user, etc. */ static function getAll($args = array()) { global $auth; $prefix = confGet('DB_TABLE_PREFIX'); ### default params ### $project = NULL; $order_by = "modified DESC"; $status_min = STATUS_UNDEFINED; $status_max = STATUS_CLOSED; $visible_only = NULL; # use project rights settings $alive_only = true; # hide deleted $date_min = NULL; $date_max = NULL; $modified_by = NULL; $not_modified_by = NULL; $show_issues = false; $limit_rowcount = NULL; $limit_offset = NULL; $unviewed_only = NULL; $type = NULL; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $str_show_issues = $show_issues ? '' : 'AND i.type != ' . ITEM_ISSUE; $str_project = $project ? 'AND i.project=' . intval($project) : ''; $str_project2 = $project ? 'AND upp.project=' . intval($project) : ''; $str_state = $alive_only ? 'AND i.state=' . ITEM_STATE_OK : ''; $str_date_min = $date_min ? "AND i.modified >= '" . asCleanString($date_min) . "'" : ''; $str_date_max = $date_max ? "AND i.modified <= '" . asCleanString($date_max) . "'" : ''; $str_modified_by = $modified_by ? 'AND i.modified_by=' . intval($modified_by) : ''; $str_not_modified_by = $not_modified_by ? 'AND i.modified_by != ' . intval($not_modified_by) : ''; if (is_array($type)) { $str_type = "AND i.type in ( " . implode(",", $type) . ")"; } else { $str_type = $type ? "AND i.type = {$type}" : ""; } if (!is_null($limit_offset) && !is_null($limit_rowcount)) { $str_limit = " LIMIT " . intval($limit_offset) . "," . intval($limit_rowcount); } else { if ($limit_rowcount) { $str_limit = " LIMIT " . intval($limit_rowcount); } else { $str_limit = ''; } } if (is_null($visible_only)) { $visible_only = $auth->cur_user && $auth->cur_user->user_rights & RIGHT_VIEWALL ? false : true; } ### only visibile for current user ### if ($visible_only) { $s_query = "SELECT i.* from {$prefix}item i, {$prefix}projectperson upp\r\n WHERE\r\n upp.person = {$auth->cur_user->id}\r\n AND upp.state = 1\r\n AND upp.project = i.project\r\n {$str_state}\r\n {$str_type}\r\n {$str_show_issues}\r\n {$str_project}\r\n {$str_project2}\r\n {$str_modified_by}\r\n {$str_not_modified_by}\r\n {$str_date_min}\r\n {$str_date_max}\r\n\r\n AND ( i.pub_level >= upp.level_view\r\n OR\r\n i.created_by = {$auth->cur_user->id}\r\n )\r\n\r\n " . getOrderByString($order_by) . $str_limit; } else { $s_query = "SELECT i.* from\r\n {$prefix}item i\r\n WHERE 1\r\n\r\n {$str_state}\r\n {$str_type}\r\n {$str_project}\r\n {$str_show_issues}\r\n {$str_modified_by}\r\n {$str_not_modified_by}\r\n {$str_date_min}\r\n {$str_date_max}\r\n\r\n " . getOrderByString($order_by) . $str_limit; } require_once confGet('DIR_STREBER') . 'db/class_projectperson.inc.php'; $dbh = new DB_Mysql(); $sth = $dbh->prepare($s_query); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $items = array(); if ($unviewed_only) { require_once confGet('DIR_STREBER') . "db/db_itemperson.inc.php"; $viewed_items = array(); foreach (ItemPerson::getAll(array('person' => $auth->cur_user->id)) as $vi) { $viewed_items[$vi->item] = $vi; } foreach ($tmp as $n) { $item = new DbProjectItem($n); if ($item->modified > $auth->cur_user->date_highlight_changes && (!isset($viewed_items[$item->id]) || $item->modified > $viewed_items[$item->id]->viewed_last)) { $items[] = $item; } } } else { foreach ($tmp as $n) { $item = new DbProjectItem($n); $items[] = $item; } } return $items; }
public static function initStreberUrl() { global $g_streber_url; $directory = explode("/tests/", $_SERVER['SCRIPT_NAME']); $g_streber_url = confGet('SELF_PROTOCOL') . "://" . asCleanString($_SERVER['HTTP_HOST']) . $directory[0]; }
function ajaxUserTasks() { $q = asCleanString(getOnePassedId("q")); $prj = intval(getOnePassedId("prj")); if ($prj == 0) { $prj = NULL; } if ($q == "") { $q = NULL; } $tasks = Task::getAll(array('search' => $q, 'project' => $prj)); $result = array(); foreach ($tasks as $t) { $result[] = array('name' => $t->name, 'id' => $t->id); } echo json_encode($result); }
/** * return files attached to project * @@@ todo: * - refacture status_min/max evaluation only if !is_null * */ static function getAll($args = NULL) { global $auth; $prefix = confGet('DB_TABLE_PREFIX'); ### default params ### $project = NULL; $latest_only = true; $order_by = "name"; $status_min = STATUS_UNDEFINED; $status_max = STATUS_CLOSED; $visible_only = true; # use project rights settings $alive_only = true; # ignore deleted $parent_item = NULL; # $images_only = false; $date_min = NULL; $date_max = NULL; $org_file = NULL; $id = NULL; $created_by = NULL; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $str_project = $project ? 'AND i.project=' . intval($project) : ''; $str_project2 = $project ? 'AND upp.project=' . intval($project) : ''; $str_is_alive = $alive_only ? 'AND i.state=' . ITEM_STATE_OK : ''; $str_date_min = $date_min ? "AND i.modified >= '" . asCleanString($date_min) . "'" : ''; $str_date_max = $date_max ? "AND i.modified <= ' " . asCleanString($date_max) . "'" : ''; $str_is_image = $images_only ? 'AND f.is_image!=0' : ''; $str_latest_only = $latest_only ? 'AND f.is_latest!=0' : ''; $str_created_by = $created_by ? 'AND i.modified_by =' . intval($created_by) : ''; $str_parent_item = !is_null($parent_item) ? 'AND f.parent_item=' . intval($parent_item) : ''; $str_org_file = $org_file ? "AND f.org_file = '" . intval($org_file) . "'" : ""; $str_id = $id ? "AND f.id = " . intval($id) : ""; if ($auth->cur_user->user_rights & RIGHT_VIEWALL) { $str_projectperson = ""; } else { $str_projectperson = "AND upp.person = {$auth->cur_user->id}"; } if ($visible_only) { $str_query = "SELECT DISTINCT i.*, f.* from {$prefix}item i, {$prefix}file f, {$prefix}projectperson upp\r\n WHERE\r\n i.type = '" . ITEM_FILE . "'\r\n {$str_project}\r\n {$str_projectperson}\r\n {$str_project2}\r\n\r\n {$str_is_alive}\r\n AND ( i.pub_level >= upp.level_view\r\n OR\r\n i.created_by = {$auth->cur_user->id}\r\n )\r\n\r\n AND i.id = f.id\r\n\t\t\t\t {$str_id}\r\n {$str_created_by}\r\n {$str_is_image}\r\n {$str_parent_item}\r\n {$str_org_file}\r\n {$str_latest_only}\r\n AND f.status >= {$status_min}\r\n AND f.status <= {$status_max}\r\n {$str_date_max}\r\n {$str_date_min}\r\n\r\n " . getOrderByString($order_by); } else { $str_query = "SELECT i.*, f.* from {$prefix}item i, {$prefix}file f\r\n WHERE\r\n i.type = '" . ITEM_FILE . "'\r\n {$str_project}\r\n {$str_is_alive}\r\n\r\n AND i.id = f.id\r\n\t\t\t {$str_id}\r\n {$str_created_by}\r\n {$str_parent_item}\r\n {$str_latest_only}\r\n AND f.status >= {$status_min}\r\n AND f.status <= {$status_max}\r\n {$str_org_file}\r\n {$str_date_max}\r\n {$str_date_min}\r\n\r\n " . getOrderByString($order_by); } $dbh = new DB_Mysql(); $sth = $dbh->prepare($str_query); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $files = array(); require_once confGet('DIR_STREBER') . 'db/class_file.inc.php'; foreach ($tmp as $t) { $file = new File($t); $files[] = $file; } return $files; }
/** * returns user by http_auth * * returns NULL of authorition failed * * Note: There are some weird things about http auth if Apache is running * PHP in CGI-mode. Read more at http://www.streber-pm.org/3733 * */ public static function getUserByHttpAuth() { log_message("setCurUserByHttpAuth()", LOG_MESSAGE_DEBUG); $tmp_auth = ''; foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER', 'REDIRECT_REDIRECT_REMOTE_USER') as $t) { if (isset($_SERVER[$t]) && $_SERVER[$t]) { $tmp_auth = $_SERVER[$t]; } } ### request authentification ### if (!$tmp_auth && !isset($_SERVER['PHP_AUTH_USER']) && !get('HTTP_AUTHORIZATION')) { header('WWW-Authenticate: Basic realm="blabl"'); header('HTTP/1.0 401 Unauthorized'); echo __('Sorry. Authentication failed'); exit; } $username = ''; $password = ''; if (isset($_SERVER['PHP_AUTH_USER'])) { $username = asCleanString($_SERVER['PHP_AUTH_USER']); if (isset($_SERVER['PHP_AUTH_PW'])) { $password = asCleanString($_SERVER['PHP_AUTH_PW']); } } else { $tmp = base64_decode(substr($tmp_auth, 6)); list($username, $password) = explode(':', $tmp); } ### try to login with nickname / password ### global $auth; return $auth->tryLoginUser($username, md5($password)); }
public function show($id = NULL, $params = NULL, $fn_argument = NULL) { global $auth; ### echo debug output ### if (isset($auth->cur_user)) { $user_name = $auth->cur_user->name; } else { $user_name = '__not_logged_in__'; } $crawler = Auth::isCrawler() ? 'crawler' : ''; log_message($user_name . '@' . getServerVar('REMOTE_ADDR', true) . " -> {$id} " . getServerVar('REQUEST_URI') . " (" . getServerVar('HTTP_USER_AGENT') . ") {$crawler}", LOG_MESSAGE_DEBUG); if (!$id) { $this->show('home'); exit; } else { if ($id != asAlphaNumeric($id)) { new FeedbackWarning("Ignored invalid page '" . asCleanString($id) . "'"); $this->show('home'); exit; } else { if (!isset($this->hash[$id])) { trigger_error('try to show undefined page-id ' . $id, E_USER_WARNING); $this->show('error'); return; } } } $handle = $this->hash[$id]; ### not authenticated ### if (!isset($auth) || !$auth->cur_user) { if (!$handle->valid_for_anonymous) { new FeedbackWarning("As an anonymous user you have not enough rights to view page '{$id}'"); $this->show('loginForm'); exit; } } ### check sufficient user-rights ### if ($handle->rights_required && !($handle->rights_required & $auth->cur_user->user_rights)) { $this->abortWarning("insufficient rights"); } ### hide modification pages from guests ### /** * Note: for some reason, this interfers with unit testing. Using the user agent for this * check here is extremely dirty, because it can be faked from attackers. This will not lead * to a result, because it switches the database for unit testing, though. */ if (getServerVar('HTTP_USER_AGENT') != 'streber_unit_tester') { if (isset($auth) && $auth->isAnonymousUser() && !$handle->valid_for_anonymous && ($handle->type == 'form' || $handle->type == 'subm' || $handle->type == 'func')) { $this->abortWarning("insufficient rights"); } } require_once $handle->req; #--- set page-handler-curpage --- $keep_cur_page_id = $this->cur_page_id; # show() might be called again, so we have to keep the page_id $this->cur_page_id = $id; $keep_cur_page = $this->cur_page; $this->cur_page = $handle; ### submit ### if ($handle->type = 'subm') { $tmp = get('from'); if ($tmp) { $this->cur_page_md5 = $tmp; } } #--- set params --- if ($params) { # global $vars; # foreach($params as $key=>$value) { # $vars[$key]=$value; # } # $vars['go']=$id; $params['go'] = $id; addRequestVars($params); } #--- avoid endless traps --- if (count($this->recursions) > MAX_PAGE_RECURSIONS) { trigger_error("maximum page recursions reached! (" . implode(",", $this->recursions) . ")", E_USER_ERROR); return; } $this->recursions[] = $id; #--- use id as function-name ---- if (function_exists($id)) { if ($fn_argument) { $id($fn_argument); # pass additional paramenter (eg. non-db-objects to xxxNew()-functions) } else { $id(); } } else { $this->abortWarning("page-call to undefined functions '{$id}'", ERROR_FATAL); } $this->cur_page_id = $keep_cur_page_id; $this->cur_page = $keep_cur_page; }
public function __toString() { global $auth; $onload_javascript = $this->page->extra_onload_js; ### include theme-config ### if ($theme_config = getThemeFile("theme_config.inc.php")) { require_once $theme_config; } ### Set uft8 header("Content-type: text/html; charset=utf-8"); ### Disable page caching ### header("Expires: -1"); header("Cache-Control: post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); $title = asHtml($this->page->title) . '/' . asHtml($this->page->title_minor) . ' - ' . confGet('APP_NAME'); $buffer = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' . '<html>' . '<head>' . '<meta http-equiv="Content-type" content="text/html; charset=utf-8">'; if (isset($auth->cur_user->language)) { $buffer .= '<meta http-equiv="Content-Language" content="' . $auth->cur_user->language . '">'; } $buffer .= '<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">' . '<META HTTP-EQUIV="EXPIRES" CONTENT="-1">' . '<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">' . '<link rel="SHORTCUT ICON" href="./favicon.ico">' . "<title>{$title}</title>"; /** * use Starlight syntax highlighting if enabled and client uses Gecko */ if (confGet('LINK_STAR_LIGHT') && preg_match("/Gecko/i", getServerVar('HTTP_USER_AGENT'), $matches)) { $buffer .= "<link rel=\"stylesheet\" href=\"themes/starlight/star-light.css\" type=\"text/css\"/>"; } $buffer .= "<link rel=\"stylesheet\" title=\"top\" media=\"screen\" type=\"text/css\" href=\"" . getThemeFile("styles.css") . "?v=" . confGet('STREBER_VERSION') . "\">"; $buffer .= "<!--[if IE]><link rel=\"stylesheet\" title=\"ie\" media=\"screen\" type=\"text/css\" href=\"" . getThemeFile("styles_ie.css") . "?v=" . confGet('STREBER_VERSION') . "\"><![endif]-->"; ### link print-style ### if (confGet('LINK_STYLE_PRINT')) { $buffer .= "<link rel=\"stylesheet\" media=\"print, embossed\" type=\"text/css\" href=\"" . getThemeFile("styles_print.css") . "?v=" . confGet('STREBER_VERSION') . "\">"; } ### Add iphone layout hints if (stristr(getServerVar('HTTP_USER_AGENT'), "iPhone")) { $buffer .= '<meta name = "viewport" content = "initial-scale = 0.7, user-scalable = no">'; $buffer .= '<link rel="stylesheet" media="screen" type="text/css" href="' . getThemeFile("iphone.css") . "?v=" . confGet('STREBER_VERSION') . '">'; $onload_javascript = 'window.scrollTo(0, 1);'; } $buffer .= '<script type="text/javascript" src="js/jquery-1.8.2.js"></script>' . '<script type="text/javascript" src="js/jquery.jeditable.1.5.x.js"></script>' . '<script type="text/javascript" src="js/misc.js' . "?v=" . confGet('STREBER_VERSION') . '"></script>' . '<script type="text/javascript" src="js/listFunctions.js' . "?v=" . confGet('STREBER_VERSION') . '"></script>'; if ($this->page->use_autocomplete) { $buffer .= '<script type="text/javascript" src="js/jquery.autocomplete.1.0.2.js' . "?v=" . confGet('STREBER_VERSION') . '"></script>'; $buffer .= '<link rel="stylesheet" type="text/css" href="' . getThemeFile("jquery.autocomplete.css") . '?v=' . confGet('STREBER_VERSION') . '" />'; } $buffer .= ' <script type="text/javascript"> '; if (confGet('TASKDETAILS_IN_SIDEBOARD')) { $buffer .= "var g_enable_sideboard= true;"; } else { $buffer .= "var g_enable_sideboard= false;"; } ### assemble onLoad function $buffer .= ' <!-- //------ on load ------- $(document).ready(function(){ '; $buffer .= $onload_javascript; if ($this->page->use_autocomplete) { $buffer .= 'initAutocompleteFields();'; } if ($this->page->autofocus_field) { $buffer .= "\r\ndocument.my_form." . $this->page->autofocus_field . ".focus();\r\ndocument.my_form." . $this->page->autofocus_field . ".select();"; } $buffer .= 'initContextMenus();'; if ($q = get('q')) { $q = asCleanString($q); if ($ar = explode(" ", $q)) { foreach ($ar as $q2) { if ($q2) { $buffer .= "highlightWord(document.getElementsByTagName('body')[0],'{$q2}'); "; } } } else { $buffer .= "highlightWord(document.getElementsByTagName('body')[0],'{$q}'); "; } } $buffer .= "misc();\r\n listFunctions();\r\n\r\n });\r\n\r\n //-->\r\n </script>" . "<script type=\"text/javascript\" src=\"js/contextMenus.js\"></script>" . "<script type=\"text/javascript\" src=\"js/searchhi.js\"></script>" . "<script type=\"text/javascript\">\r\n cMenu.menus=new Object();\r\n </script>"; /** * for notes on searchi see: http://www.kryogenix.org/code/browser/searchhi/ */ ### add calendar-functions for form-pages ### # NOTE: including calendar tremedously increases loading time! if ($this->page->use_jscalendar) { $buffer .= '<style type="text/css">@import url(' . getThemeFile('/calendar-win2k-1.css') . ');</style>' . '<script type="text/javascript" src="js/calendar.js"></script>' . '<script type="text/javascript" src="js/lang/calendar-en.js"></script>' . '<script type="text/javascript" src="js/calendar-setup.js"></script>' . '<script type="text/javascript" src="js/dragslider.js"></script>'; } ### add extra html ### $buffer .= $this->page->extra_header_html; $buffer .= "\r\n </head>"; $buffer .= '<body '; global $PH; if (isset($PH->cur_page_id)) { $buffer .= "class=\"{$PH->cur_page_id}\""; } #$buffer.="updateTableColor();"; $buffer .= '>'; # close body tag & onload $buffer .= "<div class=\"noscript\"><noscript>"; $buffer .= __("This page requires java-script to be enabled. Please adjust your browser-settings."); $buffer .= "</noscript></div><div id=\"outer\">"; return $buffer; }
function getOrderByString($f_order_str = NULL, $default = '') { if ($tmp = asCleanString($f_order_str)) { return 'ORDER BY ' . $tmp; } else { if ($tmp = asCleanString($default)) { return 'ORDER BY ' . $tmp; } } return ''; }
/** * playground @ingroup pages */ function playground() { global $PH; global $auth; if (!isset($_SERVER['REMOTE_USER']) && !isset($_SERVER['REDIRECT_REDIRECT_REMOTE_USER']) && !isset($_SERVER['PHP_AUTH_USER']) && !get('HTTP_AUTHORIZATION')) { header('WWW-Authenticate: Basic realm="blabl"'); header('HTTP/1.0 401 Unauthorized'); echo 'Sorry. You need to authenticate'; print "<pre>"; print_r($_SERVER); print "</pre>"; exit; } else { $username = ''; $password = ''; if (isset($_SERVER['PHP_AUTH_USER'])) { $username = asCleanString($_SERVER['PHP_AUTH_USER']); if (isset($_SERVER['PHP_AUTH_PW'])) { $password = asCleanString($_SERVER['PHP_AUTH_PW']); } } else { $ha = ''; if (isset($_SERVER['REDIRECT_REDIRECT_REMOTE_USER'])) { $ha = $_SERVER['REDIRECT_REDIRECT_REMOTE_USER']; } else { if (isset($_SERVER['REMOTE_USER'])) { $ha = $_SERVER['REMOTE_USER']; } } $tmp = base64_decode(substr($ha, 6)); list($username, $password) = explode(':', $tmp); } print "<br>username='******'"; print "<br>password='******'"; print "<pre>"; print_r($_SERVER); print "</pre>"; } ### create from handle ### $PH->defineFromHandle(array()); $page = new Page(); $page->cur_tab = 'home'; $page->options = array(new NaviOption(array('target_id' => 'home', 'name' => __('Today')))); $page->title = __("Today"); # $auth->cur_user->name; $page->type = __("At Home"); $page->title_minor = renderTitleDate(time()); echo new PageHeader(); echo new PageContentOpen_Columns(); measure_stop('init2'); echo "Column-Right"; echo new PageContentNextCol(); ?> <div id="pm3"> <style type="text/css"> .form_tabgroup { display:table; } .form_tabgroup UL { margin:0; padding:0; list-style:none; } .form_tabgroup LI.form_tab A { color:#777; border:0; display:block; padding:.3em .6em; } .form_tabgroup LI.form_tab { background-color:#eee; float:left; margin-right:.3em; } .form_tabgroup LI.Active { background-color:#ddd; } .form_tabgroup LI.Active A { color:#000; } .form_tabgroup DIV { padding:.5em .7em; background-color:#ddd; clear:both; } </style> <div class="form_tabgroup"> <ul> <li class="form_tab" id="tab1"><a href="#">One</a></li> <li class="form_tab" id="tab2"><a href="#">Two</a></li> <li class="form_tab" id="tab3"><a href="#">Three</a></li> </ul> <div id="tab1-body">I'm the one's tab content.</div> <div id="tab2-body">I'm the two's tab content<br />and a 2nd line.</div> <div id="tab3-body">Guess who am I -- says the three's tab content.</div> </div> <div class="form_tabgroup"> <ul> <li class="form_tab" id="tab1a"><a href="#">One</a></li> <li class="form_tab" id="tab2a"><a href="#">Two</a></li> <li class="form_tab" id="tab3a"><a href="#">Three</a></li> </ul> <div id="tab1a-body">I'm the one's tab content.</div> <div id="tab2a-body">I'm the two's tab content<br />and a 2nd line.</div> <div id="tab3a-body">Guess who am I -- says the three's tab content.</div> </div> </div> <?php echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * save field value of an item which has been edited inplace * and return formatted html code. * * If only a chapter has been edited, number defined in "chapter" */ function itemSaveField() { header("Content-type: text/html; charset=utf-8"); ### disable page caching ### header("Expires: -1"); header("Cache-Control: post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); $value = get('value'); if (is_null($value)) { return; } if (!($item_id = get('item'))) { print "Failure"; return; } global $g_wiki_project; if (!($item = DbProjectItem::getEditableById($item_id))) { print "Failure"; return; } if (!($object = DbProjectItem::getObjectById($item_id))) { print "Failure"; return; } if ($item->type == ITEM_PROJECT) { if (!($project = Project::getVisibleById($item->id))) { print "Failure getting project"; return; } } else { if (!($project = Project::getVisibleById($item->project))) { print "Failure getting project"; return; } } $g_wiki_project = $project; $field_name = 'description'; if (get('field')) { $field_name = asCleanString(get('field')); } if (!isset($object->fields[$field_name])) { return NULL; } require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; $chapter = intVal(get('chapter')); ### replace complete field ### if (is_null($chapter)) { $object->{$field_name} = $value; } else { require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; /** * split originial wiki block into chapters * start with headline and belonging text */ $org = $object->{$field_name}; if ($object->type == ITEM_TASK) { global $g_wiki_task; $g_wiki_task = $object; } $parts = getWikiChapters($org); ### replace last line return (added by textarea) ### if (!preg_match("/\n\$/", $value)) { $value .= "\n"; } #$value= str_replace("\\'", "'", $value); #$value= str_replace('\\"', "\"", $value); $parts[$chapter] = $value; $new_wiki_text = implode('', $parts); $object->{$field_name} = $new_wiki_text; } ### update $object->update(array($field_name)); ### mark parent of comment as changes if ($item->type == ITEM_COMMENT) { if ($parent_task = Task::getById($object->task)) { print "calling now changed by user"; $parent_task->nowChangedByUser(); } } print wiki2purehtml($object->{$field_name}); $item->nowChangedByUser(); }
public function print_automatic($project = NULL, $parent_task = NULL) { global $PH; global $auth; if (!isset($this->query_options['status_max'])) { $this->query_options['status_max'] = STATUS_COMPLETED; } if ($project) { $this->query_options['project'] = $project->id; } /* if(!$this->no_items_html && $project) { $this->no_items_html= $PH->getLink('taskNewFolder',__('New folder'),array('prj'=>$project->id)) ." ". __("or")." " . $PH->getLink('taskNew','',array('prj'=>$project->id)); } */ #if(!$this->active_block_function=$this->getBlockStyleFromCookie()) { # $this->active_block_function = 'list'; #} ### add filter options ### #foreach($this->filters as $f) { # foreach($f->getQuerryAttributes() as $k=>$v) { # $this->query_options[$k]= $v; # } #} $sort_cookie = "sort_{$PH->cur_page->id}_{$this->id}_{$this->active_block_function}"; if ($sort = get($sort_cookie)) { $this->query_options['order_by'] = asCleanString($sort); } if ($this->tasks_assigned_to) { $this->query_options['assigned_to_person'] = $this->tasks_assigned_to; } $this->query_options['show_folders'] = false; unset($this->columns['date_closed']); # unset($this->columns['pub_level']); unset($this->columns['estimated']); if ($auth->cur_user->user_rights & RIGHT_VIEWALL) { $this->query_options['visible_only'] = false; } $this->query_options['category'] = TCATEGORY_MILESTONE; $tasks = Task::getAll($this->query_options); $this->render_list($tasks); }
static function getTaskPeople($args = NULL) { global $auth; $prefix = confGet('DB_TABLE_PREFIX'); ### default params ### $date_min = NULL; $date_max = NULL; $created_by = NULL; # who created assigment... $person = NULL; # who has was assigned... $task = NULL; $project = NULL; $forward = NULL; $state = NULL; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $str_project = $project ? 'AND i.project=' . intval($project) : ''; $str_created_by = $created_by ? 'AND i.created_by=' . intval($created_by) : ''; $str_date_min = $date_min ? "AND i.modified >= '" . asCleanString($date_min) . "'" : ''; $str_date_max = $date_max ? "AND i.modified <= '" . asCleanString($date_max) . "'" : ''; $str_task = $task ? 'AND tp.task =' . intval($task) : ''; $str_person = $person ? 'AND tp.person =' . intval($person) : ''; $str_forward = $forward ? 'AND tp.forward = 1' : ''; $str_state = $state ? 'AND i.state =' . intval($state) : ''; ### show all ### $str_query = "SELECT tp.*, i.* from {$prefix}taskperson tp, {$prefix}item i\r\n\t\t\t WHERE\r\n\t\t\ti.type = '" . ITEM_TASKPERSON . "'\r\n\t\t\t{$str_project}\r\n\t\t\t{$str_created_by}\r\n\t\t\t{$str_forward}\r\n\t\t\t{$str_state}\r\n\t\t\tAND tp.id = i.id\r\n\t\t\t\t{$str_person}\r\n\t\t\t\t{$str_task}\r\n\t\t\t{$str_date_max}\r\n\t\t\t{$str_date_min}\r\n\t\t\t"; $dbh = new DB_Mysql(); $sth = $dbh->prepare($str_query); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $tps = array(); foreach ($tmp as $t) { $c = new TaskPerson($t); $tps[] = $c; } return $tps; }
/** * getComments($project=false) */ static function getAll($args = array()) { global $auth; $prefix = confGet('DB_TABLE_PREFIX'); require_once confGet('DIR_STREBER') . 'db/class_comment.inc.php'; ### default params ### $order_by = 'c.name'; $visible_only = true; # use project rights settings $alive_only = true; # ignore deleted $project = NULL; $task = NULL; $person = NULL; $date_min = NULL; $date_max = NULL; $search = NULL; $parent_comment = NULL; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $dbh = new DB_Mysql(); $str_is_alive = $alive_only ? 'AND i.state=1' : ''; $AND_person = $person ? 'AND i.created_by=' . intval($person) : ''; $AND_task = $task ? 'AND c.task=' . intval($task) : ''; $AND_match = $search ? "AND (MATCH (c.name,c.description) AGAINST ('" . asMatchString($search) . "*' IN BOOLEAN MODE))" : ''; $AND_project1 = $project ? "AND upp.project= {$project}" : ""; $AND_project2 = $project ? "AND i.project= {$project}" : ""; $AND_date_min = $date_min ? "AND i.modified >= '" . asCleanString($date_min) . "'" : ''; $AND_date_max = $date_max ? "AND i.modified <= '" . asCleanString($date_max) . "'" : ''; if (!is_null($parent_comment)) { $AND_comment = 'AND c.comment = ' . intval($parent_comment); } else { $AND_comment = ''; } if ($visible_only) { $str_query = "SELECT i.*, c.* from {$prefix}item i, {$prefix}comment c, {$prefix}projectperson upp\r\n WHERE\r\n upp.person = {$auth->cur_user->id}\r\n {$AND_project1}\r\n AND upp.state = 1\r\n\r\n AND i.type = '" . ITEM_COMMENT . "'\r\n AND i.project = upp.project\r\n {$AND_project2}\r\n {$str_is_alive}\r\n {$AND_person}\r\n {$AND_date_min}\r\n {$AND_date_max}\r\n AND ( i.pub_level >= upp.level_view\r\n OR\r\n i.created_by = {$auth->cur_user->id}\r\n )\r\n\r\n AND c.id = i.id\r\n {$AND_task}\r\n {$AND_match}\r\n {$AND_comment}\r\n\r\n " . getOrderByString($order_by); } else { $str_query = "SELECT i.*, c.* from {$prefix}item i, {$prefix}comment c\r\n WHERE\r\n i.type = '" . ITEM_COMMENT . "'\r\n {$AND_project2}\r\n {$str_is_alive}\r\n {$AND_person}\r\n {$AND_date_min}\r\n {$AND_date_max}\r\n\r\n AND c.id = i.id\r\n {$AND_task}\r\n {$AND_comment}\r\n {$AND_match}\r\n\r\n " . getOrderByString($order_by); } $sth = $dbh->prepare($str_query); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $comments = array(); foreach ($tmp as $n) { $comment = new Comment($n); $comments[] = $comment; } return $comments; }
* - use "customize.inc.php" in streber's root to overwrite any of this settings */ require_once "defines.inc.php"; /** * assoc. array holding initial configuration variables */ global $g_config; $g_config = array('STREBER_VERSION' => '0.095', 'STREBER_VERSION_DATE' => '2012-10-05', 'APP_NAME' => 'streber', 'APP_PAGE_URL' => 'http://www.streber-pm.org', 'PHP_VERSION_REQUIRED' => '5.0.0', 'INCLUDE_PATH' => ".", 'DIR_STREBER' => "./", 'DIR_TEMP' => "./_tmp/", 'DIR_IMAGE_CACHE' => "./_image_cache", 'DIR_RSS' => "./_rss/", 'DIR_FILES' => "./_files/", 'DIR_SETTINGS' => "./_settings/", 'FILE_DB_SETTINGS' => "db_settings.php", 'SITE_SETTINGS' => "site_settings.php", 'DEFAULT_LANGUAGE' => 'en', 'SELF_URL' => '', 'SELF_DOMAIN' => '', 'SELF_PROTOCOL' => '', 'APP_TITLE_HEADER' => "streber<span class=extend>PM</span>", 'DB_CREATE_DUMP_VERSION' => '0.095', 'STREBER_WIKI_URL' => 'http://www.streber-pm.org/index.php?go=search&search_query=', 'STREBER_WIKISYNTAX' => 'WikiSyntax!', 'DB_TYPE' => 'mysql', 'DB_TYPES' => array(), 'HOSTNAME' => 'localhost', 'DB_USERNAME' => '', 'DB_PASSWORD' => '', 'DB_NAME' => '', 'DB_TABLE_PREFIX' => '', 'DB_VERSION' => '', 'DB_TABLE_PREFIX_UNITTEST' => 'test_', 'SQL_MODE' => NULL, 'DB_USE_UTF8_ENCODING' => true, 'CHECK_PASSWORD_LEVEL' => 8, 'PERSON_PROFILE_DEFAULT' => PROFILE_DEVELOPER, 'PERSON_DEFAULT_SETTINGS' => USER_SETTING_HTML_MAIL | USER_SETTING_NOTIFY_ASSIGNED_TO_PROJECT | USER_SETTING_ENABLE_EFFORTS | USER_SETTING_ENABLE_BOOKMARKS, 'USE_PROFILER' => false, 'DISPLAY_ERROR_FULL' => false, 'DISPLAY_ERROR_LIST' => 'LIST', 'LOG_LEVEL' => LOG_MESSAGE_LOGIN_FAILURE | LOG_MESSAGE_LOGIN_SUCCESS | LOG_MESSAGE_LOGOUT | LOG_MESSAGE_HACKING_ALERT | LOG_MESSAGE_MISSING_FILES, 'USE_FIREPHP' => false, 'LIST_UNDEFINED_LANG_KEYS' => false, 'STOP_IF_INSTALL_DIRECTORY_EXISTS' => true, 'THEME_DEFAULT' => 0, 'THEME_OVERWRITE' => NULL, 'DEFAULT_LOCALE' => 'USE_TRANSLATION', 'LOGIN_MESSAGE' => "", 'STRING_LENGTH_SHORT' => 14, 'TASK_LIST_EFFORT_COLUMN' => false, 'TASK_LIST_EFFORT_RELATION_COLUMN' => false, 'LINK_REPORT_BUGS' => " Please help us by <a href='http://www.streber-pm.org/2717'>reporting a bug</a>", 'MESSAGE_OFFLINE' => "<h1>Congratulations!</h1>\n You are one of the few people witnessing this installation<br>\n of <a href='http://www.streber-pm.org'>streber</a> being offline.\n Use your chance now and <br>send a mail to <a href='%s'>%s</a> to get your special reward immediately.<br><br>\n Problem: <b>", 'EMAIL_ADMINISTRATOR' => '', 'LIST_COLOR_ODD' => '#ffffff', 'LIST_COLOR_EVEN' => '#f8f8f8', 'LIST_COLOR_SELECTED' => '#d0ffd0', 'LIST_COLOR_HOVER' => '#ffff80', 'PROJECT_DEFAULT_LABELS' => 'Bug,Feature,Enhancement,Refactor,Idea,Research,Organize,Wiki,Docu', 'PROJECT_DEFAULT_SETTINGS' => PROJECT_SETTING_ALL, 'LINK_STYLE_PRINT' => true, 'LINK_STAR_LIGHT' => false, 'SHOW_TASKS_AT_HOME_DEFAULT' => SHOW_ASSIGNED_ONLY, 'FILE_UPLOAD_SIZE_MAX' => 8000000, 'STRING_SIZE_MAX' => 256000, 'CLEAN_REFERRED_VARS' => 'HTML_ENTITIES', 'SERVER_TIME_OFFSET' => 0, 'ROUND_AUTO_DETECTED_TIME_OFFSET' => true, 'COOKIE_LIFETIME' => 60 * 60 * 24 * 30, 'CHECK_IP_ADDRESS' => false, 'ANONYMOUS_USER' => false, 'REGISTER_NEW_USERS' => false, 'ENABLE_GUEST_ACCOUNT' => false, 'REGISTER_NEW_USERS_TO_PROJECT' => 0, 'SMTP' => '', 'WORKHOURS_PER_DAY' => 10, 'WORKDAYS_PER_WEEK' => 5, 'DAYGRAPH_START_HOUR' => 8, 'DAYGRAPH_END_HOUR' => 22, 'DAYGRAPH_WIDTH' => 200, 'USE_MOD_REWRITE' => false, 'INTERNAL_COST_FEATURE' => false, 'SPAM_WORDS' => array('viagra' => 10, 'cialis' => 10, 'p**n' => 10, 'www.' => 3, '.com' => 3, '.de' => 2, 'sex' => 2, 'free' => 1, 'http' => 2, 'href' => 2, 'online' => 1, 'casino' => 3, 'buy' => 1, 'order' => 2, 'levitra' => 5, 'softtabs' => 5, 'spam' => 1, 'site' => 2), 'REJECT_SPAM_CONTENT' => 0.002, 'TASKDETAILS_IN_SIDEBOARD' => false, 'MAX_CHANGELINES_PER_PROJECT' => 5, 'MAX_CHANGELINES' => 20, 'MORE_CHANGELINES' => 20, 'LDAP' => false, 'LDAP_USERNAME_PREFIX' => '', 'LDAP_SERVER' => '', 'REPLY_ON_COMMENT_PREFIX' => '0'); /** * try to figure out url installation for links from notification mails */ if (isset($_SERVER['SCRIPT_NAME']) && $_SERVER['HTTP_HOST'] && preg_match("/\\/index\\.php/", $_SERVER['SCRIPT_NAME'])) { $url = asCleanString($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']); confChange('SELF_URL', $url); } elseif ($_SERVER['HTTP_HOST']) { $url = asCleanString($_SERVER['HTTP_HOST']); confChange('SELF_URL', $url); } /** * adjust url-prefix if https * NOTE: * - for installations at https, the urls in notifications-mails has to start with * https://www.somedome.com/ */ if (!confGet('SELF_PROTOCOL')) { if (getServerVar('HTTPS') == 'on') { confChange('SELF_PROTOCOL', 'https'); } else { confChange('SELF_PROTOCOL', 'http'); } }
static function getEffortTasks($args = NULL) { $prefix = confGet('DB_TABLE_PREFIX'); require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php'; require_once confGet('DIR_STREBER') . 'db/class_projectperson.inc.php'; $dbh = new DB_Mysql(); $project = NULL; $person = NULL; $effort_status_min = EFFORT_STATUS_NEW; $effort_status_max = EFFORT_STATUS_BALANCED; ### filter params ### if ($args) { foreach ($args as $key => $value) { if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") { trigger_error("unknown parameter", E_USER_NOTICE); } else { ${$key} = $value; } } } $str_status_min = $effort_status_min ? "AND e.status >= '" . asCleanString($effort_status_min) . "'" : ''; $str_status_max = $effort_status_max ? "AND e.status <= ' " . asCleanString($effort_status_max) . "'" : ''; $str_person = $person ? "AND e.person = '" . $person . "'" : ''; if ($effort_status_min != $effort_status_max) { $str_st = ""; } else { $str_st = ", e.status"; } if (!is_null($project)) { $query_str = "SELECT DISTINCT e.task, e.project {$str_st}\r\n FROM {$prefix}item i, {$prefix}effort e\r\n WHERE e.project = {$project}\r\n AND i.type = '" . ITEM_EFFORT . "'\r\n AND e.id = i.id\r\n {$str_status_min}\r\n {$str_status_max}\r\n {$str_person}\r\n AND i.state = '" . ITEM_STATE_OK . "';"; $sth = $dbh->prepare($query_str); $sth->execute("", 1); $tmp = $sth->fetchall_assoc(); $efforts = array(); foreach ($tmp as $t) { $effort = new Effort($t); $efforts[] = $effort; } return $efforts; } return NULL; }
public function __construct($str) { measure_start("blockLink::__construct"); global $PH; global $g_wiki_project; $this->str = ''; # prevent from further processing ### id|options|title ### if (preg_match("/\\A([^\\|]+)\\|([^|]+)\\|([^|]*)\$/", $str, $matches)) { $this->target = asCleanString($matches[1]); $this->options = explode(",", preg_replace("/[^a-z,=0-9]/", "", strtolower($matches[2]))); $this->name = $matches[3]; } else { if (preg_match("/\\A([^\\|]+)\\|([^|]+)\$/", $str, $matches)) { //$this->target="#" . asCleanString($matches[1]); $this->target = $matches[1]; $this->name = $matches[2]; } else { $this->name = ''; $this->target = $str; } } /** * urls */ if (preg_match("/\\A([\\w]+)\\:\\/\\/(\\S+)/", $this->target, $matches)) { $type = asKey($matches[1]); $target = $matches[2]; ### avoid breaking of url by double encoding of "&"-symbol... $target_url = str_replace("&", "&", asHtml($target)); if ($this->name) { $this->html = "<a rel='nofollow' class=extern title='" . asHtml($this->target) . "' href='" . $type . "://" . $target_url . "'>" . asHtml($this->name) . "</a>"; } else { $this->html = "<a class=extern title='" . asHtml($this->target) . "' href='" . $type . "://" . $target_url . "'>" . asHtml($this->target) . "</a>"; } } else { if (preg_match("/\\A\\#(\\d+)/", $this->target, $matches)) { $id = intVal($matches[1]); $this->html = FormatBlockLink::renderLinkFromItemId($id, $this->name); } else { if (preg_match("/\\A([\\w]+)\\:(\\d+)/", $this->target, $matches)) { $type = asKey($matches[1]); $target = asCleanString($matches[2]); switch ($type) { /** * embedding images... */ case 'image': measure_start("blockLink::__construct::image"); require_once confGet('DIR_STREBER') . './db/class_file.inc.php'; if (($item = DbProjectItem::getVisibleById(intVal($target))) && $item->type == ITEM_FILE && ($file = File::getVisibleById(intval($target)))) { $file = $file->getLatest(); ### if there are not options ## if (!$this->options && $this->name) { $this->options = explode(",", preg_replace("/[^a-z,=0-9]/", "", strtolower($this->name))); $this->name = asHtml($file->name); } $align = ''; $max_size = 680; $framed = false; if ($this->options) { foreach ($this->options as $o) { if ($o == 'left') { $align = 'left'; } else { if ($o == 'right') { $align = 'right'; } else { if (preg_match('/maxsize=(\\d*)/', $o, $matches)) { $max_size = $matches[1]; } else { if ($o == 'framed') { $framed = true; } } } } } } if (!($dimensions = $file->getImageDimensions($max_size))) { $this->html = '<em>' . sprintf(__("Item #%s is not an image"), $file->id) . "</em>"; return; } if ($framed) { $this->html = "<div class='frame {$align}'>" . "<a href='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id)) . "'>" . "<img class=uploaded title='" . asHtml($file->name) . "'" . " alt='" . asHtml($file->name) . "'" . " src='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id, 'max_size' => $max_size)) . "'" . " height=" . intval($dimensions['new_height']) . " width=" . intval($dimensions['new_width']) . "></a>" . '<span>' . asHtml($this->name) . " (" . "<a href='" . $PH->getUrl('fileView', array('file' => $file->id)) . "'>" . __('Image details') . ")</a>" . '</span>' . "</div>"; if (!$align) { $this->html .= '<span class=clear> </span>'; } } else { $this->html = "<a href='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id)) . "'>" . "<img class='{$align} uploaded'" . " title='" . asHtml($file->name) . "'" . " alt='" . asHtml($file->name) . "'" . " src='" . $file->getCachedUrl($max_size) . "'" . " height=" . intval($dimensions['new_height']) . " width=" . intval($dimensions['new_width']) . "></a>"; } } else { $this->name = __("Unknown File-Id:") . ' ' . $target; } measure_stop("blockLink::__construct::image"); break; /** * item */ /** * item */ case 'item': $this->html = FormatBlockLink::renderLinkFromItemId($target, $this->name); break; default: /** * note, since this message is normally printed after the header, * nobody will read this hint... */ new FeedbackHint(sprintf(__('Wiki-format: <b>%s</b> is not a valid link-type'), $type) . " " . sprintf(__("Read more about %s."), $PH->getWikiLink('WikiSyntax'))); } } else { if (preg_match("/\\Aembed\\:(\\S+)/", $this->target, $matches)) { $t = $matches[1]; /** * http://youtu.be/eb0xhLq8oAQ * * <iframe width="560" height="315" src="http://www.youtube-nocookie.com/embed/eb0xhLq8oAQ" frameborder="0" allowfullscreen></iframe> * */ if (preg_match("/^http\\:\\/\\/youtu\\.be\\/([A-Za-z0-9_->]*)/", $t, $embed_matches)) { $this->html = "<iframe width=640 height=384 src='http://www.youtube-nocookie.com/embed/{$embed_matches[1]}' frameborder=0 allowfullscreen></iframe>"; } else { if (preg_match("/^http\\:\\/\\/vimeo.com\\/(\\d*)/", $t, $embed_matches)) { $this->html = "<iframe src='http://player.vimeo.com/video/{$embed_matches[1]}?badge=0' width=640 height=384 frameborder=0 webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>"; } } } else { $this->html = FormatBlockLink::renderLinkFromTargetName($this->target, $this->name); } } } } measure_stop("blockLink::__construct"); }
public static function getByNickname($nickname) { $prefix = confGet('DB_TABLE_PREFIX'); $tmp = self::queryFromDb("SELECT * FROM {$prefix}person WHERE nickname='" . asCleanString($nickname) . "'"); if (!$tmp || count($tmp) != 1) { return false; } return $tmp[0]; }