Ejemplo n.º 1
0
 /**
  *
  * @param unknown $arrParam
  * @param string $option
  * @return multitype:unknown
  */
 public function listItems($arrParam, $option = null)
 {
     if ($option['task'] == 'books-in-cart') {
         $cart = SESSION::get('cart');
         $result = array();
         if (!empty($cart)) {
             $ids = "(";
             foreach ($cart['quantity'] as $key => $value) {
                 $ids .= "'" . $key . "', ";
             }
             $ids .= " '0')";
             $query[] = "SELECT `id`, `name`, `picture`";
             $query[] = "FROM `" . TBL_BOOK . "`";
             $query[] = "WHERE `status` = 1 AND `id` IN {$ids}";
             $query[] = "ORDER BY `ordering` ASC";
             $query = implode(" ", $query);
             $result = $this->fetchAll($query);
             foreach ($result as $key => $value) {
                 $result[$key]['quantity'] = $cart['quantity'][$value['id']];
                 $result[$key]['totalprice'] = $cart['price'][$value['id']];
                 $result[$key]['price'] = $result[$key]['totalprice'] / $result[$key]['quantity'];
             }
         }
         return $result;
     }
 }
Ejemplo n.º 2
0
 public function update()
 {
     $data['content'] = $_POST['content'];
     $id = $_POST['id'];
     if (SESSION::get('admin')) {
         $update = $this->_model->update("text", $data, "id={$id}");
     }
 }
Ejemplo n.º 3
0
 function m_post($title, $description, $image, $latitude, $longitude)
 {
     $output = 0;
     $user = null;
     $this->db;
     $this->query("SELECT id_ad FROM ads WHERE title = :title AND description = :description AND image = :image");
     $this->bind(':title', $title);
     $this->bind(':description', $description);
     $this->bind(':image', $image);
     $this->execute();
     $this->beginTransaction();
     if ($this->rowCount() == 0) {
         $this->query("SELECT id_user FROM users WHERE email = :user");
         $this->bind(':user', SESSION::get('user'));
         $this->execute();
         $user = $this->resultSet();
         $user = $user[0]['id_user'];
         if ($this->rowCount() > 0) {
             $this->query("INSERT INTO ads(title,description,latitude,longitude,user) VALUES(:title,:description,:latitude,:longitude,:user)");
             $this->bind(':title', $title);
             $this->bind(':description', $description);
             $this->bind(':latitude', $latitude);
             $this->bind(':longitude', $longitude);
             $this->bind(':user', $user);
             $this->execute();
             if ($this->rowCount() > 0) {
                 $this->query("INSERT INTO images(image_path,resolution,size,ad) VALUES(:image,null,null,:ad)");
                 $this->bind(':image', $image);
                 $this->bind(':ad', $this->lastInsertID());
                 $this->execute();
                 if ($this->rowCount() > 0) {
                     $this->query("INSERT INTO images(image_path,resolution,size,ad) VALUES(:image,null,null,:ad)");
                     $this->bind(':image', $image);
                     $this->bind(':ad', $this->lastInsertID());
                     $this->execute();
                 } else {
                     $output = -4;
                 }
             } else {
                 $output = -3;
             }
         } else {
             $output = -2;
         }
     } else {
         $output = -1;
     }
     if ($output == 0) {
         $this->endTransaction();
     } else {
         $this->cancelTransaction();
     }
     return $output;
 }
Ejemplo n.º 4
0
 public function ag()
 {
     $data['title'] = 'ADMIN';
     $data['subtitle'] = 'ADMIN';
     if (!SESSION::get('admin')) {
         $this->_view->render('header', $data);
         $this->_view->render('partials/partials_header', $data);
         $this->_view->render('admin/login', $data);
         $this->_view->render('partials/partials_footer', $data);
         $this->_view->render('footer', $data);
     } else {
         URL::REDIRECT("portfolio");
     }
 }
