PHP - Find Number Of Regular Users And How Long They Tend To Be Users
Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; Similar TutorialsThese are the specs that come to mind, CPU, RAM, Storage, Bandwith
My question is this, once you know what the point of a website is, whether it is to host videos, design something with an editor, ecommerce, if I ask a costumer "How many people do you expect to be on your site?"
Is that a fair question? Or is that arbitrary or even rhetorical like "Duh... the maximum count"
I want to know based on what is being accessed whether it is the photos displayed on page, character count, flash / javascript, whatever... how can I estimate?
This is for assigning VPS's depending on the clients requirement
I just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. I don't have a lot of money and I'm launching a high traffic website, I intend to have a payment system linked to hosting service I am using so that in the event that my website is actually successful, it can expand accordingly.
I want to know ahead of time about bandwith usage, I have a 3TB limit per month which may seem like a lot but what if thousands of users are accessing/using files that are between 2 to 10 MB each? Uploading, viewing, scrolling, text...
This calculation also applies to storage
I haven't really given this much thought, I'm just curious, I have a lot to do and I would like to start amassing information ahead of time
Thank you for any help
im new , and ... i hate tutorials .. books .. anything that does not make u part of the deal - .. thats why i started by creating something and learning from my mistakes at the same time .. i like this way of learning .. soo , while im building and trying things out .. i started thinking how the server know the person with this link is really U ? .. when u start just linking pages to each other its just a matter of finding out what is the link to do what ever u want with the users personal pages ! .. i know my questions r stupid but i just hate to go and write lessons without any effort im confused with the concept of SESSIONS and COOKIES , r they the unswer to this security problem ? how u can work with them .. ? im not asking for codes .. just general ideas about users and how they control their profiles and stuff with full security ? ill be very thankful if i get any answer ^^ Hi. my browser ist telling me there are errors on line 3 and 4 for my code. It says summin like Notice: HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR are unidentified: below is the code see if you can spot anything btw i copied down the code from beginner php tutorial 66 if you type that into youtube . Code: [Select] <?php $http_client_ip = $_SERVER['HTTP_CLIENT_IP']; $http_x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR']; $remote_addr = $_SERVER['REMOTE_ADDR']; if (!empty($http_client_ip)){ $ip_addr = $http_client_ip; }else if(!empty($http_x_forwarded_for)){ $ip_addr = $http_x_forwarded_for; }else{ $ip_addr = $remote_addr; } echo $ip_addr; ?> Thanks MOD EDIT: code tags added. how can I list a user from a table and show the results in a grid with different color eg frist in blue color second on white , 3rd on blue 4th in with etc
I do need to set select command and I have db name and ip on a file called dbconfig.php from wd calendar so I just need to read the info
ps: I cant post links so search for wd calendar and see the dbconfig.php in php folder
Hi, I am having serious issues with compatibility with IE7 and below (and even 8 but they should be rectified). There is no way I can have these problems finished before the site is online, so I want to redirect users to a page apologizing and recommending alternative browsers. Is this possible? *Please don't reply just to tell me that banning an entire browser is bad, I know it is - I plan to sort it out. But this is an extra curricular project and I'm halfway through my penultimate year of uni, so IE and it's utterly shambolic rendering of CSS is not my priority. Thankyou* I have used
$sql = "SELECT id, username FROM $tbl_name ORDER BY username"; $result = $con->query($sql); while ($row = $result->fetch_assoc()) { echo "<a href='editUser.php?id={$row['id']}'>{$row['username']}</a><br><br>\n"; echo "<style>a {color: blue; text-decoration: none;} a:hover {color: #ff0000} body {background-color: #000;} </style>"; }in euser.php which echo's out all the users in the database via an anchor tag and includes their id in the url. but when i click on their name i want to have options like: - change password - ban user e.t.c and i have tried $sql = "SELECT id FROM $tbl_name"; $result = $con->query($sql); while ($row = $result->fetch_assoc()) { echo "<a href='editUser.php?id={$row['id']}'> Change Password </a>in my other page editUser.php it posts Change Password Change Password Change Password and each change password has the 3 ids of the users this is confusing me. Hi guys, im just trying to work out an app in my head and on paper. im just wondering.. when a user registers they can choose an Avatar 100px by 100px jpg, when they upload one would i then grab the file and store all Avatars in a avatar image folder and rename it to something like.. avatar[user_id].jpg and keep them all in the same folder. or would i crate a folder called users, each user gets their own folder with files like avatar.jpg and it finds the [user_id] folder and pulls the avatar out from that, or is there a more prefered method? cheers I would get the ip address of the user that is on the site. I used $ip = $_SERVER['REMOTE_ADDR']; and it doesn't show my actual ip. Is it because im using an apache server on my computer. Hi guys, I am trying to get a admin panel, which when the user is logged in, it will check if there user access is(say for this post) 9... If there access is 9 in the database then direct to admin panel if not return them home. Thanks guys I have jobs portal where registered users posts new jobs searches
This weekly newsletter will send all the jobs posted in the site (in a week) to the registered users but in a more personalized way: For example, posted jobs looking for designers should be sent to users registered as designers.
what is the best way to do this? any recommendations? Thanks in advance.
Hello all, I am a total noob in php and some VIP asked me to make something simple for our clubhouse; A page where users can submit/input 2 codes through a textbox and store it in a database. There are 2 things i want: max 2 submits/inputs per IP(to prevent abuse)(ip stored in database). $ip = $_SERVER['REMOTE_ADDR']; $check = mysql_query("select * from table where ipcolumn='$ip'"); if (mysql_num_rows($check) > 0) $insertip = "insert into table (ipcolumn) values ('$ip')"; And i wanna catch the error when an user put in a code lower than 5 characters. not something like: if ($textarea == ""){ This is where i am so far. new.php <?php include 'includes/config.php'; mysql_select_db($mysql_database, $con); $sql="INSERT INTO users (code, code2) VALUES ('$_POST[code]','$_POST[code2]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }else{ header ("Location: /thanks.php"); } ?> includes/config.php <?php $mysql_host = "myhost.com"; $mysql_database = "mydb"; $mysql_user = "myuser"; $mysql_password = "mypass"; $con = mysql_connect($mysql_host,$mysql_user,$mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> sql.sql -- -- Table structure for table `users` -- CREATE TABLE `users` ( `code` varchar(30) collate latin1_general_ci NOT NULL, `code2` varchar(32) collate latin1_general_ci default NULL, `timestamp` int(11) unsigned NOT NULL, PRIMARY KEY (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; index.html <form action="new.php" method="post" onsubmit="return onSubmitButton();"> <input value="" id="something" class="LoginForm-Input" name="code1" size="34" style="float: left;">[/code] Hello, i am trying to make a calendar for different users which are described in the database. depending on the link to earn a calendar for the user. here's the code: Code: [Select] $sql=" SELECT user , fullname FROM users "; $resource=mysql_query($sql) or die(mysql_error()); while($array=mysql_fetch_assoc($resource)) { $users[]=$array['user']; } if (isset($_GET['user'])) { $user = $_GET['user']; setcookie('user', $user, time()+(3600*24*365)); } elseif (isset($_COOKIE['user'])) { $user = $_COOKIE['user']; } else { $user = 'bg'; } if (!(in_array($user, array_keys($users)))) { die("Грешка: няма езиков файл!"); } require_once "{$user}.php"; function switch_users_options() { global $text, $users, $user; $retval = $text['switch']; $get = $_GET; foreach ($users as $abbrv => $name) { if ($abbrv !== $user) { $get['user'] = $abbrv; $url = $_SERVER['PHP_SELF'] . '?' . http_build_query($get); $retval .= " <a href=\"{$url}\"> {$name}</a><br>"; } } return $retval; } I've taken it from one code to change the language .. the question is that it displayed on new line - users from database but the links are wrong : index.php?user=0, user=1 .. user=2 not as it should be index.php?user=user1, user=test ... please for assistance. Hello dear guys, I have this code below which is to send SMS to single mobile No, but i am willing to send this message to the whole table of mobiles that i have please help, with thanks in advance <? $url="https://www.GATEWAYSITE"; $login="LOGIN"; $pwd="PSWD"; $mittente="CO"; $numero="$cellulare"; $testo=urlencode($messaggio); $y="login=".$login."&pwd=".$pwd."&testo=".$testo."&numero=".$numero."&mittente =".$mittente; $contents = @file_get_contents($url."?".$y); print $contents; ?> What are the different ways you can keep a User "logged in"? From what I *vaguely* recall from a year or two ago when I read a whole hoard of PHP books, you commonly use cookies and sessions. But I'm asking this more from an OOP standpoint than a PHP standpoint. Let's say I have a User record in my database, and a User comes along and attempts to log in. In OOP terms, I would think you'd call some class to help log them in, and upon successfully logging in, you would "load" the User object into memory and set the "LoggedIn" field to "True". Then as long as that field was set in their object, they could surf all over the place and do things like change their account and buy things. Is that how you would do it in OOP? TomTees Hi I am creating an e-commerce website, where users who pay with their credit card are able to download pdf books. how can I make a PDF file only accessible for those users (who pay and validate their credit card) and not for everyone ? I want to know the main idea about securing these files. Hiya! , I'm currently working on a script that will allow me to track the total users on my website, and how many of these user are logged in members, or guests. I need to be able to find out the total users, total logged in, and total guests within the last 15 minutes, and the total users, total logged in, and total guests for today. Ideally, I would like to user only one table for this, and would also like to group together records in the database that have the same users_id and ip_address, as there's not much point in storing this more than once. I currently have a table that contains the following fields. sid - Stores the users session ID. user_id - Stores the user id of a logged in user. 0 is stored if the user is a guest. ip_address - Stores the IP address of the user. last_updated - Stores a timestamp of when the user was last active. I look forward to reading your responses Cheers! I have a string which is a list of user id's like "44/5/6/67/7/88/56/76/9/90/65/74/8/68". I explode this string and put them into an array, but now I have a problem of getting the users first names from the database by using the id's and putting them in alphabetical order. How can I do this? Thanks Afternoon All. I wish to re-direct users to a 404 error page on my site if an article does not exist in my database. Here's my code: $SQL = "SELECT headline FROM news WHERE news_id=".mysql_real_escape_string($_GET['news_id']); $result = mysql_query($SQL) OR die(mysql_error()); $num = mysql_num_rows($result); //** Check that the entry exists otherwise send to error page if ($num > 0) { $row = mysql_fetch_array($result); $headline = $row['headline']; } else { echo "Why is this printed? - I should be leaving this page?"; header("Location: error.php"); exit; } Now the wierd thing is that when I enter a news_id for a value that does not exist it prints the message Why is this printed? - I should be leaving this page? so it's actually going to the ELSE statement which is good, but surely it should not do this as I ask the page to re-direct? Thank you |