public static function token() { $tokens = Session::get('csrf_tokens', array()); $token = hash('md5', noise()); $tokens[] = $token; Session::put('csrf_tokens', $tokens); return $token; }
public static function token() { if ($sessionToken = Session::get('csrf_token')) { return $sessionToken; } $token = noise(64); Session::put('csrf_token', $token); return $token; }
/** * Implementation of the read method, imports the current * session if found and populates the data array */ public function read() { extract($this->driver->config); // read session ID from cookie $this->id = Cookie::read($cookie, 0); // make sure we have some data, if not lets start again if ($data = $this->driver->read($this->id)) { // set the data to an empty array $this->data = $data; } else { // Cargo has expired lets create a new ID to prevent session fixation // @see https://www.owasp.org/index.php/Session_fixation $this->id = noise(32); } }
/** * Strips none alphanumeric and dash characters * * @param string * @return string */ protected function format_filename($filename) { $dash = '-'; // remove crazy characters $filename = slug($filename) . noise(10); // trim the edges return trim($filename, $dash); }
$input['css'] = " "; } if (is_null($input['js']) || empty($input['js'])) { $input['js'] = " "; } // if there is no slug try and create one from title if (empty($input['slug'])) { $input['slug'] = slug($input['title']); } // convert to ascii $input['slug'] = slug($input['slug']); do { //Check for duplication $isDuplicate = Post::where('slug', '=', $input['slug'])->count() > 0; if ($isDuplicate) { $input['slug'] = slug(noise(10)); } } while ($isDuplicate); $validator->check('slug')->not_regex('#^[0-9_-]+$#', __('posts.slug_invalid')); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('admin/posts/add'); } if (empty($input['created'])) { $input['created'] = Date::mysql('now'); } $user = Auth::user(); $input['author'] = $user->id; if (is_null($input['comments'])) { $input['comments'] = 0;
<?php def_printfer('p', "%s\n"); p(1); catcher('warning', function () { echo "warning!\n"; }); noise('warning'); p(2); catcher('warning', function () { echo "error!\n"; }); noise('warning'); p(3); ?> --- 1 warning! 2 error! 3
Route::post('admin/amnesia', array('before' => 'csrf', 'main' => function () { $email = Input::get('email'); $validator = new Validator(array('email' => $email)); $query = User::where('email', '=', $email); $validator->add('valid', function ($email) use($query) { return $query->count(); }); $validator->check('email')->is_email(__('users.email_missing'))->is_valid(__('users.email_not_found')); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('admin/amnesia'); } $user = $query->fetch(); Session::put('user', $user->id); $token = noise(8); Session::put('token', $token); $uri = Uri::full('admin/reset/' . $token); $subject = __('users.recovery_subject'); $msg = __('users.recovery_message', $uri); mail($user->email, $subject, $msg); Notify::success(__('users.recovery_sent')); return Response::redirect('admin/login'); })); /* Reset password */ Route::get('admin/reset/(:any)', array('before' => 'guest', 'main' => function ($key) { $vars['messages'] = Notify::read(); $vars['token'] = Csrf::token(); $vars['key'] = $token = Session::get('token');
private static function application($settings) { $distro = Braces::compile(APP . 'storage/application.distro.php', array('url' => $settings['metadata']['site_path'], 'index' => mod_rewrite() ? '' : 'index.php', 'key' => noise(), 'language' => $settings['i18n']['language'], 'timezone' => $settings['i18n']['timezone'])); file_put_contents(PATH . 'anchor/config/app.php', $distro); }
function _writeSentence($image, $fg, $english, $sentenceRadius, $type) { global $semirandom; global $count; $width = imagesx($image); $height = imagesy($image); $wordRadius = array(); $float1 = 0; $float2 = 0; $english = trim($english); $charCount = 0; $Sentence = array(); $Sentence = explode(" ", $english); $sentence = array(); $punctuation = array(); $apostrophes = array(); for ($j = 0; $j < count($Sentence); $j++) { $word = array(); $Sentence[$j] = implode("", explode(" ", $Sentence[$j])); $vowel = true; for ($i = 0; $i < strlen($Sentence[$j]); $i++) { $punctuation[$j] = ''; $apostrophes[$j][$i] = false; if ($i != 0) { if ($Sentence[$j][$i] == $Sentence[$j][$i - 1]) { $word[count($word) - 1] = $word[count($word) - 1] . '@'; continue; } } if ($Sentence[$j][$i] == 'a' || $Sentence[$j][$i] == 'e' || $Sentence[$j][$i] == 'i' || $Sentence[$j][$i] == 'o' || $Sentence[$j][$i] == 'u') { if ($vowel) { $word[] = str($Sentence[$j][$i]); } else { $word[count($word) - 1] = $word[count($word) - 1] . $Sentence[$j][$i]; } $vowel = true; } else { if ($Sentence[$j][$i] == '.' || $Sentence[$j][$i] == '?' || $Sentence[$j][$i] == '!' || $Sentence[$j][$i] == '"' || $Sentence[$j][$i] == "'" || $Sentence[$j][$i] == '-' || $Sentence[$j][$i] == ',' || $Sentence[$j][$i] == ';' || $Sentence[$j][$i] == ':') { if ($Sentence[$j][$i] == "'") { $apostrophes[$j][$i] = true; } else { $punctuation[$j] = $Sentence[$j][$i]; } } else { $word[] = str($Sentence[$j][$i]); if ($Sentence[$j][$i] == 't' || $Sentence[$j][$i] == '$' || $Sentence[$j][$i] == 'r' || $Sentence[$j][$i] == 's' || $Sentence[$j][$i] == 'v' || $Sentence[$j][$i] == 'w') { $vowel = true; } else { $vowel = false; } } } } $sentence[$j] = $word; $charCount += count($word); } //stroke($fg); if ($type > 0) { //imagesetthickness($image, 3); imageellipse($image, $width / 2, $height / 2, $sentenceRadius * 2, $sentenceRadius * 2, $fg); } //imagesetthickness($image, 4); imageellipse($image, $width / 2, $height / 2, $sentenceRadius * 2 + 40, $sentenceRadius * 2 + 40, $fg); $pos = PI / 2; $maxRadius = 0; for ($i = 0; $i < count($sentence); $i++) { $wordRadius[] = constrain($sentenceRadius * count($sentence[$i]) / $charCount * 1.2, 0, $sentenceRadius / 2); if ($wordRadius[$i] > $maxRadius) { $maxRadius = $wordRadius[$i]; } } $scaleFactor = $sentenceRadius / ($maxRadius + $sentenceRadius / 2); $distance = $scaleFactor * $sentenceRadius / 2; for ($i = 0; $i < count($wordRadius); $i++) { $wordRadius[$i] *= $scaleFactor; } $x = array(); $y = array(); //stroke($fg); for ($i = 0; $i < count($sentence); $i++) { $x[] = $width / 2 + $distance * cos($pos); $y[] = $height / 2 + $distance * sin($pos); $nextIndex = 0; if ($i != count($sentence) - 1) { $nextIndex = $i + 1; } $pos -= (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * TWO_PI; $pX = $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius; $pY = $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius; switch ($punctuation[$i]) { case '.': imageellipse($image, $pX, $pY, 20, 20, $fg); break; case '?': _makeDots($image, $fg, $width / 2, $height / 2, $sentenceRadius * 1.4, 2, -1.2, 0.1); break; case '!': _makeDots($image, $fg, $width / 2, $height / 2, $sentenceRadius * 1.4, 3, -1.2, 0.1); break; case '"': imageline($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg); break; case '-': imageline($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg); imageline($image, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.3) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.2) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.2) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) + 0.3) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg); imageline($image, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.3) / (2 * $charCount) * PI) * $sentenceRadius, $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.2) / (2 * $charCount) * PI) * $sentenceRadius, $width / 2 + cos($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.2) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $height / 2 + sin($pos + (count($sentence[$i]) + count($sentence[$nextIndex]) - 0.3) / (2 * $charCount) * PI) * ($sentenceRadius + 20), $fg); break; case ',': //fill($fg); imagefilledellipse($image, $pX, $pY, 20, 20, $fg); //noFill(); break; case ';': //fill($fg); imagefilledellipse($image, $width / 2 + cos($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius - 10, $height / 2 + sin($pos + (double) (count($sentence[$i]) + count($sentence[$nextIndex])) / (2 * $charCount) * PI) * $sentenceRadius - 10, 10, 10, $fg); //noFill(); break; case ':': imageellipse($image, $pX, $pY, 25, 25, $fg); //imagesetthickness($image, 2); imageellipse($image, $pX, $pY, 15, 15, $fg); //imagesetthickness($image, 4); break; default: break; } } $otherIndex = 0; $nested = array(); for ($i = 0; $i < count($sentence); $i++) { $angle1 = 0; //angle facing onwards $angle2 = 0; //backwards if ($i == count($sentence) - 1) { $otherIndex = 0; } else { $otherIndex = $i + 1; } $angle1 = atan_wrapper($y[$i] - $y[$otherIndex], $x[$i] - $x[$otherIndex]); if (dist($x[$i] + cos($angle1) * 20, $y[$i] + sin($angle1) * 20, $x[$otherIndex], $y[$otherIndex]) > dist($x[$i], $y[$i], $x[$otherIndex], $y[$otherIndex])) { $angle1 -= PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } $angle1 -= PI / 2; if ($angle1 < 0) { $angle1 += TWO_PI; } $angle1 = TWO_PI - $angle1; $index = round(map($angle1, 0, TWO_PI, 0, (double) count($sentence[$i]))); if ($index == count($sentence[$i])) { $index = 0; } $tempChar = $sentence[$i][$index][0]; if (($tempChar == 't' || $tempChar == '$' || $tempChar == 'r' || $tempChar == 's' || $tempChar == 'v' || $tempChar == 'w') && $type > 0) { $nested[$i][$index] = true; $wordRadius[$i] = constrain($wordRadius[$i] * 1.2, 0, $maxRadius * $scaleFactor); while (dist($x[$i], $y[$i], $x[$otherIndex], $y[$otherIndex]) > $wordRadius[$i] + $wordRadius[$otherIndex]) { $x[$i] = lerp($x[$i], $x[$otherIndex], 0.05); $y[$i] = lerp($y[$i], $y[$otherIndex], 0.05); } } } $lineX = array(); $lineY = array(); $arcBegin = array(); $arcEnd = array(); $lineRad = array(); //imagesetthickness($image, 2); if ($type == 0) { $wordRadius[0] = $sentenceRadius * 0.9; $x[0] = $width / 2; $y[0] = $height / 2; } for ($i = 0; $i < count($sentence); $i++) { $pos = PI / 2; $letterRadius = $wordRadius[$i] / (count($sentence[$i]) + 1) * 1.5; for ($j = 0; $j < count($sentence[$i]); $j++) { if ($apostrophes[$i][$j]) { $a = $pos + PI / count($sentence[$i]) - 0.1; $d = 0; $tempX = $x[$i]; $tempY = $y[$i]; while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) { $tempX = $x[$i] + cos($a) * $d; $tempY = $y[$i] + sin($a) * $d; $d += 1; } imageline($image, $x[$i] + cos($a) * $wordRadius[$i], $y[$i] + sin($a) * $wordRadius[$i], $tempX, $tempY, $fg); $a = $pos + PI / count($sentence[$i]) + 0.1; $d = 0; $tempX = $x[$i]; $tempY = $y[$i]; while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) { $tempX = $x[$i] + cos($a) * $d; $tempY = $y[$i] + sin($a) * $d; $d += 1; } imageline($image, $x[$i] + cos($a) * $wordRadius[$i], $y[$i] + sin($a) * $wordRadius[$i], $tempX, $tempY, $fg); } $vowel = true; $tempX = 0; $tempY = 0; //single vowels if ($sentence[$i][$j][0] == 'a') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][0] == 'e') { $tempX = $x[$i] + cos($pos) * $wordRadius[$i]; $tempY = $y[$i] + sin($pos) * $wordRadius[$i]; imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][0] == 'i') { $tempX = $x[$i] + cos($pos) * $wordRadius[$i]; $tempY = $y[$i] + sin($pos) * $wordRadius[$i]; imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos + PI / 2; $arcEnd[] = $pos + 3 * PI / 2; $lineRad[] = $letterRadius; } else { if ($sentence[$i][$j][0] == 'o') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius / 1.6); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius / 1.6); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][0] == 'u') { $tempX = $x[$i] + cos($pos) * $wordRadius[$i]; $tempY = $y[$i] + sin($pos) * $wordRadius[$i]; imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos - PI / 2; $arcEnd[] = $pos + PI / 2; $lineRad[] = $letterRadius; } else { $vowel = false; } } } } } if ($vowel) { imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg); if (strlen($sentence[$i][$j]) == 1) { } else { //double vowels if ($sentence[$i][$j][1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg); } } } else { // consonants if ($sentence[$i][$j][0] == 'b' || $sentence[$i][$j][0] == '#' || $sentence[$i][$j][0] == 'd' || $sentence[$i][$j][0] == 'f' || $sentence[$i][$j][0] == 'g' || $sentence[$i][$j][0] == 'h') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 0.95); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 0.95); _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2); $lines = 0; if ($sentence[$i][$j][0] == '#') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1); } else { if ($sentence[$i][$j][0] == 'd') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1); } else { if ($sentence[$i][$j][0] == 'f') { $lines = 3; } else { if ($sentence[$i][$j][0] == 'g') { $lines = 1; } else { if ($sentence[$i][$j][0] == 'h') { $lines = 2; } } } } } for ($k = 0; $k < $lines; $k++) { $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos + 0.5; $arcEnd[] = $pos + TWO_PI - 0.5; $lineRad[] = $letterRadius * 2; } if (strlen($sentence[$i][$j]) > 1) { $vowelIndex = 1; if ($sentence[$i][$j][1] == '@') { _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.3, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2); $vowelIndex = 2; } if (strlen($sentence[$i][$j]) == $vowelIndex) { $pos -= TWO_PI / count($sentence[$i]); continue; } if ($sentence[$i][$j][$vowelIndex] == 'a') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'e') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'i') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos + PI / 2; $arcEnd[] = $pos + 3 * PI / 2; $lineRad[] = $letterRadius; } else { if ($sentence[$i][$j][$vowelIndex] == 'o') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'u') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos - PI / 2; $arcEnd[] = $pos + PI / 2; $lineRad[] = $letterRadius; } } } } } if (strlen($sentence[$i][$j]) == $vowelIndex + 2) { if ($sentence[$i][$j][$vowelIndex + 1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg); } } } } if ($sentence[$i][$j][0] == 'j' || $sentence[$i][$j][0] == 'k' || $sentence[$i][$j][0] == 'l' || $sentence[$i][$j][0] == 'm' || $sentence[$i][$j][0] == 'n' || $sentence[$i][$j][0] == 'p') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius); imageellipse($image, $tempX, $tempY, $letterRadius * 1.9, $letterRadius * 1.9, $fg); imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg); $lines = 0; if ($sentence[$i][$j][0] == 'k') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1); } else { if ($sentence[$i][$j][0] == 'l') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1); } else { if ($sentence[$i][$j][0] == 'm') { $lines = 3; } else { if ($sentence[$i][$j][0] == 'n') { $lines = 1; } else { if ($sentence[$i][$j][0] == 'p') { $lines = 2; } } } } } for ($k = 0; $k < $lines; $k++) { $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = 0; $arcEnd[] = TWO_PI; $lineRad[] = $letterRadius * 1.9; } if (strlen($sentence[$i][$j]) > 1) { $vowelIndex = 1; if ($sentence[$i][$j][1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 2.3, $letterRadius * 2.3, $fg); $vowelIndex = 2; } if (strlen($sentence[$i][$j]) == $vowelIndex) { $pos -= TWO_PI / count($sentence[$i]); continue; } if ($sentence[$i][$j][$vowelIndex] == 'a') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'e') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'i') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos + PI / 2; $arcEnd[] = $pos + 3 * PI / 2; $lineRad[] = $letterRadius; } else { if ($sentence[$i][$j][$vowelIndex] == 'o') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius * 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius * 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'u') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos - PI / 2; $arcEnd[] = $pos + PI / 2; $lineRad[] = $letterRadius; } } } } } if (strlen($sentence[$i][$j]) == $vowelIndex + 2) { if ($sentence[$i][$j][$vowelIndex + 1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 1.3, $letterRadius * 1.3, $fg); } } } } if ($sentence[$i][$j][0] == 't' || $sentence[$i][$j][0] == '$' || $sentence[$i][$j][0] == 'r' || $sentence[$i][$j][0] == 's' || $sentence[$i][$j][0] == 'v' || $sentence[$i][$j][0] == 'w') { $tempX = $x[$i] + cos($pos) * $wordRadius[$i]; $tempY = $y[$i] + sin($pos) * $wordRadius[$i]; $nextIndex; if ($i == count($sentence) - 1) { $nextIndex = 0; } else { $nextIndex = $i + 1; } $angle1 = atan_wrapper($y[$i] - $y[$nextIndex], $x[$i] - $x[$nextIndex]); if (dist($x[$i] + cos($angle1) * 20, $y[$i] + sin($angle1) * 20, $x[$nextIndex], $y[$nextIndex]) > dist($x[$i], $y[$i], $x[$nextIndex], $y[$nextIndex])) { $angle1 -= PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } if (isset($nested[$i][$j])) { _makeArcs($image, $fg, $x[$nextIndex], $y[$nextIndex], $x[$i], $y[$i], $wordRadius[$i], $wordRadius[$nextIndex] + 20, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2); } else { _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.5, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $float1, $float2); } $lines = 0; if ($sentence[$i][$j][0] == '$') { if (isset($nested[$i][$j])) { _makeDots($image, $fg, $x[$nextIndex], $y[$nextIndex], $wordRadius[$nextIndex] * 1.4 + 14, 2, $angle1, $wordRadius[$nextIndex] / 500); } else { _makeDots($image, $fg, $tempX, $tempY, $letterRadius * 2.6, 2, $pos, 0.5); } } else { if ($sentence[$i][$j][0] == 'r') { if (isset($nested[$i][$j])) { _makeDots($image, $fg, $x[$nextIndex], $y[$nextIndex], $wordRadius[$nextIndex] * 1.4 + 14, 3, $angle1, $wordRadius[$nextIndex] / 500); } else { _makeDots($image, $fg, $tempX, $tempY, $letterRadius * 2.6, 3, $pos, 0.5); } } else { if ($sentence[$i][$j][0] == 's') { $lines = 3; } else { if ($sentence[$i][$j][0] == 'v') { $lines = 1; } else { if ($sentence[$i][$j][0] == 'w') { $lines = 2; } } } } } if (isset($nested[$i][$j])) { for ($k = 0; $k < $lines; $k++) { $lineX[] = $x[$nextIndex]; $lineY[] = $y[$nextIndex]; $arcBegin[] = $float1; $arcEnd[] = $float2; $lineRad[] = $wordRadius[$nextIndex] * 2 + 40; } } else { for ($k = 0; $k < $lines; $k++) { $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $float1; $arcEnd[] = $float2; $lineRad[] = $letterRadius * 3; } } if (strlen($sentence[$i][$j]) > 1) { if ($sentence[$i][$j][1] == '@') { if (isset($nested[$i][$j])) { _makeArcs($image, $fg, $x[$nextIndex], $y[$nextIndex], $x[$i], $y[$i], $wordRadius[$i], ($wordRadius[$nextIndex] + 20) * 1.2, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2); } else { _makeArcs($image, $fg, $tempX, $tempY, $x[$i], $y[$i], $wordRadius[$i], $letterRadius * 1.8, $pos + TWO_PI, $pos - TWO_PI, $float1, $float2); } } } } if ($sentence[$i][$j][0] == '%' || $sentence[$i][$j][0] == 'y' || $sentence[$i][$j][0] == 'z' || $sentence[$i][$j][0] == '&' || $sentence[$i][$j][0] == 'q' || $sentence[$i][$j][0] == 'x') { $tempX = $x[$i] + cos($pos) * $wordRadius[$i]; $tempY = $y[$i] + sin($pos) * $wordRadius[$i]; imageellipse($image, $tempX, $tempY, $letterRadius * 2, $letterRadius * 2, $fg); imagearc_radians($image, $x[$i], $y[$i], $wordRadius[$i] * 2, $wordRadius[$i] * 2, $pos - PI / count($sentence[$i]), $pos + PI / count($sentence[$i]), $fg); $lines = 0; if ($sentence[$i][$j][0] == 'y') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 2, $pos, 1); } else { if ($sentence[$i][$j][0] == 'z') { _makeDots($image, $fg, $tempX, $tempY, $letterRadius, 3, $pos, 1); } else { if ($sentence[$i][$j][0] == '&') { $lines = 3; } else { if ($sentence[$i][$j][0] == 'q') { $lines = 1; } else { if ($sentence[$i][$j][0] == 'x') { $lines = 2; } } } } } for ($k = 0; $k < $lines; $k++) { $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = 0; $arcEnd[] = TWO_PI; $lineRad[] = $letterRadius * 2; } if (strlen($sentence[$i][$j]) > 1) { $vowelIndex = 1; if ($sentence[$i][$j][1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 2.3, $letterRadius * 2.3, $fg); $vowelIndex = 2; } if (strlen($sentence[$i][$j]) == $vowelIndex) { $pos -= TWO_PI / count($sentence[$i]); continue; } if ($sentence[$i][$j][$vowelIndex] == 'a') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] + $letterRadius / 2); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] + $letterRadius / 2); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'e') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'i') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos + PI / 2; $arcEnd[] = $pos + 3 * PI / 2; $lineRad[] = $letterRadius; } else { if ($sentence[$i][$j][$vowelIndex] == 'o') { $tempX = $x[$i] + cos($pos) * ($wordRadius[$i] - $letterRadius); $tempY = $y[$i] + sin($pos) * ($wordRadius[$i] - $letterRadius); imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); } else { if ($sentence[$i][$j][$vowelIndex] == 'u') { imageellipse($image, $tempX, $tempY, $letterRadius, $letterRadius, $fg); $lineX[] = $tempX; $lineY[] = $tempY; $arcBegin[] = $pos - PI / 2; $arcEnd[] = $pos + PI / 2; $lineRad[] = $letterRadius; } } } } } if (strlen($sentence[$i][$j]) == $vowelIndex + 2) { if ($sentence[$i][$j][$vowelIndex + 1] == '@') { imageellipse($image, $tempX, $tempY, $letterRadius * 1.8, $letterRadius * 1.8, $fg); } } } } } $pos -= TWO_PI / count($sentence[$i]); } } //imagesetthickness($image, 2); $lineLengths = array(); //stroke($fg); $used = new UsedLines(); for ($i = 0; $i < count($lineX); $i++) { $indexes = array(); $angles = array(); for ($j = 0; $j < count($lineX); $j++) { if (round($lineY[$i]) == round($lineY[$j]) && round($lineX[$i]) == round($lineX[$j])) { continue; } if ($used->exists($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j])) { continue; } $b = false; for ($k = 0; $k < count($lineLengths); $k++) { if ($lineLengths[$k] == dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j]) + $lineX[$i] + $lineY[$i] + $lineX[$j] + $lineY[$j]) { $b = true; break; } } if ($b) { continue; } $angle1 = atan_wrapper($lineY[$i] - $lineY[$j], $lineX[$i] - $lineX[$j]); if (dist($lineX[$i] + cos($angle1) * 20, $lineY[$i] + sin($angle1) * 20, $lineX[$j], $lineY[$j]) > dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j])) { $angle1 -= PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } if ($angle1 < 0) { $angle1 += TWO_PI; } if ($angle1 < $arcEnd[$i] && $angle1 > $arcBegin[$i]) { $angle1 -= PI; if ($angle1 < 0) { $angle1 += TWO_PI; } if ($angle1 < $arcEnd[$j] && $angle1 > $arcBegin[$j]) { $indexes[] = $j; $angles[] = $angle1; } } } if (count($indexes) == 0) { $a = 0; if ($semirandom) { $a = map(noise($count + $i * 5), 0, 1, $arcBegin[$i], $arcEnd[$i]); } else { $a = random($arcBegin[$i], $arcEnd[$i]); } $d = 0; $tempX = $lineX[$i] + cos($a) * $d; $tempY = $lineY[$i] + sin($a) * $d; while (pow($tempX - $width / 2, 2) + pow($tempY - $height / 2, 2) < pow($sentenceRadius + 20, 2)) { $tempX = $lineX[$i] + cos($a) * $d; $tempY = $lineY[$i] + sin($a) * $d; $d += 1; } imageline($image, $lineX[$i] + cos($a) * $lineRad[$i] / 2, $lineY[$i] + sin($a) * $lineRad[$i] / 2, $tempX, $tempY, $fg); } else { $r; if ($semirandom) { $r = 0; } else { $r = floor(random(count($indexes))); } $j = $indexes[$r]; $a = $angles[$r] + PI; imageline($image, $lineX[$i] + cos($a) * $lineRad[$i] / 2, $lineY[$i] + sin($a) * $lineRad[$i] / 2, $lineX[$j] + cos($a + PI) * $lineRad[$j] / 2, $lineY[$j] + sin($a + PI) * $lineRad[$j] / 2, $fg); $lineLengths[] = dist($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j] + $lineX[$i] + $lineY[$i] + $lineX[$j] + $lineY[$j]); $used->add($lineX[$i], $lineY[$i], $lineX[$j], $lineY[$j]); $templineX = array(); $templineY = array(); $temparcBegin = array(); $temparcEnd = array(); $templineRad = array(); for ($k = 0; $k < count($lineX); $k++) { if ($k != $j && $k != $i) { $templineX[] = $lineX[$k]; $templineY[] = $lineY[$k]; $temparcBegin[] = $arcBegin[$k]; $temparcEnd[] = $arcEnd[$k]; $templineRad[] = $lineRad[$k]; } } $lineX = $templineX; $lineY = $templineY; $arcBegin = $temparcBegin; $arcEnd = $temparcEnd; $lineRad = $templineRad; $i -= 1; } } }
<?php catcher('warning', function ($one, $two, $three) { echo $one . $two . $three; }); noise('warning', 1, 2, 3); ?> --- 123