Пример #1
0
     // Hash the url
     $filename = get_filename($url);
 } else {
     // No URL set so error
     header('HTTP/1.0 400 Bad Request');
     echo "No URL was specified";
     $ok = false;
 }
 if ($ok) {
     if (file_exists($filename)) {
         // Send cached file
         $file = file_get_contents($filename, false, NULL, strlen($garbage));
     } else {
         // Load the image and save the file if valid image if found
         // Get the contents of the URL
         $file = file_get_contents(my_urlencode($url));
         // Check if it is an image
         $img = @imagecreatefromstring($file);
         if ($img) {
             $max = 800;
             $w = imagesx($img);
             $h = imagesy($img);
             if ($w > $max || $h > $max) {
                 // Resize the image if needed
                 $scale = min($max / $w, $max / $h);
                 $new_w = intval($scale * $w);
                 $new_h = intval($scale * $h);
                 $new_img = imagecreatetruecolor($new_w, $new_h);
                 imagecopyresampled($new_img, $img, 0, 0, 0, 0, $new_w, $new_h, $w, $h);
                 imagedestroy($img);
                 imagejpeg($new_img, $filename);
Пример #2
0
echo '		</select>
			<table class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>Source</th>
						<th>Your translation</th>
					</tr>
				</thead>
				<tbody>';
foreach ($translations_source as $translation_source) {
    echo '			<tr ' . (!isset($translations[$translation_source]) ? 'class="error"' : '') . '>
						<td>
							' . htmlspecialchars($translation_source, ENT_NOQUOTES, 'utf-8') . '
						</td>
						<td>
							<input type="text" name="' . my_urlencode($translation_source) . '"
								' . (isset($translations[$translation_source]) ? 'value="' . htmlspecialchars($translations[$translation_source], ENT_COMPAT, 'utf-8') . '"' : '') . '
							/>
						</td>
					</tr>';
}
echo '			</tbody>
			</table>
			<input type="submit" name="submitTranslations" class="btn btn-primary" />
		</form>
	</body>
</html>';
function just_quotes($s)
{
    return addcslashes($s, '\\\'');
}