public function confirmAction($invitee) { $posSpecialChar = strpos($invitee, "<"); $substremail = substr($invitee, $posSpecialChar); $email = substr($substremail, 1); $indexPosSpecialChar = indexOf("<"); $searchCode = substr($invitee, $indexPosSpecialChar); $query = $em->createQueryBuilder()->select('e')->from('meetmeBundle\\Entity\\Event', 'e')->where('e.searchCode = ?1')->setParameter(1, $searchCode)->getQuery()->getResult(); $events = $query->getResult(); $query = $em->createQueryBuilder()->select('ip')->from('meetmeBundle\\Entity\\InvitedPerson', 'ip')->where('ip.email = ?1')->setParameter(1, $email)->getQuery(); $invitedPersons = $query->getResult(); foreach ($events as $event) { $invitedEvent = $InvitedEvent(); foreach ($invitedPersons as $invitedPerson) { $em = $this->getDoctrine()->getManager(); $qb = $em->createQueryBuilder(); $q = $qb->update('meetmeBundle\\Entity\\InvitedEvent', 'ie')->set('ie.acceptedInvitDate', '?1')->where('ie.idinvited = ?2')->andWhere('ie.idevent = ?3')->setParameter(1, new \DateTime("now"))->setParameter(2, $invitedPerson->getId())->setParameter(2, $event->getId())->getQuery(); $p = $q->execute(); } //$em->persist($invitedEvent); //$em->flush(); } /* $em = $this->getDoctrine()->getManager(); $qb = $em->createQueryBuilder(); $q = $qb->update('meetmeBundle\Entity\InvitedPerson', 'p') ->set('p.acceptedInvitationDate', '?1') ->where('p.email = ?2') ->setParameter(1, new \DateTime("now")) ->setParameter(2, $substremail) ->getQuery(); $p = $q->execute(); */ return $this->render('meetmeBundle:twig_html:login.html.twig'); }
function index2Of($str1, $str2) { if (indexOf($str1, $str2) || indexOf($str2, $str1)) { return true; } else { return false; } }
public static function ForceResponse($method, $url, $requestData) { UrlUtils::$_method = strtolower($method); UrlUtils::$_requestData = json_encode($requestData); UrlUtils::$_mainUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot); UrlUtils::$_query = array(); $queryIndex = indexOf($url, "?"); if ($queryIndex > 0) { $query = substr($url, $queryIndex + 1); UrlUtils::$_query = parse_str($query); } UrlUtils::$_fake = true; }
function LCAudioFileStatus($currentRecord, $authToken) { $this->setStatus($this->getKeyValue($currentRecord, ATTRIB_AUDIO_FILE_STATUS)); if ($this->getStatus() == VALUE_STATUS_EXISTS) { $audioUrl = $this->getKeyValue($currentRecord, ATTRIB_AUDIO_FILE_DOWNLOAD_URI); if ($authToken != null && strlen($authToken) > 0 && indexOf(strtolower($audioUrl), "hza=") == -1) { if (indexOf($audioUrl, "?") == -1) { $audioUrl .= "?"; } else { if (!endsWith($audioUrl, "&")) { $audioUrl .= "&"; } } $audioUrl .= "hzA=" . urlencode(utf8_encode($authToken)); } $this->setUri($audioUrl); } }
/** * Verifies that the specified path is within valid root paths. * * @param String $path Path to verify. * @return Bool true if the path is valid, false if it's invalid. */ function verifyPath($path) { $fs = "file"; $valid = false; // Parse out FS if (preg_match('/([a-z]+):\\/\\/(.+)/', $path, $matches)) { $fs = $matches[1]; $path = $matches[2]; } // Filesystem wasn't found if (!isset($this->_fileSystems[$fs])) { trigger_error($this->getLangItem("error", "no_filesystem", array("path" => $path)), FATAL); die; } $path = $this->decryptPath($path); // /../ is never valid if (indexOf($this->addTrailingSlash($path), "/../") != -1) { return false; } if ($fs != 'file') { return true; } foreach ($this->_rootPaths as $rootPath) { if ($this->isChildPath($rootPath, $path)) { $valid = true; } } return $valid; }
public static function IsPreRelease($version) { $version = strtolower($version); $tmp = indexOf($version, "-"); return $tmp > 0; }
/** * Replaces the variables in the expression with the values of the variables * for this instance of the evaluator. * @param $expression * The expression being processed. * * @return mixed A new expression with the variables replaced with their values. * * @throws EvaluationException * Thrown is an error is encountered while processing the * expression. */ public function replaceVariables($expression) { $openIndex = $expression->indexOf(EvaluationConstants::OPEN_VARIABLE); if ($openIndex < 0) { return $expression; } $replacedExpression = $expression; while ($openIndex >= 0) { $closedIndex = -1; if ($openIndex >= 0) { $closedIndex = $replacedExpression->indexOf(EvaluationConstants::CLOSED_VARIABLE, $openIndex + 1); if ($closedIndex > $openIndex) { $variableName = $replacedExpression->substring($openIndex + strlen(EvaluationConstants::OPEN_VARIABLE), $closedIndex); // Validate that the variable name is valid. try { $this->isValidName($variableName); } catch (InvalidArgumentException $iae) { throw new EvaluationException("Invalid variable name of '" . $variableName + "'.", $iae); } $variableValue = $this->getVariableValue($variableName); $variableString = EvaluationConstants::OPEN_VARIABLE . $variableName . EvaluationConstants::CLOSED_VARIABLE; $replacedExpression = EvaluationHelper::replaceAll($replacedExpression, $variableString, $variableValue); } else { break; } } // Start looking at the beginning of the string, since // the length string has changed and characters have moved // positions. $openIndex = $replacedExpression . indexOf(EvaluationConstants::OPEN_VARIABLE); } // If an open brace is left over, then a variable could not be replaced. $openBraceIndex = $replacedExpression->indexOf(EvaluationConstants::OPEN_VARIABLE); if ($openBraceIndex > -1) { throw new EvaluationException("A variable has not been closed (index=" . $openBraceIndex . ")."); } return $replacedExpression; }
function defaultInfo($ip, $tPort, $port) { $out = ""; $html = ""; $fp = fsockopen($ip, $tPort, $errno, $errstr, 30); if ($fp) { fputs($fp, "sel " . $port . "\n"); fputs($fp, "si\n"); fputs($fp, "quit\n"); while (!feof($fp)) { $out .= fgets($fp, 1024); } $out = str_replace("[TS]", "", $out); $out = str_replace("OK", "", $out); $out = trim($out); $name = substr($out, indexOf($out, "server_name="), strlen($out)); $name = substr($name, 0, indexOf($name, "server_platform=") - strlen("server_platform=")); $os = substr($out, indexOf($out, "server_platform="), strlen($out)); $os = substr($os, 0, indexOf($os, "server_welcomemessage=") - strlen("server_welcomemessage=")); $tsType = substr($out, indexOf($out, "server_clan_server="), strlen($out)); $tsType = substr($tsType, 0, indexOf($tsType, "server_udpport=") - strlen("server_udpport=")); $welcomeMsg = substr($out, indexOf($out, "server_welcomemessage="), strlen($out)); $welcomeMsg = substr($welcomeMsg, 0, indexOf($welcomeMsg, "server_webpost_linkurl=") - strlen("server_webpost_linkurl=")); if ($tsType[0] == 1) { $tsTypeText = "Freeware Clan Server"; } else { $tsTypeText = "Freeware Public Server"; } $html = "<tr><td class=\"boldbread\">Server:</td></tr>\n"; $html .= "<tr><td class=\"bread\">" . $name . "<br><br></td></tr>\n"; $html .= "<tr><td class=\"boldbread\">Server IP:</td></tr>\n"; $html .= "<tr><td class=\"bread\">" . $ip . ":" . $port . "<br><br></td></tr>\n"; $html .= "<tr><td class=\"boldbread\">Version:</td></tr>\n"; $html .= "<tr><td class=\"bread\">" . @getTSVersion($ip, $tPort, $port) . "<br><br></td></tr>\n"; $html .= "<tr><td class=\"boldbread\">Type:</td></tr>\n"; $html .= "<tr><td class=\"bread\">" . $tsTypeText . "<br><br></td></tr>\n"; $html .= "<tr><td class=\"boldbread\">Welcome Message:</td></tr>\n"; $html .= "<tr><td class=\"bread\">" . $welcomeMsg . "<br><br></td></tr>"; fclose($fp); } return $html; }
} $out = str_replace('[TS]', '', $out); $out = str_replace('OK', '', $out); $out = trim($out); $name = substr($out, indexOf($out, 'server_name='), strlen($out)); $name = substr($name, 0, indexOf($name, 'server_platform=') - strlen('server_platform=')); $os = substr($out, indexOf($out, 'server_platform='), strlen($out)); $os = substr($os, 0, indexOf($os, 'server_welcomemessage=') - strlen('server_welcomemessage=')); $uptime = substr($out, indexOf($out, 'server_uptime='), strlen($out)); $uptime = substr($uptime, 0, indexOf($uptime, 'server_currrentusers=') - strlen('server_currrentusers=')); $cAmount = substr($out, indexOf($out, 'server_currentchannels='), strlen($out)); $cAmount = substr($cAmount, 0, indexOf($cAmount, 'server_bwinlastsec=') - strlen('server_bwinlastsec=')); $user = substr($out, indexOf($out, 'server_currentusers='), strlen($out)); $user = substr($user, 0, indexOf($user, 'server_currentchannels=') - strlen('server_currentchannels=')); $max = substr($out, indexOf($out, 'server_maxusers='), strlen($out)); $max = substr($max, 0, indexOf($max, 'server_allow_codec_celp51=') - strlen('server_allow_codec_celp51=')); fclose($fp); } $uArray = array(); $innerArray = array(); $out = ""; $j = 0; $k = 0; $fp = fsockopen($uip, $tPort, $errno, $errstr, 30); if ($fp) { fputs($fp, "pl " . $port . "\n"); fputs($fp, "quit\n"); while (!feof($fp)) { $out .= fgets($fp, 1024); } $out = str_replace('[TS]', '', $out);
function defaultInfo($ip, $tPort, $port) { $out = ''; $html = ''; $fp = fsockopen($ip, $tPort, $errno, $errstr, 30); if ($fp) { fputs($fp, "sel " . $port . "\n"); fputs($fp, "si\n"); fputs($fp, "quit\n"); while (!feof($fp)) { $out .= fgets($fp, 1024); } $out = str_replace('[TS]', '', $out); $out = str_replace('OK', '', $out); $out = trim($out); $name = substr($out, indexOf($out, "server_name="), strlen($out)); $name = convertCharset(substr($name, 0, indexOf($name, "server_platform=") - strlen("server_platform="))); $os = substr($out, indexOf($out, "server_platform="), strlen($out)); $os = convertCharset(substr($os, 0, indexOf($os, "server_welcomemessage=") - strlen("server_welcomemessage="))); $tsType = substr($out, indexOf($out, "server_clan_server="), strlen($out)); $tsType = substr($tsType, 0, indexOf($tsType, "server_udpport=") - strlen("server_udpport=")); $welcomeMsg = substr($out, indexOf($out, "server_welcomemessage="), strlen($out)); $welcomeMsg = convertCharset(substr($welcomeMsg, 0, indexOf($welcomeMsg, "server_webpost_linkurl=") - strlen("server_webpost_linkurl="))); if ($tsType[0] == 1) { $tsTypeText = "Freeware Clan Server"; } else { $tsTypeText = "Freeware Public Server"; } $html = "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\" class=\"fHeading\">Server:</td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\">{$name}<br /><br /></td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\" class=\"fHeading\">Server IP:</td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\">{$ip}:{$port}<br /><br /></td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\" class=\"fHeading\">Version:</td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\">" . getTSVersion($ip, $tPort, $port) . "<br /><br /></td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\" class=\"fHeading\">Type:</td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\">{$tsTypeText}<br /><br /></td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\" class=\"fHeading\">Welcome Message:</td></tr>\n"; $html .= "<tr class=\"bg1\"><td id=\"contentMainFirst\" style=\"border:0\">{$welcomeMsg}<br /><br /></td></tr>"; fclose($fp); } return $html; }
} $out = str_replace("[TS]", "", $out); $out = str_replace("OK", "", $out); $out = trim($out); $name = substr($out, indexOf($out, "server_name="), strlen($out)); $name = substr($name, 0, indexOf($name, "server_platform=") - strlen("server_platform=")); $os = substr($out, indexOf($out, "server_platform="), strlen($out)); $os = substr($os, 0, indexOf($os, "server_welcomemessage=") - strlen("server_welcomemessage=")); $uptime = substr($out, indexOf($out, "server_uptime="), strlen($out)); $uptime = substr($uptime, 0, indexOf($uptime, "server_currrentusers=") - strlen("server_currrentusers=")); $cAmount = substr($out, indexOf($out, "server_currentchannels="), strlen($out)); $cAmount = substr($cAmount, 0, indexOf($cAmount, "server_bwinlastsec=") - strlen("server_bwinlastsec=")); $user = substr($out, indexOf($out, "server_currentusers="), strlen($out)); $user = substr($user, 0, indexOf($user, "server_currentchannels=") - strlen("server_currentchannels=")); $max = substr($out, indexOf($out, "server_maxusers="), strlen($out)); $max = substr($max, 0, indexOf($max, "server_allow_codec_celp51=") - strlen("server_allow_codec_celp51=")); fclose($fp); } $uArray = array(); $innerArray = array(); $out = ""; $j = 0; $k = 0; $fp = fsockopen($uip, $tPort, $errno, $errstr, 30); if ($fp) { fputs($fp, "pl " . $port . "\n"); fputs($fp, "quit\n"); while (!feof($fp)) { $out .= fgets($fp, 1024); } $out = str_replace("[TS]", "", $out);
public function BuildSubBatch($src) { global $v2BatchDebug; $res = new SubBatch(); $i = 0; $res->Action = null; $res->ContentId = null; for (; $i < sizeof($src); $i++) { $li = $src[$i]; if (starts_with($li, "Content-ID")) { $res->ContentId = substr($li, strlen("Content-ID:") + 1); } else { if (starts_with($li, "POST")) { $res->Action = substr($li, strlen("POST") + 1); $res->Method = "post"; } else { if (starts_with($li, "GET")) { $res->Action = substr($li, strlen("GET") + 1); $res->Method = "get"; break; } else { if (starts_with($li, "PUT")) { $res->Action = substr($li, strlen("PUT") + 1); $res->Method = "put"; } else { if (starts_with($li, "DELETE")) { $res->Action = substr($li, strlen("DELETE") + 1); $res->Method = "delete"; } else { if (starts_with($li, "Content-Length")) { $res->ContentLength = substr($li, strlen("Content-Length:") + 1); $i += 2; break; } } } } } } } if ($res->Action != null) { $http = indexOf($res->Action, " HTTP"); if ($http > 0) { $res->Action = substr($res->Action, 0, $http); } if (indexOf($res->Action, "http") != 0) { $res->Action = UrlUtils::CurrentUrl($res->Action); } } //Add the space after the method $res->Data = ""; while ($i < sizeof($src) && $res->Method != "get") { if ($res->Data != "") { $res->Data .= "\n" . $src[$i]; } else { $res->Data .= $src[$i]; } $i++; } return $res; }
******************************************************************************/ /* $Id: view.php 76014 2009-08-25 20:30:43Z trollinger $ */ error_reporting(E_ERROR); require_once '../../config.php'; require_once 'lib.php'; //Wimba Library require_once "lib/php/common/WimbaLib.php"; require_once "lib/php/common/DatabaseManagement.php"; require_once 'lib/php/vt/WimbaVoicetools.php'; require_once 'lib/php/vt/WimbaVoicetoolsAPI.php'; require_once 'lib/php/common/WimbaCommons.php'; require_once 'lib/php/vt/VtAction.php'; $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or $action = optional_param('action', PARAM_ACTION); if (indexOf($_SERVER['HTTP_REFERER'], "/grader/") != -1) { //we come from the gradebook if (!($cm = get_record("course_modules", "id", $id))) { error("Course Module ID was incorrect"); } if (!($course = get_record("course", "id", $cm->course))) { error("Course is misconfigured"); } if (!($voicetool = get_record("voicepodcaster", "id", $cm->instance))) { error("Course module is incorrect"); } redirection("index.php?id=" . $voicetool->course . "&action=displayGrade&gradeId=" . $voicetool->id . "&resource_id=" . $voicetool->rid); exit; } else { if (isset($action) && $action != "launchCalendar" && $id || !isset($action)) { if (!($cm = get_record("course_modules", "id", $id))) {
echo '<td class="header" id="pubPlace"> Place Published </td>'; echo '</tr>'; $highlight = false; $sentence_ids = array(); $counter = 0; while ($row = mysql_fetch_array($result)) { $counter += 1; if ($counter <= (1 + $page) * $pageLength && $counter > $pageLength * $page) { echo '<tr class="search-result">'; echo '<td class="hidden-id">'; echo '<a href="view.php?id=' . $row['id'] . '_' . $row['sent_id'] . '"><img class="view" src="img/view.png" value="' . $row['id'] . '_' . $row['sent_id'] . '">'; echo '</a></td>'; if ($fulltext) { echo '<td>'; foreach (explode(' ', $row['sentence']) as $word) { $highlight = indexOf(strtolower($word), $toHighlight); if ($highlight >= 0) { echo '<span class="highlight' . $highlight % 10 . '">' . $word . ' </span>'; } else { echo $word . ' '; } } echo '</td>'; echo '<td>' . $row['type'] . '</td>'; } echo '<td>' . $row['title'] . '</td>'; echo '<td>' . $row['full'] . '</td>'; echo '<td>' . $row['date'] . '</td>'; echo '<td>' . $row['publisher'] . '</td>'; echo '<td>' . $row['pubPlace'] . '</td>'; echo '</tr>';
function guiComboBox($name, $options, $values, $ix_selected = 0) { echo '<select name="' . $name . '" size="1' . "\">\n"; if ($ix_selected == null) { $ix_selected = !isset($_POST[$name]) ? -1 : indexOf($options, $_POST[$name]); } foreach ($options as $ix => $text) { echo '<option' . ($ix == $ix_selected ? ' selected' : '') . ($values ? ' value="' . $values[$ix] . '"' : '') . '>' . htmlentities($text) . "\n"; } echo "</select>\n"; }
function loadart($row, $typearr) { global $cache, $mac; //if (!is_array($this->page_typearr)){ $this->page_typearr = getValueByArray($cache[1], "t_id", $mac["arttypeid"]); } $this->page_typearr = $typearr; $mac["arttypepid"] = $this->page_typearr["t_pid"]; $cacheName = "art_" . $mac["arttypeid"]; $cachetemplatename = "template_art"; $templatepath = root . "template/" . app_templatedir . "/" . app_htmldir . "/" . $this->page_typearr["t_arttemplate"]; if (chkCache($cacheName)) { $this->html = getCache($cacheName); } else { $this->html = getFileByCache($cachetemplatename, $templatepath); setCache($cacheName, $this->html, 0); } $this->html = replaceStr($this->html, "[artinfo:page]", $mac["page"]); $this->page_type = "art"; $contentarr = explode("[artinfo:page]", $row["a_content"]); if ($mac["page"] <= count($contentarr)) { $this->page_content = $contentarr[$mac["page"] - 1]; } $this->page = $mac["page"]; $this->page_id = $row["a_id"]; $this->page_name = $row["a_title"]; $this->page_enname = $row["a_entitle"]; $this->page_size = 1; $this->data_count = count($contentarr); $this->page_count = count($contentarr); $this->pageshow(); unset($contentarr); $slink = $this->getArtLink($row["a_id"], $row["a_title"], $row["a_entitle"], $this->page_typearr["t_id"], $this->page_typearr["t_name"], $this->page_typearr["t_enname"], true); $this->html = replaceStr($this->html, "[artinfo:hits]", "<span id=\"hit\">加载中</span><script>getHit('art','" . $row["a_id"] . "')</script>"); $this->html = replaceStr($this->html, "[artinfo:fav]", "<a href=\"javascript:void(0)\" onclick=\"sitefav('http://" . app_siteurl . $slink . "','" . $row["a_title"] . "');return false;\"/>我要收藏</a>"); $this->html = replaceStr($this->html, "[artinfo:share]", "<a href=\"javascript:void(0)\" onclick=\"copyData(document.title +' ' + window.location.href);return false;\"/>我要分享</a>"); if (indexOf($this->html, "[artinfo:textlink]")) { $typeLink = $this->getArtTypeLink($this->page_typearr["t_id"], $this->page_typearr["t_name"], $this->page_typearr["t_enname"], true); $this->html = replaceStr($this->html, "[artinfo:textlink]", $this->getTypeText($mac["arttypeid"], $this->page_typearr["t_pid"], $this->page_typearr["t_name"], $typeLink, "art") . " » <a href='" . $slink . "'>" . $row["a_title"] . "</a>"); } if (indexOf($this->html, "[artinfo:prelink]")) { $this->html = replaceStr($this->html, "[artinfo:prelink]", $this->getArtPreNextLink($row["a_id"], 0)); } if (indexOf($this->html, "[artinfo:nextlink]")) { $this->html = replaceStr($this->html, "[artinfo:nextlink]", $this->getArtPreNextLink($row["a_id"], 1)); } $this->replaceComment(2, $row["a_id"]); $this->replaceMood(2, $row["a_id"]); $labelRule = buildregx("\\[artinfo:\\s*([0-9a-zA-Z]+)([\\s]*[len|style]*)[=]??([\\da-zA-Z\\-\\\\/\\:\\s]*)\\]", ""); preg_match_all($labelRule, $this->html, $matches2); for ($j = 0; $j < count($matches2[0]); $j++) { $marktemp = $this->parse("art", $matches2[0][$j], $matches2[0][$j], $matches2[1][$j], $matches2[3][$j], $row, 0); $this->html = replaceStr($this->html, $matches2[0][$j], $marktemp); } unset($matches2); $this->mark(); $this->ifEx(); $this->run(); }
function outComboBox(&$session, $name, $options, $values = null, $ix_selected = 0) { echo TAG_SELECT_NAME; echo $name; echo TAGA_APO_SIZE_END; if ($ix_selected == null) { $ix_selected = !isset($_POST[$name]) ? -1 : indexOf($options, $_POST[$name]); } foreach ($options as $ix => $text) { echo TAG_OPTION; if ($ix == $ix_selected) { echo TAGAV_SELECTED; } if ($values) { echo TAGA_VALUE; echo $values[$ix]; echo TAG_APO; } echo TAG_SUFFIX; echo htmlentities($text); echo "\n"; } echo TAG_SELECT_END; }
/** * Checks if an array contains an item. * ```php * contains('foo', ['foo', 'bar', 'baz']) // true * contains('hi', ['foo', 'bar', 'baz']) // false * contains('hi', 'Hello World') // false * contains('He', 'Hello World') // true * ``` * * @signature a -> [a] -> Boolean * @signature String -> String -> Boolean * @param mixed $item * @param array|string $list * @return bool */ function contains() { $contains = function ($item, $list) { return -1 != indexOf($item, $list); }; return apply(curry($contains), func_get_args()); }
/** * 移动节点 * @param array $haystack * @param string $needle * @param string $field * @param strint $flag * @return int * @static */ function nodeMove(&$haystack, $needle, $field = '', $flag = 'up') { $index = indexOf($haystack, $needle, $field); $result = $index; if ($index >= 0) { switch ($flag) { case 'up': if ($index > 0) { $tmp = $haystack[$index - 1]; $haystack[$index - 1] = $haystack[$index]; $haystack[$index] = $tmp; } else { $result = -2; } break; case 'down': if ($index < sizeof($haystack) - 1) { $tmp = $haystack[$index + 1]; $haystack[$index + 1] = $haystack[$index]; $haystack[$index] = $tmp; } else { $result = -2; } break; default: break; } } return $result; }
public function SaveNuspec($nupkgFile, $e) { global $loginController; $nugetDb = new NuGetDb(); $os = new PhpNugetObjectSearch(); $query = "Id eq '" . $e->Id . "' orderby Version desc"; $os->Parse($query, $nugetDb->GetAllColumns()); $res = $nugetDb->GetAllRows(999999, 0, $os); if (sizeof($res) > 0 && !$loginController->Admin) { $id = $res[0]->UserId; if ($id != $e->UserId) { throw new Exception("Unauthorized!"); } } else { if (sizeof($res) > 0 && $loginController->Admin) { $e->UserId = $res[0]->UserId; } } $e->IsPreRelease = indexOf($e->Version, "-") > 0; if ($nugetDb->AddRow($e, false)) { $destination = Path::Combine(Settings::$PackagesRoot, $e->Id . "." . $e->Version . ".nupkg"); if (strtolower($nupkgFile) != strtolower($destination)) { if (file_exists($destination)) { unlink($destination); } rename($nupkgFile, $destination); } } else { if (strtlower($nupkgFile) != strtlower($destination)) { if (file_exists($nupkgFile)) { unlink($nupkgFile); } } } }