Ejemplo n.º 1
0
 public function checkperm($packname, $perm = array())
 {
     global $smarty, $db, $user, $pm;
     if (!isset($this->_config['usual'])) {
         $usual = 'denie';
     } else {
         $usual = $this->_config['usual'];
     }
     switch ($usual) {
         case 'denie':
             $smarty->assign('MODUL', $packname);
             showTemplate('permission', 'perm');
             echo $pm->getTpl();
             exit;
             break;
         case 'allow':
             break;
         default:
             $smarty->assign('MODUL', $packname);
             showTemplate('permission', 'perm');
             echo $pm->getTpl();
             exit;
             break;
     }
     return true;
 }
Ejemplo n.º 2
0
function AjaxController_orderList($args)
{
    loadModule('orders');
    $offset = intval($args['offset']);
    $limit = intval($args['limit']);
    $data = Orders_getOrderList($args['status'], $offset, $limit, $ordersCount);
    if (is_numeric($data) && $data < 0) {
        $message = getMessage(getConfig('errors')[$data]);
        echo json_encode(['status' => 'error', 'message' => $message]);
    } else {
        $data = showTemplate('orderList', ['orderList' => $data, 'ordersCount' => $ordersCount, 'offset' => $offset, 'limit' => $limit], true);
        echo json_encode(['status' => 'data', 'data' => $data]);
    }
}
Ejemplo n.º 3
0
function createSystem()
{
    global $settings;
    global $_testInstall_Ok;
    try {
        /*
         * The settings system is used to create a lot of output,
         * we swallow it all
         */
        ob_start();
        /*
         * Get the schema version and other constants
         */
        require_once "lib/Bootstrap.php";
        $bootstrap = new Bootstrap();
        /*
         * Now create the database
         */
        $dbsettings = $_SESSION['spotsettings']['db'];
        $dbCon = dbeng_abs::getDbFactory($dbsettings['engine']);
        $dbCon->connect($dbsettings['host'], $dbsettings['user'], $dbsettings['pass'], $dbsettings['dbname']);
        $daoFactory = Dao_Factory::getDAOFactory($dbsettings['engine']);
        $daoFactory->setConnection($dbCon);
        /*
         * The database must exist before we can get the Service_Settings_Base instance
         */
        $dbStruct = SpotStruct_abs::factory($dbsettings['engine'], $daoFactory->getConnection());
        $dbStruct->updateSchema();
        $spotSettings = $bootstrap->getSettings($daoFactory, false);
        $svcUpgradeBase = new Services_Upgrade_Base($daoFactory, $spotSettings, $dbsettings['engine']);
        /*
         * Create all the different settings (only the default) ones
         */
        $svcUpgradeBase->settings();
        /*
         * Create the users
         */
        $svcUpgradeBase->users();
        /*
         * print all the output as HTML comment for debugging
         */
        $dbCreateOutput = ob_get_contents();
        ob_end_clean();
        /*
         * Now it is time to do something with
         * the information the user has given to us
         */
        /*
         * Update the NNTP settings in the databas
         */
        $spotSettings->set('nntp_nzb', $_SESSION['spotsettings']['nntp']['nzb']);
        $spotSettings->set('nntp_hdr', $_SESSION['spotsettings']['nntp']['hdr']);
        $spotSettings->set('nntp_post', $_SESSION['spotsettings']['nntp']['post']);
        /*
         * Create the given user
         */
        $svcUserRecord = new Services_User_Record($daoFactory, $spotSettings);
        $spotUser = $_SESSION['spotsettings']['adminuser'];
        /*
         * and actually add the user
         */
        $spotUser['userid'] = $svcUserRecord->createUserRecord($spotUser)->getData('userid');
        /*
         * When the new user was created a random password was assigned, 
         * so now have to set the supplied password
         */
        $svcUserRecord->setUserPassword($spotUser);
        # Change the administrators' account password to that of this created user
        $adminUser = $svcUserRecord->getUser(SPOTWEB_ADMIN_USERID);
        $adminUser['newpassword1'] = $spotUser['newpassword1'];
        $svcUserRecord->setUserPassword($adminUser);
        # update the settings with our system type and our admin id
        $spotSettings->set('custom_admin_userid', $spotUser['userid']);
        $spotSettings->set('systemtype', $spotUser['systemtype']);
        # Set the system type
        $svcUpgradeBase->resetSystemType($spotUser['systemtype']);
        /* 
         * Create the necessary database connection information
         */
        $dbConnectionString = '';
        switch ($_SESSION['spotsettings']['db']['engine']) {
            case 'pdo_mysql':
                $dbConnectionString .= "\$dbsettings['engine'] = 'pdo_mysql';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['user'] = '******'spotsettings']['db']['user'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['pass'] = '******'spotsettings']['db']['pass'] . "';" . PHP_EOL;
                break;
                # mysql
            # mysql
            case 'pdo_pgsql':
                $dbConnectionString .= "\$dbsettings['engine'] = 'pdo_pgsql';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['user'] = '******'spotsettings']['db']['user'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['pass'] = '******'spotsettings']['db']['pass'] . "';" . PHP_EOL;
                break;
                # pdo_pgsql
        }
        # switch
        # Try to create the dbsettings.inc.php file for the user
        @file_put_contents("dbsettings.inc.php", "<?php" . PHP_EOL . $dbConnectionString);
        $createdDbSettings = file_exists("dbsettings.inc.php");
        showTemplate("step-final.inc.php", array('createdDbSettings' => $createdDbSettings, 'dbCreateOutput' => $dbCreateOutput, 'dbConnectionString' => $dbConnectionString));
    } catch (Exception $x) {
        showTemplate("fatalerror.inc.php", array('x' => $x));
    }
    # exception
}
Ejemplo n.º 4
0
 case 'main':
     smartyAddPack();
     $smarty->assign('content', $pm->parsePackLangConst('index', 'pdbp_settings'));
     showTemplate('main', 'pdbp_settings');
     break;
 case 'showsettings':
     if (!isset($_GET['pack'])) {
         $pm->showPackError('no_pack_selected', 'pdbp_settings', 200, true);
         exit;
     }
     smartyAddPack();
     $form = $pm->generateCfgForm($_GET['pack']);
     $smarty->assign('content', $form[1]);
     $smarty->assign('js', $form[0]);
     $smarty->assign('cfgform', true);
     showTemplate('main', 'pdbp_settings');
     break;
 case 'save':
     if (!isset($_GET['pack'])) {
         $pm->showPackError('no_pack_selected', 'pdbp_settings', 200, true);
         exit;
     }
     $return = $pm->saveForm($_GET['pack']);
     if ($return) {
         $pm->showPackError('saved', 'pdbp_settings', 200, true);
         exit;
     } else {
         $pm->showPackError('save_failed', 'pdbp_settings', 200, true);
         exit;
     }
     break;