Ejemplo n.º 5
0
 public function logout()
 {
     if (\SESSION::get('uid') != '') {
         // session_destroy();
         // session_unset();
         \SESSION::remove_all();
         // only for this app
         // setcookie(PREFX.'st',0,1);
         header("Location: ./");
         // here we can put session message like "you logged out"
         exit;
     } else {
         \CORE::msg('debug', 'Not signed in yet');
     }
 }
Ejemplo n.º 6
0
/**
 * Returns the state of the player from the database,
 * uses a user_id if one is present, otherwise
 * defaults to the currently logged in player, but can act on any player
 * if another username is passed in.
 * @param $user user_id or username
 * @param @password Unless true, wipe the password.
**/
function get_player_info($user = null, $password = false)
{
    $sql = new DBAccess();
    $player_data = null;
    if (is_numeric($user)) {
        $sel_player = "select * from players where player_id = '" . $user . "' limit 1";
    } else {
        $username = either($user, SESSION::is_set('username') ? SESSION::get('username') : null);
        // Default to current session user.
        $sel_player = "select * from players where uname = '" . sql($username) . "' limit 1";
    }
    $player_data = $sql->QueryRowAssoc($sel_player);
    if (!$password) {
        unset($player_data['pname']);
    }
    return $player_data;
}
Ejemplo n.º 7
0
 private function __construct()
 {
     $uid = \SESSION::get('uid');
     if ($uid != '') {
         $this->uid = (int) $uid;
         if ($this->uid > 0) {
             $gid = \SESSION::get('gid');
             if ($gid != '') {
                 $this->gid = (int) $gid;
             }
             $pid = \SESSION::get('pid');
             if ($pid != '') {
                 $this->pid = (int) $pid;
             }
             $user = \SESSION::get('user');
             if ($user != '') {
                 $this->username = $user;
             }
         }
     }
     \CORE::msg('debug', 'user (uid:' . $this->uid . '; gid:' . $this->gid . ';)');
 }
Ejemplo n.º 8
0
 public function upload()
 {
     if (SESSION::get('admin')) {
         if (isset($_FILES['image'])) {
             $errors = array();
             $file_name = $_FILES['image']['name'];
             $file_size = $_FILES['image']['size'];
             $file_tmp = $_FILES['image']['tmp_name'];
             $file_type = $_FILES['image']['type'];
             $file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
             $expensions = array("jpeg", "jpg", "png", "pdf");
             if (in_array($file_ext, $expensions) === false) {
                 $errors[] = "extension not allowed, please choose a JPEG or PNG file.";
             }
             if ($file_size > 2097152) {
                 $errors[] = 'File size must be excately 2 MB';
             }
             if (empty($errors) == true) {
                 $id = $_POST['id_content3'];
                 $clause = "WHERE id = {$id}";
                 $old_data = $this->_model->selectAllClauseOrderBy("text", $clause, null, null);
                 $old_data_picture = $old_data[0]['content'];
                 if (file_exists($old_data_picture)) {
                     unlink($old_data_picture);
                 }
                 $new_data_picture = "assets/vita/" . $file_name;
                 move_uploaded_file($file_tmp, $new_data_picture);
                 $data['content'] = $new_data_picture;
                 $update = $this->_model->update("text", $data, "id={$id}");
                 return print_r("Success");
             } else {
                 return print_r("Error");
             }
         } else {
             return print_r("No File");
         }
     }
 }
Ejemplo n.º 9
0
 * Deals with the non-skill based attacks and stealthed attacks.
 *
 * @package combat
 * @subpackage attack
 */
$private = true;
$alive = true;
$page_title = "Battle Status";
$quickstat = "player";
include SERVER_ROOT . "interface/header.php";
$recent_attack = null;
$start_of_attack = microtime(true);
$attack_spacing = 0.2;
// fraction of a second
if (SESSION::is_set('recent_attack')) {
    $recent_attack = SESSION::get('recent_attack');
}
if ($recent_attack && $recent_attack > $start_of_attack - $attack_spacing) {
    echo "<p>Even the best of ninjas cannot attack that quickly.</p>";
    echo "<a href='attack_player.php'>Return to combat</a>";
    SESSION::set('recent_attack', $start_of_attack);
    die;
} else {
    SESSION::set('recent_attack', $start_of_attack);
}
?>

