/**
  * Handles the current node in the xml reading loop.
  * @param DOMNode $node The current xml node
  * @param GetItemRecommendationResult $resultObj The object which will be returned to the end-user
  * @return boolean True if the node was handled
  */
 protected function handleXmlReaderCurrentNode(DOMNode $node, $resultObj)
 {
     if (parent::handleXmlReaderCurrentNode($node, $resultObj)) {
         return true;
     }
     switch ($node->nodeName) {
         case "item":
             $resultObj->setItemId($node->textContent);
             return true;
         case "bundles":
             //bundles list
             foreach ($node->childNodes as $itemNode) {
                 if ($itemNode->nodeName == "item") {
                     $item = new BundleRecommendation();
                     readItem($itemNode, $item);
                     $resultObj->addRecommendedBundles($item);
                 }
             }
             return true;
     }
     return false;
 }
                        <button type="submit" name="rent" class="form-control btn btn-info">Rent</button>
                      </div>
                    </div>
                   
                  </fieldset>
                      </form>
                  
              </div>
                     <?php 
include_once 'Que.php';
if (isset($_POST['upSearch'])) {
    $sTxt = $_POST['upSearchTxt'];
    if (strlen($sTxt) < 1) {
        $upError[] = "enter rentperiod";
    } else {
        readItem($sTxt, "AND status='available'");
    }
}
?>
  <script type="text/javascript">
                    function selectedUpdate(val){
                            record = val.split(",");
                            document.getElementById("itemNo").value=record[0];
                            document.getElementById("title").value=record[2];
//                            document.getElementById("upGenre").value=record[2];
//                            document.getElementById("upDescription").value=record[3];
//                            document.getElementById("upPrice").value=record[4];
//                            document.getElementById("upRentalPeriod").value=record[5];
//                            document.getElementById("upStatus").value=record[6];
//                            document.getElementById("upType").value=\''.$tbl.'\';
//                            alert("wewewew");
 if (empty($total_weight)) {
     $total_weight = 'null';
 }
 if (empty($memo)) {
     $memo = 'null';
 } else {
     $memo = mynl2br($memo);
 }
 $tab = array();
 $tab = file($filename);
 for ($i = 0; $i < sizeof($tab); $i++) {
     @(list($id1, $id_item, $category, $subcategory, $title1, $filename1, $digital, $folder, $currency, $weight, $price, $quantity, $option1, $option2, $tax1, $ship, $discount1, $discount2, $ip_name, $id_cart) = explode('|', $tab[$i]));
     $_SESSION['digital'] = $digital;
     @($cat = $subcategory == 'none' ? $category : $subcategory);
     $ItemFile = 'categories/' . $cat . '/' . $id_item . '.dat';
     $it = readItem($ItemFile);
     if ($it[5] >= $quantity) {
         $qty = $it[5] - $quantity;
     } else {
         $qty = 0;
     }
     $dtqty = $it[0] . '||' . $it[1] . '||' . $it[2] . '||' . $it[3] . '||' . $it[4] . '||' . $qty . '||' . $it[6] . '||' . $it[7] . '||' . $it[8] . '||' . $it[9] . '||' . $it[10] . '||' . $it[11] . '||' . $it[12] . '||' . $it[13] . '||' . $it[14] . '||' . $it[15] . '||' . $it[16] . '||' . $it[17] . '||' . $it[18] . '||' . $it[19] . '||' . $it[20];
     if (!preg_match("#^0{2}#", "{$it['5']}")) {
         $fp = fopen($ItemFile, "w");
         fwrite($fp, $dtqty);
         fclose($fp);
     }
     $opt1 = $option1 == "null" ? '' : ' - ' . $option1;
     $opt2 = $option2 == "null" ? '' : ' - ' . $option2;
     if ($weight == "null") {
         $ShoppingCart .= $quantity . " - " . $title1 . $opt1 . $opt2 . " - " . @number_format($price, 2, '.', ',') . " " . $symbole . "\n";
示例#4
0
    /**
     * Constructor for CGallery.
     *
     *
     */
    public function __construct()
    {
        /**
         * Display error message.
         *
         * @param string $message the error message to display.
         */
        function errorMessage($message)
        {
            header("Status: 404 Not Found");
            die('gallery.php says 404 - ' . htmlentities($message));
        }
        /**
         * Read directory and return all items in a ul/li list.
         *
         * @param string $path to the current gallery directory.
         * @param array $validImages to define extensions on what are considered to be valid images.
         * @return string html with ul/li to display the gallery.
         */
        function readAllItemsInDir($path, $validImages = array('png', 'jpg', 'jpeg', 'gif'))
        {
            $files = glob($path . '/*');
            $gallery = "<ul class='gallery'>\n";
            $len = strlen(GALLERY_PATH);
            foreach ($files as $file) {
                $parts = pathinfo($file);
                $href = str_replace('\\', '/', substr($file, $len + 1));
                // Is this an image or a directory
                if (is_file($file) && in_array($parts['extension'], $validImages)) {
                    $item = "<img src='img.php?src=" . GALLERY_BASEURL . $href . "&amp;width=128&amp;height=128&amp;crop-to-fit' alt=''/>";
                    $caption = basename($file);
                } elseif (is_dir($file)) {
                    $item = "<img src='http://dbwebb.se/kod-exempel/skapa-ett-galleri-av-dina-bilder-med-php/img/folder.png' alt=''/>";
                    $caption = basename($file) . '/';
                } else {
                    continue;
                }
                // Avoid to long captions breaking layout
                $fullCaption = $caption;
                if (strlen($caption) > 18) {
                    $caption = substr($caption, 0, 10) . '…' . substr($caption, -5);
                }
                $gallery .= "<li><a href='?path={$href}' title='{$fullCaption}'><figure class='figure overview'>{$item}<figcaption>{$caption}</figcaption></figure></a></li>\n";
            }
            $gallery .= "</ul>\n";
            return $gallery;
        }
        /**
         * Read and return info on choosen item.
         *
         * @param string $path to the current gallery item.
         * @param array $validImages to define extensions on what are considered to be valid images.
         * @return string html to display the gallery item.
         */
        function readItem($path, $validImages = array('png', 'jpg', 'jpeg', 'gif'))
        {
            $parts = pathinfo($path);
            if (!(is_file($path) && in_array($parts['extension'], $validImages))) {
                return "<p>This is not a valid image for this gallery.";
            }
            // Get info on image
            $imgInfo = list($width, $height, $type, $attr) = getimagesize($path);
            $mime = $imgInfo['mime'];
            $gmdate = gmdate("D, d M Y H:i:s", filemtime($path));
            $filesize = round(filesize($path) / 1024);
            // Get constraints to display original image
            $displayWidth = $width > 800 ? "&amp;width=800" : null;
            $displayHeight = $height > 600 ? "&amp;height=600" : null;
            // Display details on image
            $len = strlen(GALLERY_PATH);
            $href = GALLERY_BASEURL . str_replace('\\', '/', substr($path, $len + 1));
            $item = <<<EOD
<p><img src='img.php?src={$href}{$displayWidth}{$displayHeight}' alt=''/></p>
<p>Original image dimensions are {$width}x{$height} pixels. <a href='img.php?src={$href}'>View original image</a>.</p>
<p>File size is {$filesize}KBytes.</p>
<p>Image has mimetype: {$mime}.</p>
<p>Image was last modified: {$gmdate} GMT.</p>
EOD;
            return $item;
        }
        /**
         * Create a breadcrumb of the gallery query path.
         *
         * @param string $path to the current gallery directory.
         * @return string html with ul/li to display the thumbnail.
         */
        function createBreadcrumb($path)
        {
            $parts = explode('/', trim(substr($path, strlen(GALLERY_PATH) + 1), '/'));
            $breadcrumb = "<ul class='breadcrumb'>\n<li><a href='?'>Hem</a> »</li>\n";
            if (!empty($parts[0])) {
                $combine = null;
                foreach ($parts as $part) {
                    $combine .= ($combine ? '/' : null) . $part;
                    $breadcrumb .= "<li><a href='?path={$combine}'>{$part}</a> » </li>\n";
                }
            }
            $breadcrumb .= "</ul>\n";
            return $breadcrumb;
        }
        //
        // Get incoming parameters
        //
        $path = isset($_GET['path']) ? $_GET['path'] : null;
        $pathComplete = GALLERY_PATH . DIRECTORY_SEPARATOR . $path;
        $pathToGallery = realpath($pathComplete);
        $basePath = realpath(GALLERY_PATH);
        //
        // Validate incoming arguments
        //
        $pathToGallery !== false or errorMessage("The path to the gallery image seems to be a non existing path.");
        $basePath !== false or errorMessage("The basepath to the gallery, GALLERY_PATH, seems to be a non existing path.");
        is_dir(GALLERY_PATH) or errorMessage('The gallery dir "' . GALLERY_PATH . '" is not a valid directory.');
        substr_compare($basePath, $pathToGallery, 0, strlen($basePath)) == 0 or errorMessage("Security constraint: Source gallery is not directly below the directory GALLERY_PATH.\n" . $basePath . "\n" . $pathToGallery);
        //
        // Read and present images in the current directory
        //
        if (is_dir($pathToGallery)) {
            $this->gallery = readAllItemsInDir($pathToGallery);
        } else {
            if (is_file($pathToGallery)) {
                $this->gallery = readItem($pathToGallery);
            }
        }
        //
        // Prepare content and store it all in variables in the Branax container.
        //
        $this->breadcrumb = createBreadcrumb($pathToGallery);
    }
?>
</span><br> -->
                        <button type="submit" name="update" class="form-control btn btn-info">Update</button>
                      </div>
                    </div>

                  </fieldset>
                </form></div>
                   <?php 
include_once 'Que.php';
if (isset($_POST['upSearch1'])) {
    $sTxt1 = $_POST['upSearchTxt1'];
    if (strlen($sTxt1) < 1) {
        $upError[] = "enter something";
    } else {
        readItem($sTxt1);
    }
}
?>
                  <script type="text/javascript">
                    function selectedUpdate(val){
                             records = val.split(",");
                            document.getElementById("itNo").value=records[0];
                            document.getElementById("title1").value=records[1];
                            document.getElementById("stats1").value=records[2];
                             document.getElementById("type1").value=<?php 
echo "{$sType}";
?>
;
                            record = val.split(",");
                            document.getElementById("upList").value=record[0];
示例#6
0
            header('Access-Control-Allow-Methods: GET,POST,DELETE,OPTIONS');
            break;
        default:
            throw new InvalidArgumentException('Unsupported HTTP verb: ' . $method);
    }
} else {
    // Item
    if (!array_key_exists($id, $data)) {
        throw new InvalidArgumentException('Unknown item: ' . $id);
    }
    switch ($method) {
        case 'GET':
            echo readItem($data, $id);
            break;
        case 'DELETE':
            $data = deleteItem($data, $id);
            saveData($data);
            break;
        case 'PATCH':
            $payload = getPayload();
            $data = updateItem($data, $id, $payload);
            saveData($data);
            echo readItem($data, $id);
            break;
        case 'OPTIONS':
            header('Access-Control-Allow-Methods: GET,DELETE,PATCH,OPTIONS');
            break;
        default:
            throw new InvalidArgumentException('Unsupported HTTP verb: ' . $method);
    }
}