This is the error i am getting, line 38 is $('#messageModal').on('shown.bs.modal', function() {
error:
Uncaught ReferenceError: $ is not defined
at index.php:38
This is the error i am getting, line 38 is $('#messageModal').on('shown.bs.modal', function() {
error:
Uncaught ReferenceError: $ is not defined
at index.php:38
So i changed it, but i am getting all sorts of errors. Here is my updated code:
$('#messageModal').on('shown.bs.modal', function() {
$.ajax({
type: "GET",
url: "https://www.tekcomsolutions.com/secure/viewmessage.php",
datatype: "html",
data:{ dataId : $(a[data-target="#messageModal"]).data('id')},
success: function(r) {
$('#messageBody').html(r);
}
});
});
here is my link:
<a href="#" type="button" class="btn btn-primary btn-xs" id="launchModal" data-toggle="modal" data-id="'.$values['ID'].'" data-target="#messageModal">View</a>
And my viewmessage.php:
if(isset($_GET['data-id']) || is_numeric($_GET['data-id'])){
$id = mysqli_real_escape_string($link,$_GET['data-id'] );
$query = "SELECT * FROM `tb_cform` WHERE `ID`='$id'";
$result = mysqli_query($link, $query);
$message = "";
while ($row = mysqli_fetch_assoc($result)){
$message .= '<div><h4>Subject: </h4><h5>'.$row['subj'].'<h5></div>';
$message .= '<hr><br>';
$message .= '<div><b>Message:<br>'.$row['message'].'</b></div>';
}
echo $message;
}
So here is what is happening,
1) When i click on Test 1 Message, it shows the message for test 1 like it should.
2) When I click on Test 2 Message, it still shows 'test 1' Message.
I have an example username and password if you want to see.
https://tekcomsolutions.com/secure/
UName: testuser
PWord: testuser
Hey @Diafol, So, for the AJAX Function, does that go something like this:
$('#myModal').on('show.bs.modal', function(){
$.ajax
({
type: "POST",
url: "viewmessage.php",
data: data-id='+ id',
cache: false,
success: function(r)
{
$("#messageBody").html(r);
}
});
});
then the viewmessage.php is this:
<?php
$id = $_GET['id'];
$query = "SELECT * FROM `tb_cform` WHERE `ID`='$id'";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_assoc($result)){
$message = $row['subj'];
$message .= '<hr><br>';
$message .= $row['message'];
}
print $message;
?>
and to call the data model:
<a href="" type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-id='.$row['ID']' data-target="#myModal">View</a>
Am i close?
<!-- Modal -->
<div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div id="messageBody" class="modal-body">
Info Should Populate Here.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Sorry about that. I forgot one of the main parts!
I am trying to populate the data in a modal via AJAX, but i am unsure how to do so.
The link right now is <a href="viewmessage.php?id='.$row['ID']'">View</a>
Since there is only 1 Message in the Database, the number is 70.
I have seen multiple things online but I am not sure how to implement it.
the modal I want to use will have the ID = "messageModal" and I want to use 1 modal to populate every value. I can create a php page of viewmessage.php that will run the query and return the response.
viewmessage.php:
$query = "SELECT * FROM `tb_cform` WHERE `ID`='$id'";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_assoc($result)){
$message = $row['subj'];
$message .= '<hr><br>';
$message .= $row['message'];
}
print $message
<?php
$email = $_SESSION['user_email'];
$qry = "SELECT qbcd_user_email.address, qbcd_user_email.user_id FROM qbcd_user_email INNER JOIN qbcd_user ON qbcd_user.id = qbcd_user_email.user_id INNER JOIN qbcd_ticket ON qbcd_ticket.user_id WHERE (qbcd_user_email.address = '.$email.') ORDER BY qbcd_ticket.ticket_id DESC";
$result = mysqli_query($link, $qry);
while ($row = mysqli_fetch_assoc($result)){
echo $row['qbcd_ticket.number'];
}
?>
Here is what i have tried so far, the result when i do a VAR_DUMP($qry);
come up with string(287) "SELECT qbcd_user_email.address, qbcd_user_email.user_id FROM qbcd_user_email INNER JOIN qbcd_user ON qbcd_user.id = qbcd_user_email.user_id INNER JOIN qbcd_ticket ON qbcd_ticket.user_id WHERE (qbcd_user_email.address = '.patrick.kershner@gmail.com.') ORDER BY qbcd_ticket.ticket_id DESC"
.
The query seems to be working fine, but it is not displaying any results in the WHILE loop.
I am using OS Ticket and I have another site for Members Area,I
am trying to join the 3 tables that have the information that corresponds to the customer by EMAIL.
the first table is:qbcd_ticket:
ticket_id | number | user_id | user_email_id | status_id | dept_id | and more...
5 | 762086| 2 | 0 | 1| 1 |
the next is qbcd_user_email
rows:
id | user_id | flags | address
2 | 2 | 0 | example@demo.com
the last is: qbcd_user
id | org_id | default_email_id | status | name | created | updated
2 | 0 | 2 | 0 | Customer Name | 2017-03-03 10:44:28 | 2017-03-03 10:44:28
The information that I need to display, is all corresponding Tickets associated with the customer where it = the email address.
The database connection and display is something I can do, however, I do not know how to perform an interjoin or a join request.
the only static variable that will not change is $_SESSION['user_email']; which is logged by logging into the members area.
If you can assist me with this that would be great.
That's not a bad idea, but I still had to have it draw from a database and display it 3 wide. That's where I needed the code came from. I do however like it. The site I am using is not actually bootstrap, however. I changed templates. They are still repsonsive, but not bootstrap responsive.
this is what i was trying to acheive. I found a solution and adapted it.
include ("lock.php");
// Select the data from table_name
$result = mysqli_query($bd,"SELECT * FROM products");
// Display the table
echo "<table class=\"table table-bordered\">";
// Put results into table
$counter = 0;
while($row = mysqli_fetch_array($result))
{
// Display the image
echo "<td align='left'><a href=\"" .$row['path'] . "\">
<span class='producttable'><img width='140' src=\"" . $row['path'] . "\" border=1 alt=\"" . $row["path"] . "\" title=\"" . $row["price"] . "\"></span>
<br>
<span class='producttext'>$row[product_name]</span></br><br>$row[description]
</br>
</span></a>";
echo "<br><span class='producttext'><strong>£$row[search_price]</strong></span></br>";
$counter++; # increment count every iteration
if ( $counter % 3 == 0 )
{
echo "<tr />";
}
}
echo "</td>";
echo "</table>";
its not for a slider, it's to show all the images on the screen, but have them as the format described. I can put them in a table format IE:
<?php
<table>
echo '<tr><td>Img 1</td><td>Img 2</td><td>Img 3</td></tr>';
LOOP
to the next row...
ETC.. till all results in the DB are done.
</table>
So basically, i want it to do :
123
456
789
I have the css that has it loop them all, but it fills the page, I want it to be like the above when it runs the loop.
I have a code that is working to show images and description. But I am trying to get it to loop through 3 pictures wide, then loop again. and display them, I am going to add pagination to the script, but before i do that i need it to loop.
here is my script:
include ("lock.php");
$my_que[0] = mysqli_query($bd,"SELECT * FROM `products`");
for( $i = 0; $i < mysqli_num_rows( $my_que[0] ); $i++ )
{
$row = mysqli_fetch_array( $my_que[0] );
print '<div><img width="200" height="200" src="'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];.'admin/'. $row['path'] . '" / class="img-rounded">'.$row['description'].'</div><br>';
}
Nevermind, I fixed it, I didnt add the LI tags to the number elements, so it was messing it all up. this discussion is now solved.
Okay guys, i finally added a pagination Script see below
<?php
$start=0;
$limit=3;
if(isset($_GET['id'])){
$id=$_GET['id'];
$start=($id-1)*$limit;
}
$query = "SELECT * FROM `blog_posts` ORDER BY postID DESC LIMIT $start, $limit";
$result = mysqli_query($bd, $query);
while ($row = mysqli_fetch_assoc($result)){
echo '<div>';
echo '<img src="../mini_logo.png" height="25" width="50">';
echo '<h3><a href="viewpost.php?id='.$row['postID'].'">'.$row['postTitle'].'</a></h3>';
echo '<p>Posted by '.$row['postBy']. ' on '.date('M jS Y H:i:s', strtotime($row['postDate'])).'</p>';
echo '<p>'.$row['postDesc'].'</p>';
echo '<p align="right"><a class="btn btn-primary btn-md active" role="button" href="viewpost.php?id='.$row['postID'].'">Read More <span class="glyphicon glyphicon-arrow-right"> </span></a></p>';
But for some weird reason it outputting like this:
<div>
<img height="25" src="../mini_logo.png" width="50">
<h3><a href="viewpost.php?id=25">Pagination Test</a></h3>
<p>Posted by Patrick Kershner on Apr 19th 2017 21:44:43</p>
<p></p>
<p>test Pagin</p>
<p></p>
<p align="right"><a class="btn btn-primary btn-md active" href="viewpost.php?id=25" role="button">Read More <span class="glyphicon glyphicon-arrow-right"></span></a></p>
</div>
echo '</div><hr>';
<hr>
<div>
<img height="25" src="../mini_logo.png" width="50">
<h3><a href="viewpost.php?id=24">This is legit!</a></h3>
}
<p>Posted by Patrick Kershner on Apr 19th 2017 21:35:28</p>
<p></p>
echo '<nav aria-label="Page navigation">';
<p>This is actually how we do it!</p>
<p></p>
$rows=mysqli_num_rows(mysqli_query($bd,"select * from blog_posts"));
<p align="right"><a class="btn btn-primary btn-md active" href="viewpost.php?id=24" role="button">Read More <span class="glyphicon glyphicon-arrow-right"></span></a></p>
</div>
$total=ceil($rows/$limit);
<hr>
<div>
<img height="25" src="../mini_logo.png" width="50">
<h3><a href="viewpost.php?id=22">Do we work on iMac?</a></h3>
if($id>1)
<p>Posted by Patrick Kershner on Apr 5th 2017 21:31:01</p>
<p></p>
{
<p>This should answer that question</p>
<p></p>
echo "<li><a href='?id=".($id-1)."' ><span aria-hidden=\"true\">«</span></a></li>"; <p align="right"><a class="btn btn-primary btn-md active" href="viewpost.php?id=22" role="button">Read More <span class="glyphicon glyphicon-arrow-right"></span></a></p>
</div>
<hr>
<nav aria-label="Page navigation">
<ul class="pagination">
<li>
<a href='?id=1'>1</a>
</li>
<li>
<a href='?id=2'>2</a>
</li>
<li>
<a href='?id=1'><span aria-hidden="true">»</span></a>
</li>
</ul>
</nav>
}
echo "<ul class=\"pagination\">";
for($i=1;$i<=$total;$i++)
{
if($i==$id) …
Try this....
if ($row['PROT_A']="Y" && $row['CFHL_A']="$G2")
{
echo "<img src='/fantasy/images/current.png' width='12' height='12'>";
}
I am not using PDO connection and i dont have any PDO scripting in my site. Its all simple things, I am not looking for extravigance, I am looking for practicality. I would have to change alot of code just for this to work.
Hey everyone, I have a MYSQLI statement that i would like to add pagination to. I would like to have it set to 5 per page, and not have a negative value if you are on page 1 (disables back link) Every tutorial i have been seeing allows for a negative back and i cannot figure it out. My code is as follows and I know that i have to introduce the Pagination before the while statement and it needs to finish after the while statement..
<?php
$query = "SELECT * FROM `blog_posts` ORDER BY postID DESC ";
$result = mysqli_query($bd, $query);
while ($row = mysqli_fetch_assoc($result)){
echo '<div>';
echo '<img src="../mini_logo.png" height="25" width="50">';
echo '<h3><a href="viewpost.php?id='.$row['postID'].'">'.$row['postTitle'].'</a></h3>';
echo '<p>Posted by '.$row['postBy']. ' on '.date('M jS Y H:i:s', strtotime($row['postDate'])).'</p>';
echo '<p>'.$row['postDesc'].'</p>';
echo '<p align="right"><a class="btn btn-primary btn-md active" role="button" href="viewpost.php?id='.$row['postID'].'">Read More <span class="glyphicon glyphicon-arrow-right"> </span></a></p>';
echo '</div><hr>';
}
?>
Any help would be awesome!
Guys, i am getting an unexpected T_While Error on my code, I cannot figure it out. can you help?
<?php
$sql = "SELECT id, u_name, u_email, subj, phone FROM tb_cform ";
$result = $conn->query($sql);
echo '<table><tr><th>Name</th><th>Email</th><th>Subjec</th><th>Phone</th></tr>';
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["u_name"]."</td><td>".$row["u_email"]."</td><td>".$row["subj"]."</td><td>".$row["phone"]."</td></tr>";
}
} else {
echo "0 results";
}
echo "</table>";
$bd->close();
?>
Hey Everyone, I am looking for possibly a CRM that can be used for multiple items:
1. Invoicing
2. Credit Card Processing
3. Front End Website
4. Customer Area/Members Pages
5. Admin Area
6. Integrate with Quickbooks?
7. Manage Employees (Time and Sales)
8. Inventory Management
Any advice would be helpful. I am not looking to spend alot of money, If there are opensource CRM's that will do this, that would be fine. I have already tried OSPOS and its just not what i am looking for.
kinda, when i generate content via php, i want the midde column to change height, but not the sidebars
hey everyone,
I am looking for a website template that is mobile responsive, with a header and 3 columns. in the left and right column there will be 3 items in each with a fixed height on each. the middle column needs to be adaptable to move without affecting the "Sidebars" height. I tried to use bootstrap but i am unable to get the results that i want.
Diafol, to answer the one question that i missed, there is no database, its all user input.
Patrick_18 is my alt, for some reason my email has 2 tied to it and i am not sure why.
Kinda, When i toggle the auto pay to yes, i want it to take 5.00 from the laccess(1-10) box, then i toggle no, it puts the 5.00 back. So, if there is a value of 25.00 it will be 25 if it is no, and 20 if yes.
Hey guys,
I have a code on excel, that will count the critera if there is more than one box filled out.
=COUNTIF(C5:D14,"<>0")
But now i am converting this code to jquery and i cannot figure it out.
on my page, there is a toggle button, yes/no selector for autopay,
<td><input name="autopay" type="radio" value="y" />Y<input type="radio" name="autopay" value="n" />N</td>
The input fields are labelled as such:
<td><input type="text" name="laccess1" id="laccess1" class="form-control" value="0.00" /></td>
<td><input type="text" name="laccess2" id="laccess2" class="form-control" value="0.00" /></td>
I am trying to get it to count them if they have a value in it, like 25.00 or more and when the toggle event happens, I want it to take 5.00 off per box that has a value in it. I am going to have a total of 10 of these boxes that can be used.
The code I am going to use for the toggle event is:
$( "#autopay" ).toggle(
function() {
$( '#overallTotal' ).val - (amount of inputs
that meet the critera * 5);
},
);
I have a code:
$data=$_SESSION['title'];
$view=$con->query("select flower.*, mystash.* from flower,mystash where mystash.name like '%$data%' OR flower.name like '%$data%' ORDER BY name ASC");
$check=$view;
if($check!="")
{
while($descri=mysqli_fetch_object($view))
{
I am trying to get the name from each table flower
and mystash
each have a column in there of name
I am not sure why this is not working but it just return no results for '%$data%'
I think i need a str_replace(); code to make it work, but i cannot figure it out
Hello,
I have an array that returns city and state in this format: Detroit,MI
I want it to be shown as Michigan/Detroit
is there any way of doing this?
Here is my foreach code:
foreach ($i['popularCities'] as $a => $value)
{
echo '<li>' . $value . '</li>' . PHP_EOL;
}
Thanks
Its working beautifully! Thanks
My connecting string is attached above as an include. Is that going to return all results back to the user?
Hello,
I am trying to get this to loop through all the available items in a database and return the results.
<?php
$qry = mysqli_query($con,"SELECT * FROM `favorites` WHERE `username` = '$id'") or die(mysqli_error($con));
while($rowa = mysqli_fetch_array($qry)) {
$slugname = $rowa['slug_name'];
$url = $rowa['slug'];
echo '<a href="'.$url.'>'.$slugname.'</a>"';
}
?>
I think i need a foreach loop, but not sure how todo it.
Thanks in advance
That works perfectly Gabriel, Thanks for that!
Im not to keen with jquery. I know a little bit of it. I did write this:
<?php
include 'connect.php';
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$username = $_POST['user_id'];
$liked = $_POST['liked'];
$slug = $_POST['url_slug'];
mysqli_query($con,"INSERT INTO favorites (username ,slug, value) VALUES ('$username','$slug',$liked)");
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
mysqli_close($con);
?>
Hello,
I am looking for a script to add items to a database that can be found in the my account section,
The table in the database is structured:
id | user_id | slug
I want to use the ajax to update and remove it later on down the road if they want to.
The items are in a loop on the search page and I would like to also have the code added to the item details page.
Does anyone know of a code like that? or is it easy to write?
Thanks in advance!
better array structure
Array
(
[0] => Array
(
[sl_translate] => description,descriptionPlain,category
[id] => 239
[slug] => pineapple
[name] => Pineapple
[symbol] => Pin
[category] => Hybrid
[description] => <p>Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks. </p>
[descriptionPlain] => Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks.
[aka] =>
[rating] => 3.9
[reviewCount] => 70
[flavors] => Array
(
[0] => Array
(
[name] => Pineapple
[score] => 62.237394957983
)
[1] => Array
(
[name] => Sweet
[score] => 35.136554621849
)
[2] => Array
(
[name] => Tropical
[score] => 22.111344537815
)
[3] => Array
(
[name] => Pungent
[score] => 14.443277310924
)
[4] => Array
(
[name] => Earthy
[score] => 9.453781512605
)
)
[effects] => Array
(
[0] => Array
(
[name] => Happy
[score] => 98.203419298754
)
[1] => Array
(
[name] => Relaxed
[score] => 89.338235294118
)
[2] => Array
(
[name] => Euphoric
[score] => 87.393146913938
)
[3] => Array
(
[name] => Uplifted
[score] => 76.494132135613
)
[4] => Array
(
[name] => Hungry
[score] => 60.111199652275
)
)
[symptoms] => Array
(
[0] => Array
(
[name] => Stress …
Hello, I am getting a weird error when i try to run this array:
//leafly api keys
$appID ='Blah';
$appKEY = 'blah';
//init curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://data.leafly.com/strains/".strtolower($data)); //change the strain dynamically of course for your app
curl_setopt($ch,CURLOPT_HTTPHEADER,array('APP_ID:'.$appID,'APP_KEY:'.$appKEY));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
//Clean it into an php array object and set var
$cleaned_response = json_decode($output,true);
foreach($cleaned_response as $image){
//continue;
echo'<img height="100" width="100" src="'.$image['photos'].'"/>'; //<--Line 73
}
// Look at it
print_r($cleaned_response);
// close curl resource to free up system resources
$output = curl_init();
then when i run the script, i get this:
<b>Warning</b>: Illegal string offset 'thumb' in <b>C:\xampp\htdocs\~review\search1.php</b> on line <b>73</b><br />
The array that is returned is:
array(25) { ["sl_translate"]=> string(37) "description,descriptionPlain,category" ["id"]=> int(239) ["slug"]=> string(9) "pineapple" ["name"]=> string(9) "Pineapple" ["symbol"]=> string(3) "Pin" ["category"]=> string(6) "Hybrid" ["description"]=> string(247) "
Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks.
" ["descriptionPlain"]=> string(240) "Pineapple marijuana strain is a phenotype F2 of the ERSB indica Pineapple that was inbred and feminized. The buds smell like the actual fruit of pineapple and even tend to resemble the fruit when growing. Flowering time is 7-8 weeks. " ["aka"]=> NULL ["rating"]=> float(3.9) ["reviewCount"]=> int(70) ["flavors"]=> array(5) { [0]=> array(2) { ["name"]=> string(9) "Pineapple" ["score"]=> float(62.237394957983) } [1]=> array(2) { ["name"]=> string(5) "Sweet" ["score"]=> float(35.136554621849) } …
Change to this:
.cbp-fwslider {
margin: 0px 0px 10px; padding: 0px; border: 1px solid rgb(0, 0, 0); border-image: none; overflow: hidden; position: relative; z-index:-1;
}
Change the z-index of your slider to be behind the content or the dropdowns to infront of it.
Ahh thanks pritaeas!, Sikander, mysql is outdated and will not use it. I perfer mysqli or PDO Thanks though.
Hello, I found this script and have used it for my login system.
http://www.wikihow.com/Discussion:Create-a-Secure-Login-Script-in-PHP-and-MySQL
I have changed some variables but none the less its the same.
I am trying to create a reset password script here is what i tried so far:
function resetPassword(){
//Main Info
$id = $_POST['id'];
$email = $_POST['email'];
$pass= $_POST['password'];
//salt and pass info
$random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
$password = hash('sha512', $pass.$random_salt);
//Run the Query
$update_stmt = $mysqli->prepare("UPDATE members SET password='$password' AND salt='$random_salt' WHERE id = ?");
$update_stmt->bind_param('s', $id);
if($update_stmt->execute()) {
if(login($email, $password, $mysqli) == true) {
header('Location: ../signin.php?pass=1');
}else {
header('Location: ../passreset.php?error=1');
}
}
}
but its not updating the password in the database. I have it in a functions.php page to enable it to work and be called. any ideas why its not working?
This is my jquery code:
function renderFileRow(data) {
var $link = $('<a class="name" />')
.attr('href', data.is_dir ? '#' + data.path : './'+data.path)
.text(data.name);
var $dl_link = $('<a/>').attr('href','?do=download&file='+encodeURIComponent(data.path))
.addClass('download').text('download');
var $delete_link = $('<a href="#" />').attr('data-file',data.path).addClass('delete').text('delete');
var perms = [];
if(data.is_readable) perms.push('read');
if(data.is_writable) perms.push('write');
if(data.is_executable) perms.push('exec');
var $html = $('<tr />')
.addClass(data.is_dir ? 'is_dir' : '')
.append( $('<td class="first" />').append($link) )
.append( $('<td/>').attr('data-sort',data.is_dir ? -1 : data.size)
.html($('<span class="size" />').text(formatFileSize(data.size))) )
.append( $('<td/>').attr('data-sort',data.mtime).text(formatTimestamp(data.mtime)) )
.append( $('<td/>').text(perms.join('+')) )
.append( $('<td/>').append($dl_link).append( data.is_deleteable ? $delete_link : '') )
return $html;
}
Yea, My Jquery code creates the # using an attr.() function if there is a directory. That is when the #userfiles/username/subfolder
appears in the url. I am wanting to stop that or change so they cannont change the username in the url.
Dani, yea, i seen that, it gets set by the jquery that I have. I have tried to take it out but then the file manager will not work. I think what i need is to set a php condition that says if user x tries to access user b's files echo Not allowed, but I am unsure where to put the conditions or how to structure it. I have tried:
if($file == $_SESSION['username']){
//continue with code
//php code here
}else{
echo'Not allowed to access these files.';
but that didnt work, I know it has to do with the session variable that is in there. Since the users file manager is set at page load. But if you take the #userfiles/username/subfolder
and change the username to usernamex
it will show that users files.
This is what i see...
Diafol, I think it would be easier to set a condition to check if that user is logged in, but I am finding it difficult to set that condition, here is my PHP code to get the file list and such based on username, where and what would i set to test if said user is trying to access a different users folder?
setlocale(LC_ALL,'en_US.UTF-8');
$tmp = realpath($_REQUEST['file']);
if($tmp === false)
err(404,'File or Directory Not Found');
if(substr($tmp, 0,strlen(__DIR__)) !== __DIR__)
err(403,"Forbidden");
if(!$_COOKIE['_sfm_xsrf'])
setcookie('_sfm_xsrf',bin2hex(openssl_random_pseudo_bytes(16)));
if($_POST) {
if($_COOKIE['_sfm_xsrf'] !== $_POST['xsrf'] || !$_POST['xsrf'])
err(403,"XSRF Failure");
}
$file = $_REQUEST['file'] ?: './userfiles/'.htmlentities($_SESSION['username']);
if($_GET['do'] == 'list') {
if (is_dir($file)) {
$directory = $file;
$result = array();
$files = array_diff(scandir($directory), array('.','..'));
foreach($files as $entry) if($entry !== basename(__FILE__)) {
$i = $directory . '/' . $entry;
$stat = stat($i);
$result[] = array(
'mtime' => $stat['mtime'],
'size' => $stat['size'],
'name' => basename($i),
'path' => preg_replace('@^\./@', '', $i),
'is_dir' => is_dir($i),
'is_deleteable' => (!is_dir($i) && is_writable($directory)) ||
(is_dir($i) && is_writable($directory) && is_recursively_deleteable($i)),
'is_readable' => is_readable($i),
'is_writable' => is_writable($i),
'is_executable' => is_executable($i),
);
}
} else {
err(412,"Not a Directory");
}
echo json_encode(array('success' => true, 'is_writable' => is_writable($file), 'results' =>$result));
exit;
} elseif ($_POST['do'] == 'delete') {
rmrf($file);
exit;
} elseif ($_POST['do'] == 'mkdir') {
chdir($file);
@mkdir($_POST['name']);
exit;
} elseif ($_POST['do'] == 'upload') {
var_dump($_POST);
var_dump($_FILES);
var_dump($_FILES['file_data']['tmp_name']);
var_dump(move_uploaded_file($_FILES['file_data']['tmp_name'], $file.'/'.$_FILES['file_data']['name']));
exit;
} elseif ($_GET['do'] == 'download') {
$filename = basename($file);
header('Content-Type: ' . mime_content_type($file));
header('Content-Length: '. filesize($file));
header(sprintf('Content-Disposition: attachment; filename=%s',
strpos('MSIE',$_SERVER['HTTP_REFERER']) ? rawurlencode($filename) : "\"$filename\"" ));
ob_flush();
readfile($file);
exit;
}
function rmrf($dir) …
No, it still shows up when i go into a subfolder...
Im about to
So something like this would work?
# Nice looking URLs (no query string)
# domain.com/category-name-1/ to domain.com/category.php?name=category-name-1
RewriteRule ^([A-Za-z0-9-]+)/?$ filemgr.php [L]