Ejemplo n.º 5
0
function updateThesaurusEntry($elementid, $query)
{
    // wouldn't it be nice if our database supported transactions? ;\
    $success = false;
    $error = false;
    global $db, $db_prefix;
    $newvalue = $db->quote($query['newvalue']);
    switch ($query['element']) {
        case 'name':
            $sql = "select * from {$db_prefix}artist where id = {$elementid}";
            if ($row = $db->GetRow($sql)) {
                $artistid = $db->quote($row['id']);
                $newartistid = $artistid;
                if ($artistid != "'0'") {
                    // don't update the '0' = noplace record
                    // if there's an already existing entry for the specified value, delete the current row
                    $src = $db->quote($row['src']);
                    $name = $db->quote($row['name']);
                    $sql = "select * from {$db_prefix}artist where name = {$newvalue} and src = {$src} and id != {$artistid}";
                    if ($existingrow = $db->getRow($sql)) {
                        // the specified new value already exists as a previous entry; delete this entry and change everything to point to the existing entry
                        $sql = "delete from {$db_prefix}artist where id = {$artistid}";
                        if ($result = $db->Execute($sql)) {
                            $newartistid = $db->quote($existingrow['id']);
                        } else {
                            $error = 'err_removing_old_row';
                        }
                        $newsounds = $db->quote($existingrow['sounds']);
                    } else {
                        // no existing entry matches the new value; so update the current record
                        $tdb = getThesaurusDB();
                        $sounds = $tdb->get_sounds_string($query['newvalue']);
                        $newsounds = $db->quote($sounds);
                        $sql = "update {$db_prefix}artist set name = {$newvalue}, sounds = {$newsounds} where id={$artistid}";
                        if (!($result = $db->Execute($sql))) {
                            $error = 'err_updateerror';
                        }
                    }
                    if (!$error) {
                        $sql = "update {$db_prefix}meta" . " set name1id = {$newartistid}," . " name1 = {$newvalue}," . " name1sounds = {$newsounds}" . " where name1id={$artistid}";
                        if ($result = $db->Execute($sql)) {
                            $sql = "update {$db_prefix}meta" . " set name2id = {$newartistid}," . " name2 = {$newvalue}," . " name2sounds = {$newsounds}" . " where name2id={$artistid}";
                            if ($result = $db->Execute($sql)) {
                                $success = true;
                            } else {
                                $error = 'err_update_child_table_2';
                            }
                        } else {
                            $error = 'err_update_child_table_1';
                        }
                    }
                } else {
                    $error = 'err_unsafe_update_requested';
                }
            } else {
                $error = 'err_norecord';
            }
            break;
        case 'location':
            $sql = "select * from {$db_prefix}location where id = {$elementid}";
            if ($row = $db->GetRow($sql)) {
                $locationid = $db->quote($row['id']);
                $newlocationid = $locationid;
                if ($locationid != "'0'") {
                    if (!empty($query['newvalueid'])) {
                        $id = $db->quote($query['newvalueid']);
                        $sql = "select * from {$db_prefix}location where id = {$id}";
                    } else {
                        $sql = "select * from {$db_prefix}location where location = {$newvalue} and id != {$locationid} order by length(hierarchy)";
                    }
                    $existingrecords = $db->getAll($sql);
                    if ($existingrecords !== false) {
                        switch (count($existingrecords)) {
                            case 0:
                                $existing = false;
                                break;
                            case 1:
                                $existing = true;
                                $existingrow = $existingrecords[0];
                                break;
                            default:
                                $options = array('locations' => $existingrecords);
                                showTemplate('edit_thesaurus_new.tpl', true, false, $row, $options);
                                exit;
                        }
                        if ($existing) {
                            $sql = "delete from {$db_prefix}location where id = {$locationid}";
                            if ($result = $db->Execute($sql)) {
                                $newlocationid = $db->quote($existingrow['id']);
                                $newsounds = $db->quote($existingrow['sounds']);
                            } else {
                                $error = 'err_removing_old_row';
                            }
                        } else {
                            $tdb = getThesaurusDB();
                            $sounds = $tdb->get_sounds_string($query['newvalue']);
                            $newsounds = $db->quote($sounds);
                            $sql = "update {$db_prefix}location set location = {$newvalue}, sounds = {$newsounds}, hierarchy='', src='dilps' where id={$locationid}";
                            if (!($result = $db->Execute($sql))) {
                                $error = 'err_updateerror';
                            }
                        }
                        if (!$error) {
                            $sql = "update {$db_prefix}meta" . " set locationid = {$newlocationid}," . " location = {$newvalue}," . " locationsounds = {$newsounds}" . " where locationid={$locationid}";
                            if ($result = $db->Execute($sql)) {
                                $success = true;
                            } else {
                                $error = 'err_update_child_table';
                            }
                        }
                    } else {
                        $error = 'err_dberror';
                    }
                } else {
                    // don't update the '0' = noplace record
                    $error = 'err_unsafe_update_requested';
                }
            } else {
                $error = 'err_norecord';
            }
            break;
        case 'institution':
            $sql = "select * from {$db_prefix}meta where id = {$elementid}";
            if ($row = $db->GetRow($sql)) {
                $locationid = $db->quote($row['locationid']);
                $old = $db->quote($row['institution']);
                if ($locationid != "'0'" && strlen($old) > 2) {
                    $sql = "update {$db_prefix}meta set institution={$newvalue}" . " where locationid = {$locationid}" . " and institution = {$old}";
                    if ($row = $db->Execute($sql)) {
                        $success = true;
                    } else {
                        $error = 'err_updateerror';
                    }
                } else {
                    // we shouldn't be updating empty institutions (this would update all empty institutions for the given location)
                    $error = 'err_unsafe_delete_requested';
                }
            } else {
                $error = 'err_norecord';
            }
            break;
        default:
            $error = 'err_missingparam';
            break;
    }
    return array($success, $error);
}
Ejemplo n.º 6
0
<?php

