示例#1
0
function processRequest(&$db)
{
    ob_end_clean();
    include_once BASE_PATH . "/lib/output.php";
    Output::buffer();
    $link = "http://mywebsql.net/updates.php?j=1&" . "c=MyWebSQL&l=" . urlencode(LANGUAGE) . "&v=" . urlencode(APP_VERSION) . "&t=" . urlencode(THEME_PATH);
    // include compact edition in update if we are using one
    if (defined('MYWEBSQL_COMPACT_DIST')) {
        $link .= "&e=compact";
    }
    $output = "";
    if (ini_get("allow_url_fopen")) {
        $output = file_get_contents($link);
    } else {
        $output = curl_get($link);
    }
    Session::set('updates', 'check', '1');
    echo $output;
    $db->disconnect();
    Output::flush();
    die;
}
示例#2
0
 * @author     Samnan ur Rehman
 * @copyright  (c) 2008-2014 Samnan ur Rehman
 * @web        http://mywebsql.net
 * @license    http://mywebsql.net/license
 */
define('BASE_PATH', dirname(__FILE__));
header("Content-Type: text/html;charset=utf-8");
include_once BASE_PATH . "/lib/session.php";
Session::init();
date_default_timezone_set('UTC');
include BASE_PATH . '/modules/configuration.php';
initConfiguration();
// buffer unless we are in the download module (it will handle the buffering itself)
if (v($_REQUEST["type"]) != "dl") {
    include_once BASE_PATH . "/lib/output.php";
    Output::buffer();
} else {
    $_REQUEST["type"] = 'download';
}
if (defined("TRACE_FILEPATH") && TRACE_FILEPATH && defined("TRACE_MESSAGES") && TRACE_MESSAGES) {
    ini_set("error_log", TRACE_FILEPATH);
}
include_once BASE_PATH . "/lib/util.php";
require BASE_PATH . '/modules/auth.php';
$auth_module = new MyWebSQL_Authentication();
if (!$auth_module->authenticate()) {
    if (v($_REQUEST["q"]) == "wrkfrm") {
        echo view('session_expired');
    } else {
        include BASE_PATH . "/modules/splash.php";
        $form = view('auth', array('LOGINID' => htmlspecialchars($auth_module->getUserName()), 'SERVER_NAME' => htmlspecialchars($auth_module->getCustomServer()), 'SERVER_TYPE' => htmlspecialchars($auth_module->getCustomServerType())));
示例#3
0
/**
 * This file is a part of MyWebSQL package
 *
 * @file:      modules/viewblob.php
 * @author     Samnan ur Rehman
 * @copyright  (c) 2008-2012 Samnan ur Rehman
 * @web        http://mywebsql.net
 * @license    http://mywebsql.net/license
 */
function processRequest(&$db)
{
    // verify that the blob data is from the existing and valid query
    $queryCode = v($_REQUEST['query']);
    if (Session::get('select', 'query') == "" || md5(Session::get('select', 'query')) != $queryCode) {
        echo view('invalid_request');
        return;
    }
    $id = v($_REQUEST["id"]);
    $name = v($_REQUEST["name"]);
    $isEditable = isBlobEditable();
    $table = Session::get('select', 'unique_table');
    // Session::get('select', 'table')
    $message = '';
    if (v($_REQUEST['act']) == 'save' && $isEditable && count($_FILES) > 0 && isset($_FILES['blobdata'])) {
        $result = saveBlobData($db, $table, $id, $name);
        $message = $result ? '<div class="message ui-state-default">' . __('Blob data saved') . '</div>' : '<div class="message ui-state-error">' . __('Failed to save blob data') . '</div>';
        unset($_REQUEST["blobtype"]);
    }
    include BASE_PATH . "/config/blobs.php";
    $bType = v($_REQUEST["blobtype"]) && array_key_exists(v($_REQUEST["blobtype"]), $blobTypes) ? v($_REQUEST["blobtype"]) : "txt";
    // @todo: optimize. this should always fetch one row
    $blobOptions = '';
    $query = Session::get('select', 'query');
    if ($table == "") {
        $applyLimit = true;
    } else {
        $applyLimit = strpos($query, "limit ");
    }
    if ($applyLimit == false) {
        $query .= $db->getLimit(1, $id);
    }
    if (!$db->query($query) || $db->numRows() == 0) {
        echo view('error_page');
        return;
    }
    $row = $applyLimit == false ? $db->fetchRow() : $db->fetchSpecificRow($id);
    // show as image etc ...
    if ($bType && v($_REQUEST["show"]) && $blobTypes[$bType][2]) {
        ob_end_clean();
        include_once BASE_PATH . "/lib/output.php";
        Output::buffer();
        header($blobTypes[$bType][2]);
        print $row[$name];
        return true;
    }
    foreach ($blobTypes as $k => $v) {
        if ($bType == $k) {
            $blobOptions .= "<option value='{$k}' selected=\"selected\">{$v['0']}</option>\n";
        } else {
            $blobOptions .= "<option value='{$k}'>{$v['0']}</option>\n";
        }
    }
    // try to show the blob data as specified type
    if ($bType && $blobTypes[$bType] && v($blobTypes[$bType][3])) {
        if (strpos($blobTypes[$bType][3], "#link#") !== false) {
            $blobData = str_replace("#link#", "?q=wrkfrm&type=viewblob&show=1&id={$id}&name={$name}&blobtype={$bType}&query=" . urlencode($queryCode), $blobTypes[$bType][3]);
        } else {
            $blobData = htmlspecialchars($row[$name]);
        }
    } else {
        if ($bType && $blobTypes[$bType] && v($blobTypes[$bType][4])) {
            $func = $blobTypes[$bType][4];
            $blobData = htmlspecialchars(print_r($func($row[$name]), 1));
        } else {
            $blobData = htmlspecialchars($row[$name]);
        }
    }
    $toolbar = $isEditable ? view('viewblob_toolbar', array('BLOBOPTIONS' => $blobOptions)) : '<div class="message ui-state-default">' . __('Blob data is not editable') . '</div>';
    $replace = array('ID' => $id, 'NAME' => $name, 'BLOBOPTIONS' => $blobOptions, 'BLOBDATA' => $blobData, 'TABLE' => $table == "" ? "" : htmlspecialchars($table), 'QCODE' => md5(Session::get('select', 'query')), 'BLOB_TOOLBAR' => $toolbar, 'MESSAGE' => $message);
    echo view('viewblob', $replace);
}