flashmaster

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

0 Neutral

About flashmaster

  • Rank
    Jr. Member
  1. Hi and thanks for the reply. Ok just to be clear, i dont need to manage the script in the admin/backend. I just want it to connect to the database. I dont want users to be able to login to the admin area just a general password that i have set in the database. It works with the database outside the template folder just to be clear. Im a total beginner at php and this script is from github. The database file is just an example not the correct one Dont have the experience to build something from scratch, just want this script to work right now. I have tested the module "page protector" but i dont want the user to have access to the admin with its password. And also there is no "Log out" function. Also i want to style the login page.
  2. Hi, i need some help with a login script that im trying to implement under PW. When im enter the protectedpage.php it goes to login.php and then i fill in username/password and press login it just refreshes the login.php again and the input fields are empty. It should go to protectedpage.php after that but its not working. I think that there is a path och paths in the script that its wrong. All files are in the root of the template folder and i have a database table that im trying to fetch. I have also added the pages as templates in admin. If you see anything wrong with this please help. /thanks protectedpage.php <?php session_start(); require_once('config.php'); //phpinfo(); if(isset($_SESSION['id'])){ ?> <!doctype html> <html lang="sv-se"> <head> </head> <body> Lorem ipsum sit dolor amet. </body> </html> <?php } else{ header( "Location:../protectedpage"); } ?> login.php <?php session_start(); require_once( 'config.php' ); if ( isset( $_SESSION[ 'id' ] ) ) { header( "Location:protectedpage.php" ); } else { ?> <!DOCTYPE html> <html> <head> <title>Logga in</title> <link rel="stylesheet" href="<?=$config->urls->templates;?>css/login.css"> <script type="text/javascript" src="<?=$config->urls->templates;?>js/login.js"></script> </head> <body style="background-color:#bdc3c7"> <div id="main-wrapper"> <center> <h2>Logga in</h2> </center> <form action="../login" method="post" onsubmit="return validate(this);"> <div class="inner_container"> <div class="formgroup"><label class="lable-side"><b>Epost</b></label> <input type="text" class="text-side" name="email" id="email" value="<?php if(isset($_POST['login'])) { echo $_POST['email']; } else{ } ?>" autofocus> </div> <div class="formgroup"><label class="lable-side"><b>Lösenord</b></label> <input type="password" id="password" class="text-side" name="password"> </div> <div class="btngrp"><button class="login_button" name="login" type="submit">Login</button> <button type="reset" class="reset_btn">Återställ</button> </div> <div class="register_div"><a href="../register" class="register_link"><span>Registrera ny användare</span></a> </div> </div> </form> <?php if ( isset( $_POST[ 'login' ] ) ) { $email = $_POST[ 'email' ]; $password = $_POST[ 'password' ]; $query = $con->prepare( "select * from users where email=?" ); $query->bind_param( 's', $email ); $query->execute(); $result = $query->get_result(); $row = $result->fetch_assoc(); $hash_pwd = $row[ 'password' ]; $hash = password_verify( $password, $hash_pwd ); if ( $hash == 0 ) { echo '<script type="text/javascript">alert("Invalid Credentials")</script>'; } else { $query = $con->prepare( "select * from users where email='$email' and password=? " ); $query->bind_param( 's', $hash_pwd ); $query->execute(); $query_run = $query->get_result(); //echo mysql_num_rows($query_run); if ( $query_run ) { if ( mysqli_num_rows( $query_run ) > 0 ) { $row = mysqli_fetch_array( $query_run, MYSQLI_ASSOC ); $_SESSION[ 'email' ] = $row[ 'email' ]; $_SESSION[ 'id' ] = $row[ 'id' ]; header( "Location:../protectedpage" ); } else { echo '<script type="text/javascript">alert("No such Email exists. Invalid Credentials")</script>'; } } else { echo '<script type="text/javascript">alert("Database Error")</script>'; } } } else {} ?> </div> </body> </html> <?php } ?> config.php <?php $con = mysqli_connect( "localhost", "root", "htf43434" )or die( 'Database connect ' . mysql_error() ); mysqli_select_db( $con, 'ksf' ); ?>
  3. Hi and thanks for the reply. Changing to url: '/', did the trick with the event now showing up thanks! Now the issue with it saving to the database is left. Dont know if the database(sql) table that i posted before is correct?
  4. Not sure your comment did help or not. Can you be more specific about where i should place the files? I always have them in the site/templates/ folder. Why cant i have the files there? The script works but besides the two issues that i told about in the beginning.
  5. Hi, i need some help with a calendar script (Full Calendar) Issue 1 Its not saving to the database. This function dont work either when the script is running alone outside Processwire. Issue 2 (Fixed) When i click to ad an event and click save it wont turn up in blue, it just disapear. This function works when the script is running alone outside Processwire. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- I have attached the script running alone so you can se how it works. I have also pasted the code below that im trying to work under the template folder inside Processwire. If you can look at the code and se whats wrong with it. Im not that good at PHP or Javascript so i need you help. demo http://demos.phplift.net/jquery-fullcalendar-integration-bootstrap-php-mysql/ home.php <?php include( "database.php" ); if ( isset( $_POST[ 'action' ] )or isset( $_GET[ 'view' ] ) ) //show all events { if ( isset( $_GET[ 'view' ] ) ) { header( 'Content-Type: application/json' ); $start = mysqli_real_escape_string( $connection, $_GET[ "start" ] ); $end = mysqli_real_escape_string( $connection, $_GET[ "end" ] ); $result = mysqli_query( $connection, "SELECT id, start ,end ,title FROM events where (date(start) >= ‘$start’ AND date(start) <= ‘$end’)" ); while ( $row = mysqli_fetch_assoc( $result ) ) { $events[] = $row; } echo json_encode( $events ); exit; } elseif ( $_POST[ 'action' ] == "add" ) // add new event section { mysqli_query( $connection, "INSERT INTO events ( title , start , end ) VALUES ( '" . mysqli_real_escape_string( $connection, $_POST[ "title" ] ) . "', '" . mysqli_real_escape_string( $connection, date( 'Y-m-d H:i:s', strtotime( $_POST[ "start" ] ) ) ) . "‘, '" . mysqli_real_escape_string( $connection, date( 'Y-m-d H:i:s', strtotime( $_POST[ "end" ] ) ) ) . "‘ )" ); header( 'Content-Type: application/json' ); echo '{"id":"' . mysqli_insert_id( $connection ) . '"}'; exit; } elseif ( $_POST[ 'action' ] == "update" ) // update event { mysqli_query( $connection, "UPDATE events set start = '" . mysqli_real_escape_string( $connection, date( 'Y-m-d H:i:s', strtotime( $_POST[ "start" ] ) ) ) . "', end = '" . mysqli_real_escape_string( $connection, date( 'Y-m-d H:i:s', strtotime( $_POST[ "end" ] ) ) ) . "' where id = '" . mysqli_real_escape_string( $connection, $_POST[ "id" ] ) . "'" ); exit; } elseif ( $_POST[ 'action' ] == "delete" ) // remove event { mysqli_query( $connection, "DELETE from events where id = '" . mysqli_real_escape_string( $connection, $_POST[ "id" ] ) . "'" ); if ( mysqli_affected_rows( $connection ) > 0 ) { echo "1"; } exit; } } ?> <!doctype html> <html lang="sv-se"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <style type="text/css"> img { border-width: 0 } * { font-family: 'Lucida Grande', sans-serif; } </style> <style type="text/css"> .block a:hover { color: silver; } .block a { color: #fff; } .block { position: fixed; background: #2184cd; padding: 20px; z-index: 1; top: 240px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script src="<?=$config->urls->templates;?>js/script.js" type="text/javascript"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> <link href="<?=$config->urls->templates;?>css/fullcalendar.css" rel="stylesheet"/> <link href="<?=$config->urls->templates;?>css/fullcalendar.print.css" rel="stylesheet" media="print"/> <script src="<?=$config->urls->templates;?>js/moment.min.js"></script> <script src="<?=$config->urls->templates;?>js/fullcalendar.js"></script> </head> <body> <div class="container">fsefsefes <div class="row"> <div id="calendar"></div> </div> </div> <!-- Modal --> <div id="createEventModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Add Event</h4> </div> <div class="modal-body"> <div class="control-group"> <label class="control-label" for="inputPatient">Event:</label> <div class="field desc"> <input class="form-control" id="title" name="title" placeholder="Event" type="text" value=""> </div> </div> <input type="hidden" id="startTime"/> <input type="hidden" id="endTime"/> <div class="control-group"> <label class="control-label" for="when">When:</label> <div class="controls controls-row" id="when" style="margin-top:5px;"> </div> </div> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> <button type="submit" class="btn btn-primary" id="submitButton">Save</button> </div> </div> </div> </div> <div id="calendarModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Event Details</h4> </div> <div id="modalBody" class="modal-body"> <h4 id="modalTitle" class="modal-title"></h4> <div id="modalWhen" style="margin-top:5px;"></div> </div> <input type="hidden" id="eventID"/> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> <button type="submit" class="btn btn-danger" id="deleteButton">Delete</button> </div> </div> </div> </div> <!--Modal--> <div style='margin-left: auto;margin-right: auto;text-align: center;'> </div> </body> </html> database.php (i have configure this in my file at localhost) this is just an example. <?php $connection = mysqli_connect('host','username','password','database') or die(mysqli_error($connection)); ?> js/script.js $(document).ready(function(){ var calendar = $('#calendar').fullCalendar({ header:{ left: 'prev,next today', center: 'title', right: 'agendaWeek,agendaDay' }, defaultView: 'agendaWeek', editable: true, selectable: true, allDaySlot: false, events: "home.php?view=1", eventClick: function(event, jsEvent, view) { endtime = $.fullCalendar.moment(event.end).format('h:mm'); starttime = $.fullCalendar.moment(event.start).format('dddd, MMMM Do YYYY, h:mm'); var mywhen = starttime + ' - ' + endtime; $('#modalTitle').html(event.title); $('#modalWhen').text(mywhen); $('#eventID').val(event.id); $('#calendarModal').modal(); }, //header and other values select: function(start, end, jsEvent) { endtime = $.fullCalendar.moment(end).format('h:mm'); starttime = $.fullCalendar.moment(start).format('dddd, MMMM Do YYYY, h:mm'); var mywhen = starttime + ' - ' + endtime; start = moment(start).format(); end = moment(end).format(); $('#createEventModal #startTime').val(start); $('#createEventModal #endTime').val(end); $('#createEventModal #when').text(mywhen); $('#createEventModal').modal('toggle'); }, eventDrop: function(event, delta){ $.ajax({ url: 'home.php', data: 'action=update&title='+event.title+'&start='+moment(event.start).format()+'&end='+moment(event.end).format()+'&id='+event.id , type: "POST", success: function(json) { //alert(json); } }); }, eventResize: function(event) { $.ajax({ url: 'home.php', data: 'action=update&title='+event.title+'&start='+moment(event.start).format()+'&end='+moment(event.end).format()+'&id='+event.id, type: "POST", success: function(json) { //alert(json); } }); } }); $('#submitButton').on('click', function(e){ // We don't want this to act as a link so cancel the link action e.preventDefault(); doSubmit(); }); $('#deleteButton').on('click', function(e){ // We don't want this to act as a link so cancel the link action e.preventDefault(); doDelete(); }); function doDelete(){ $("#calendarModal").modal('hide'); var eventID = $('#eventID').val(); $.ajax({ url: 'home.php', data: 'action=delete&id='+eventID, type: "POST", success: function(json) { if(json == 1) $("#calendar").fullCalendar('removeEvents',eventID); else return false; } }); } function doSubmit(){ $("#createEventModal").modal('hide'); var title = $('#title').val(); var startTime = $('#startTime').val(); var endTime = $('#endTime').val(); $.ajax({ url: 'home.php', data: 'action=add&title='+title+'&start='+startTime+'&end='+endTime, type: "POST", success: function(json) { $("#calendar").fullCalendar('renderEvent', { id: json.id, title: title, start: startTime, end: endTime, }, true); } }); } }); database table CREATE TABLE events ( id int(11) NOT NULL AUTO_INCREMENT, start datetime DEFAULT NULL, end datetime DEFAULT NULL, title text, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; fullcalendar.rar
  6. Hi, thanks for the reply i will try to test if it works.
  7. I think there is something wrong with the main.js because it wont load the login screen. I have paste the javascript below so if anybody can see whats wrong or maybe not with the script below it would be super. // Show pages function showabout() { page_load(); div_hide('#content_div'); $.get('about.php', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded('about'); }); } function showlogin() { page_load(); div_hide('#content_div'); $.get('login.php', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded(); var user_email = $('#user_email_input').val(); var user_password = $('#user_password_input').val(); if(user_email != '' && user_password != '') { setTimeout(function() { $('#login_form').submit(); }, 250); } else { input_focus('#user_email_input'); } }); } function shownew_user() { page_load(); div_hide('#content_div'); $.get('login.php?new_user', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded(); input_focus('#user_name_input'); }); } function showforgot_password() { page_load(); div_hide('#content_div'); $.get('login.php?forgot_password', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded(); }); } function showreservations() { page_load('reservation'); div_hide('#content_div'); $.get('reservation.php', function(data) { $('#content_div').html(data); div_fadein('#content_div'); $.get('reservation.php?week='+global_week_number, function(data) { $('#reservation_table_div').html(data).slideDown('slow', function() { setTimeout(function() { div_fadein('#reservation_table_div'); }, 250); }); page_loaded(); }); }); } function showweek(week, option) { if(week == 'next') { var week = parseInt($('#week_number_span').html()) + 1; } else if(week == 'previous') { var week = parseInt($('#week_number_span').html()) - 1; } else { var week = parseInt(week); } if(isNaN(week)) { notify('Invalid week number', 4); } else { if(week < 1) { var week = 52; } else if(week > 52) { var week = 1; } page_load('week'); div_hide('#reservation_table_div'); $.get('reservation.php?week='+week, function(data) { $('#reservation_table_div').html(data); $('#week_number_span').html(week); div_fadein('#reservation_table_div'); page_loaded('week'); if(week != global_week_number) { $('#reservation_today_button').css('visibility', 'visible'); } if(option == 'today') { setTimeout(function() { $('#today_span').animate({ opacity: 0 }, 250, function() { $('#today_span').animate({ opacity: 1 }, 250); }); }, 500); } }); } } function showcp() { page_load(); div_hide('#content_div'); $.get('cp.php', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded(); }); } function showhelp() { page_load(); div_hide('#content_div'); $.get('help.php', function(data) { $('#content_div').html(data); div_fadein('#content_div'); page_loaded(); }); } // Page load function page_load(page) { // All setTimeout(function() { if($('#content_div').css('opacity') == 0) { notify('Loading...', 300); } }, 500); // Individual if(page == 'reservation') { setTimeout(function() { if($('#reservation_table_div').is(':hidden')) { notify('Loading...', 300); } }, 500); } else if(page == 'week') { setTimeout(function() { if($('#reservation_table_div').css('opacity') == 0) { notify('Loading...', 300); } }, 500); } } function page_loaded(page) { // All $.get('main.php?day_number', function(data) { if(data != global_day_number) { notify('Day have changed. Refreshing...', '300'); setTimeout(function() { window.location.replace('.'); }, 2000); } }); setTimeout(function() { if($('#notification_inner_cell_div').is(':visible') && $('#notification_inner_cell_div').html() == 'Loading...') { notify(); } }, 1000); read_reservation_details(); // Individual if(page == 'about') { $('#about_latest_version_p').html('<img src="img/loading.gif" alt="Loading"> Getting latest version...'); setTimeout(function() { $.get('main.php?latest_version', function(data) { if($('#about_latest_version_p').length) { $('#about_latest_version_p').html(data); } }); }, 1000); } } // Login function login() { var user_email = $('#user_email_input').val(); var user_password = $('#user_password_input').val(); $('#login_message_p').html('<img src="img/loading.gif" alt="Loading"> Logging in...').slideDown('fast'); var remember_me_checkbox = $('#remember_me_checkbox').prop('checked'); if(remember_me_checkbox) { var user_remember = 1; } else { var user_remember = 0; } $.post('login.php?login', { user_email: user_email, user_password: user_password, user_remember: user_remember }, function(data) { if(data == 1) { input_focus(); setTimeout(function() { window.location.replace('.'); }, 1000); } else { if(data == '') { $('#login_message_p').html('<span class="error_span">Wrong email and/or password</span>'); $('#user_email_input').val(''); $('#user_password_input').val(''); input_focus('#user_email_input'); } else { $('#login_message_p').html(data); } } }); } function logout() { notify('Logging out...', 300); $.get('login.php?logout', function(data) { setTimeout(function() { window.location.replace('.'); }, 1000); }); } function create_user() { var user_name = $('#user_name_input').val(); var user_email = $('#user_email_input').val(); var user_password = $('#user_password_input').val(); var user_password_confirm = $('#user_password_confirm_input').val(); if($('#user_secret_code_input').length) { var user_secret_code = $('#user_secret_code_input').val(); } else { var user_secret_code = ''; } if(user_password != user_password_confirm) { $('#new_user_message_p').html('<span class="error_span">Passwords do not match</span>').slideDown('fast'); $('#user_password_input').val(''); $('#user_password_confirm_input').val(''); input_focus('#user_password_input'); } else { $('#new_user_message_p').html('<img src="img/loading.gif" alt="Loading"> Creating user...').slideDown('fast'); $.post('login.php?create_user', { user_name: user_name, user_email: user_email, user_password: user_password, user_secret_code: user_secret_code }, function(data) { if(data == 1) { input_focus(); setTimeout(function() { $('#new_user_message_p').html('User created successfully! Logging in... <img src="img/loading.gif" alt="Loading">'); setTimeout(function() { window.location.replace('#login'); }, 2000); }, 1000); } else { input_focus(); $('#new_user_message_p').html(data); } }); } } // Reservation function toggle_reservation_time(id, week, day, time, from) { if(session_user_is_admin == '1') { if(week < global_week_number || week == global_week_number && day < global_day_number) { notify('You are reserving back in time. You can do that because you\'re an admin', 4); } else if(week > global_week_number + global_weeks_forward) { notify('You are reserving more than '+global_weeks_forward+' weeks forward in time. You can do that because you\'re an admin', 4); } } var user_name = $(id).html(); if(user_name == '') { $(id).html('Wait...'); $.post('reservation.php?make_reservation', { week: week, day: day, time: time }, function(data) { if(data == 1) { setTimeout(function() { read_reservation(id, week, day, time); }, 1000); } else { notify(data, 4); setTimeout(function() { read_reservation(id, week, day, time); }, 2000); } }); } else { if(offclick_event == 'mouseup' || from == 'details') { if(user_name == 'Wait...') { notify('One click is enough', 4); } else if(user_name == session_user_name || session_user_is_admin == '1') { if(user_name != session_user_name && session_user_is_admin == '1') { var delete_confirm = confirm('This is not your reservation, but because you\'re an admin you can remove other users\' reservations. Are you sure you want to do this?'); } else { var delete_confirm = true; } if(delete_confirm) { $(id).html('Wait...'); $.post('reservation.php?delete_reservation', { week: week, day: day, time: time }, function(data) { if(data == 1) { setTimeout(function() { read_reservation(id, week, day, time); }, 1000); } else { notify(data, 4); setTimeout(function() { read_reservation(id, week, day, time); }, 2000); } }); } } else { notify('You can\'t remove other users\' reservations', 2); } if($('#reservation_details_div').is(':visible')) { read_reservation_details(); } } } } function read_reservation(id, week, day, time) { $.post('reservation.php?read_reservation', { week: week, day: day, time: time }, function(data) { $(id).html(data); }); } function read_reservation_details(id, week, day, time) { if(typeof id != 'undefined' && $(id).html() != '' && $(id).html() != 'Wait...') { if($('#reservation_details_div').is(':hidden')) { var position = $(id).position(); var top = position.top + 50; var left = position.left - 100; $('#reservation_details_div').html('Getting details...'); $('#reservation_details_div').css('top', top+'px').css('left', left+'px'); $('#reservation_details_div').fadeIn('fast'); reservation_details_id = id; reservation_details_week = week; reservation_details_day = day; reservation_details_time = time; $.post('reservation.php?read_reservation_details', { week: week, day: day, time: time }, function(data) { setTimeout(function() { if(data == 0) { $('#reservation_details_div').html('This reservation no longer exists. Wait...'); setTimeout(function() { if($('#reservation_details_div').is(':visible') && $('#reservation_details_div').html() == 'This reservation no longer exists. Wait...') { read_reservation(reservation_details_id, reservation_details_week, reservation_details_day, reservation_details_time); read_reservation_details(); } }, 2000); } else { $('#reservation_details_div').html(data); if(offclick_event == 'touchend') { if($(reservation_details_id).html() == session_user_name || session_user_is_admin == '1') { var delete_link_html = '<a href="." onclick="toggle_reservation_time(reservation_details_id, reservation_details_week, reservation_details_day, reservation_details_time, \'details\'); return false">Delete</a> | '; } else { var delete_link_html = ''; } $('#reservation_details_div').append('<br><br>'+delete_link_html+'<a href="." onclick="read_reservation_details(); return false">Close this</a>'); } } }, 500); }); } } else { $('div#reservation_details_div').fadeOut('fast'); } } // Admin control panel function list_users() { $.get('cp.php?list_users', function(data) { $('#users_div').html(data); }); } function reset_user_password() { if(typeof $(".user_radio:checked").val() !='undefined') { var user_id = $(".user_radio:checked").val(); $('#user_administration_message_p').html('<img src="img/loading.gif" alt="Loading"> Resetting password...').slideDown('fast'); $.post('cp.php?reset_user_password', { user_id: user_id }, function(data) { if(data == 0) { $('#user_administration_message_p').html('<span class="error_span">You can change your password at the bottom of this page</span>').slideDown('fast'); } else { setTimeout(function() { $('#user_administration_message_p').html(data); }, 1000); } }); } else { $('#user_administration_message_p').html('<span class="error_span">You must pick a user</span>').slideDown('fast'); } } function change_user_permissions() { if(typeof $(".user_radio:checked").val() !='undefined') { var user_id = $(".user_radio:checked").val(); $('#user_administration_message_p').html('<img src="img/loading.gif" alt="Loading"> Changing permissions...').slideDown('fast'); $.post('cp.php?change_user_permissions', { user_id: user_id }, function(data) { if(data == 1) { setTimeout(function() { list_users(); $('#user_administration_message_p').html('Permissions changed successfully. The user must re-login to get the new permissions'); }, 1000); } else { $('#user_administration_message_p').html(data); } }); } else { $('#user_administration_message_p').html('<span class="error_span">You must pick a user</span>').slideDown('fast'); } } function delete_user_data(delete_data) { if(typeof $(".user_radio:checked").val() !='undefined') { var delete_confirm = confirm('Are you sure?'); if(delete_confirm) { var user_id = $(".user_radio:checked").val(); $('#user_administration_message_p').html('<img src="img/loading.gif" alt="Loading"> Deleting...').slideDown('fast'); $.post('cp.php?delete_user_data', { user_id: user_id, delete_data: delete_data }, function(data) { if(data == 1) { setTimeout(function() { $('#user_administration_message_p').slideUp('fast', function() { if(delete_data == 'reservations') { list_users(); get_usage(); } else if(delete_data == 'user') { list_users(); } }); }, 1000); } else { $('#user_administration_message_p').html(data); } }); } } else { $('#user_administration_message_p').html('<span class="error_span">You must pick a user</span>').slideDown('fast'); } } function delete_all(delete_data) { if(delete_data == 'reservations') { var delete_confirm = confirm('Are you sure you want to delete ALL reservations? Database backup is a good idea!'); } else if(delete_data == 'users') { var delete_confirm = confirm('Are you sure you want to delete ALL users? Database backup is a good idea!'); } else if(delete_data == 'everything') { var delete_confirm = confirm('Are you sure you want to delete EVERYTHING (including you)? The first user created afterwards will become admin. Database backup is a good idea!'); } if(delete_confirm) { $('#database_administration_message_p').html('<img src="img/loading.gif" alt="Loading"> Deleting...').slideDown('fast'); $.post('cp.php?delete_all', { delete_data: delete_data }, function(data) { if(data == 1) { setTimeout(function() { if(delete_data == 'everything') { window.location.replace('#logout'); } else { list_users(); $('#database_administration_message_p').slideUp('fast'); } }, 1000); } else { $('#database_administration_message_p').html(data); } }); } } function save_system_configuration() { var price = $('#price_input').val(); $('#system_configuration_message_p').html('<img src="img/loading.gif" alt="Loading"> Saving...'); $('#system_configuration_message_p').slideDown('fast'); $.post('cp.php?save_system_configuration', { price: price }, function(data) { if(data == 1) { input_focus(); setTimeout(function() { $('#system_configuration_message_p').slideUp('fast', function() { get_usage(); }); }, 1000); } else { input_focus('#price_input'); $('#system_configuration_message_p').html(data); } }); } // User control panel function get_usage() { $.get('cp.php?get_usage', function(data) { $('#usage_div').html(data); }); } function get_reservation_reminders() { $.get('cp.php?get_reservation_reminders', function(data) { $('#reservation_reminders_span').html(data); }); } function add_one_reservation() { $('#usage_message_p').html('<img src="img/loading.gif" alt="Loading"> Saving...').slideDown('fast'); $.post('reservation.php?make_reservation', { week: '0', day: '0', time: '0' }, function(data) { if(data == 1) { setTimeout(function() { if($('#users_div').length) { list_users(); } get_usage(); $('#usage_message_p').slideUp('fast'); }, 1000); } else { $('#usage_message_p').html(data); } }); } function toggle_reservation_reminder() { $('#settings_message_p').html('<img src="img/loading.gif" alt="Loading"> Saving...').slideDown('fast'); $.post('cp.php?toggle_reservation_reminder', function(data) { if(data == 1) { setTimeout(function() { if($('#users_div').length) { list_users(); } get_reservation_reminders(); $('#settings_message_p').slideUp('fast'); }, 1000); } else { $('#settings_message_p').html(data); } }); } function change_user_details() { var user_name = $('#user_name_input').val(); var user_email = $('#user_email_input').val(); var user_password = $('#user_password_input').val(); var user_password_confirm = $('#user_password_confirm_input').val(); if(user_password != user_password_confirm) { $('#user_details_message_p').html('<span class="error_span">Passwords do not match</span>').slideDown('fast'); $('#user_password_input').val(''); $('#user_password_confirm_input').val(''); input_focus('#user_password_input'); } else { $('#user_details_message_p').html('<img src="img/loading.gif" alt="Loading"> Saving and refreshing...').slideDown('fast'); $.post('cp.php?change_user_details', { user_name: user_name, user_email: user_email, user_password: user_password }, function(data) { if(data == 1) { input_focus(); setTimeout(function() { window.location.replace('.'); }, 1000); } else { input_focus(); $('#user_details_message_p').html(data); } }); } } // UI function div_fadein(id) { setTimeout(function() { if(global_css_animations == 1) { $(id).addClass('div_fadein'); } else { $(id).animate({ opacity: 1 }, 250); } }, 1); } function div_hide(id) { $(id).removeClass('div_fadein'); $(id).css('opacity', '0'); } function notify(text, time) { if(typeof text != 'undefined') { if(typeof notify_timeout != 'undefined') { clearTimeout(notify_timeout); } $('#notification_inner_cell_div').css('opacity', '1'); if($('#notification_div').is(':hidden')) { $('#notification_inner_cell_div').html(text); $('#notification_div').slideDown('fast'); } else { $('#notification_inner_cell_div').animate({ opacity: 0 }, 250, function() { $('#notification_inner_cell_div').html(text); $('#notification_inner_cell_div').animate({ opacity: 1 }, 250); }); } notify_timeout = setTimeout(function() { $('#notification_inner_cell_div').animate({ opacity: 0 }, 250, function() { $('#notification_div').slideUp('fast'); }); }, 1000 * time); } else { if($('#notification_div').is(':visible')) { $('#notification_inner_cell_div').animate({ opacity: 0 }, 250, function() { $('#notification_div').slideUp('fast'); }); } } } function input_focus(id) { if(offclick_event == 'touchend') { $('input').blur(); } if(typeof id != 'undefined') { $(id).focus(); } } // Document ready $(document).ready( function() { // Detect touch support if('ontouchstart' in document.documentElement) { onclick_event = 'touchstart'; offclick_event = 'touchend'; } else { onclick_event = 'mousedown'; offclick_event = 'mouseup'; } // Visual feedback on click $(document).on(onclick_event, 'input:submit, input:button, .reservation_time_div', function() { $(this).css('opacity', '0.5'); }); $(document).on(offclick_event+ ' mouseout', 'input:submit, input:button, .reservation_time_div', function() { $(this).css('opacity', '1.0'); }); // Buttons $(document).on('click', '#reservation_today_button', function() { showweek(global_week_number, 'today'); }); $(document).on('click', '#reset_user_password_button', function() { reset_user_password(); }); $(document).on('click', '#change_user_permissions_button', function() { change_user_permissions(); }); $(document).on('click', '#delete_user_reservations_button', function() { delete_user_data('reservations'); }); $(document).on('click', '#delete_user_button', function() { delete_user_data('user'); }); $(document).on('click', '#delete_all_reservations_button', function() { delete_all('reservations'); }); $(document).on('click', '#delete_all_users_button', function() { delete_all('users'); }); $(document).on('click', '#delete_everything_button', function() { delete_all('everything'); }); $(document).on('click', '#add_one_reservation_button', function() { add_one_reservation(); }); // Checkboxes $(document).on('click', '#reservation_reminders_checkbox', function() { toggle_reservation_reminder(); }); // Forms $(document).on('submit', '#login_form', function() { login(); return false; }); $(document).on('submit', '#new_user_form', function() { create_user(); return false; }); $(document).on('submit', '#system_configuration_form', function() { save_system_configuration(); return false; }); $(document).on('submit', '#user_details_form', function() { change_user_details(); return false; }); // Links $(document).on('click mouseover', '#user_secret_code_a', function() { div_fadein('#user_secret_code_div'); return false; }); $(document).on('click', '#previous_week_a', function() { showweek('previous'); return false; }); $(document).on('click', '#next_week_a', function() { showweek('next'); return false; }); // Divisions $(document).on('mouseout', '.reservation_time_cell_div', function() { read_reservation_details(); }); $(document).on('click', '.reservation_time_cell_div', function() { var array = this.id.split(':'); toggle_reservation_time(this, array[1], array[2], array[3], array[0]); }); $(document).on('mousemove', '.reservation_time_cell_div', function() { var array = this.id.split(':'); read_reservation_details(this, array[1], array[2], array[3]); }); // Mouse pointer $(document).on('mouseover', 'input:button, input:submit, .reservation_time_div', function() { this.style.cursor = 'pointer'; }); }); // Hash change function hash() { var hash = window.location.hash.slice(1); if(hash == '') { if(typeof session_logged_in != 'undefined') { showreservations(); } else { showlogin(); } } else { if(hash == 'about') { showabout(); } else if(hash == 'new_user') { shownew_user(); } else if(hash == 'forgot_password') { showforgot_password(); } else if(hash == 'help') { showhelp(); } else if(hash == 'cp') { showcp(); } else if(hash == 'logout') { logout(); } else { window.location.replace('.'); } } } // Window load $(window).load(function() { // Make sure cookies are enabled $.cookie(global_cookie_prefix+'_cookies_test', '1'); var test_cookies_cookie = $.cookie(global_cookie_prefix+'_cookies_test'); if(test_cookies_cookie == null) { window.location.replace('error.php?error_code=3'); } else { $.cookie(global_cookie_prefix+'_cookies_test', null); hash(); $(window).bind('hashchange', function () { hash(); }); } }); // Settings $(document).ready( function() { $.ajaxSetup({ cache: false }); });
  8. I know very very little about php just a few lines in fact so thats why i need your help. I know design/frontend html css. I need all the functions in the script. But for now i dont need to change any text or anything through admin in this stage. The problem is that the login screen wont show up when i put it inside the template map.
  9. Ok maybe i was not clear enought about this. I have tried this 1. Installed a blank copy of processwire 2. Then i took all the files in the attachment that works outside processwire. 3. In admin i clicked on add new template and then all the pages was there so i added them. 4. In the code i changed the path to all the links etc to (example) <script src="<?=$config->urls->templates;?>js/jquery-cookies.js" type="text/javascript"></script> instead of <script src="js/jquery-cookies.js" type="text/javascript"></script> Dont know what else to do?
  10. It got very confusing for me right now I am really bad at php so thats why i need help with this. I dont need any fields/template for the script, dont need to change anything in admin but maybe later though. Have you downloaded the attached files and look at it?
  11. Hi, thanks for your reply. I want to have this script under Processwire in the default template map. I am gonna modify the look of it later but for now i just want it to work. I have a website that im working on and this is gonna be a sub page later on. I dont need to have any fields to edit inside admin. Just have it as it is. Thinking the problem is with some kind of path for it to work, im clueless though.
  12. Hi im new to this forum and i need some help with a booking system that i have trying to implement under Processwire. I hope that i can explain as much as i can what my problem is. Here is the orginal script https://github.com/olejon/phpmyreservation I downloaded the script and got some help to fix it because it was all messed up. I have attached a file "ReservationSystem.rar" and it should work out of the box. Also attached the database file "Phpmyreservation.sql". The thing is the script works great as it is now but when i install a blank version of processwire and import the script to the template folder it wont work. I have tried many things but cant get it to work just error after error etc. Please ask me if you need some more information about this. I know you are the experts so thats why im asking you. ReservationSystem.rar phpmyreservation.sql