function widget($args, $n = '') { // $args is an array of strings that help widgets to conform to // the active theme: before_widget, before_title, after_widget, // and after_title are the array keys. Default tags: li and h2. extract($args); //nb. $name comes out of this, hence the use of $n global $advman_engine; //If name not passed in (Sidebar Modules), extract from the widget-id (WordPress Widgets) if ($n == '') { $l = length(__('Ad: ')); $n = substr($args['widget_name'], $l); //Chop off beginning advman- bit } if ($n == 'default-ad') { $n = $advman_engine->getSetting('default-ad'); } $ad = $advman_engine->selectAd($n); if (!empty($ad)) { $widgets = $advman_engine->getSetting('widgets'); $id = substr(md5($ad->name), 0, 10); $suppress = !empty($widgets[$id]['suppress']); $ad_widget = ''; $ad_widget .= $suppress ? '' : $before_widget; if (!empty($widgets[$id]['title'])) { $ad_widget .= $suppress ? '' : $before_title; $ad_widget .= $widgets[$id]['title']; $ad_widget .= $suppress ? '' : $after_title; } $ad_widget .= $ad->display(); //Output the selected ad $ad_widget .= $suppress ? '' : $after_widget; echo $ad_widget; } }
public static function truncate($subject, $length, $omission = '...') { if (length($subject) > $length) { $omission_length = length($omission); $subject = substr($subject, 0, length($subject) - $omission_length); $subject .= $omission; } return $subject; }
/** * Determine if a given string ends with a given substring. * * @param string $haystack * @param string|array $needles * * @return bool */ function ends_with(string $haystack, $needles) : bool { foreach ((array) $needles as $needle) { if ((string) $needle === substr($haystack, -length($needle))) { return true; } } return false; }
/** * Returns the number of elements in a list. * * @param Cons $alist a list */ function length($alist) { if (isNull($alist)) { return 0; } elseif (isPair($alist)) { return 1 + length(cdr($alist)); } else { throw new \InvalidArgumentException("{$alist} is not a proper list"); } }
/** * */ function wfSpecialGeo($page = '') { global $wgOut, $wgLang, $wgRequest; $coordinates = htmlspecialchars($wgRequest->getText('coordinates')); $coordinates = explode(":", $coordinates); $ns = array_shift($coordinates); $ew = array_shift($coordinates); if (0 < count($coordinates)) { $zoom = length(array_shift($coordinates)); } else { $zoom = 6; } $ns = explode(".", $ns); $ew = explode(".", $ew); while (count($ns) < 3) { $ns[] = "0"; } while (count($ew) < 3) { $ew[] = "0"; } $mapquest = "http://www.mapquest.com/maps/map.adp?latlongtype=decimal&latitude={$ns[0]}.{$ns[1]}&longitude={$ew[0]}.{$ew[1]}&zoom={$zoom}"; $mapquest = "<a href=\"{$mapquest}\">Mapquest</a>"; $wgOut->addHTML("{$mapquest}"); /* if( $wgRequest->getVal( 'action' ) == 'submit') { $page = $wgRequest->getText( 'pages' ); $curonly = $wgRequest->getCheck( 'curonly' ); } else { # Pre-check the 'current version only' box in the UI $curonly = true; } if( $page != "" ) { header( "Content-type: application/xml; charset=utf-8" ); $pages = explode( "\n", $page ); $xml = pages2xml( $pages, $curonly ); echo $xml; wfAbruptExit(); } $wgOut->addWikiText( wfMsg( "exporttext" ) ); $titleObj = Title::makeTitle( NS_SPECIAL, "Export" ); $action = $titleObj->escapeLocalURL(); $wgOut->addHTML( " <form method='post' action=\"$action\"> <input type='hidden' name='action' value='submit' /> <textarea name='pages' cols='40' rows='10'></textarea><br /> <label><input type='checkbox' name='curonly' value='true' checked='checked' /> " . wfMsg( "exportcuronly" ) . "</label><br /> <input type='submit' /> </form> " ); */ }
function Perla_strlen($text) { if (isset($text)) { return length($text); } else { return 'Podaj ciąg mający więcej niż 0 znaków!'; } echo Perla_reverse('perła'); //test }
public function getParentCategory($category_id) { if (length($category_id) < 2) { throw Dolcore_Exception(sprintf(_('Tried to get the parent category of a top category %s'), $category_id)); } $parent_id = substr($category_id, 0, -1); $parent = $this->getCategory($parent_id); if (!$parent) { throw Dolcore_Exception(sprintf(_('No parent category for child category %s'), $category_id)); } return $parent; }
function readbtable($tfile, $genelist, $numgenes) { $f = fopen($tfile, "rb"); $out = array(); for ($i = 0; $i < length($genelist); $i++) { fseek($f, $genelist[$i] * $numgenes - 1); #from start??? $out[] = fread($f, $numgenes); #double somehow } fclose($f); return $out; }
public function addItem($vars = array()) { $cnf = Zend_Registry::get('cnf'); $db = Zend_Db::factory($cnf->db); $cols = ""; $values = ""; foreach ($vars as $key => $value) { $coma = length($cols) > 0 ? "," : ""; $cols += $coma + "`{$key}\\`"; $values += $coma + "\\'{$value}\\'"; } $db->query("INSERT admin_menu ({$cols}) VALUES ({$values})"); }
public function checkLastConsonantSoftness($word) { if (($substring = last_position_for_one_of_chars(lower($word), array_map(__NAMESPACE__ . '\\lower', self::$consonants))) !== false) { if (in_array(slice($substring, 0, 1), ['й', 'ч', 'щ'])) { // always soft consonants return true; } else { if (length($substring) > 1 && in_array(slice($substring, 1, 2), ['е', 'ё', 'и', 'ю', 'я', 'ь'])) { // consonants are soft if they are trailed with these vowels return true; } } } return false; }
public static function substr($str, $startPos, $length = 0) { if ($startPos < 0) { $startPos = length($str) + $startPos; if ($startPos < 0) { $startPos = length($str); } } preg_match_all("/./u", $str, $array); if ($length) { $end = $startPos + $length; return join("", array_slice($array[0], $start, $end)); } else { return join("", array_slice($array[0], $start)); } }
public function do($searchData, $cleanWord) { if (length($cleanWord) > length($searchData)) { throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!'); } if (!is_array($searchData)) { $result = str_replace($cleanWord, '', $searchData); } else { if (!is_array($cleanWord)) { $cleanWordArray[] = $cleanWord; } else { $cleanWordArray = $cleanWord; } $result = array_diff($searchData, $cleanWordArray); } return $result; }
function url_upload($url) { if ($img_type = $this->check_img_url($url)) { $content = $this->down_with_curl($url); } else { $this->err_msg .= ' !URL изображения не верен '; return FALSE; } if ($content == false && length($content) < 100) { $this->err_msg .= ' !Изображение не загруженно '; return FALSE; } $img_fname = md5($content) . '.' . $img_type; file_put_contents($this->img_folder . $img_fname, $content); $this->file_data = array('file_name' => $img_fname, 'file_path' => $this->img_folder); return TRUE; }
function traerCapacitacionMenu() { $db = Conectar(); $sql = "SELECT * FROM capacitacion ORDER BY id_cap DESC"; $resultado = $db->query($sql); while ($data = $resultado->fetch_object()) { echo ' <article class="CursosImagenes col" > <h2><a class="LinkCursos" href="curso_detalle.php?id=' . $data->id_cap . '#aqui" >' . length($data->titulo) . '</a></h2> <a href="curso_detalle.php?id=' . $data->id_cap . '#aqui" rel="nofollow" > <div class="ImagenCurso"><img class="SacarSeccionCelular" src="upload/' . $data->imagen . '"/><div class="HoverCursos"><div class="SimboloMas"></div></div></div> </a> </article> '; } return $resultado; }
/** * Replaces all old string within the expression with new strings. * * @param String|\Tbm\Peval\Types\String $expression * The string being processed. * @param String|\Tbm\Peval\Types\String $oldString * The string to replace. * @param String|\Tbm\Peval\Types\String $newString * The string to replace the old string with. * * @return mixed The new expression with all of the old strings replaced with new * strings. */ public function replaceAll(string $expression, string $oldString, string $newString) { $replacedExpression = $expression; if ($replacedExpression != null) { $charCtr = 0; $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr); while ($oldStringIndex > -1) { // Remove the old string from the expression. $buffer = new StringBuffer($replacedExpression->subString(0, oldStringIndex)->getValue() . $replacedExpression->substring($oldStringIndex + $oldString . length())); // Insert the new string into the expression. $buffer . insert($oldStringIndex, $newString); $replacedExpression = buffer . toString(); $charCtr = $oldStringIndex + $newString->length(); // Determine if we need to continue to search. if ($charCtr < $replacedExpression->length()) { $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr); } else { $oldStringIndex = -1; } } } return $replacedExpression; }
public function actionCreate() { $model = new Parametro(); if (isset($_POST['Parametro'])) { $model->setAttributes($_POST['Parametro']); if (length($model->ValorFecha) > 0) { $model->ValorFecha = date('Y-m-d', CDateTimeParser::parse($model->ValorFecha, Yii::app()->locale->dateFormat)); } try { if ($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('view', 'id' => $model->idParametro)); } } } catch (Exception $e) { $model->addError('', $e->getMessage()); } } elseif (isset($_GET['Parametro'])) { $model->attributes = $_GET['Parametro']; } $this->render('create', array('model' => $model)); }
<?php $a = fopen('raha.txt', 'w'); fwrite($a, 'my name is raha'); fread($a, length($a));
/** * Adds user to the database * * Registration function, this controls the sign up functionality. * @global array * @global resource * @param string $username username of user being added * @param string $password password of user being added * @param string $password_again password again to be checked against first $password * @param string $email email incase email registration is turned on * @param string $age mm/dd/yyyy * @return string|boolean */ function add_user($username, $password, $password_again, $email, $age = false) { global $config, $database; // 904 - Registration complete, needs to validate email! // Check Username if (!alpha($username, 'alpha-underscore')) { return lang_parse('error_invalid_chars', array(lang('username'))); } // Username Taken if (username_check($username)) { return lang('error_username_taken'); } // Check Username Length $length = length($username, $config['min_name_length'], $config['max_name_length']); if ($length) { if ($length == "TOO_LONG") { return lang('error_username_too_long'); } else { return lang('error_username_too_short'); } } // Check Password Length $length = length($password, $config['min_name_length'], $config['max_name_length']); if ($length) { if ($length == "TOO_LONG") { return lang('error_password_too_long'); } else { return lang('error_password_too_short'); } } // Setup Passwords if ($password == $password_again) { $raw_pass = $password; $password = md5($password); } else { return lang('error_password_match'); } // Check email if (!is_email($email)) { return lang_parse('error_invalid_given', array(lang('email'))); } // Banned? $query = "SELECT * FROM `users` WHERE `email` = '{$email}' AND `banned` = '1' LIMIT 1"; $result = $database->query($query); if ($database->num($result) > 0) { return lang('error_banned_email'); } // Exist? $query = "SELECT * FROM `users` WHERE `email` = '{$email}' LIMIT 1"; $result = $database->query($query); // Email exists if ($database->num($result) > 0) { return lang('error_email_used'); } // Do we have to validate age? if ($config['age_validation']) { if ($age) { // Start grabbing age data~ $age_data = explode('/', $age); if (alpha($age_data[2], 'numeric')) { if (strlen($age_data[2]) < 4) { return lang('error_year_invalid'); } $old_enough = age_limit($age_data[2], $config['age_validation']); if (!$old_enough) { return lang_parse('error_year_young', array($config['age_validation'])); } } else { return lang_parse('error_given_not_numeric', array(lang('year_c'))); } } else { return lang('error_year_invalid'); } } load_hook('add_user_check'); // Finally Add user if ($config['email_validation']) { // The Key for Validation $key = md5($username . $email . substr(microtime(), 1, 3)); // The query $query = "INSERT INTO `users` (`username`,`password`,`email`,`join_date`,`age`,`active`,`key`) VALUES ('{$username}', '{$password}', '{$email}', '" . time() . "','{$age}','0','{$key}')"; } else { // The query $query = "INSERT INTO `users` (`username`,`password`,`email`,`join_date`,`age`,`active`) VALUES ('{$username}', '{$password}', '{$email}', '" . time() . "','{$age}','1')"; } // Return Data if ($result = $database->query($query)) { // Auto login if (!$config['email_validation']) { // log them in login($username, false, $raw_pass); // Return True return true; } else { // Subject / Message replacing $subject = str_replace('{site_name}', $config['site_name'], $config['email_subject']); $subject = str_replace('{username}', $username, $subject); $subject = str_replace('{email}', $email, $subject); // The message $message = str_replace('{site_name}', $config['site_name'], $config['email_message']); $message = str_replace('{username}', $username, $message); $message = str_replace('{email}', $email, $message); $message = str_replace('{link}', $config['url_path'] . "/register.php?e={$email}&k={$key}", $message); // Mail the results riot_mail($email, $subject, nl2nl($message)); // Return the results return 904; } } else { return false; } }
/** * Allows updating of topics, stuck or closed, and posts * @global array * @global array * @global resource * @param integer $id post we are editing * @param string $topic post subject * @param string $content post content * @param integer $reply id of topic we are replying to * @param boolean $sticky are we sticking it to the top? * @param boolean $closed are we closing it? * @return string|int */ function update($id, $category, $topic, $content, $sticky = false, $closed = false) { global $config, $user_data, $database; // The time. milliseconds / seconds may change. $time = time(); // Is the id numeric? if (!alpha($id, 'numeric')) { return lang_parse('error_given_not_numeric', array(lang('post') . " " . lang('id'))); } // Grab the data for the update. $post_data = topic($id); // Check to see if the post or topic was found. if (!$post_data) { return lang('error_post_missing'); } // Pre-Parse $topic = strip_repeat($topic); // Can't update a replies category! if ($post_data['reply']) { $category = $post_data['category']; } // Check validity of category as numeric if (!alpha($category, 'numeric')) { return lang('error_invalid_category'); } // Check to see if category exists $category = category($category); if (!$category) { return lang('error_invalid_category'); } // Check category settings against user if (!$user_data['admin']) { if ($category['aop'] && $post_data['reply']) { if (!$user_data['admin'] || !$user_data['moderator']) { return lang('error_invalid_category'); } } if ($category['aot'] && !$post_data['reply']) { if ($user_data['id'] != $category['aot']) { return lang('error_invalid_category'); } } } // Is the user currently logged in? If not we can't update return error. if ($_SESSION['logged_in']) { // Editing a topic not post if ($post_data['reply'] == 0) { // Is there a topic? if ($topic == "") { return lang_parse('error_no_given', array(lang('username'))); } } else { // If there was no topic put re: on it. if ($topic == "") { $topic = "re:"; } } // Is the subject valid? if (!alpha($topic, 'alpha-extra')) { return lang_parse('error_invalid_chars', array(lang('subject'))); } // Did they give us any content to work with? if ($content != "") { if (!is_string(length($content, $config['message_minimum_length'], $config['message_max_length']))) { // Check to see if the user is an admin and able to sticky / close the topic if ($_SESSION['admin'] || $_SESSION['moderator']) { // Sticky $sticky = $sticky ? '1' : '0'; // Closed $closed = $closed ? '1' : '0'; // Admin functions update_field($id, 'sticky', $sticky); update_field($id, 'closed', $closed); } // Parsing $topic = $database->escape($topic); $content = $database->escape($content); // Update the post already inside of the database with the new data $result = $database->query("UPDATE `forum` SET `category`='{$category['id']}', `subject`='{$topic}', `message`='{$content}', `updated`='{$time}', `replies`='{$replies}' WHERE id = '{$id}'") or die(mysql_error()); // Did it work? if ($result) { // Update replies with category if ($category != $post_data['category'] && !$post_data['reply']) { $database->query("UPDATE `forum` SET `category`='{$category['id']}' WHERE `reply` = {$id}"); } return true; } else { return false; } } else { return lang_parse('error_message_length', array($config['message_max_length'], $config['message_minimum_length'])); } } else { return lang_parse('error_no_given', array(lang('message'))); } } else { return lang('error_not_logged'); } }
private function getSidFromURI($url, $cookieName) { $sid = ""; if ($url != null) { // if (debug . messageEnabled()) { // debug . message("getSidFromURI: url=" + url); // } if ($url != null && length($url) > 0) { $start = strpos($url, $cookieName); if ($start) { $start = $start + length($cookieName) + 1; $end = strpos($url, SessionEncodeURL::QUERY, $start); if ($end) { $sid = substr($url, $start, $end - 1); } else { $sid = substr($url, $start); } } } } // if (debug . messageEnabled()) { // debug . message("getSidFromURL: sid =" + sid); // } return $sid; }
$display = "{$lang['change_right_sls_pass']}"; } } else { if ($GET_code == '06') { $query = "SELECT COUNT(*) FROM {$CONFIG_sql_cpdbname}.user_profile WHERE user_id = \"" . $CP['login_id'] . "\""; $sql->result = $sql->execute_query($query, 'change_profile.php'); $sql->total_query++; if (!$sql->result()) { $display = "{$lang['change_wrong_time_offset']}"; } else { $sql->execute_query("UPDATE {$CONFIG_sql_cpdbname}.user_profile SET user_time_offset = \"" . mysql_res($POST_u_timezone) . "\" WHERE user_id = \"" . $CP['login_id'] . "\" ", 'change_profile.php'); $sql->total_query++; $display = "{$lang['change_right_time_offset']}"; } } else { if ($GET_code == '07' && length($POST_display_name, 4, 24)) { $POST_password = mysql_res(checkmd5($CONFIG_md5_support, $POST_password)); $POST_display_name = checkstring($POST_display_name, 1); $query = "SELECT userid FROM {$CONFIG_sql_dbname}.login WHERE account_id = \"" . $CP['login_id'] . "\" AND user_pass = \"" . $POST_password . "\""; $sql->result = $sql->execute_query($query, 'change_profile.php'); $sql->total_query++; $row = $sql->fetch_row(); if (!$sql->count_rows()) { $display = "{$lang['change_wrong_display_name']}"; } else { $query = "SELECT COUNT(*) FROM {$CONFIG_sql_cpdbname}.user_profile WHERE display_name = \"" . mysql_res($POST_display_name) . "\""; $sql->result = $sql->execute_query($query, 'change_profile.php'); $sql->total_query++; $count1 = $sql->result(); $query = "SELECT COUNT(*) FROM {$CONFIG_sql_dbname}.login WHERE userid = \"" . $POST_display_name . "\" AND userid != \"" . $row["userid"] . "\""; $sql->result = $sql->execute_query($query, 'change_profile.php');
/** * 长度是否大于提供的数值 * @param string $s 判断的字串 * @param int $length 判断大于的长度 * @return boolean */ function is_longer_than($s, $length) { if (!is_int($length)) { return false; } return length($s) > $length; }
function createEventFromPending($uid) { // load in the file $handle = openPendingFile("r"); while ($line = fgets($handle)) { if ($uid == $line.substr(0, $uid.length())) { $data = explode(',', $line); // if approved if ($decision = 'y') { createEvent("", $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]); return true; } // if rejected. else should be okay because it was validated above else { // send email to student notifying them of the rejection. fix! $student = infoForAttendee($data[6]); $body = "Hello " . $student['name'] . ".\n"; $body .= "Your meeting was declined.\n"; $body .= "Better luck next time!\n"; sendEmail($student['email'], "Meeting Declined", $body); return true; } } } return false; }
/** * Checks equality of binary values * * @param string $binary1 First binary value * @param string $binary2 Second binary value * * @return boolean */ public static function binaryEqual($binary1, $binary2) { if (is_null($binary1) || is_null($binary2)) { return false; } $length1 = length($binary1); $length2 = length($binary2); if ($length1 != $length2) { return false; } for ($i = 0; $i < $length1; $i++) { if ($binary1[$i] != $binary2[$i]) { return false; } } return true; }
public static function latinAlphabetToUnicode($text, $aipaitaiMode) { if ($aipaitaiMode == '1') { $aipaitai = TRUE; } else { $aipaitai = FALSE; } $preparedText = self::_prepare_string($text); $s = str_split($preparedText); $i = 0; $l = count($s); $d = NULL; $sb = array(); while ($i < $l) { $c = $s[$i]; if ($c === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1404; } else { $d = 0x1403; $i--; } } else { $d = 0x1403; $i--; } } elseif ($c === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1406; } else { $d = 0x1405; $i--; } } else { $d = 0x1405; $i--; } } elseif ($c === 'A') { if ($aipaitai) { $d = 0x1401; } else { array_push($sb, 0x140a); $d = 0x1403; } # ai } elseif ($c === 'a') { # a $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x140b; } else { $d = 0x140a; $i--; } } else { $d = 0x140a; $i--; } } elseif ($c === 'b' || $c === 'p') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1432; } else { $d = 0x1431; $i--; } # pi } else { $d = 0x1431; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1434; } else { $d = 0x1433; $i--; } # pu } else { $d = 0x1433; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x142f; } else { array_push($sb, 0x1438); $d = 0x1403; } # pai } elseif ($e === 'a') { # pa $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1439; } else { $d = 0x1438; $i--; } # pa } else { $d = 0x1438; # pa $i--; } } else { $d = 0x1449; $i--; } # p } else { $i--; $d = 0x1449; # p } } elseif ($c === 'd' || $c === 't') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x144f; } else { $d = 0x144e; $i--; } # ti } else { $d = 0x144e; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1451; } else { $d = 0x1450; $i--; } # tu } else { $d = 0x1450; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x144c; } else { array_push($sb, 0x1455); $d = 0x1403; } # tai } elseif ($e === 'a') { # ta $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1456; } else { $d = 0x1455; $i--; } # ta } else { $d = 0x1455; # ta $i--; } } else { $d = 0x1466; $i--; } # t } else { $i--; $d = 0x1466; # t } } elseif ($c === 'k') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x146e; } else { $d = 0x146d; $i--; } # ki } else { $d = 0x146d; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1470; } else { $d = 0x146f; $i--; } # ku } else { $d = 0x146f; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x146b; } else { array_push($sb, 0x1472); $d = 0x1403; } # kai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1473; } else { $d = 0x1472; $i--; } # ka } else { $d = 0x1472; # ka $i--; } } else { $d = 0x1483; $i--; } # k } else { $i--; $d = 0x1483; # k } } elseif ($c === 'g') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x148c; } else { $d = 0x148b; $i--; } # gi } else { $d = 0x148b; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x148e; } else { $d = 0x148d; $i--; } # gu } else { $d = 0x148d; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1489; } else { array_push($sb, 0x1490); $d = 0x1403; } # gai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1491; } else { $d = 0x1490; $i--; } # ga } else { $d = 0x1490; # ga $i--; } } else { $d = 0x14a1; $i--; } # g } else { $i--; $d = 0x14a1; # g } } elseif ($c === 'm') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x14a6; } else { $d = 0x14a5; $i--; } # mi } else { $d = 0x14a5; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x14a8; } else { $d = 0x14a7; $i--; } # mu } else { $d = 0x14a7; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x14a3; } else { array_push($sb, 0x14aa); $d = 0x1403; } # mai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x14ab; } else { $d = 0x14aa; $i--; } # ma } else { $d = 0x14aa; # ma $i--; } } else { $d = 0x14bb; $i--; } # m } else { $i--; $d = 0x14bb; # m } } elseif ($c === 'n') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x14c3; } else { $d = 0x14c2; $i--; } # ni } else { $d = 0x14c2; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x14c5; } else { $d = 0x14c4; $i--; } # nu } else { $d = 0x14c4; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x14c0; } else { array_push($sb, 0x14c7); $d = 0x1403; } # nai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x14c8; } else { $d = 0x14c7; $i--; } # na } else { $d = 0x14c7; # na $i--; } } else { $d = 0x14d0; $i--; } # n } else { $i--; $d = 0x14d0; # n } } elseif ($c === 's') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x14f0; } else { $d = 0x14ef; $i--; } # si } else { $d = 0x14ef; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x14f2; } else { $d = 0x14f1; $i--; } # su } else { $d = 0x14f1; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x14ed; } else { array_push($sb, 0x14f4); $d = 0x1403; } # sai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x14f5; } else { $d = 0x14f4; $i--; } # sa } else { $d = 0x14f4; # sa $i--; } } else { $d = 0x1505; $i--; } # s } else { $i--; $d = 0x1505; # s } } elseif ($c === 'l') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x14d6; } else { $d = 0x14d5; $i--; } # li } else { $d = 0x14d5; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x14d8; } else { $d = 0x14d7; $i--; } # lu } else { $d = 0x14d7; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x14d3; } else { array_push($sb, 0x14da); $d = 0x1403; } # lai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x14db; } else { $d = 0x14da; $i--; } # la } else { $d = 0x14da; # la $i--; } } else { $d = 0x14ea; $i--; } # l } else { $i--; $d = 0x14ea; # l } } elseif ($c === 'j') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1529; } else { $d = 0x1528; $i--; } # ji } else { $d = 0x1528; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x152b; } else { $d = 0x152a; $i--; } # ju } else { $d = 0x152a; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1526; } else { array_push($sb, 0x152d); $d = 0x1403; } # jai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x152e; } else { $d = 0x152d; $i--; } # ja } else { $d = 0x152d; # ja $i--; } } else { $d = 0x153e; $i--; } # j } else { $i--; $d = 0x153e; # j } } elseif ($c === 'v') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1556; } else { $d = 0x1555; $i--; } # vi } else { $d = 0x1555; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1558; } else { $d = 0x1557; $i--; } # vu } else { $d = 0x1557; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1553; } else { array_push($sb, 0x1559); $d = 0x1403; } # vai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x155a; } else { $d = 0x1559; $i--; } # va } else { $d = 0x1559; # va $i--; } } else { $d = 0x155d; $i--; } # v } else { $i--; $d = 0x155d; # v } } elseif ($c === 'r') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1547; } else { $d = 0x1546; $i--; } # ri } else { $d = 0x1546; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1549; } else { $d = 0x1548; $i--; } # ru } else { $d = 0x1548; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1542; } else { array_push($sb, 0x154b); $d = 0x1403; } # nai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x154c; } else { $d = 0x154b; $i--; } # ra } else { $d = 0x154b; # ra $i--; } } else { $d = 0x1550; $i--; } # r } else { $i--; $d = 0x1550; # r } } elseif ($c === 'q') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1580; } else { $d = 0x157f; $i--; } # qi } else { $d = 0x157f; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1582; } else { $d = 0x1581; $i--; } # qu } else { $d = 0x1581; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x166f; } else { array_push($sb, 0x1583); $d = 0x1403; } # nai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1584; } else { $d = 0x1583; $i--; } # qa } else { $d = 0x1583; # qa $i--; } } else { $d = 0x1585; $i--; } # q } else { $i--; $d = 0x1585; # q } } elseif ($c === '&') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x15a1; } else { $d = 0x15a0; $i--; } # &i } else { $d = 0x15a0; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x15a3; } else { $d = 0x15a2; $i--; } # &u } else { $d = 0x15a2; $i--; } } elseif ($e === 'A') { array_push($sb, 0x15a4); $d = 0x1403; } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x15a5; } else { $d = 0x15a4; $i--; } # &a } else { $d = 0x15a4; # &a $i--; } } else { $d = 0x15a6; $i--; } # & } else { $i--; $d = 0x15a6; # & } } elseif ($c === 'N') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1590; } else { $d = 0x158f; $i--; } # ngi } else { $d = 0x158f; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1592; } else { $d = 0x1591; $i--; } # ngu } else { $d = 0x1591; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1670; } else { array_push($sb, 0x1593); $d = 0x1403; } # ngai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1594; } else { $d = 0x1593; $i--; } # nga } else { $d = 0x1593; # nga $i--; } } else { $d = 0x1595; $i--; } # ng } else { $i--; $d = 0x1595; # ng } } elseif ($c === 'X') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1672; } else { $d = 0x1671; $i--; } # nngi } else { $d = 0x1671; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1674; } else { $d = 0x1673; $i--; } # nngu } else { $d = 0x1673; $i--; } } elseif ($e === 'A') { if ($aipaitai) { array_push($sb, 0x1596); $d = 0x1489; } else { array_push($sb, 0x1675); $d = 0x1403; } } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1676; } else { $d = 0x1675; $i--; } # nnga } else { $d = 0x1675; # nnga $i--; } } else { $d = 0x1596; $i--; } # nng } else { $i--; $d = 0x1596; # nng } } elseif ($c === 'H') { $d = 0x157c; } elseif ($c === 'h') { # Nunavik h $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x1576; } else { $d = 0x1575; $i--; } # hi } else { $d = 0x1575; $i--; } } elseif ($e === 'u') { $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1578; } else { $d = 0x1577; $i--; } # hu } else { $d = 0x1577; $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x1574; } else { array_push($sb, 0x1579); $d = 0x1403; } # hai } elseif ($e === 'a') { # $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x157a; } else { $d = 0x1579; $i--; } # ha } else { $d = 0x1579; $i--; } } else { $d = 0x157b; $i--; } # h } else { $i--; $d = 0x157b; # h } } elseif ($c === 'Q') { #qq array_push($sb, 0x1585); $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x146d; $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'i') { $d = 0x146e; } else { $i--; } # qqi = q+ki } else { $i--; } } elseif ($e === 'u') { $d = 0x146f; $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'u') { $d = 0x1470; } else { $i--; } # qqu = q+ku } else { $i--; } } elseif ($e === 'A') { if ($aipaitai) { $d = 0x146b; } else { array_push($sb, 0x1472); $d = 0x1403; } # nai } elseif ($e === 'a') { $d = 0x1472; $i++; if ($i < $l) { $e = $s[$i]; if ($e === 'a') { $d = 0x1473; } else { $i--; } # qqa = q+ka } else { # qqa = q+ka $i--; } } else { # shouldn't happen $d = 0x1585; $i--; } # qq } else { # shouldn't happen $i--; $d = 0x1585; $sb = substr($sb, 0, length($sb) - 1); } } elseif ($c === 'H') { $d = 0x157c; } else { $d = ord($c); } $i++; array_push($sb, $d); } $out = ''; $out = utf8::numeric_to_utf8($sb); // foreach ($sb as $n) { // $str = utf8::numeric_to_utf8($n); // $out .= $str; // } return $out; // return implode('',array_map('utf8::numeric_to_utf8',$sb)); }
/** * Return the length of a string * @param string $string the input string * @param bool $mb to use or not to use mb_strlen * @return int the length of the input string * @author Rod Elias <*****@*****.**> */ function len($string, $mb = false) { return length($string, $mb); }
/** * Allows updating of topics, stuck or closed, and posts * @global array * @global array * @param integer $id post we are editing * @param string $topic post subject * @param string $content post content * @param integer $reply id of topic we are replying to * @param boolean $sticky are we sticking it to the top? * @param boolean $closed are we closing it? * @return string|int */ function update($id, $topic, $content, $sticky = false, $closed = false) { global $config, $user_data; // The time. milliseconds / seconds may change. $time = time(); // Is the id numeric? if (!alpha($id, 'numeric')) { return lang_parse('error_given_not_numeric', array(lang('post') . " " . lang('id'))); } // Grab the data for the update. $post_data = topic($id); // Check to see if the post or topic was found. if (!$post_data) { return lang('error_post_missing'); } // Pre-Parse $topic = clean_input(strip_repeat($topic)); $content = htmlentities($content); $content = clean_input(stripslashes($content)); // Is the user currently logged in? If not we can't update return error. if ($_SESSION['logged_in']) { // Editing a topic not post if ($post_data['reply'] == 0) { if ($topic == "") { return lang_parse('error_no_given', array(lang('username'))); } } else { if ($topic == "") { $topic = "re:"; } } // Is the subject valid? if (!alpha($topic, 'alpha-extra')) { return lang_parse('error_invalid_chars', array(lang('subject'))); } // Did they give us any content to work with? if ($content != "") { if (!is_string(length($content, $config['message_minimum_length'], $config['message_max_length']))) { // Check to see if the user is an admin and able to sticky / close the topic if ($_SESSION['admin'] || $_SESSION['moderator']) { // Sticky $sticky = $sticky ? '1' : '0'; // Closed $closed = $closed ? '1' : '0'; // Admin functions update_field($id, 'sticky', $sticky); update_field($id, 'closed', $closed); } // Parsing $content = htmlspecialchars($content); // Update the post already inside of the database with the new data $result = mysql_query("UPDATE `forum` SET `subject`='{$topic}', `message`='{$content}', `updated`='{$time}', `replies`='{$replies}' WHERE id = '{$id}'") or die(mysql_error()); // Did it work? if ($result) { return true; } else { return false; } } else { return lang_parse('error_message_length', array($config['message_max_length'], $config['message_minimum_length'])); } } else { return lang_parse('error_no_given', array(lang('message'))); } } else { return lang('error_not_logged'); } }
/** * Cleans up the guest array * @global array * @global array */ function profile_edit() { global $config, $user_data, $errors, $key, $data; // Check the data, output error into errors array if there was an error. if ($key == "title") { // Check the data, output error into errors array if there was an error. if (alpha($data, 'alpha-spacers') || $data == "") { if (!in_array($data, $config['banned_titles'])) { $length = length($data, 2, 32); if ($length) { if ($length == "TOO_LONG") { $errors[$key] = lang('error_title_too_long'); } else { $errors[$key] = lang('error_title_too_short'); } } else { // update user update_user($user_data['id'], false, $key, $data); // update revisions if (insert_revision($user_data['id'], $data)) { $errors[$key] = insert_revision($user_data['id'], $data); } } } } else { $errors[$key] = lang_parse('error_invalid_chars', array(lang('title_c'))); } } }
function _write_url_external() { $_ = func_get_args(); # Network drives are different. We will handle them separately # MS/Novell network drives and shares start with \\ if (preg_match('[^external:\\\\]', $_[4])) { return call_user_func_array(array(&$this, '_write_url_external_net'), $_); } $record = 0x1b8; # Record identifier $length = 0x0; # Bytes to follow $row1 = $_[0]; # Start row $col1 = $_[1]; # Start column $row2 = $_[2]; # End row $col2 = $_[3]; # End column $url = $_[4]; # URL string if (isset($_[5])) { $str = $_[5]; # Alternative label } $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format # Strip URL type and change Unix dir separator to Dos style (if needed) # $url = preg_replace('[^external:]', '', $url); $url = preg_replace('[/]', "\\", $url); # Write the visible label if (!isset($str)) { $str = preg_replace('[\\#]', ' - ', $url); } $str_error = $this->write_string($row1, $col1, $str, $xf); if ($str_error == -2) { return $str_error; } # Determine if the link is relative or absolute: # relative if link contains no dir separator, "somefile.xls" # relative if link starts with up-dir, "..\..\somefile.xls" # otherwise, absolute # $absolute = 0x2; # Bit mask if (!preg_match('[\\]', $url)) { $absolute = 0x0; } if (preg_match('[^\\.\\.\\]', $url)) { $absolute = 0x0; } # Determine if the link contains a sheet reference and change some of the # parameters accordingly. # Split the dir name and sheet name (if it exists) # list($dir_long, $sheet) = preg_split('/\\#/', $url); $link_type = 0x1 | $absolute; //!!! if (isset($sheet)) { $link_type |= 0x8; $sheet_len = pack("V", length($sheet) + 0x1); $sheet = join("", split('', $sheet)); $sheet .= ""; } else { $sheet_len = ''; $sheet = ''; } # Pack the link type $link_type = pack("V", $link_type); # Calculate the up-level dir count e.g.. (..\..\..\ == 3) /* TODO $up_count = 0; $up_count++ while $dir_long =~ s[^\.\.\\][]; $up_count = pack("v", $up_count); */ # Store the short dos dir name (null terminated) $dir_short = $dir_long . ""; # Store the long dir name as a wchar string (non-null terminated) $dir_long = join("", preg_split('', $dir_long, -1, PREG_SPLIT_NO_EMPTY)); $dir_long = $dir_long . ""; # Pack the lengths of the dir strings $dir_short_len = pack("V", strlen($dir_short)); $dir_long_len = pack("V", strlen($dir_long)); $stream_len = pack("V", strlen($dir_long) + 0x6); # Pack the undocumented parts of the hyperlink stream $unknown1 = pack("H*", 'D0C9EA79F9BACE118C8200AA004BA90B02000000'); $unknown2 = pack("H*", '0303000000000000C000000000000046'); $unknown3 = pack("H*", 'FFFFADDE000000000000000000000000000000000000000'); $unknown4 = pack("v", 0x3); # Pack the main data stream $data = pack("vvvv", $row1, $row2, $col1, $col2) . $unknown1 . $link_type . $unknown2 . $up_count . $dir_short_len . $dir_short . $unknown3 . $stream_len . $dir_long_len . $unknown4 . $dir_long . $sheet_len . $sheet; # Pack the header data $length = strlen($data); $header = pack("vv", $record, $length); # Write the packed data $this->_append($header . $data); return $str_error; }
$forum_perm .= ":start_perm:"; } $forum_perm .= "[/g" . $g_id . "]"; } $sql->execute_query("INSERT INTO {$CONFIG_sql_cpdbname}.forum (category_id,forum_title,forum_description,forum_perm) VALUES (\"" . mysql_res($POST_c) . "\",\"" . $POST_forum_name . "\",\"" . $POST_forum_description . "\",\"" . $forum_perm . "\")", 'forum_manage.php'); } break; case editcategory: if (length($POST_category_name, 1, 50)) { $POST_category_name = checkstring($POST_category_name, 1); $sql->execute_query("UPDATE {$CONFIG_sql_cpdbname}.memory SET memory_value3=\"" . $POST_category_name . "\" WHERE memory_object=\"forum_category\" AND memory_value1=\"" . mysql_res($POST_c) . "\""); $sql->total_query++; } break; case editforum: if (length($POST_forum_name, 1, 50) && length($POST_forum_description, 0, 100)) { $POST_forum_name = checkstring($POST_forum_name, 1); $POST_forum_description = checkstring($POST_forum_description, 1); $query = "SELECT g_id, g_title FROM {$CONFIG_sql_cpdbname}.groups ORDER by g_id"; $sql->result = $sql->execute_query($query, 'forum_manage.php'); while ($grow = $sql->fetch_row()) { $g_id = $grow[0]; $forum_perm .= "[g" . $g_id . "]"; if ($_POST["show_forum_" . $g_id . ""]) { $forum_perm .= ":show_perm:"; } if ($_POST["read_topics_" . $g_id . ""]) { $forum_perm .= ":read_perm:"; } if ($_POST["reply_topics_" . $g_id . ""]) { $forum_perm .= ":reply_perm:";