Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello i need help to make a product display page from xml file .... any one who can help me thanks i got an xml file products.xml <PRODUCT> <PRODUCTS_NAME>Name of the product</PRODUCTS_NAME> <PRODUCTS_DESCRIPTION>Details of the products.</PRODUCTS_DESCRIPTION> <PRODUCTS_IMAGE>1111.jpg</PRODUCTS_IMAGE> <PRODUCTS_PRICE>44$</PRODUCTS_PRICE> </PRODUCT> ok i used this code to get information of all the product name on the page <?php $xml=simplexml_load_file("products.xml") or die("Error: Cannot create object"); foreach($xml->children() as $products) { echo $products->PRODUCTS_NAME. "<br>"; } ?> its show all product name line by line ok so all i want to show full product one by one ... For example ( Product image | then product name | Then product price | Then product details ) Thanks for your help in advanced waiting for your answers
  2. I'm in need of some assistance. I'm no expert in PHP / MySQL. I have an old website that uses MySQL to store information. I have all of the .php files that have the sql queries in them, but I don't have any of the MySQL table structures. I would have to manually create the tables via phpmyadmin, but I don't know how to extract the correct required table structure from the .php files. Any help would be greatly appreciated. Thanks
  3. I am having a bit of issue. I have a simple query that loops to find each record, like this. // select query here if(count($result) > 0) { foreach($result as $row) { $userid = $row['user_id']; $_SESSION['userid'] = $userid; } } else { // error here } I want to use the "$userid" on a different page; so I created a session for it. When ever I use that session on another page, it gives me only the last record's user id and not the first one. How can I fix this?
  4. Keep getting these two errors when trying to UPDATE a field called "type" to 'banana' based on the fuitid. Why is this happening? Undefined index: fruitid in update.php You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 <form method="POST" action="update.php"> <select> <option value="">Select</option> <?php $sql = "SELECT fruitid, datefrom, dateto FROM fruits"; $sqlresult = $link->query($sql); $sqllist = array(); while($row = mysqli_fetch_array($sqlresult)) { echo "<option>".$row['datefrom']." - ".$row['dateto']."</option>"; } ?> </select> <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/> <input type="submit" value="Submit" name="submit"/> </form> <?php if(isset($_POST['submit'])) { $fruitid= mysqli_real_escape_string($link,$_POST['fruitid']); $sql = "UPDATE `fruits` SET `type`='banana' WHERE fruitid = $fruitid"; if (mysqli_query($link, $sql)) { echo "updated"; } else { echo "problem: " . mysqli_error($link); } } ?>
  5. I am reading images from the directory 'images' which contains several folders with images. I want to show every image in a div and with the checkbox to decide if it is fashion or not fashion. I am using the following code in order to read files from directory and showing them in browser. The divs is one after other: <?php function listFolderFiles($dir){ $html = ''; // Init the session if it did not start yet if(session_id() == '') session_start(); $html .= '<ol>'; foreach(new DirectoryIterator($dir) as $folder){ if(!$folder->isDot()){ if($folder->isDir()){ // $html .= '<li>'; $user = $dir . '/' . $folder; foreach (new DirectoryIterator($user) as $file) { if($file != '.' && $file != '..'){ $image = $user . '/' . $file; // Check the pictures URLs in the session if(isset($_SESSION['pictures']) && is_array($_SESSION['pictures'])){ // Check if this image was already served if(in_array($image, $_SESSION['pictures'])){ // Skip this image continue; } } else { // Create the session variable $_SESSION['pictures'] = array(); } // Add this image URL to the session $_SESSION['pictures'][] = $image; // Build the form //echo $image, "</br>"; $html .= ' <style> form{ font-size: 150%; font-family: "Courier New", Monospace; display: inline-block; align: middle; text-align: center; font-weight: bold; } </style> <form class = "form" action="' . action($image) . '" method="post"> <div> <img src="' . $image . '" alt="" /> </div> <label for="C1">FASHION</label> <input id="fashion" type="radio" name="fashion" id="C1" value="fashion" /> <label for="C2"> NON FASHION </label> <input id="nfashion" type="radio" name="nfashion" id="C2" value="nfashion" /> <input type="submit" value="submit" /> </form>'; // Show one image at a time // Break the loop break 2; } } // $html .= '</li>'; } } } $html .= '</ol>'; return $html; } //##### Action function function action($img){ $myfile = fopen("annotation.txt", "a"); if (isset($_POST['fashion'])) { fwrite($myfile, $img." -- fashion\n"); // echo '<br />' . 'fashion image'; } else{ fwrite($myfile, $img." -- nonFashion\n"); // echo '<br />' . ' The submit button was pressed<br />'; } } echo listFolderFiles('images//'); ?> When I make call of action($image) from inside form tag, I noticed, that a default value of submit it is parsed to the function, thus it stores the name of the image with the default value and the chosen value for the first image it is parsed to the second image, the chosen value of the second image it is stored to the file with the third image and so on. When I make call in side input submit tag it began storing to the file from the second image with the value of the first one and so on. I couldn't manage to have stored to the file the correct correspondence between the image and the chosen value. Where should I make call of the action function in order to do it properly?
  6. This should all be working but I think I might be overlooking something. Problem 1. I am using ajax to process a form. I don't think the problem is with ajax(works with other queries), but rather with php. Here is my simple query. $stmt = $db->prepare("SELECT * FROM records WHERE request_by = :request_by, request_to = :request_to AND session = :session"); $stmt->bindParam(':request_by', $byUserid); $stmt->bindParam(':request_to', $toUserid); $stmt->bindValue(':session', 1); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); if(count($result) > 0) { $success = 'This was successful.'; } else { $error = 'There was a problem.'; } This above query gives me this error. Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' request_to = '7' AND session = '1'' at line 1 Problem 2. Say the main page is "index.php" with submit form and I am using ajax via url: process.php. Well on "index.php" page, I have foreach loop that gets me a "$toUserid" for each record. I would like to use that "$toUserid" in "process.php" page. I tried setting it as a session but still it won't give me that exact userid. It'll give me the same userid as the user I am currently logged in. What exactly I am doing wrong and how I can i fix it?
  7. I have a script that resizes and uploads an image. It works great. Now I would like to add a new function to it that will detect if there is a duplicate image already posted. If there is, it will not upload the image. I have found a script that has that function. I am just a little lost on how to incorporate that into my php code. Here is my image upload/resize code. if(Input::exists()) { if(Token::check(Input::get('token'))) { // Setting up image folders based on user id $userDir= 'images/'.$userid.'/'; if(!is_dir($userDir)){ mkdir('images/'.$userid.'/', 0775); } else { // Uploading image with resize and crop. if(isset($_FILES['image'])) { if (empty($_FILES['image']['name'])) { $error = 'Please choose an image!'; } else { function swapHW() { global $height, $width, $newheight, $newwidth; $tempHeight = $height; $tempWidth = $width; $height = $tempWidth; $width = $tempHeight; $tempHeight = $newheight; $tempWidth = $newwidth; $newheight = $tempWidth; $newwidth = $tempHeight; } function getOrientedImage($imagePath){ $image = imagecreatefromstring(file_get_contents($imagePath)); $exif = exif_read_data($imagePath); if(!empty($exif['Orientation'])) { switch($exif['Orientation']) { case 8: $image = imagerotate($image,90,0); swapHW(); break; case 3: $image = imagerotate($image,180,0); break; case 6: $image = imagerotate($image,-90,0); swapHW(); break; } } return $image; } $name = $_FILES['image']['name']; $temp = $_FILES['image']['tmp_name']; $type = $_FILES['image']['type']; $size = $_FILES['image']['size']; $ext = strtolower(end(explode('.', $name))); $size2 = getimagesize($temp); $width = $size2[0]; $height = $size2[1]; $upload = md5(rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000)); // Restrictions for uploading $maxwidth = 6000; $maxheight = 6000; $allowed = array('image/jpeg', 'image/jpg', 'image/png', 'image/gif'); // Recognizing the extension switch($type){ // Image/Jpeg case 'image/jpeg': $ext= '.jpeg'; break; // Image/Jpg case 'image/jpg': $ext= '.jpg'; break; // Image/png case 'image/png': $ext= '.png'; break; // Image/gif case 'image/gif': $ext= '.gif'; break; } // upload variables $path = $userDir . $upload . $ext; $thumb_path = $userDir . 'thumb_' . $upload . $ext; // check if extension is allowed. if(in_array($type, $allowed)) { // Checking if the resolution is FULLHD or under this resolution. if($width <= $maxwidth && $height <= $maxheight) { if($size <= 5242880) { // check the shape of the image if ($width == $height) {$shape = 1;} if ($width > $height) {$shape = 2;} if ($width < $height) {$shape = 3;} //Adjusting the resize script on shape. switch($shape) { // Code to resize a square image. case 1: $newwidth = 300; $newheight = 225; break; // Code to resize a tall image case 2: $newwidth = 300; $ratio = $newwidth / $width; $newheight = round($height * $ratio); break; // Code to resize a wide image. case 3: $newheight = 225; $ratio = $newheight / $height; $newidth = round($width * $ratio); break; } // Resizing according to extension. switch($type) { // Image/Jpeg case 'image/jpeg'; $img = imagecreatefromjpeg($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/Jpg case 'image/jpg'; $img = imagecreatefromjpeg($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/png case 'image/png'; $img = imagecreatefrompng($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagepng($thumb, $thumb_path); break; // Image/gif case 'image/gif'; $img = imagecreatefromgif($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagegif($thumb, $thumb_path); break; } try { $stmt = $db->prepare("INSERT INTO images(path, thumb_path) VALUES(:path, :thumb_path)"); $stmt->bindParam('path', $path); $stmt->bindParam('thumb_path', $thumb_path); $stmt->execute(); if($stmt == false){ $error = 'There was a problem uploading your image.'; } else { $success = 'Your image has been uploaded.'; move_uploaded_file($temp, $path); } } catch(Exception $e) { die($e->getMessage()); } } else { $error = 'Your image size is too big.'; } } else { $error = 'Your image resolution exceeds the limit.'; } } else { $error = 'Your have uploaded a forbidden extension.'; } } } } } } This guy has found a way to find duplicate images. Here is his script. http://www.catpa.ws/php-duplicate-image-finder/ I could really use some help on integrating his method into mine.
  8. If you search for images on Google images, you will see how they setup their images, side by side and have infinity scroll. I don't care about the infinity scroll part, but I am interested in how they set up the images? My plan is to retrive the images from the database and use pagination numbers.
  9. Hello, i would like to know to how to make this script work. I get information using this link below in index.php, after i get the information i want to insert/update in database information which i don't show on the page self. index.php <?php echo '<a href="example.com?url='. $row['url'] . '&name='. $row['name'] .'&info='. $row['info'] .'&privat='. $row['privat'] .'" target="_blank">Edit</a> ';?> So like this here below i show the information. get_info.php <?php echo $_GET['name']; ?> Which works fine. So now updating the database. $ip_address = $_SERVER['REMOTE_ADDR']; // Ip address works fine $name = $_GET['name']; // not working $r_name = $_POST['$name']; // not working $r_name= 'test'; // this is working. mysql_query("insert into r_test (r_name,r_ip) values('$r_name','$ip_address')") or die(mysql_error()); So how can i get the value and insert in database, only row r_ip is updated with the ip address. I hope i explained it well Thanks in advance.
  10. We have a wordpress install with the plugin wp-job manager installed. https://wpjobmanager.com We add and manage jobs via YouRecruit but we want to update them to our wordpress database (wp-job manager) every time they're added, updated or we deleted. We also have a plugin/api module from YouRecruit which extends the wp job manager plugin and enables us to post and delete jobs to wp-job manager using xml. This is all the documentation I have on the API module from YouRecruit below and there are no settings in the back end of wordpress for you to fill in. Based on what I have read below I am assuming the plugin handles most of the processing but you still have to write your own PHP script and host it at 'http://www.yoursite.com/jobload/get_job.php' for example. At least this is what it says. I'm thinking were going to have to fetch the xml with simple_xml there is a brief code snipped in the documentation on doing this. I then don't know where to go from there or if this is the correct way to go about dealing with this issue. http://yourecruit.com/resources_public/wordpress_job_manager_api.php http://yourecruit.com/resources_public/own_site_posting.php Could anyone confirm if I am thinking along the right lines here. Thanks your advice is very much appreciated.
  11. I'm rather new to PHP, and I've run into a problem develeoping this script that I can't figure out. It's fairly simple in that it fetches the user input via a search box and cross references it against a blacklist and whitelist in the form of two seperate .txt. files. However, the enclosed code seems to ignore the second if statement and will always return "unknown website" even if users' input is in the blacklist. The first if statement works correctly though, so I'm a little bit lost as to where I've gone wrong. I'm also not sure how I shoud approach implementing case sensentivity and checking if the user input contains a specfiic word that's on a line. For example, if a user inputted phpfreaks into the search box it would still come out as legimtmate even though I didn't specifically state phpfreaks (it would be the full url, e.g. phpfreaks.com) in the whitelist txt file. From my research I would think the strpos function or preg_match might work, but I'm not sure how I should put it in there. <?php $search = $_POST['search']; $blacklist = file_get_contents("illegitimatesites.txt"); $whitelist = file_get_contents("legitimatesites.txt"); $blacklist = explode("\n", $blacklist); $whitelist = explode("\n", $whitelist); if(in_array($_POST['search'], $whitelist)){ //checks if site is in array echo "This website is an authorised distributor"; } else{ if(in_array($_POST['search'], $blacklist)){ //checks if site is in array echo "This website is NOT an authorised distributor"; } else{ echo "Unknown website"; } } ?>
  12. $_DIR['ROOT'] = $_SERVER['DOCUMENT_ROOT'] .'/..';//Outside the scope of WWW root $_DIR['LOG'] = $_DIR['ROOT'] .'/logs/LogFiles/' . $_SERVER['SERVER_NAME']; if (!is_dir($_DIR['LOG'])){Mkdir($_DIR['LOG'],0700,TRUE);} I created a directory to log with on my Dev server assigning all sorts of values to these logs but i got some resolving DNS names that are not associated with my website at all. Why would $_SERVER['SERVER_NAME'] be resolving other names that are not related to my server? Expected Posiblities 127.0.0.1 Internal IP Address External IP Address test.example.com (My Website URI) Unexpected Results www.baidu.com www.epochtimes.jp www.ly.com
  13. Hey guys, I am not sure how to do a proper range in my if statement. I need a range where count is between 1 and 10. I am using this statement below, but it is just considering the $count<=10 and 0 is included in this statement. I require a different function for $count = 0. Thanks in advance! if ($count <= 10 && $count >= 1)
  14. helloI have 2 php files . one on my pc and one on my host . which is on the host gets an input and check it and after that returns a string . I want to send that input from my php that's on my pc to another one and give the returned string and use it (without any changes in screen . for example opening firefox) how can i do it . thanks a lot
  15. I am working on trying to get php code to take a record set from mysql table and rotate the records, so when you refresh the page, the first record would show at the top of the list, then record 2 and so on down the line. If you were a new person to come to the page, record 2 would show at the top of the list, then record 3 and down the line, and record 1 would now be at the bottom. I have a position column in the table and when the page loads it will update the position field of each record to be one less then it was before, so when the next person to come to the page, it will be up one spot in the table. My issue is that when the page gets refreshed to quickly or I have had it not finish updating the records and then there is multiple records with the same position number. I am looking to only have 9 records only for the example, so if Position is set to 1 it will be set to 9, if not it will take Position - 1. if(isset($_GET["page"])){ } else{ $sql = "SELECT ID,Name,Position FROM tableA ORDER BY Position DESC"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { if($row["Position"] == 1){ $p = 9; } else{ $p = $row["Position"]-1; } $conn->query("UPDATE tableA SET Position = $p WHERE ID = $row[ID]"); } mysqli_free_result($result); } Am I going down the right path? It just seems like it will not work 100% of the time. Hopefully I explained what is going wrong fully and clearly. Thank in advance.
  16. Hi, I have a question is this situation possible below? sample database table Information ID, Username,Password,level 1 user1 Pass1 1 2 user2 Pass2 2 I want a php code i which when I login my username and password it will check 3 fields in the table, the username and password if it matches from the database and the it will check what level is the user. So if ever username and password is correct it will check if what level is the user, so if the users level is 1 it will go to level1.php page and if 2 it will go to level2.php Hope you can help me with this problem of mine.
  17. I am not very advanced in web programming I need help.. I am using an API and my sql database. I would to implement live/ dynamic updates in the text field where user will input their text, and the web should first check the database then the api live. I would also like to retrieve the user input without refreshing the page, so the retrieved information regarding the inputted text should be automatically loaded without refreshing the page. please help .
  18. I have a mysql table named songs with 3 columns, id, artist,title. Most of the songs in the artist column are correct, ex: artist ------------------ John Denver Loretta Lynn Shania Twain Luke Bryan But some of the songs in the artist column are reveresed with a comma, ex: artist ----------------- Dever, John Lynn. Loretta Twain, Shania Bryan, Luke Is there an easy php code snippet or mysql statement that i can use to reverse the order of first name and last name and remove the comma in the last example so the artst columd matches the first example? I hope this makes sense, thanks, Dale.
  19. Can Someone please look at the following zip file and edit index and code-gen so when someone refer required amount of visitors, php echo will redirect them to complete.php I have got css and js but not uploading as they are too big Thanks (please help me) script.zip
  20. i'm creating a ticketing system and i need some assistance. The code directly below displays the database records and the delete works fine. The edit however isn't picking the values in the various fields. <?Php require "config.php"; $page_name="currentout.php"; $start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)){ echo "Data Error"; exit; } $eu = ($start - 0); $limit = 10; $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; $nume = $dbo->query("select count(id) from receipt")->fetchColumn(); echo "<TABLE class='t1'>"; echo "<tr><th>ID</th><th>Name</th><th>Pass</th><th>Amount</th><th>Action</th></tr>"; $query=" SELECT * FROM receipt limit $eu, $limit "; foreach ($dbo->query($query) as $row) { @$m=$i%2; @$i=$i+1; echo "<tr class='r$m'><td>$row[id]</td><td>$row[name]</td><td>$row[phone_num]</td><td>$row[Amount]</td><td><a href='delete.php?id=$row[id]'>delete</a></td><td><a href='edit.php?id=$row[id]'>Edit</a></td></tr>"; } echo "</table>"; if($nume > $limit ){ echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; if($back >=0) { print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; } echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$l</font>";} $l=$l+1; } echo "</td><td align='right' width='30%'>"; if($this1 < $nume) { print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; } ?> The code below is edit.php. It's supposed to display the various fields when clicked to allow for editing but it isn't picking any field, PLEASE assist. <?Php require "config.php"; $sql = "SELECT FROM receipt WHERE ID= :ID"; $stmt = $dbo->prepare($sql); $stmt->bindParam(':ID', $_GET['id'], PDO::PARAM_INT); $stmt->execute(); ?> <form action="update.php" method="post" enctype="multipart/form-data"> <table align="center"> <tr> <td> <label><strong>Full Names</strong></label></td> <td> <input type='text' name='name' value=" <?php echo $row['name']; ?>" /> <input type="hidden" name="id" value="<?php echo $id; ?> " /> <br /></td> </tr> <tr> <td><label><strong>ID/Passport No. </strong></label></td> <td> <input type="text" name="pass" value="<?php echo $row['id_passno']; ?> " /><br /></td> </tr> <tr> <td> <label><strong>Phone No. </strong></label></td> <td><input type="text" name="phone" value="<?php echo $row['phone_num']; ?>" /> <br /></td> </tr> <tr> <td> <label><strong>Amount (KShs.) </strong></label></td> <td><input type="text" name="amount" value="<?php echo $row['Amount']; ?> "/> <br /></td> </tr> <tr> <td> <input type="reset" name="Reset" value="CANCEL" onClick="return confirm('Discard changes?');" /> <br></td> <td> <input type="submit" name="Submit2" value="SUBMIT" /> </td> </tr> </table> </form>
  21. Sorry if i posted this in the wrong place but i dident see anthing about Active Directory or Security Questions But has anyone used Active Directory as their User Database? Has anyone even tryed braking Active Directory with injection attacks? Notes that i have found so far: Php Sends to CMD first so encode userdata in base64 as a transport layer $rand is a random number to prevent users from useing Success: as a ligitimate user You will need to clean up the many many spaces that powershell sends back as it is a concole Special Charicters dont need to be escaped I am using Win 2008 RC2 Apache PHP (of course) Powershell Active Directory PHP Script $psScriptPath = 'C:/Apache/PSScripts/' //Path outside Website Root $rand = mt_rand(mt_getrandmax(),mt_getrandmax()); //UTF-8 Standard only $username = utf8_decode($_POST["username"]); $password = utf8_decode($_POST["password"]); $base64_username = base64_encode($username); //Transport Layer Base64 $base64_password = base64_encode($password); //Transport Layer Base64 //The danger happens here as it is sent to powershell. $query = shell_exec('powershell.exe -ExecutionPolicy ByPass -command "' . $psScriptPath . '" < NUL -rand "' . $rand . '" < NUL -base64_username "' . $base64_username . '" < NUL -base64_password "' . $base64_password . '" < NUL');// Execute the PowerShell script, passing the parameters Powershell Script #*============================================================================= #* Script Name: adpwchange2014.ps1 #* Created: 2014-10-07 #* Author: #* Purpose: This is a simple script that queries AD users. #* Reference Website: http://theboywonder.co.uk/2012/07/29/executing-powershell-using-php-and-iis/ #* #*============================================================================= #*============================================================================= #* PARAMETER DECLARATION #*============================================================================= param( [string]$base64_username, [string]$base64_password, [string]$rand ) #*============================================================================= #* IMPORT LIBRARIES #*============================================================================= if ((Get-Module | where {$_.Name -match "ActiveDirectory"}) -eq $null){ #Loading module Write-Host "Loading module AcitveDirectory..." Import-Module ActiveDirectory }else{ write-output "Error: Please install ActiveDirectory Module" EXIT NUL Stop-Process -processname powershell* } #*============================================================================= #* PARAMETERS #*============================================================================= $username = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64_username)) $password = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($base64_password)) #*============================================================================= #* INITIALISE VARIABLES #*============================================================================= # Increase buffer width/height to avoid PowerShell from wrapping the text before # sending it back to PHP (this results in weird spaces). $pshost = Get-Host $pswindow = $pshost.ui.rawui $newsize = $pswindow.buffersize $newsize.height = 1000 $newsize.width = 300 $pswindow.buffersize = $newsize #*============================================================================= #* EXCEPTION HANDLER #*============================================================================= #*============================================================================= #* FUNCTION LISTINGS #*============================================================================= Function Test-ADAuthentication { Param($Auth_User, $Auth_Pass) Write-Output "Running Function Test-ADAuthenication" $domain = $env:USERDOMAIN Add-Type -AssemblyName System.DirectoryServices.AccountManagement $ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, $domain) $pc.ValidateCredentials($Auth_User, $Auth_Pass).ToString() } #*============================================================================= #* SCRIPT BODY #*============================================================================= Write-Output $PSVersionTable Write-Output " " $authentication = Test-ADAuthentication "$username" "$password" if ($authentication -eq $TRUE) { Write-Output "Success:$rand Authentication" }elseif ($authentication -eq $FALSE) { Write-Output "Failed:$rand Authentication" }else { Write-Output "Error: EOS" EXIT NUL Stop-Process -processname powershell* } #*============================================================================= #* SCRIPT Exit #*============================================================================= Write-Output "End Of Script" EXIT NUL Stop-Process -processname powershell*
  22. I am trying to create a history of requested URI's (upto 3) for two purposes Login page and Error Logging. My problem is the Session is written and the values are set yet i can not retrieve the values in it upon a refresh. The use of an Array is to manage the quantity of max values (not written in yet). <?php session_start(); //printing $_SESSION['REQUEST_URI'] here will result in nothing when it should contain something. $REQUEST_URI = time().','.$_SERVER['REQUEST_URI']; if(is_array($_SESSION['REQUEST_URI'])){array_push($_SESSION['REQUEST_URI'],array($REQUEST_URI));} else{$_SESSION['REQUEST_URI'] = array($REQUEST_URI);Print('never set? ');}//if dosent exist create the array if(isset($_SESSION['REQUEST_URI'])){print_r($_SESSION['REQUEST_URI']);} ?> Session contains REQUEST_URI|a:1:{i:0;s:19:"1422925783,/~Debug/";} After a refresh i expect REQUEST_URI|a:2:{i:0;s:19:"1422925783,/~Debug/";i:1;s:28:"1422925784,/~Debug/index.php";} Yet it only contains REQUEST_URI|a:1:{i:0;s:28:"1422925784,/~Debug/index.php";}
  23. i am creating a responsive website. I'll give you an example. I am retriving 100 items from mysql database using php. I am only showing 20 items per page using simple pagination with arrows. I keep this format on desktop and tablets. However, I would like to show less items when I am viewing the page on a smartphone. So instead of 20 items per page, it'll show 5 items per page along with the pagination arrows. I was wondering if this is possible with PHP or would I have to use javascript?
  24. What I remember from my college days is that isset check whether the variable has a value set or not and return true or false value. However I encountered a code in wordpress - // Set up the content width value based on the theme's design and stylesheet. if ( ! isset( $content_width ) ) $content_width = 625; Here why is this sign used ! This sign is actually not equal to, Right?
  25. Hai.. currently i am developing client dashboard using php/mysql.Here is my problem i need to create a tab named as notes.Using this tab the logged in users can add a new note or edit his existing note and save as text file.. when user gets logged in he can able to see his notes.. May i know how to do this in php? Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.