<?php

// This is intended for use with Javascript Ajax and as the subject to the
// "<img src=" or as the subject to a Javascript sequence
// like "var i = new Image(); i.src=mysqlslideshow.php?image=2;"
ini_set("error_log", "./ERROR.log");
require "dbclass.connectinfo.i.php";
// has $Host, $User, $Password
if (file_exists("../class")) {
    require_once "../class/mysqlslideshow.class.php";
} else {
    require_once "../vendor/autoload.php";
}
$ss = new MySqlSlideshow($Host, $User, $Password, $Database);
//********************
// This is an Ajax call.
// Get the image given an id.
// The arguments are:
// image=id
// type=raw optional argument, if pressent then the raw image data is returned with the proper mime type header. If not present
//   then returns an echoed data package that can be the argument to "<img src=" tag.
// addinfo=1 optional argument, if present and if not specified as raw then the "<::subject::>text<::description::>text" is
// appended onto the base64 image packet. If type=raw then addinfo is ignored!
if ($_GET['image']) {
    extract($_GET);
    if ($type == 'raw') {
        $ar = $ss->getImage($image, "");
        // the second arg defaults to base64 so here we want to unset it.
        Header("Content-type: {$mime}");
        $data = $ar['data'];
        echo $data;
Example #2
0
// This is a server side example
// Start a PHP Session
session_start();
require_once "dbclass.connectinfo.i.php";
// has $Host, $User, $Password
// This file has the MySqlSlideshow class
if (file_exists("../class")) {
    require_once "../class/mysqlslideshow.class.php";
} else {
    require_once "../vendor/autoload.php";
}
// Construct the slideshow class:
// There is a 4th argument for the database name if not "mysqlslideshow" and a 5th argument for the table name if not
// "mysqlslideshow"
$ss = new MySqlSlideshow($Host, $User, $Password, $Database);
// use values from dbclass.connectinfo.i.php
// for use in <form action="$self" tags.
$self = $_SERVER['PHP_SELF'];
// Check for Microsoft Internet Explorer -- because everything Microsoft makes is broken!
$isIe = preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']);
$ieMsg = $isIe ? '<p style="color: red">Microsoft Internet Explorer Version, because Microsoft can not do it like anyone else!</p>' : "";
// This file should not be in the Apache path for security reasons
//********************
// Start of Slide Show Logic
// NOTE THE ORDER. STOP must be before START and session checking.
// One could of course design this section differently so the
// order was not important but this is only an example of using the CLASS.
if ($_POST['stop']) {
    unset($_SESSION['next']);
    echo <<<EOF
Example #3
0
<?php

// Add selected images from a directory
// This file should not be in the Apache path for security reasons
require_once "dbclass.connectinfo.i.php";
// has $Host, $User, $Password
// This file has the MySqlSlideshow class
if (file_exists("../class")) {
    require_once "../class/mysqlslideshow.class.php";
} else {
    require_once "../vendor/autoload.php";
}
// Construct the slideshow class:
// There is a 4th argument for the database name if not "mysqlslideshow" and a
// 5th argument for the table name if not "mysqlslideshow"
$ss = new MySqlSlideshow($Host, $User, $Password, $Database);
// use values from dbclass.connectinfo.i.php
$self = $_SERVER[PHP_SELF];
// Add Image
if ($_POST) {
    extract($_POST);
    $adding = '';
    for ($i = 0; $i < $count; ++$i) {
        $image = eval("return \$box{$i};");
        if ($image) {
            $subject = eval("return \$subject{$i};");
            $desc = eval("return \$desc{$i};");
            if (($ret = $ss->addImage($image, $subject, $desc, $type)) === true) {
                $adding .= "<p>Image added: {$image}, subject={$subject}, description={$desc}</p>\n";
            } else {
                $adding .= "<p style='color: red'>{$ret}</p>\n";
// Add or Update an Image in the Database table
// This file should not be in the Apache path for security reasons
require_once "dbclass.connectinfo.i.php";
// has $Host, $User, $Password
// This file has the MySqlSlideshow class
if (file_exists("../class")) {
    require_once "../class/mysqlslideshow.class.php";
} else {
    require_once "../vendor/autoload.php";
}
// Construct the slideshow class:
// There is a 4th argument for the database name if not "mysqlslideshow" and
// a 5th argument for the table name if not "mysqlslideshow"
// use values from dbclass.connectinfo.i.php
$ss = new MySqlSlideshow($Host, $User, $Password, $Database);
//********************
// The following section is used to add images and text to the database
// Options to URL:
// ?image=imagefilename&subject=subject&desciption=description
// only image is required.
// ?update=id&subject=subject&desciption=description
// only update id is required but one would think that ether or both additonal arguments
// would make more sense
// With NO arguments slide show plus display table of image info.
if ($image = $_GET['image']) {
    // Add a new image to the table.
    $subject = $_GET['subject'];
    $desc = $_GET['description'];
    $type = $_GET['type'] ? $_GET['type'] : 'link';
    if (($ret = $ss->addImage($image, $subject, $desc, $type)) !== true) {