<span class="brownHeading">Battle Status</span>

<hr>
Ejemplo n.º 10
0
function get_username()
{
    return SESSION::is_set('username') ? SESSION::get('username') : NULL;
}
Ejemplo n.º 11
0
/**
 * Returns the state of the player from the database,
 * uses a user_id if one is present, otherwise
 * defaults to the currently logged in player, but can act on any player
 * if another username is passed in.
 * @param $user user_id or username
**/
function char_info($p_id)
{
    if (!$p_id) {
        if (defined('DEBUG') && DEBUG) {
            nw_error('DEPRECATED: call to char_info with a null argument.  For clarity reasons, this is now deprecated, use the player object instead. Backtrace: ' . print_r(debug_backtrace(), true));
        }
        return self_info();
    }
    $id = whichever($p_id, SESSION::get('player_id'));
    // *** Default to current player. ***
    if (!is_numeric($id)) {
        // If there's no id, don't try to get any data.
        return null;
    }
    $player = new Player($id);
    // Constructor uses DAO to get player object.
    $player_data = array();
    if ($player instanceof Player && $player->id()) {
        // Turn the player data vo into a simple array.
        $player_data = (array) $player->vo;
        $player_data['clan_id'] = $player->getClan() ? $player->getClan()->getID() : null;
        $player_data = add_data_to_player_row($player_data);
    }
    return $player_data;
}
Ejemplo n.º 12
0
      // ColorBox resize function, seems do work now
      var resizeTimer;
      $(window).resize(function(){
        if (resizeTimer) clearTimeout(resizeTimer);
          resizeTimer = setTimeout(function() {
          if ($('#cboxOverlay').is(':visible')) {
            //reload ist selbst hinugefügt in colorbox.js, public func welche einfach nur load() aufruft
            $.colorbox.reload();
          }
        }, 300)
      });

   });
  </script>
  <?php 
