function http_parse_request($result, $headerMode = true) { $resHeaders = array(); $resBody = array(); foreach (explode("\n", $result) as $line) { if ($headerMode) { if (strStartsWith($line, 'HTTP/')) { $httpInfoRecord = explode(' ', trim($line)); if ($httpInfoRecord[1] == '100') { $ignoreUntilHTTP = true; } else { $ignoreUntilHTTP = false; $resHeaders['code'] = $httpInfoRecord[1]; $resHeaders['HTTP'] = $line; } } else { if (trim($line) == '') { if (!$ignoreUntilHTTP) { $headerMode = false; } } else { $hdr_key = trim(CutSegment(':', $line)); $resHeaders[strtolower($hdr_key)] = trim($line); } } } else { $resBody[] = $line; } } $body = trim(implode("\n", $resBody)); $data = json_decode($body, true); return array('length' => strlen($body), 'result' => $resHeaders['code'], 'headers' => $resHeaders, 'data' => $data, 'body' => $body); }
public function testThatStrStartsWithCorrectlyIdentifiesIfAStringStartsWithASubString() { $string = 'fooBar'; $this->assertTrue(strStartsWith($string, 'foo')); $string = 'barFoo'; $this->assertFalse(strStartsWith($string, 'foo')); }
public function __call($name, $arguments) { $reflect = new ReflectionClass($this); $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED); $fields = array(); foreach ($props as $key => $value) { $fields[] = $value->getName(); } if (strStartsWith($name, "get")) { $field = lcfirst(preg_replace("#get(.*)#", "\$1", $name)); if (in_array($field, $fields, true)) { return $this->{$field}; } else { throw new Exception("Field {$field} not defined."); } } if (strStartsWith($name, "set")) { $field = lcfirst(preg_replace("#set(.*)#", "\$1", $name)); if (in_array($field, $fields, true)) { $this->{$field} = $arguments[0]; } else { throw new Exception("Field {$field} not defined."); } } }
public function getCommandByObjectId(IdRequestObject $idRequestObject) { $pyramidObject = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $idRequestObject->getId()); $pyramidType = $pyramidObject->get_attribute("OBJ_TYPE"); if ($pyramidType != "0" && strStartsWith($pyramidType, "container_pyramiddiscussion")) { return new \Pyramiddiscussion\Commands\Index(); } return null; }
function __construct() { parent::__construct(); // find all the test methods in this unit test $methods = get_class_methods($this); foreach ($methods as $method) { if (strStartsWith($method, 'test')) { $this->testMethods[] = $method; } } }
function convRealToRelative($realpath) { // 指定的绝对路径必须在 root 范围之内,否则返回 '' if (!strStartsWith($realpath, $GLOBALS['wfs_root'] . '/')) { return ''; } // 截取出相对路径(不带前导分隔符) return strStripPrefix($realpath, strlen($GLOBALS['wfs_root']) + 1); }
/** * Converts a string to defined native PHP type. * * @param string $string The string to convert * @param string $typename The name of the required resulting PHP type. * Allowed types are (bool|boolean|double|float|int|integer|string|array) * @return mixed */ public static function StrToType(string $string, $typename) { if (null === $string) { return null; } $t = new Type($string); if (!$t->hasAssociatedString()) { return null; } $string = $t->getStringValue(); switch (\strtolower($typename)) { case 'bool': case 'boolean': $res = false; static::IsBoolConvertible($string, $res); return $res; case 'float': return \floatval(\str_replace(',', '.', $string)); case 'double': if (!static::IsDecimal($string, true)) { return null; } $res = \str_replace(',', '.', $string); $tmp = \explode('.', $res); $ts = \count($tmp); if ($ts > 2) { $dv = $tmp[$ts - 1]; unset($tmp[$ts - 1]); $dv = \join('', $tmp) . '.' . $dv; return \doubleval($dv); } return \doubleval($res); case 'int': case 'integer': if (static::IsInteger($string) || static::IsDecimal($string, true)) { return \intval($string); } return null; case 'string': return $string; case 'array': if (\strlen($string) < 1) { return []; } if (\strlen($string) > 3) { if (\substr($string, 0, 2) == 'a:') { try { $res = \unserialize($string); if (\is_array($res)) { return $res; } } catch (\Exception $ex) { } } if (strStartsWith($string, '[') && strEndsWith($string, ']')) { try { return (array) \json_decode($string); } catch (\Exception $ex) { } } else { if (strStartsWith($string, '{') && strEndsWith($string, '}')) { try { return (array) \json_decode($string); } catch (\Exception $ex) { } } } } return array($string); default: if (\strlen($string) < 1) { return null; } if (\strlen($string) > 3) { if (\substr($string, 0, 2) == 'O:' && \preg_match('~^O:[^"]+"' . $typename . '":~', $string)) { try { $res = \unserialize($string); if (!\is_object($res)) { return null; } if (\get_class($res) == $typename) { return $res; } } catch (\Throwable $ex) { } } } return null; } }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $user = $GLOBALS["STEAM"]->get_current_steam_user(); $userID = $user->get_id(); $pyramidRoom = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $pyramiddiscussionExtension = \Pyramiddiscussion::getInstance(); $pyramiddiscussionExtension->addCSS(); $pyramiddiscussionExtension->addJS(); $content = $pyramiddiscussionExtension->loadTemplate("pyramiddiscussion_index.template.html"); $admingroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINGROUP"); $basegroup = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_BASEGROUP"); $startElements = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAX"); $maxcol = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL"); $deadlines = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_DEADLINES"); $user_management = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT"); $deadlines_used = false; $currentUserGroup = 0; $objtype = $pyramidRoom->get_attribute("OBJ_TYPE"); if (!strStartsWith($objtype, "container_pyramiddiscussion")) { $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml("Objekt " . $this->id . " ist keine Pyramidendiskussion."); $frameResponseObject->addWidget($rawWidget); return $frameResponseObject; } // if one or more deadlines past by since the last visit on this page, change the phase $phase = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ACTCOL"); if ($phase != 0 && $phase <= $maxcol && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0) { $currentDeadline = $deadlines[$phase]; while (true) { if ($currentDeadline > time()) { break; } else { $phase++; $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ACTCOL", $phase); if ($phase == $maxcol + 1) { break; } $currentDeadline = $deadlines[$phase]; } } } $adminoptions_change = -1; if (isset($this->params[1])) { $adminoptions_change = $this->params[1]; } // if current user is admin display actionbar if ($admingroup->is_member($user)) { $adminconfig = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_ADMINCONFIG"); if (array_key_exists($userID, $adminconfig)) { $options = $adminconfig[$userID]; // change show/hide settings if ($adminoptions_change != -1) { if ($adminoptions_change == 1) { $options["show_adminoptions"] = "true"; } else { $options["show_adminoptions"] = "false"; } $adminconfig[$userID] = $options; $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig); } } else { $adminconfig[$userID] = array(); $options = $adminconfig[$userID]; $options["show_adminoptions"] = "true"; $adminconfig[$userID] = $options; $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig); } if ($options["show_adminoptions"] == "true") { $actionbar = new \Widgets\Actionbar(); $actions = array(array("name" => "Konfiguration", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Teilnehmerverwaltung", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "users/" . $this->id), array("name" => "Rundmail erstellen", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "mail/" . $this->id), array("name" => "Adminmodus ausschalten", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->id . "/0")); $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); } else { $actionbar = new \Widgets\Actionbar(); $actions = array(array("name" => "Adminmodus einschalten", "link" => $pyramiddiscussionExtension->getExtensionUrl() . "Index/" . $this->id . "/1")); $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); } } // display the general information block $content->setCurrentBlock("BEGIN BLOCK_PYRAMID_INFORMATION"); $content->setVariable("JS_URL", $pyramiddiscussionExtension->getAssetUrl()); $content->setVariable("GENERAL_INFORMATION", "Allgemeine Informationen"); $content->setVariable("PHASE_LABEL", "Aktueller Status:"); // if user is an admin and adminoptions are shown, display a select box to change the current phase if (isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true") { for ($count = 0; $count <= $maxcol + 2; $count++) { $content->setCurrentBlock("BLOCK_PHASE_OPTION"); $content->setVariable("PHASE_ID", $count); if ($count == 0) { $content->setVariable("PHASE_VALUE", "Gruppeneinteilungsphase"); } else { if ($count <= $maxcol) { $content->setVariable("PHASE_VALUE", $count . ". Diskussionsphase"); } else { if ($count == $maxcol + 1) { $content->setVariable("PHASE_VALUE", "Endphase"); } else { $content->setVariable("PHASE_VALUE", "Pyramide einfrieren"); } } } if ($count == $phase) { $content->setVariable("PHASE_SELECTED", "selected"); } $content->setVariable("CHANGE_PHASE", "Ändern"); $params = "{ id : " . $pyramidRoom->get_id() . ", action : 'phase', newphase : document.getElementById('phase').value }"; $content->setVariable("CHANGE_PHASE_ACTION", "sendRequest('Index', " . $params . ", '" . $pyramidRoom->get_id() . "', 'reload');"); $content->parse("BLOCK_PHASE_OPTION"); } } else { $content->setCurrentBlock("BLOCK_PYRAMID_PHASE_NOADMIN"); if ($phase == 0) { $content->setVariable("PHASE_VALUE", "Gruppeneinteilungsphase"); } else { if ($phase <= $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL")) { $content->setVariable("PHASE_VALUE", $phase . ". Diskussionsphase"); } else { if ($phase == $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_MAXCOL") + 1) { $content->setVariable("PHASE_VALUE", "Endphase"); } else { $content->setVariable("PHASE_VALUE", "Pyramide eingefroren"); } } } $content->parse("BLOCK_PYRAMID_PHASE_NOADMIN"); } $content->setVariable("DEADLINE_LABEL", "Deadline:"); // display current deadline if deadlines are used and override is off if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0 && $phase != 0 && $phase <= $maxcol) { $content->setVariable("DEADLINE_VALUE", date("d.m.Y H:i", (int) $deadlines[$phase])); $content->setVariable("DISPLAY_OVERRIDE", "none"); $deadlines_used = true; // if user is admin, adminoptions are shown, deadlines are used but override is on, display a dialog to stop the override } else { if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 1 && isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true") { $content->setVariable("DEADLINE_VALUE", "Aktuelle Phase wurde trotz der Verwendung von Deadlines manuell gesetzt. Die Deadlines werden im Moment nicht berücksichtigt."); $content->setVariable("DEADLINE_OVERRIDE_LABEL", "Deadlines aktivieren"); $params = "{ id : " . $pyramidRoom->get_id() . ", action : 'deadlines' }"; $content->setVariable("DEADLINE_OVERRIDE_ACTION", "sendRequest('Index', " . $params . ", '" . $pyramidRoom->get_id() . "', 'reload');"); } else { $content->setVariable("DEADLINE_VALUE", "keine"); $content->setVariable("DISPLAY_OVERRIDE", "none"); } } $content->setVariable("INFO_LABEL", "Infotext:"); $content->setVariable("INFO_VALUE", nl2br($pyramidRoom->get_attribute("OBJ_DESC"))); $content->parse("BEGIN BLOCK_PYRAMID_INFORMATION"); // display pyramid $content->setCurrentBlock("BLOCK_PYRAMID"); // create array to store the users for all positions $users = array(); for ($count = 1; $count <= $maxcol; $count++) { for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) { $users[$count . $count2] = array(); } } // for every phase $maxuser = 1; for ($count = 1; $count <= $maxcol; $count++) { // if deadlines are used, display deadline of every phase on the top of the phase if ($pyramidRoom->get_attribute("PYRAMIDDISCUSSION_USEDEADLINES") == "yes" && $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES") == 0 && $phase <= $maxcol) { $content->setCurrentBlock("BLOCK_PYRAMID_DEADLINE"); $content->setVariable("DEADLINE_ID", "deadline" . $count); $content->setVariable("DEADLINE_DATE", date("d.m.Y H:i", (int) $deadlines[$count])); $content->parse("BLOCK_PYRAMID_DEADLINE"); } // create user array for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) { $position = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . $count . "_" . $count2); $positionGroup = $position->get_attribute("PYRAMIDDISCUSSION_RELGROUP"); $positionMembers = $positionGroup->get_members(); // add the users from the positions in the first phase to their corresponding arrays if ($count == 1) { if ($positionMembers instanceof \steam_user) { $users[$count . $count2] = $positionMembers->get_id(); if ($positionMembers->get_id() == $userID) { $currentUserGroup = $positionGroup->get_id(); } } else { foreach ($positionMembers as $positionMember) { array_push($users[$count . $count2], $positionMember->get_id()); if ($positionMember->get_id() == $userID) { $currentUserGroup = $positionGroup->get_id(); } } } if (count($users[$count . $count2]) > $maxuser) { $maxuser = count($users[$count . $count2]); } // add users to the arrays of the positions for all other phases } else { $users[$count . $count2] = array_merge($users[$count - 1 . ($count2 * 2 - 1)], $users[$count - 1 . $count2 * 2]); } } // for every position in a phase for ($count2 = 1; $count2 <= $startElements / pow(2, $count - 1); $count2++) { $position = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $pyramidRoom->get_path() . "/Position_" . $count . "_" . $count2); $positionGroup = $position->get_attribute("PYRAMIDDISCUSSION_RELGROUP"); $positionMembers = $positionGroup->get_members(); // get the names from all users of the current position (that still take part in the discussion) $participants = $pyramidRoom->get_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT"); foreach ($users[$count . $count2] as $currentUserID) { if (!isset($participants[$currentUserID])) { $participants[$currentUserID] = 0; $pyramidRoom->set_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT", $participants); } if ($participants[$currentUserID] == 0 || $participants[$currentUserID] >= $count) { $currentMember = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $currentUserID); } } // get position read states $read_states = $position->get_attribute("PYRAMIDDISCUSSION_POS_READ_STATES"); if (!is_array($read_states)) { $read_states = array(); } // determine if there are unread comments for the current position $comments_read = 1; $comments = $position->get_annotations(); foreach ($comments as $comment) { $comment_read_states = $comment->get_attribute("PYRAMIDDISCUSSION_COMMENT_READ_STATES"); if (!is_array($comment_read_states)) { $comment_read_states = array(); } if (!array_key_exists($userID, $comment_read_states) || $comment_read_states[$userID] != "1") { $comments_read = 0; break; } } $read = false; $content->setCurrentBlock("BLOCK_PYRAMID_POSITION"); $state = "phase" . $count . " "; if ($count <= $phase && count($users[$count . $count2]) > 0) { $state = $state . "active "; } else { if (!($phase == 0 && $count == 1) || $phase != 0 && count($users[$count . $count2]) == 0) { $state = $state . "inactive "; $content->setVariable("POSITION_ACTION_HIDDEN", "hidden"); $read = true; } else { $state = $state . "active "; } } if (in_array($userID, $users[$count . $count2])) { $state = $state . "my "; if ($phase != 0) { if ($phase == $count && (!isset($user_management[$currentUserID]) || $user_management[$currentUserID] == 0 || $user_management[$currentUserID] >= $count)) { // current discussion phase $content->setVariable("POSITION_ACTION_LABEL", "Position lesen<br>und bearbeiten"); $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"'); } else { if ($count < $phase) { // previous discussion phase $content->setVariable("POSITION_ACTION_LABEL", "Position lesen"); $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"'); } } $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id()); if (array_key_exists($userID, $read_states) && $read_states[$userID] == "1" || $position->get_content() == "0" || $position->get_content() == "") { $read = true; } } else { // group choosing phase, my position $content->setVariable("POSITION_ACTION_LABEL", "Position<br>verlassen"); $params = "{ id : " . $position->get_id() . ", pyramid : " . $pyramidRoom->get_id() . ", action : 'join', formergroup : " . $currentUserGroup . ", newgroup : " . $positionGroup->get_id() . " }"; $content->setVariable("POSITION_ACTION_URL", "javascript:sendRequest('EditPosition', " . $params . ", '" . $position->get_id() . "', 'reload');"); $read = true; } } else { if ($phase != 0) { if ($count < $phase) { // previous discussion phase, other positions (reading allowed) $content->setVariable("POSITION_ACTION_LABEL", "Position lesen"); $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id()); if (array_key_exists($userID, $read_states) && $read_states[$userID] == "1" || $position->get_content() == "0" || $position->get_content() == "") { $read = true; } $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"'); } else { if ($phase == $count) { // current discussion phase, other positions (reading not allowed) $content->setVariable("POSITION_ACTION_HIDDEN", "hidden"); $read = true; } } } else { // group choosing phase, other positions $content->setVariable("POSITION_ACTION_LABEL", "Position<br>beitreten"); $params = "{ id : " . $position->get_id() . ", pyramid : " . $pyramidRoom->get_id() . ", action : 'join', formergroup : " . $currentUserGroup . ", newgroup : " . $positionGroup->get_id() . " }"; $content->setVariable("POSITION_ACTION_URL", "javascript:sendRequest('EditPosition', " . $params . ", '" . $position->get_id() . "', 'reload');"); $read = true; } } if ($read) { $state = $state . "read"; $content->setVariable("READSTATUS_ICON", "read_position"); $content->setVariable("READSTATUS_TITLE", "Position gelesen"); } else { $state = $state . "unread"; $content->setVariable("READSTATUS_ICON", "not_read_position"); $content->setVariable("READSTATUS_TITLE", "Position ungelesen"); } if ($phase > 0 && $phase != $maxcol + 2 && (isset($options["show_adminoptions"]) && $options["show_adminoptions"] == "true")) { $content->setVariable("POSITION_ACTION_URL", $pyramiddiscussionExtension->getExtensionUrl() . "ViewPosition/" . $pyramidRoom->get_id() . "/" . $position->get_id()); $content->setVariable("POSITION_ACTION_HIDDEN", ""); $content->setVariable("POSITION_ACTION_LABEL", "Position lesen<br>und bearbeiten"); $content->setVariable("COMMENTS_URL", 'href="' . $pyramiddiscussionExtension->getExtensionUrl() . 'ViewPosition/' . $pyramidRoom->get_id() . '/' . $position->get_id() . '#comments"'); } $content->setVariable("POSITION_ID", "position" . $count . $count2); $content->setVariable("POSITION_STATE", $state); $content->setVariable("POSITION_LABEL", "Position " . $count . "-" . $count2); $content->setVariable("ASSETURL", $pyramiddiscussionExtension->getAssetUrl()); if ($comments_read == 1) { $content->setVariable("ANNOTATION_COUNT", count($comments)); $content->setVariable("ANNOTATION_TITLE", "Keine ungelesenen Kommentare vorhanden"); $content->setVariable("COMMENTSTATUS_ICON", "no_comments"); } else { $content->setVariable("ANNOTATION_COUNT", "<b>" . count($comments) . "</b>"); $content->setVariable("ANNOTATION_TITLE", "Ungelesene Kommentare vorhanden"); $content->setVariable("COMMENTSTATUS_ICON", "comments"); } foreach ($users[$count . $count2] as $currentUserID) { if (!isset($user_management[$currentUserID]) || $user_management[$currentUserID] == 0 || $user_management[$currentUserID] >= $count) { $currentUser = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $currentUserID); $pic_id = $currentUser->get_attribute("OBJ_ICON")->get_id(); $pic_link = $pic_id == 0 ? PATH_URL . "styles/standard/images/anonymous.jpg" : PATH_URL . "download/image/" . $pic_id . "/15/20"; $content->setCurrentBlock("BLOCK_PYRAMID_POSITION_USER"); $content->setVariable("USER_URL", PATH_URL . "user/index/" . $currentUser->get_name()); $content->setVariable("PIC_URL", $pic_link); $content->setVariable("USER_NAME", $currentUser->get_full_name()); $content->parse("BLOCK_PYRAMID_POSITION_USER"); } } $content->parse("BLOCK_PYRAMID_POSITION"); } } $heights = array(); $heights[0] = 5; // gap switch ($maxuser) { case 1: $heights[1] = 106; break; case 2: $heights[1] = 126; break; case 3: $heights[1] = 146; break; case 4: $heights[1] = 166; break; default: $heights[1] = 176; break; } $heights[2] = 2 * $heights[1] - 0.5 * $heights[1] + 1 * $heights[0]; $heights[3] = 3 * $heights[1] + 2 * $heights[0]; $heights[4] = 4 * $heights[1] + 3 * $heights[0]; $heights[5] = 8 * $heights[1] + 7 * $heights[0]; $heights[6] = 16 * $heights[1] + 15 * $heights[0]; $heights[7] = 32 * $heights[1] + 31 * $heights[0]; // special case if ($maxcol == 3) { $heights[3] = 2 * $heights[1] + 1 * $heights[0]; } $css = ""; for ($count = 1; $count <= $maxcol; $count++) { $css = $css . ".phase" . $count . " { width: 120px; height: " . $heights[$count] . "px; } \n"; } // background triangle $triangle = $startElements * ($heights[0] + $heights[1]) * 0.5 + 16; $triangle_end = array(0, 300, 450, 600, 720); if ($startElements <= 16) { $css = $css . "\n\t\t\t.pyramid_triangle {\n\t \t\t\tborder-color: transparent transparent transparent #FDF1A7;\n\t \t\t\tborder-style: solid;\n\t \t\t\tborder-width: " . $triangle . "px 0px " . $triangle . "px " . $triangle_end[$maxcol - 1] . "px;\n\t \t\t\twidth:0px;\n\t \t\t\theight:0px;\n\t\t\t}"; } $content->setVariable("CSS_HEIGHTS", $css); $content->setVariable("JS_STARTPOSITIONS", $startElements); $content->setVariable("JS_GAP", $heights[0]); $content->setVariable("JS_HEIGHT", $heights[1]); $content->setVariable("JS_DEADLINES", $deadlines_used); $content->setVariable("EMPTY_DIV_HEIGHT", $startElements * ($heights[0] + $heights[1]) + 16 . "px"); $content->parse("BLOCK_PYRAMID"); $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline("Pyramidendiskussion: " . $pyramidRoom->get_name()); return $frameResponseObject; }
} $memcache_status = ob_get_clean(); ob_start(); $normalUrl = cqrequest('http://'.cfg('service/server').'/?signin'); $prettyUrl = cqrequest('http://'.cfg('service/server').'/signin'); ?><div class="banner"> <? if(substr($prettyUrl['headers']['code'], 0, 1) != '4') print('<div class="smallwin">Pretty URLs supported</div>'); else print('<div class="win">Pretty URLs not supported</div>');?> </div><? $server_status = ob_get_clean(); ob_start(); $pingServer = cfg('ping/server'); if(!strStartsWith($pingServer, 'http://')) $pingServer = 'http://'.$pingServer; if(file_exists('log/cron.last.log')) { $btype = 'smallwin'; $lastPing = filectime('log/cron.last.log'); $lastPingText = 'Last ping: '.ageToString($lastPing, 'very recently'); } else { $btype = 'fail'; $lastPingText = 'Waiting for ping from '.$pingServer.'...'; } if(cfg('ping/remote') && cfg('ping/server') != '') { $pingStatus = h2_nv_retrieve('ping/status'); if($pingStatus['server'] != $pingServer)
/** * search backwards starting from haystack length characters from the end * * @param $string * @param $search * @return bool */ function strStartsWith($string, $search) { if (empty($string) || empty($search)) { throw new InvalidArgumentException("String and Search values cannot be empty."); } if (is_array($search)) { foreach ($search as $i => $str) { if (strStartsWith($string, $str)) { return true; } } return false; } return strrpos($string, $search, -strlen($string)) !== false; }
{ if(!$parse['func'][$function]) tlog(false, $function.' in '.$parse2['files'][$decl], 'OK', 'fail'); else $okCount1++; } } tlog(true, 'Other declarations: '.$okCount1, 'OK', 'fail'); tsection('Unused Code'); ksort($parse['func']); foreach($parse['func'] as $function => $decl) if(!strStartsWith($parse2['files'][$decl], './plugins/') && !strStartsWith($parse2['files'][$decl], './log/') && !strStartsWith($parse2['files'][$decl], './static/')) { if(!inStr($parse2['files'][$decl], 'controller') && substr($function, 0, 1) != '_' && substr($function, 0, 1) != '(' && !strStartsWith($parse2['files'][$decl], './msg') && !$ignoreCallCheck[$function] && !strEndsWith($function, 'callback()') && !strStartsWith($function, 'js_') && !strStartsWith($function, 'dyn_') && $function != 'h2_exceptionhandler()') { if(!$parse['call'][$function]) tlog(false, $function.' in '.$parse2['files'][$decl], 'OK', 'fail'); else $okCount2++; } } tlog(true, 'Other calls: '.$okCount2, 'OK', 'fail'); tsection_end(); ?><!--<pre> <? print_r($parse); ?>
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $user = $GLOBALS["STEAM"]->get_current_steam_user(); $groups = $user->get_groups(); $options_group = ""; $options_course = ""; // add options for every group the current user is member in and for every course the user is staff member in foreach ($groups as $group) { if ((strStartsWith($group->get_groupname(), "PrivGroup") || strStartsWith($group->get_groupname(), "PublicGroup")) && !strStartsWith($group->get_name(), "group_")) { $options_group = $options_group . "<option value=\"" . $group->get_id() . "\">" . $group->get_name() . "</option> \n"; } else { if (strStartsWith($group->get_groupname(), "Courses") && !strStartsWith($group->get_name(), "group_") && $group->get_name() == "staff") { $group = $group->get_parent_group(); $name = $group->get_attribute("OBJ_DESC") . " (" . $group->get_name() . ")"; $options_course = $options_course . "<option value=\"" . $group->get_id() . "\">" . $name . "</option> \n"; } } } $ajaxResponseObject->setStatus("ok"); $ajaxForm = new \Widgets\AjaxForm(); $ajaxForm->setSubmitCommand("Create"); $ajaxForm->setSubmitNamespace("TCR"); $ajaxForm->setHtml(<<<END <style type="text/css"> .attribute { clear: left; padding: 5px 2px 5px 2px; } .attributeName { float: left; padding-right: 20px; text-align: right; width: 80px; } .attributeNameRequired { float: left; padding-right: 20px; text-align: right; font-weight: bold; width: 80px; } .attributeValue { float: left; width: 300px; } .attributeValue .text, .attributeValue textarea { wwidth: 100px; } .attributeValueColumn { float: left; position: relative; text-align: center; } </style> <div class="attribute"> \t<div class="attributeNameRequired">Titel*:</div> \t<div><input type="text" class="text" value="" name="title"></div> </div> <div class="attribute"> \t<div class="attributeNameRequired">Runden*:</div> \t<div><input type="text" class="text" value="" name="rounds"></div> </div> <div class="attribute"> \t<div class="attributeNameRequired">Erstellen in*:</div> \t<div> \t\t<input type="radio" value="1" name="group_course" onClick="document.getElementById('group').style.display = 'none'; document.getElementById('course').style.display = '';">Kurs \t\t<input type="radio" value="2" name="group_course" onClick="document.getElementById('group').style.display = ''; document.getElementById('course').style.display = 'none';">Gruppe \t</div> </div> <div class="attribute" id="course" style="display:none;"> \t<div class="attributeNameRequired">Kurs*:</div> \t<div> \t\t<select name="course"> \t\t{$options_course} \t\t</select> \t</div> </div> <div class="attribute" id="group" style="display:none;" title=""> \t<div class="attributeNameRequired">Gruppe*:</div> \t<div> \t\t<select name="group"> \t\t{$options_group} \t\t</select> \t</div> </div> END ); $ajaxResponseObject->addWidget($ajaxForm); return $ajaxResponseObject; }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $user = $GLOBALS["STEAM"]->get_current_steam_user(); $groups = $user->get_groups(); $options_basegroup = ""; $options_admingroup = ""; $options_course = ""; foreach ($groups as $group) { if ((strStartsWith($group->get_groupname(), "PrivGroup") || strStartsWith($group->get_groupname(), "PublicGroup")) && !strStartsWith($group->get_name(), "group_")) { if ($group->is_admin($user)) { $options_basegroup = $options_basegroup . "<option value=\"" . $group->get_id() . "\">" . $group->get_name() . "</option> \n"; } $options_admingroup = $options_admingroup . "<option value=\"" . $group->get_id() . "\">" . $group->get_name() . "</option> \n"; } else { if (strStartsWith($group->get_groupname(), "Courses") && !strStartsWith($group->get_name(), "group_") && $group->get_name() == "staff") { $group = $group->get_parent_group(); $name = $group->get_attribute("OBJ_DESC") . " (" . $group->get_name() . ")"; $options_course = $options_course . "<option value=\"" . $group->get_id() . "\">" . $name . "</option> \n"; } } } $ajaxResponseObject->setStatus("ok"); $ajaxForm = new \Widgets\AjaxForm(); $ajaxForm->setSubmitCommand("Create"); $ajaxForm->setSubmitNamespace("Pyramiddiscussion"); $ajaxForm->setHtml(<<<END <style type="text/css"> .attribute { clear: left; padding: 5px 2px 5px 2px; } .attributeName { float: left; padding-right: 20px; text-align: right; width: 80px; } .attributeNameRequired { float: left; padding-right: 20px; text-align: right; font-weight: bold; width: 80px; } .attributeValue { float: left; width: 300px; } .attributeValue .text, .attributeValue textarea { wwidth: 100px; } .attributeValueColumn { float: left; position: relative; text-align: center; } </style> <div class="attribute"> \t<div class="attributeNameRequired">Titel*:</div> \t<div><input type="text" class="text" value="" name="title"></div> </div> <div class="attribute"> \t<div class="attributeNameRequired">Anzahl der Startfelder*:</div> \t<div> \t\t<select name="startElements" size="1" style="width: 50%"> \t\t\t<option value="2">2</option> \t\t\t<option value="4">4</option> \t\t\t<option value="8">8</option> \t\t\t<option value="16">16</option> \t\t\t<option value="32">32</option> \t\t\t<option value="64">64</option> \t\t</select> \t</div> </div> <div class="attribute"> \t<div class="attributeNameRequired">Eingabeeditor*:</div> \t<div> \t\t<select name="editor" size="1" style="width: 50%"> \t\t\t<option value="text/plain">Einfacher Text</option> \t\t\t<option value="text/html">HTML Notation</option> \t\t\t<option value="text/wiki">Wiki Notation</option> \t\t</select> \t</div> </div> <div class="attribute"> \t<div class="attributeNameRequired">Erstellen in*:</div> \t<div> \t\t<input type="radio" value="1" name="group" onClick="document.getElementById('admingroup').style.display = 'none'; document.getElementById('basegroup').style.display = 'none'; document.getElementById('course').style.display = '';">Kurs \t\t<input type="radio" value="2" name="group" onClick="document.getElementById('admingroup').style.display = ''; document.getElementById('basegroup').style.display = ''; document.getElementById('course').style.display = 'none';">Gruppe \t</div> </div> <div class="attribute" id="course" style="display:none;"> \t<div class="attributeNameRequired">Kurs*:</div> \t<div> \t\t<select name="course"> \t\t\t{$options_course} \t\t</select> \t</div> </div> <div class="attribute" id="basegroup" style="display:none;" title="Es werden nur Gruppen angezeigt, in denen Sie Administrator sind."> \t<div class="attributeNameRequired">Basisgruppe*:</div> \t<div> \t\t<select name="basegroup"> \t\t\t{$options_basegroup} \t\t</select> \t</div> </div> <div class="attribute" id="admingroup" style="display:none;"> \t<div class="attributeNameRequired">Admingruppe*:</div> \t<div> \t\t<select name="admingroup"> \t\t\t{$options_admingroup} \t\t</select> \t</div> </div> END ); $ajaxResponseObject->addWidget($ajaxForm); return $ajaxResponseObject; }
function urlUnify($raw) { if (!strStartsWith($raw, 'http')) { $raw = 'http://' . $raw; } $u = parse_url($raw); $s = strtolower($u['host']) . $u['path']; if ($u['query'] != '') { $s .= '?' . $u['query']; } return $s; }