function ValidateLinkedin($value, $returnInt = false) { if (str_is_int($value)) { return $returnInt ? $value : true; } if (trim($value) == "") { return true; } $matches = array(); preg_match("/^.*?linkedin\\.com.*?[?&]+key\\=(\\d+).*?\$/i", $value, $matches); if (str_is_int($matches[1])) { return $returnInt ? $matches[1] : true; } preg_match("/^.*?linkedin\\.com.*?[?&]+id\\=(\\d+).*?\$/i", $value, $matches); if (str_is_int($matches[1])) { return $returnInt ? $matches[1] : true; } return false; }
function db_connect() { debug_msg("FUNCTION: " . __FUNCTION__, 3); if (!defined('__GOT_MYSQL__')) { /* connect to mySQL database */ $cfunction = S9YCONF_DB_PERSISTENT ? 'mysql_pconnect' : 'mysql_connect'; if (!function_exists($cfunction)) { die('MySQL support is not available in this PHP configuration!'); } function str_is_int($str) { $var = intval($str); return "{$str}" == "{$var}"; } $mysql_port = str_is_int(S9YCONF_DB_PORT) ? ':' . S9YCONF_DB_PORT : ''; $connected = @$cfunction(S9YCONF_DB_HOST . $mysql_port, S9YCONF_DB_USER, S9YCONF_DB_PWD) or die("unable to connect to database on '" . S9YCONF_DB_HOST . "' with user '" . S9YCONF_DB_USER . "'<br />" . '(' . mysql_errno() . ') ' . mysql_error() . '<br />' . "Please check your settings in dbconfig.php !<br />"); mysql_select_db(S9YCONF_DB_NAME) or die("Please first create your database '" . S9YCONF_DB_NAME . "' and make sure your user has got the correct access rights on it !"); define('S9YCONF_MYSQL_CONNECTION', $connected); define('__GOT_MYSQL__', 1); } debug_msg("S9YCONF_MYSQL_CONNECTION: " . S9YCONF_MYSQL_CONNECTION, 5); debug_msg("__GOT_MYSQL__: " . __GOT_MYSQL__, 5); }
function db_connect($error_expected = FALSE) { debug_msg("FUNCTION: " . __FUNCTION__, 3); debug_msg("ERROR EXPECTED: '" . $error_expected . "'", 5); if (!$error_expected) { if (!defined('__GOT_MYSQL__')) { /* connect to mySQL database */ $cfunction = S9YCONF_DB_PERSISTENT ? 'mysql_pconnect' : 'mysql_connect'; if (!function_exists($cfunction)) { die('MySQL support is not available in this PHP configuration!'); } function str_is_int($str) { $var = intval($str); return "{$str}" == "{$var}"; } $mysql_port = str_is_int(S9YCONF_DB_PORT) ? ':' . S9YCONF_DB_PORT : ''; $connected = @$cfunction(S9YCONF_DB_HOST . $mysql_port, S9YCONF_DB_USER, S9YCONF_DB_PWD) or die("unable to connect to database on '" . S9YCONF_DB_HOST . "' with user '" . S9YCONF_DB_USER . "'<br />" . '(' . mysql_errno() . ') ' . mysql_error() . '<br />' . "Please check your settings in dbconfig.php !<br />"); mysql_select_db(S9YCONF_DB_NAME) or die("Please first create your database '" . S9YCONF_DB_NAME . "' and make sure your user has got the correct access rights on it !"); define('S9YCONF_MYSQL_CONNECTION', $connected); define('__GOT_MYSQL__', 1); } debug_msg("S9YCONF_MYSQL_CONNECTION: " . S9YCONF_MYSQL_CONNECTION, 5); debug_msg("__GOT_MYSQL__: " . __GOT_MYSQL__, 5); } else { if (!defined('__GOT_MYSQL__')) { /* connect to mySQL database */ debug_msg("DB PERSISTENT: '" . S9YCONF_DB_PERSISTENT . "'", 5); $cfunction = S9YCONF_DB_PERSISTENT ? 'mysql_pconnect' : 'mysql_connect'; debug_msg("CFUNCTION: '" . $cfunction . "'", 5); if (!function_exists($cfunction)) { die('MySQL support is not available in this PHP configuration!'); } function str_is_int($str) { $var = intval($str); return "{$str}" == "{$var}"; } debug_msg("DB PORT: '" . S9YCONF_DB_PORT . "'", 5); $mysql_port = str_is_int(S9YCONF_DB_PORT) ? ':' . S9YCONF_DB_PORT : ''; debug_msg("MYSQL PORT: '" . $mysql_port . "'", 5); debug_msg("DB HOST: '" . S9YCONF_DB_HOST . "'", 5); debug_msg("DB USER: '******'", 5); debug_msg("DB PWD: '" . S9YCONF_DB_PWD . "'", 5); $connected = @$cfunction(S9YCONF_DB_HOST . $mysql_port, S9YCONF_DB_USER, S9YCONF_DB_PWD); debug_msg("CONNECTED: '" . $connected . "'", 5); if (!is_resource($connected)) { return false; } debug_msg("DB NAME: '" . S9YCONF_DB_NAME . "'", 5); $dbconnect = mysql_select_db(S9YCONF_DB_NAME); debug_msg("DBCONNECT: '" . $dbconnect . "'", 5); if (!$dbconnect) { return false; } define('S9YCONF_MYSQL_CONNECTION', $connected); define('__GOT_MYSQL__', 1); } debug_msg("S9YCONF_MYSQL_CONNECTION: " . S9YCONF_MYSQL_CONNECTION, 5); debug_msg("__GOT_MYSQL__: " . __GOT_MYSQL__, 5); return true; // Return true as we have connected } }
function isIntegerValue($arr) { for ($i = 0; $i < count($arr); $i++) { if (trim($arr[$i]) != "" && !str_is_int($arr[$i])) { break; } } if ($i == count($arr)) { return 1; } else { return 0; } }
} if ($ui['nickname']) { $datas['display_name'] = $ui['nickname']; } // if( $ui['nickname'] ) $datas['user_login'] = $ui['nickname']; $status = wp_update_user($datas); if (!$status || is_wp_error($status)) { print_r(json_encode(array('error' => 1, 'msg' => '修改失败,请稍后再试'))); exit; } print_r(json_encode(array('error' => 0))); exit; break; case 'comments': $count = u_comment_count(); if (str_is_int($ui['paged']) && $count && $ui['paged'] <= ceil($count / 10)) { $printr['items'] = u_comment_data($ui['paged']); $printr['max'] = $count; } break; default: # code... break; } print_r(json_encode($printr)); exit; function u_get_thumbnail_src() { global $post; $content = _get_post_thumbnail(); preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
function get_view_layout($member, $userInfo) { $result = sprintf('<div class="divContainer" onmouseout="HideInfo(%d)"><div class="divInfo" ID="divInfo%d" onmouseover="ShowInfo(%d)">', $member['account_id'], $member['account_id'], $member['account_id']); $serverURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http") . '://' . $_SERVER['SERVER_NAME']; //link to profile. $user_location = $serverURL . '/members/' . $member['account_lid']; $user_location = sprintf('<a href="%s" title="%s" target=_blank><img src="/egroupware/fudforum/3814588639/theme/default/images/msg_about.gif"></a>', $user_location, lang("elg_view_profile") . ": " . $member['account_lid']); $account_linkedin = str_is_int($member[account_linkedin]) ? setInteger($member[account_linkedin]) : 1; if ($account_linkedin < 1000) { $account_linkedin = '<a href="javascript:WarningMessage(\'' . lang("WarningEmtpyLinkedInProfile") . '\');void(0);" title="' . lang("WarningEmtpyLinkedInProfile") . '"><img src="/egroupware/elgg-link/templates/default/images/linkedin_logo_invalid.gif"></a>'; } else { $linkedIn_user_location = 'https://www.linkedin.com/profile?viewProfile=&key=' . $member[account_linkedin]; $account_linkedin = sprintf('<a href="%s" target="top" title="%s"><img src="/egroupware/elgg-link/templates/default/images/linkedin_logo.gif"></a>', $linkedIn_user_location, lang("elg_view_linkedIn_profile") . ": " . $member['account_lid']); } $pmuser_location = $serverURL . '/egroupware/index.php?menuaction=messenger.uimessenger.compose&message_to=' . $member['account_lid'] . '&'; $pmuserStr = sprintf('<a href="%s" title="%s" target=_blank><img src="/egroupware/fudforum/3814588639/theme/default/images/msg_pm.gif"></a>', $pmuser_location, lang("elg_send_private_message_to") . ": " . $member['account_lid']); $result .= sprintf('<table border="0" width="100%%" cellspacing="3" cellpadding="0" onmouseout="HideInfo(%d)"> <tr> <td>%s</td> <td>%s</td> </tr> <tr> <td>%s</td> <td>%s</td> </tr> <tr> <td>%s</td> <td>%s</td> </tr> </table>', $member['account_id'], lang("Profile URL"), $user_location, lang("linkedin URL"), $account_linkedin, lang("Instant MSG"), $pmuserStr); $result .= '</div></div>'; return $result; }
function guppy_validateField($fieldDataRaw, $fieldTitle, $fieldType, &$commander) { if ($fieldType == 'int') { if (!str_is_int($fieldDataRaw)) { $commander->errorMessage(_GUPPYINVALIDINT . ': ' . guppy_Translate($fieldTitle)); } } else { if ($fieldType == 'real') { if (!is_numeric($fieldDataRaw)) { $commander->errorMessage(_GUPPYINVALIDREAL . ': ' . guppy_Translate($fieldTitle)); } } else { if ($fieldType == 'date') { list($year, $month, $day) = split('-', $fieldDataRaw); if (!checkdate($month, $day, $year)) { $commander->errorMessage(_GUPPYINVALIDDATE . ': ' . guppy_Translate($fieldTitle)); } } else { if ($fieldType == 'time') { list($hour, $min, $sec) = split(':', $fieldDataRaw); if ($hour < 0 || $hour > 23 || $min < 0 || $min > 59 || $sec < 0 || $sec > 59) { $commander->errorMessage(_GUPPYINVALIDTIME . ': ' . guppy_Translate($fieldTitle)); } } } } } }
} if (str_is_int($from) == 1) { $sequence = substr($sequence, $from); } } // if sequence does not exists, display error if ($sequence == "") { die("Error: no sequence selected for computing"); } // if sequence is to sort to work with, display error if (strlen($sequence) < $window + 1400) { die("Error: sequence is very small for the selected window size."); } // when oligo-skew is requested, computing time will be long; let know the user and compute data for oligo-skew if ($_POST["oskew"] == 1) { if (str_is_int($_POST["oligo_len"]) == 1) { print "Computing...(will be aborted after 15 minutes; oligo-skews require intense computing). Please wait. "; flush(); // in next line a funstion will compute an array with distances $oligo_skew_array = Oligo_skew_array_calculation($sequence, $window, $_POST["oligo_len"], $_POST["strands"]); } } // create image with skews $data_table = Create_image($sequence, $window, $GC, $AT, $KETO, $GmC, $oligo_skew_array, $_POST["oligo_len"], $from, $to, $name); // in next lines, the image is shown ?> <h1>Skew from custom sequences</h1> <p> <img src="image.png?<?php print date("U"); ?>
function get_int($var) { if (str_is_int($var)) { return intval($var); } return null; }
function freshports_CategoryDisplay($db, $category, $PageNo = 1, $PageSize = DEFAULT_PAGE_SIZE) { global $TableWidth; global $User; header('HTTP/1.1 200 OK'); $Debug = 0; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { if (isset($_SERVER["REDIRECT_QUERY_STRING"])) { parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts); if (isset($query_parts['page'])) { $PageNo = $query_parts['page']; } if (isset($query_parts['page_size'])) { $PageSize = $query_parts['page_size']; } } } if (!isset($page) || $page == '') { $page = 1; } if (!isset($page_size) || $page_size == '') { $page_size = $User->page_size; } if ($Debug) { echo "\$page = '{$page}'<br>\n"; echo "\$page_size = '{$page_size}'<br>\n"; } SetType($PageNo, "integer"); SetType($PageSize, "integer"); if (!isset($PageNo) || !str_is_int("{$PageNo}") || $PageNo < 1) { $PageNo = 1; } if (!isset($PageSize) || !str_is_int("{$PageSize}") || $PageSize < 1 || $PageSize > MAX_PAGE_SIZE) { $PageSize = DEFAULT_PAGE_SIZE; } if ($Debug) { echo "\$PageNo = '{$PageNo}'<br>\n"; echo "\$PageSize = '{$PageSize}'<br>\n"; } require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/watch_lists.php'; if ($category->IsPrimary()) { $WatchLists = new WatchLists($db); $WatchListCount = $WatchLists->IsOnWatchList($User->id, $category->element_id); } $title = $category->{'name'}; # find out how many ports are in this category $PortCount = $category->PortCount($category->name); global $User; if ($Debug) { echo "\$User->id='{$User->id}'"; } freshports_Start($title, 'freshports - new ports, applications', 'FreeBSD, index, applications, ports'); $port = new Port($db); $numrows = $port->FetchByCategoryInitialise($category->name, $User->id, $PageSize, $PageNo); ?> <?php echo freshports_MainTable(); ?> <tr><td valign="top" width="100%"> <?php echo freshports_MainContentTable(); ?> <tr> <?php echo freshports_PageBannerText('Category listing - ' . $category->{'name'}); ?> </tr> <tr><td> <?php if ($category->IsPrimary()) { if ($WatchListCount) { echo freshports_Watch_Link_Remove('', 0, $category->{'element_id'}); } else { echo freshports_Watch_Link_Add('', 0, $category->{'element_id'}); } } ?> <BIG><BIG><B><?php echo $category->{'description'}; ?> </B></BIG></BIG>- Number of ports in this category: <?php echo $PortCount; ?> <p> Ports marked with a <sup>*</sup> actually reside within another category but have <b><?php echo $category->{'name'}; ?> </b> listed as a secondary category. <?php global $ShowAds, $BannerAd; if ($ShowAds && $BannerAd) { echo "<br><center>\n" . Ad_728x90() . "\n</center>\n"; } echo '<div align="center"><br>'; freshports_CategoryNextPreviousPage($category->name, $PortCount, $PageNo, $PageSize); echo '</div>'; ?> </td></tr> <?php if ($Debug) { echo "\$CategoryID = '{$CategoryID}'<BR>\n"; echo "GlobalHideLastChange = {$GlobalHideLastChange}<BR>\n"; echo "\$numrows = {$numrows}<BR>\n"; } $ShowShortDescription = "Y"; $HTML = freshports_echo_HTML("<TR>\n<TD>\n"); require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php'; $port_display = new port_display($db, $User); $port_display->SetDetailsCategory(); for ($i = 0; $i < $numrows; $i++) { $port->FetchNth($i); $port_display->port = $port; $Port_HTML = $port_display->Display(); $HTML .= $port_display->ReplaceWatchListToken($port->{'onwatchlist'}, $Port_HTML, $port->{'element_id'}); } // end for echo $HTML; ?> </TD></TR> <TR><TD> <div align="center"><br> <?php freshports_CategoryNextPreviousPage($category->name, $PortCount, $PageNo, $PageSize); ?> </div> </TD></TR> </TABLE> <TD VALIGN="top" WIDTH="*" ALIGN="center"> <?php echo freshports_SideBar(); ?> </td> </TR> </TABLE> <?php echo freshports_ShowFooter(); ?> </body> </html> <?php }
function get_content(&$arguments, $properties) { $template = $this->onInitContent(&$arguments, $properties); if (!$this->isDonateRequest()) { if (count($_POST) > 0) { if ($GLOBALS['phpgw']->session->appsession('isWelcome') != 1) { $template->CollectPostedData($this->formCfg, true, false); $this->words["moneydonateDisplay"] = $template->defaults["isdonate"] == "1" ? "block" : "none"; $this->OnPostData(&$template); //begin: Validation block $template->ValidatePostedData($this->formCfg, true); $template->defaults["account_lid"] = $this->setUserUID(&$template); if ($template->defaults['birth_y'] != "" && !str_is_int($template->defaults['birth_y']) || $template->defaults['birth_y'] != "" && str_is_int($template->defaults['birth_y']) && intval($template->defaults['birth_y']) > intval(date("Y")) - 16) { $template->errorsBlocks["birth_y_ErrRule"] = $this->words['birthInvalid']; } else { //$template->defaults['birthDate'] = sprintf("%d-%d-%d", $template->defaults['birth_d'], $template->defaults['birth_m'], $template->defaults['birth_y']); $template->defaults['birthDate'] = $template->defaults['birth_y']; } if ($template->HasValidationErrors()) { $template->assign_block_vars("FORM_ERROR", array("Message" => $this->words['commonError'])); $this->WriteDebugInformation($template); } else { $userID = $this->getNewUniqueId($template); if ($userID == 0) { $template->assign_block_vars("UNIQUE_ERROR", array("Message" => $this->words['uniqueError'])); $this->WriteDebugInformation($template); } else { $GLOBALS['phpgw']->session->appsession('joinusUserid', '', $userID); $template->defaults['account_user_id'] = $userID; $this->setPrivilegesToNewUser($userID, $template); $elggUserID = $this->getNewElggUniqueId($userID, $template); $this->appendElggProfileData($elggUserID, $template); $this->SendRegistrationEmail($arguments, $template); $GLOBALS['phpgw']->session->appsession('isWelcome', '', ''); $GLOBALS['phpgw']->session->appsession('isWelcome', '', 1); } } //end: Validation block } } else { $GLOBALS['phpgw']->session->appsession('isWelcome', '', ''); $GLOBALS['phpgw']->session->appsession('isWelcome', '', 0); } if ($GLOBALS['phpgw']->session->appsession('isWelcome') == 0) { $template->FillBlockWithStaticValues($this->formCfg, "FORM", $this->words, $this->mysql_link); } else { $this->ClearData(); $template->assign_block_vars("REGISTER_COMPLETE", array("JoinUsSuccess" => lang("joinus success"))); if ($this->IsUserWantToDonate($template)) { $template->assign_block_vars("DONATE", array_merge(array("amount" => $template->defaults["moneydonate"], "FLANG" => strtoupper($GLOBALS['page']->lang), "TitleText" => $this->words["DonateTitleText"], "USERID" => $GLOBALS['phpgw']->session->appsession('joinusUserid')), $_SERVER)); $template->assign_block_vars("DONATE." . strtoupper($GLOBALS['page']->lang), array()); } } } else { if ($this->ValidPaypalTransaction() && str_is_int($_GET["item_number"])) { $template->assign_block_vars("DONATE_VALID", array("text" => $this->words["validDonate"])); $sql = "update phpgw_accounts set paypal_accepted = 1 where paypal_accepted = 0 and account_id = " . $_GET["item_number"]; $res = mysql_query($sql, $this->mysql_link); } else { $template->assign_block_vars("DONATE_INVALID", array("text" => $this->words["invalidDonate"])); } } return $template->pparse('form'); }
if (!isset($page) || $page == '') { $page = 1; } if (!isset($page_size) || $page_size == '') { $page_size = $User->page_size; } if ($Debug) { echo "\$page = '{$page}'<br>\n"; echo "\$page_size = '{$page_size}'<br>\n"; } SetType($PageNo, "integer"); SetType($PageSize, "integer"); if (!isset($PageNo) || !str_is_int("{$PageNo}") || $PageNo < 1) { $PageNo = 1; } if (!isset($PageSize) || !str_is_int("{$PageSize}") || $PageSize < 1 || $PageSize > MAX_PAGE_SIZE) { $PageSize = DEFAULT_PAGE_SIZE; } if ($Debug) { echo "\$PageNo = '{$PageNo}'<br>\n"; echo "\$PageSize = '{$PageSize}'<br>\n"; } $Title = 'Commit found by '; if ($message_id) { $Title .= 'message id'; # if found, this will be > 0 if (strpos($message_id, MESSAGE_ID_OLD_DOMAIN)) { # yes, we found an old message_id. Convert it, # and redirect them to the permanent new location # $new_message_id = freshports_MessageIDConvertOldToNew($message_id);
// Get the genetic code to be used for translation $genetic_code = $_POST["genetic_code"]; // Get the frames to be translated $frames = $_POST["frames"]; // When usage of custom genetic code is requested, if ($_POST["usemycode"] == 1) { $mycode = strtoupper($_POST["mycode"]); $mycode = preg_replace("([^FLIMVSPTAY*HQNKDECWRG\\*])", "", $mycode); if (strlen($mycode) != 64) { die("Error:<br>The custom code is not correct (is not 64 characters long).<HR>"); } $genetic_code = "custom"; } // minimum protein size $protsize = $_POST["protsize"]; if (str_is_int($protsize) != 1 or $protsize < 10) { die("Error:<br>Minimum size of protein sequence is not correct (minimum size is 10)."); } // TRANSLATE if ($genetic_code == "custom") { // Translate in 5-3 direction $frame[1] = translate_DNA_to_protein_customcode(substr($sequence, 0, floor(strlen($sequence) / 3) * 3), $mycode); if ($frames > 1) { $frame[2] = translate_DNA_to_protein_customcode(substr($sequence, 1, floor((strlen($sequence) - 1) / 3) * 3), $mycode); $frame[3] = translate_DNA_to_protein_customcode(substr($sequence, 2, floor((strlen($sequence) - 2) / 3) * 3), $mycode); } // Translate the complementary sequence if ($frames > 3) { // Get complementary $rvsequence = RevComp_DNA($sequence); //calculate frames 4-6