Example #1
0
function scandirectory($dir)
{
    // create an array for directory content
    $dir_content = array();
    if (file_exists($dir)) {
        foreach (scandir($dir) as $f) {
            if (!$f || $f[0] == '.') {
                continue;
            }
            if (is_dir($dir . DS . $f)) {
                $dir_content[] = array("name" => $f, "type" => "folder", "path" => $dir . DS . $f, "items" => scandirectory($dir . DS . $f));
            } else {
                $dir_content[] = array("name" => $f, "type" => "file", "path" => $dir . DS . $f, "size" => filesize($dir . DS . $f));
            }
        }
    }
    return $dir_content;
}
Example #2
0
        $newresponse = $newresponse->withStatus(401);
    }
    return $newresponse;
});
//API function:GET:Get file list
$app->get('/getfilelist/{token}/{user_id}', function (Request $request, Response $response, $args) use($app) {
    //set output header: content-type
    $newresponse = $response->withHeader('Content-type', 'application/json');
    //check if token is expired or invalid
    if (!checktoken($args['user_id'], $args['token'])) {
        //request not authorised
        $newresponse = $newresponse->withStatus(401);
        //return $newresponse;
        return $newresponse;
    }
    $tmp = json_encode(scandirectory("."));
    $newresponse->getBody()->write($tmp);
    return $newresponse;
});
//API function:GET:Download specific file
$app->get('/getfile/{id}/{token}/{user_id}', function (Request $request, Response $response, $args) use($app) {
    //set output header: content-type
    $newresponse = $response->withHeader('Content-type', 'application/json');
    //check if token is expired or invalid
    if (!checktoken($args['user_id'], $args['token'])) {
        //request not authorised
        $newresponse = $newresponse->withStatus(401);
        //return $newresponse;
        return $newresponse;
    }
    //id is id of file from database
Example #3
0
<?php

require_once '../../includes/functions.php';
require_once '../../includes/defines.php';
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    if (isset($_POST['apiKey']) && trim($_POST['apiKey']) == '123') {
        $files = scandirectory(STORAGE_ROOT);
        header('Content-type: application/json');
        echo json_encode(array('status' => 'ok', 'files' => $files));
    }
}
die;
Example #4
0
 <?php 
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    if (isset($_POST['apiKey']) && trim($_POST['apiKey']) == '123') {
        require_once __DIR__ . '/../../functions/functions.php';
        $dir = realpath(__DIR__ . '/../../storage');
        $files = scandirectory($dir);
        header('Content-type: application/json');
        echo json_encode(array('status' => 'ok', 'files' => $files));
    }
}
die;
Example #5
0
             if ($option->option_value == $variable->value) {
                 $content .= ' selected="selected" ';
             }
             $content .= '>&nbsp;' . $option->option_text . "</option>\n";
         }
     }
     $content .= '</select>' . "\n";
     $content .= '</span>' . "\n";
 } elseif (strtolower($variable->type) == 'image') {
     $options = $wpdb->get_results("SELECT * FROM " . $canvas->options . " WHERE var_id = '{$variable->variable_id}'");
     $content .= '<p>' . $variable->description . ':</p>';
     $content .= '<input type="hidden" id="directory" value="' . $options[0]->option_value . '">';
     $selected = '<input type="hidden" id="selected_image">';
     $content .= '<input type="hidden" id="path" name="' . $variable->variable_name . '" value="' . $variable->value . '">';
     $content .= '<div class="gallery">';
     $files = scandirectory(ABSPATH . $options[0]->option_value);
     foreach ($files as $file) {
         $class = '';
         if (substr($file, -3) == 'jpg' || substr($file, -3) == 'gif' || substr($file, -3) == 'png') {
             if ($options[0]->option_value . $file == $variable->value) {
                 $class = 'class="selected_image"';
                 $selected = '<input type="hidden" id="selected_image" value="' . $file . '">';
             }
             list($width, $height) = @getimagesize(get_bloginfo('wpurl') . '/' . $options[0]->option_value . $file);
             if ($width > 250) {
                 $height = $height * 250 / $width;
                 $width = 250;
             }
             $content .= '<a href="javascript:void(0)" onclick="Canvas.gallerySwitch(\'' . $file . '\')"><img ' . $class . ' id="' . $file . '" src="' . get_bloginfo('wpurl') . '/' . $options[0]->option_value . $file . '" title="' . $file . '" alt="' . $file . '" style="height: ' . $height . 'px; width: ' . $width . 'px;" /></a>';
         }
     }