showTemplate("header");
?>

<div class="container">
	<h1 class="h1">Произошла ошибка</h1>

	<div>
		<?php 
echo $errorText;
?>
 <a href="/" class="link"><?php 
echo getMessage('go_to_index');
?>
</a>
	</div>
		
	</div>
</div>

<?php 
showTemplate("footer");
Ejemplo n.º 7
0
/*
 * This file is part of Paradise-Bird-Project.
 * Paradise-Bird-Project is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * Paradise-Bird-Project is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Paradise-Bird-Project.  If not, see <http://www.gnu.org/licenses/>.
 */
global $pm, $user;
if ($user->isLoggedIn()) {
    $pm->showPackError('already_logged_in', 'users_login', 200, true, 'index.php');
    exit;
}
if (isset($_GET['users_action'])) {
    $action = $_GET['users_action'];
} else {
    $action = 'main';
}
switch ($action) {
    case 'main':
        showTemplate('login', 'users_login');
        break;
    default:
        $pm->showError('UNKNOWN_ACTION');
        exit;
}
Ejemplo n.º 8
0
* Copyright (c) 2015, Aron Heinecke
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
$info = "";
if (true) {
    //DEBUG ONLY
    $e = ini_set('display_errors', true);
    if ($e !== "1") {
        echo $e;
    }
    error_reporting(E_ALL);
    $info = 'Error-Log:On';
}
require_once 'includes/ytdownl.php';
if (isset($_REQUEST['ajaxCont'])) {
    if (function_exists('getAjax')) {
        echo getAjax();
    } else {
        http_response_code(404);
        echo 'ERROR: No custom request function found!';
    }
} else {
    require_once 'includes/template.inc.php';
    showTemplate();
}
Ejemplo n.º 9
0
function PageController_createOrder()
{
    showTemplate('createOrder');
}
Ejemplo n.º 10
0
function ErrorController_notFound()
{
    showTemplate('error', ['errorText' => getMessage('page_not_found')]);
}