} elseif ($db instanceof TikiDb_Pdo) { require_once 'lib/tikisession-pdo.php'; } } elseif (isset($prefs['session_storage']) && $prefs['session_storage'] == 'memcache' && TikiLib::lib("memcache")->isEnabled()) { require_once 'lib/tikisession-memcache.php'; } if (!isset($prefs['session_cookie_name']) || empty($prefs['session_cookie_name'])) { $prefs['session_cookie_name'] = session_name(); } session_name($prefs['session_cookie_name']); // Only accept PHP's session ID in URL when the request comes from the tiki server itself // This is used by features that need to query the server to retrieve tiki's generated html and images (e.g. pdf export) // It could be , that the server initiates his request with its own ip, so we check also if server == remote // Note: this is an incomplete implemenation - the session handling does not really work this way. Session data is lost and not regenerated. // Maybe better to use tokens: see i.e. the example in lib/pdflib.php if (isset($_GET[session_name()]) && ($tikilib->get_ip_address() == '127.0.0.1' || $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"])) { $_COOKIE[session_name()] = $_GET[session_name()]; session_id($_GET[session_name()]); } //Set tikiroot and tikidomain to blank string if not set. if (empty($tikiroot)) { $tikiroot = ""; } if (empty($tikidomain)) { $tikidomain = ""; } if ($prefs['cookie_consent_feature'] === 'y' && empty($_COOKIE[$prefs['cookie_consent_name']])) { $feature_no_cookie = true; } else { $feature_no_cookie = false; }
} elseif ($api_tiki == 'pdo') { require_once ('lib/tikisession-pdo.php'); } } elseif ( isset($prefs['session_storage']) && $prefs['session_storage'] == 'memcache' && TikiLib::lib("memcache")->isEnabled() ) { require_once ('lib/tikisession-memcache.php'); } if ( ! isset( $prefs['session_cookie_name'] ) || empty( $prefs['session_cookie_name'] ) ) { $prefs['session_cookie_name'] = session_name(); } session_name($prefs['session_cookie_name']); // Only accept PHP's session ID in URL when the request comes from the tiki server itself // This is used by features that need to query the server to retrieve tiki's generated html and images (e.g. pdf export) if (isset($_GET[session_name()]) && $tikilib->get_ip_address() == '127.0.0.1') { $_COOKIE[session_name()] = $_GET[session_name()]; session_id($_GET[session_name()]); } $start_session = true; if ( isset($prefs['session_silent']) && $prefs['session_silent'] == 'y' && empty($_COOKIE[session_name()]) ) { $start_session = false; } // If called from the CDN, refuse to execute anything $cdn_pref = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? $prefs['tiki_cdn_ssl'] : $prefs['tiki_cdn']; if ( $cdn_pref ) { $host = parse_url($cdn_pref, PHP_URL_HOST); if (isset($_SERVER['HTTP_HOST']) && $host == $_SERVER['HTTP_HOST'] ) { header("HTTP/1.0 404 Not Found");
public function copy_item($from, $to, $except = null, $only = null, $status = null) { global $user, $prefs; if ($prefs['feature_categories'] == 'y') { $categlib = TikiLib::lib('categ'); $cats = $categlib->get_object_categories('trackeritem', $from); } if (empty($to)) { $is_new = 'y'; $info_to['trackerId'] = $this->items()->fetchOne('trackerId', array('itemId' => $from)); $info_to['status'] = empty($status) ? $this->items()->fetchOne('status', array('itemId' => $from)) : $status; $info_to['created'] = $info_to['lastModif'] = $this->now; $info_to['createdBy'] = $info_to['lastModifBy'] = $user; $to = $this->items()->insert($info_to); } $query = 'select ttif.*, ttf.`type`, ttf.`options` from `tiki_tracker_item_fields` ttif left join `tiki_tracker_fields` ttf on (ttif.`fieldId` = ttf.`fieldId`) where `itemId`=?'; $result = $this->fetchAll($query, array($from)); $clean = array(); $factory = new Tracker_Field_Factory(); foreach ($result as $res) { $typeInfo = $factory->getFieldInfo($res['type']); $options = Tracker_Options::fromSerialized($res['options'], $typeInfo); $res['options_array'] = $options->buildOptionsArray(); if ($prefs['feature_categories'] == 'y' && $res['type'] == 'e') { //category if (!empty($except) && in_array($res['fieldId'], $except) || !empty($only) && !in_array($res['fieldId'], $only)) { // take away the categories from $cats if (ctype_digit($res['options_array'][0]) && $res['options_array'][0] > 0) { $filter = array('identifier' => $res['options_array'][0], 'type' => 'children'); } else { $filter = null; } $children = $categlib->getCategories($filter, true, false); $local = array(); foreach ($children as $child) { $local[] = $child['categId']; } $cats = array_diff($cats, $local); } } if (!empty($except) && in_array($res['fieldId'], $except) || !empty($only) && !in_array($res['fieldId'], $only) || $res['type'] == 'q') { continue; } if (!empty($is_new) && in_array($res['type'], array('u', 'g', 'I')) && ($res['options_array'][0] == 1 || $res['options_array'][0] == 2)) { $res['value'] = $res['type'] == 'u' ? $user : ($res['type'] == 'g' ? $_SESSION['u_info']['group'] : TikiLib::get_ip_address()); } if (in_array($res['type'], array('A', 'N'))) { // attachment - image continue; //not done yet } //echo "duplic".$res['fieldId'].' '. $res['value'].'<br>'; if (!in_array($res['fieldId'], $clean)) { $this->itemFields()->delete(array('itemId' => $to, 'fieldId' => $res['fieldId'])); $clean[] = $res['fieldId']; } $data = array('itemId' => $to, 'fieldId' => $res['fieldId'], 'value' => $res['value']); $this->itemFields()->insert($data); } if (!empty($cats)) { $trackerId = $this->items()->fetchOne('trackerId', array('itemId' => $from)); $this->categorized_item($trackerId, $to, "item {$to}", $cats); } return $to; }