Beispiel #1
0
function generatemyimg($imgid)
{
    //include('bdd.php');
    $finalimg = '';
    $query = 'SELECT img FROM astropix_articles WHERE id = ' . $imgid;
    // 		$req = $bdd->prepare($query);
    // 		try { $req->execute(); }
    // 		catch (Exception $e) { return false;}
    // 		$data = $req->fetch();
    $data = reqex($query);
    if (!$data or !preg_match('#(\\.jpg|\\.jpeg|\\.png|\\.gif)$#isU', $data['img'])) {
        $finalimg = 'cross.png';
    } else {
        if (preg_match('#(\\.jpg|\\.jpeg)$#isU', $data['img'])) {
            $img = imagecreatefromjpeg($data['img']);
        } elseif (preg_match('#(\\.png)$#isU', $data['img'])) {
            $img = imagecreatefrompng($data['img']);
        } elseif (preg_match('#(\\.gif)$#isU', $data['img'])) {
            $img = imagecreatefromgif($data['img']);
        } else {
            return false;
        }
        $max = 115;
        $x = imagesx($img);
        $y = imagesy($img);
        if ($x > $max or $y > $max) {
            if ($x > $y) {
                $nx = $max;
                $ny = $y / ($x / $max);
            } else {
                $nx = $x / ($y / $max);
                $ny = $max;
            }
        }
        $nimg = imagecreatetruecolor($nx, $ny);
        imagecopyresampled($nimg, $img, 0, 0, 0, 0, $nx, $ny, $x, $y);
        if (preg_match('#(\\.jpg|\\.jpeg)$#isU', $data['img'])) {
            imagejpeg($nimg, 'images/' . $imgid . '.jpg');
            $finalimg = 'images/' . $imgid . '.jpg';
        } elseif (preg_match('#(\\.png)$#isU', $data['img'])) {
            imagepng($nimg, 'images/' . $imgid . '.png');
            $finalimg = 'images/' . $imgid . '.png';
        } elseif (preg_match('#(\\.gif)$#isU', $data['img'])) {
            imagegif($nimg, 'images/' . $imgid . '.gif');
            $finalimg = 'images/' . $imgid . '.gif';
        } else {
            $finalimg = 'cross.png';
        }
        $imgid = $finalimg;
    }
    //end else !$data
    return $imgid;
}
Beispiel #2
0
        $dbpwd = '';
    }
    $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname;
    $bdd = new PDO($dsn, $dbuser, $dbpwd, $pdo_options);
    $req = $bdd->prepare($query);
    if (preg_match('#SELECT #isU', $query)) {
        try {
            $req->execute();
        } catch (Exception $e) {
            return false;
        }
        $data = $req->fetchAll();
        if (isset($data[0])) {
            $data = $data[0];
        }
        $max = count($data);
        for ($i = 0; $i < $max; $i++) {
            unset($data[$i]);
        }
        return $data;
    } else {
        try {
            $req->execute();
            return true;
        } catch (Exception $e) {
            return false;
        }
    }
}
reqex('SET NAMES "UTF8"');
Beispiel #3
0
<body>
	<div id="contentview">
		<table id="menuview"><?php 
if (!$id) {
    echo '<tr>
					<td class="divview">
						Merci de choisir un article. Redirection dans 5s...
						<script type="text/javascript">setTimeout("window.location.href = \'view.php\';", 5000);</script>
					</td>
				</tr>';
} else {
    if ($data) {
        $id = $data['id'];
        $prev = reqex('SELECT * FROM `astropix_articles` WHERE `artdate` < \'' . $data['artdate'] . '\' ORDER BY `artdate` DESC LIMIT 0, 1');
        $prev = $prev ? $prev['id'] : 0;
        $next = reqex('SELECT * FROM `astropix_articles` WHERE `artdate` > \'' . $data['artdate'] . '\' ORDER BY `artdate` ASC LIMIT 0, 1');
        $next = $next ? $next['id'] : 0;
        echo "\t\t\t<tr>\n";
        echo "\t\t\t\t" . '<th class="divview" colspan="3">';
        if ($next) {
            echo '<a href="viewer.php?id=' . $next . '">&lt;&lt;&lt;</a>&nbsp;';
        }
        echo htmlentities($data['title']);
        if ($prev) {
            echo '&nbsp;<a href="viewer.php?id=' . $prev . '">&gt;&gt;&gt;</a>';
        }
        echo "</th>\n";
        echo "\t\t\t</tr>\n";
        echo "\t\t\t<tr>\n";
        echo "\t\t\t\t" . '<td class="divview" id="artimage" colspan="2">' . "\n";
        echo "\t\t\t\t\t" . '<a href="' . $data['img'] . '" target="_blank">';