if (SESSION::get('admin')) {
    ?>
  <script type="text/javascript">
	$(document).ready(function(){
      //trigger modal
      $('.modal-trigger-newBilder').leanModal();
    });
   function confirmDelete(id,album_id){
     console.log("id : "+album_id);
     $.ajax({
        type: 'POST',
        data: {
              id: id,
              album_id:album_id
        },
        url: <?php 
Ejemplo n.º 13
0
// Stage of delete process.
$in_changePass = in('changepass');
$changePass = $in_changePass && $in_changePass == 1 ? 1 : null;
$newPass = in('newpass', null, 'toPassword');
$passW = in('passw', null, 'toPassword');
// *** To verify whether there's a password put in.
$changeprofile = in('changeprofile');
$newprofile = in('newprofile', null, 'toMessage');
$username = get_username();
$user_id = get_user_id();
$player = get_player_info();
$confirm_delete = false;
$profile_changed = false;
$profile_max_length = 500;
// Should match the limit in limitStatChars.js
$delete_attempts = SESSION::is_set('delete_attempts') ? SESSION::get('delete_attempts') : null;
if ($deleteAccount) {
    $verify = false;
    $verify = is_authentic($username, $passW);
    if ($verify == true && !$delete_attempts) {
        // *** Username&password matched, on the first attempt.
        pauseAccount($username);
        // This may redirect and stuff?
    } else {
        if ($deleteAccount == 2) {
            SESSION::set('delete_attempts', 1);
            $error = 'Deleting of account failed, please email ' . SUPPORT_EMAIL;
        } else {
            $confirm_delete = true;
        }
    }
Ejemplo n.º 14
0
         // *** Guard Gold ***
         addGold($username, $guard_gold);
         echo "The guard is defeated!<br>\n";
         echo "Guard does {$guard_attack} points of damage.<br>\n";
         echo "You have gained {$guard_gold} gold.<br>\n";
         if (getLevel($username) > 15) {
             $added_bounty = floor((getLevel($username) - 10) / 5);
             echo "You have slain a member of the military!  A bounty of " . $added_bounty * 10 . " gold has been placed on your head!<br>\n";
             addBounty($username, $added_bounty * 10);
         }
     }
 } else {
     if ($victim == "thief") {
         // Check the counter to see whether they've attacked a thief multiple times in a row.
         if (SESSION::is_set('counter')) {
             $counter = SESSION::get('counter');
         } else {
             $counter = 1;
         }
         $counter = $counter + 1;
         SESSION::set('counter', $counter);
         // Save the current state of the counter.
         if ($counter > 20 && rand(1, 3) == 3) {
             // Only after many attacks do you have the chance to be attacked back by the group of theives.
             SESSION::set('counter', 0);
             // Reset the counter to zero.
             echo "<img src='images/scenes/KunitsunaTrainingWithTengu.jpg' alt='' style='width:1000px'>";
             echo "<p>A group of tengu thieves is waiting for you. They seem to be angered by your attacks on their brethren.</p>";
             $group_attack = rand(50, 150);
             if (!subtractHealth($username, $group_attack)) {
                 // If the den of theives killed the attacker.
Ejemplo n.º 15
0
function getStatus($who)
{
    global $sql, $status_array;
    if (!$sql) {
        $sql = new DBAccess();
    }
    $status = $sql->QueryItem("SELECT status FROM players WHERE uname = '{$who}'");
    if ($who == SESSION::get('username')) {
        $_SESSION['status'] = $status;
    }
    $status_array['Stealth'] = $status & STEALTH ? 1 : 0;
    $status_array['Poison'] = $status & POISON ? 1 : 0;
    $status_array['Frozen'] = $status & FROZEN ? 1 : 0;
    $status_array['ClassState'] = $status & CLASS_STATE ? 1 : 0;
    $status_array['Skill1'] = $status & SKILL_1 ? 1 : 0;
    $status_array['Skill2'] = $status & SKILL_2 ? 1 : 0;
    $status_array['Invited'] = $status & INVITED ? 1 : 0;
    return $status_array;
}
Ejemplo n.º 16
0
$private = isset($private) ? $private : NULL;
$quickstat = isset($quickstat) ? $quickstat : NULL;
$alive = isset($alive) ? $alive : NULL;
$page_title = isset($page_title) ? $page_title : "NinjaWars";
$error = null;
// Logged in or alive error.
update_activity_info();
// *** Updates the activity of the page viewer in the database.
if (!is_logged_in()) {
    if ($private) {
        $error = render_viewable_error('log_in');
        // Content being in the error triggers a die at the end of the header.
    }
} else {
    // **************** Player information settings. *******************
    $username = SESSION::get('username');
    $player = new Player($username);
    // Defaults to current session user.
    $players_id = $player->player_id;
    $player_id = $players_id;
    // Just two aliases for the player id.
    $players_email = $player->vo->email;
    // TODO: Turn this into a list extraction?
    // password and messages intentionally excluded.
    $players_turns = $player->vo->turns;
    $players_health = $player->vo->health;
    $players_bounty = $player->vo->bounty;
    $players_gold = $player->vo->gold;
    $players_level = $player->vo->level;
    $players_class = $player->vo->class;
    $players_strength = $player->vo->strength;
Ejemplo n.º 17
0
        <div class="right">
          <a  <?php 
if ($data['menu_active'] === 'kontakt') {
    ?>
class="active"<?php 
}
?>
 href="<?php 
echo DIR;
?>
impressum">IMPRESSUM</a>
        </div>
        <a class="modal-trigger-footer" style="color:white" href="#modal_login_footer">
          <?php 
if (SESSION::get('admin')) {
    echo SESSION::get('admin');
    ?>
            Logout
         <?php 
}
?>
        </a>
       </div>
      </div>
    </footer>
    <!-- Modal Structure -->
    <div id="modal_login_footer" class="modal">
      <?php 
if (!Session::get('admin')) {
    ?>
      <div class="modal-content">
Ejemplo n.º 18
0
if ($gherdazu == 'adabei') {
    //module_main ($get_vars['menuitem']);
    //$akt_album = $get_vars['airyal'];
    /*if ($akt_album == "") 
    			$fertigesAlbum = $menuAlbum;
    		else
    			$fertigesAlbum = new airy_album($akt_album, 'fla_airy_files/');*/
    //$menuAlbum->airy_init();
    echo $menuAlbum->get_html($get_vars);
} else {
    if ($gherdazu == 'tatigern') {
        $loginerr = true;
    } else {
        $loginerr = false;
    }
    echo login_formular(SESSION::get('user'), $server_vars['PHP_SELF'], $loginerr);
    echo <<<FLA
\t\t\t    <script type="text/javascript">
\t\t\t\t  window.onload = function () {
\t\t\t\t\t    //Loginseite
\t\t\t\t\t  \tx = document.getElementsByTagName('input')[0];
\t\t\t\t\t\tif (x) {x.focus();}\t
\t\t\t\t  }
\t\t\t\t</script>
FLA;
}
?>
    </div>

	<div id="footer">
		<?php 
Ejemplo n.º 19
0
 public function is_authorized($full_check = false, $errors = false)
 {
     $authorized = false;
     if (\SESSION::get('uid') != '') {
         if ($full_check) {
             $DB = \DB::init();
             if ($DB->connect()) {
                 $uid = (int) \SESSION::get('uid');
                 $sql = "SELECT `usr-login` FROM `n-users` WHERE `usr-uid`=:uid LIMIT 1;";
                 $sth = $DB->dbh->prepare($sql);
                 $sth->execute(array('uid' => $uid));
                 \CORE::init()->msg('debug', 'Checking is user authorized via database.');
                 if ($sth->rowCount() != 1) {
                     header("Location: ./?c=user&act=logout");
                     exit;
                 } else {
                     $authorized = true;
                 }
             }
         } else {
             $authorized = true;
         }
     }
     if (!$authorized && $errors) {
         \CORE::init()->msg('error', 'You are not logged in');
     }
     return $authorized;
 }
Ejemplo n.º 20
0
 public function uploadBilder()
 {
     if (SESSION::get('admin')) {
         $album_id = $_POST['album_id'];
         $data['albums'] = $this->_model->selectOne("albums", "id", $album_id);
         $album_name = $data['albums'][0]['name'];
         $album_slug = $data['albums'][0]['slug'];
         $kategorie_id = $data['albums'][0]['kategorie_id'];
         $upload['kategorie_id'] = $kategorie_id;
         $upload['album_id'] = $album_id;
         $kategorie = $this->_model->selectOne("kategories", "id", $kategorie_id);
         $kategorie_name = $kategorie[0]['name'];
         $kategorie_slug = $kategorie[0]['slug'];
         if (!empty($_FILES)) {
             $total_upload = count($_FILES["images"]["name"]);
             $clause = "WHERE album_id ={$album_id}";
             $count_current_in_album = $this->_model->count("images", $clause);
             $total_current_in_album = $count_current_in_album[0]['total'];
             for ($i = 0; $i < count($_FILES["images"]["name"]); $i++) {
                 $next_reihenfolge = $total_current_in_album + $i + 1;
                 $tmpFilePath = $_FILES["images"]['tmp_name'];
                 //$upload['title'] = preg_replace('/\\.[^.\\s]{3,4}$/', '', $_FILES["images"]["name"][$i]);
                 if ($tmpFilePath != "") {
                     $date = date('Y-m-d');
                     $newfolder = getcwd() . "/assets/collections/" . $kategorie_slug . "/" . $album_slug;
                     if (!is_dir($newfolder)) {
                         mkdir($newfolder, 0777, true);
                         chmod($newfolder, 0777);
                     }
                     $newfolderCover = getcwd() . "/assets/collections/" . $kategorie_slug . "/" . $album_slug . "/cover";
                     if (!is_dir($newfolderCover)) {
                         mkdir($newfolderCover, 0777, true);
                         chmod($newfolderCover, 0777);
                     }
                     $size = $_FILES["images"]["size"][$i];
                     $newFile = $_FILES["images"]["name"][$i];
                     $newFilePath = 'assets/collections/' . $kategorie_slug . "/" . $album_slug . '/' . $newFile;
                     $newFilePathCover = "assets/collections/" . $kategorie_slug . "/" . $album_slug . "/cover/" . $newFile;
                     $foto_name = $_FILES["images"]["name"][$i];
                     //$upload['title'] = preg_replace('/\\.[^.\\s]{3,4}$/', '', $foto_name);
                     $upload['title'] = NULL;
                     $uploads = move_uploaded_file($tmpFilePath[$i], $newFilePath);
                     list($width, $height) = getimagesize($newFilePath);
                     $ratio = $width / $height;
                     if ($width > 2500 || $height > 2500) {
                         $convertpercentage = 0.1;
                     } else {
                         $convertpercentage = 0.3;
                     }
                     $tenpercentwidth = $convertpercentage * $width;
                     $tenpercentheight = $convertpercentage * $height;
                     $target_width = $tenpercentheight * $ratio;
                     $target_height = $tenpercentwidth / $ratio;
                     if ($width < $height) {
                         $bild_form = 1;
                     } else {
                         $bild_form = 2;
                     }
                     //insert to database
                     $save = $this->insert($_FILES["images"]["name"][$i], $newFilePath, $newFilePathCover, $upload['album_id'], $upload['kategorie_id'], $upload['title'], $size, $bild_form, $next_reihenfolge);
                     //resize file
                     $file = $newFilePath;
                     //indicate the path and name for the new resized file
                     $resizedFile = $newFilePathCover;
                     //call the function (when passing path to pic)
                     $img = $this->smart_resize_image($file, null, $target_width, $target_height, false, $resizedFile, false, false, 100);
                     //$img = $this->compress($file , $resizedFile , $convert_percentage );
                     if ($img) {
                         Message::set("Upload success", 'success');
                     } else {
                         Message::set("Upload fail", 'error');
                     }
                 } else {
                     Message::set('Please choose at least one image to upload', 'error');
                 }
             }
         } else {
             Message::set("Upload fail", 'error');
         }
     } else {
         Message::set("Do not have authorization", 'error');
     }
     header('Location: ' . $_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 21
0
 /**
  *	Is Test
  *	Whilst running unit tests, this will be true.
  *	@return BOOL
  */
 public static function isTest()
 {
     if (isset($_GET['isTest']) && Auth::isAuthenticated() && Auth::currentUser()->can("runTestingTools")) {
         SESSION::set("isTest", $_GET['isTest']);
     }
     return !static::isDev() && (SESSION::get("isTest") || TOUCHBASE_ENV == 'test' || in_array(@$_SERVER['HTTP_HOST'], static::config()->get("servers")->get("testing", [])));
 }
Ejemplo n.º 22
0
function account_id()
{
    return SESSION::get('account_id');
}
Ejemplo n.º 23
0
$private = false;
$alive = false;
if ($error = init($private, $alive)) {
    display_error($error);
} else {
    require_once LIB_ROOT . "control/lib_player_list.php";
    require_once LIB_ROOT . "control/lib_player.php";
    DatabaseConnection::getInstance();
    $username = self_name();
    $char_id = self_char_id();
    $searched = in('searched', null, 'no filter');
    // Don't filter the search setting.
    $list_by_rank = $searched && substr_compare($searched, '#', 0, 1) === 0;
    // Whether the search is by rank.
    $hide_setting = !$searched && SESSION::is_set('hide_dead') ? SESSION::get('hide_dead') : 'dead';
    // Defaults to hiding dead via session.
    $hide = $searched ? 'none' : in('hide', $hide_setting);
    // search override > get setting > session setting
    $alive_only = $hide == 'dead';
    $page = in('page', 1);
    // Page will get changed down below.
    $alive_count = 0;
    $record_limit = 20;
    // *** The number of players that gets shown per page.
    $view_type = in('view_type');
    $rank = get_rank($char_id);
    $dead_count = query_item("SELECT count(player_id) FROM rankings WHERE alive = false");
    $page = in('page');
    if (!$searched && $hide_setting != $hide) {
        SESSION::set('hide_dead', $hide);