-
Posts
334 -
Joined
-
Last visited
Everything posted by inversesoft123
-
This code is working fine with older database entries.. problem is only with newly added files let me restore my database and update it again.. We have many albums near about 230 each album contains some ringtones. each ringtone is having 3 types of it full compressed and in amr format for mobile. Now this problem is with only newly added few albums (no duplicate entries in database) and contents of that album. Thank you very much for your help.
-
OK I have removed some unnecessary part from previous code. Tried to make it more consistent. $selectalbum="SELECT * from pf_amusic where id='$albumid'"; $selectalbum2=mysql_query($selectalbum); $selectalbum3=mysql_fetch_array($selectalbum2); //Include the PS_Pagination class include('../ps_pagination.php'); //Connect to mysql db $conn = mysql_connect('localhost','-----------','--------------'); mysql_select_db('----------',$conn); $filesa = "SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel, vpre FROM pf_fmusic WHERE (aid='$albumid' AND vpre='complete') ORDER BY id DESC"; //Create the PS_Pagination object some values are passed to ps_pagination class for next and previous links as I am using Apache mod rewrite. $pager = new PS_Pagination($conn, $filesa, 9, 5, $albumid, $sortid, $sub, $selectalbum3[uid], $title, $collective); $results = $pager->paginate(); /////////////// While loop for pagination begins ////////////////// while($files=mysql_fetch_array($results)) { $ext = end(explode('.', $files[3])); $compactfilename = substr($files[4],0,"25"); echo "<table align=\"left%\" width=\"100%\" border=\"0\">"; echo "<tr>"; echo "<b>$files[4]</b><hr>"; ///////////// Get Other versions of file ////////// Viz. Full, Compressed and AMR for mobiles... ///////////// $othrvs = mysql_query("SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel, vpre FROM pf_fmusic WHERE filename='$files[4]' ORDER BY id DESC LIMIT 3"); echo "</tr><tr>"; //while loop for other versions while($othrv=mysql_fetch_array($othrvs)) { if($othrv[10] =="complete") { $fitype = "FULL (128 Kbps)"; } else if($othrv[10] =="compressed") { $fitype = "COMPRESSED (16 Kbps)"; } else { $fitype = "MOBILE AMR"; } //while loop for other versions ends $modurl= ereg_replace("[^A-Za-z0-9]", "-", $files[4]); // For mod_rewrite urls echo "<td><a class =\"link\" href =\"http://www.-----------.com/landing/$othrv[0]/$othrv[1]/$current_folder/$albumid/$sortid/$ref/$modurl.php\">$fitype</a><br/>Size :"; print ByteSize("$othrv[2]"); echo "<br/>Hits : $othrv[5]</td>"; // Printing file size } echo "</tr>"; echo "</table>"; echo "<hr color=\"#660099\" size=3>"; } /////////////// While loop for pagination ends ////////////////// //Display the navigation echo " <tr><td><br/> \n"; echo"<div class=\"wp-pagenavi\">"; echo $pager->renderFullNav(); echo " </div> </tr></td>\n"; echo "</table>";
-
Okay here is complete code. Thanks for your reply //Include the PS_Pagination class include('../ps_pagination.php'); //Connect to mysql db $conn = mysql_connect('localhost','-----------','--------------'); mysql_select_db('----------',$conn); $filesa = "SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel, vpre FROM pf_fmusic WHERE (aid='$albumid' AND vpre='complete') ORDER BY id DESC"; ///Create the PS_Pagination object $pager = new PS_Pagination($conn, $filesa, 9, 5, $albumid, $sortid, $sub, $selectalbum3[uid], $title, $collective); $results = $pager->paginate(); if(!$selectalbum3[artwork]) { echo "<tr><td><img src=\"http://www.-----------.com/images/no_preview.jpg\" alt=\".\"/></td></tr>"; if(isset($_SESSION['user'])) { echo "<tr><td><a class='link' href=\"http://www.-----------.com/updatepreview.php?type=$current_folder&fileid=$albumid\" width=\"200\" height=\"250\" alt=\".\"/>Update Preview</a></td></tr>"; } } else { echo "<tr><td><img src=\"http://www.-----------.comm/files/music/musicname/thumbs/$selectalbum3[uid]/$selectalbum3[artwork]\" width=\"200\" height=\"250\" alt=\".\"/></td></tr>"; } echo "<tr><td><hr color=\"#660099\" size=3></td></tr>"; while($files=mysql_fetch_array($results)) { $ext = end(explode('.', $files[3])); $compactfilename = substr($files[4],0,"25"); echo "<table align=\"left%\" width=\"100%\" border=\"0\">"; echo "<tr>"; echo "<b>$files[4]</b><hr>"; ///////////// Get Other versions of file ////////// Viz. Full, Compressed and AMR for mobiles... ///////////// $othrvs = mysql_query("SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel, vpre FROM pf_fmusic WHERE filename='$files[4]' ORDER BY id DESC LIMIT 3"); echo "</tr><tr>"; while($othrv=mysql_fetch_array($othrvs)) { if($othrv[10] =="complete") { $fitype = "FULL (128 Kbps)"; } else if($othrv[10] =="compressed") { $fitype = "COMPRESSED (16 Kbps)"; } else { $fitype = "MOBILE AMR"; } $modurl= ereg_replace("[^A-Za-z0-9]", "-", $files[4]); echo "<td><a class =\"link\" href =\"http://www.-----------.com/landing/$othrv[0]/$othrv[1]/$current_folder/$albumid/$sortid/$ref/$modurl.php\">$fitype</a><br/>Size :"; print ByteSize("$othrv[2]"); echo "<br/>Hits : $othrv[5]</td>"; } echo "</tr>"; echo "</table>"; echo "<hr color=\"#660099\" size=3>"; $selectres = "SELECT * FROM pf_resolutions WHERE swidth='$files[6]' AND sheight='$files[7]'"; $selectres2=mysql_query($selectres); $selectres3=mysql_fetch_array($selectres2); $selecthandsets="SELECT * from pf_handsets where ID='$selectres3[iD]'"; $selecthandsets2=mysql_query($selecthandsets); $selecthandsets3=mysql_fetch_array($selecthandsets2); if(isset($_SESSION['user'])) { $selectrescat = "SELECT * FROM pf_handsets WHERE hand_set='$selectuser3[hand_set]'"; $selectrescat2=mysql_query($selectrescat); $selectrescat3=mysql_fetch_array($selectrescat2); if($selectres3[iD] == $selectrescat3[iD]) { echo "<br/><img src=\"http://www.-----------.com/chat/images/onebit_34.png\" alt=\"loc\"/></i>Works fine with your phone.</td></tr>\n"; } else { echo "<br/><img src=\"http://www.-----------.com/chat/images/onebit_36.png\" alt=\"loc\"/></i>May not work with your phone.</td></tr>\n"; } } } //Display the navigation echo " <tr><td><br/> \n"; echo"<div class=\"wp-pagenavi\">"; echo $pager->renderFullNav(); echo " </div> </tr></td>\n"; echo "</table>";
-
can anybody tell me what's wrong with my query ? $filesa = "SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel, vpre FROM pf_fmusic WHERE (aid='$albumid' AND vpre='complete') ORDER BY id DESC"; I am using this in while loop with ps_pagination class but getting 2 records for same set of files. in other words its running while loop 2 time complete code is here... $filesa = "SELECT id, uid, size, filehash, filename, dwnloads, swidth, sheight, fores, flabel FROM ibwf_fmusic WHERE (aid='$albumid' AND vpre='complete') ORDER BY id DESC"; $pager = new PS_Pagination($conn, $filesa, 9, 5, $albumid, $sortid, $sub, $selectalbum3[uid], $title, $collective); $results = $pager->paginate(); while($files=mysql_fetch_array($results)) { // Blah Blah } Output is something like this 1. song 1 2. song 2 3. song 3 4. song 4 1. song 1 2. song 2 3. song 3 4. song 4 Thanks is advance
-
Here we are moving uploaded file to specific folder and renaming it to mynewname.jpg and deleting temporary file. $newfilename = "mynewname.jpg"; copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],"/home/domain/public_html/files/".$newfilename); unlink($HTTP_POST_FILES['uploadedfile']['tmp_name']); In previous steps you can free extensions from original file $extensionorig = end(explode('.', $filename)); if ($extensionorig == 'jar') { $ext = ".jar"; } else if ($extensionorig == 'jad') { $ext = ".jad"; } else { echo "Untrusted File"; $flag++ // push to error page }
-
$extension = end(explode('.',$filename));
-
Fatal error: Allowed memory size of 67108864 bytes exhausted
inversesoft123 replied to redfort's topic in PHP Coding Help
Hi check for this setting in php.ini memory_limit = ***M ; Maximum amount of memory a script may consume (***MB) Increase Limit and Restart Apache. -
I hope Time is a not UNIX time or timestamp. cheers!
-
Even you can try like this $result = mysql_query("SELECT * FROM Content ORDER BY Time ASC, ID DESC LIMIT $start, 10"); // OR $result = mysql_query("SELECT * FROM Content ORDER BY Time ASC, ID ASC LIMIT $start, 10");
-
Is there any reason to include login.php into the head section ? It should be in-between opening and closing body tags <body> </body>
-
$result = mysql_query("SELECT * FROM Content ORDER BY Time ASC LIMIT $start, 10"); As I see here you ordering by Time. Are you sure that your primary key is Time ? I don't think so, Try it to order by unique id from the table Content. mainly id ID or UID whatever.
-
$myFile = "newuser.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 5); fclose($fh); $pices=explode(' ', $theData); echo "<a href=\".?act=Profile&id=$pices[1]\">$pices[0]</a>";
-
The problem is that your PHP version and server probably don't support the deprecated $HTTP_POST_VARS collection. as you are running on Windows.. That's probably the source of the issue. Try replacing with $_POST in your code <?php if ($_POST['submit']) { if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { } //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); //$ext = substr($filename, strrpos($filename, '.') + 1); if (($_FILES["uploaded_file"]["size"] < 26214400)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/upload/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { $ip_address = $_SERVER['REMOTE_ADDR']; $file_hash = hash('ripemd160', '$filename'); echo 'Link to your file: <a href="http://localhost/filehosting/download.php?d='. $file_hash.'">http://localhost/filehosting/download.php?d='.$file_hash.'</a>'; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("filehosting"); $sql="INSERT INTO data(ID, file_location, file_hash, file_ip_address) VALUES ('','$filename','$file_hash','$ip_address')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only files under 25MBs are accepted for upload"; echo 'Upgrade your account to upload bigger files.'; } } else { echo "<h2>Upload:</h2> <form enctype='multipart/form-data' action='upload.php' method='post'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000' /><br /> Choose a file to upload:<br /> <input name='uploaded_file' type='file' /><br /> <input type='submit' name='submit' value='Upload' /><br /> </form>"; } ?>
-
<?php if ($HTTP_POST_VARS['submit']) { if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { } //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); //$ext = substr($filename, strrpos($filename, '.') + 1); if (($_FILES["uploaded_file"]["size"] < 26214400)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/upload/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { $ip_address = $_SERVER['REMOTE_ADDR']; $file_hash = hash('ripemd160', '$filename'); echo 'Link to your file: <a href="http://localhost/filehosting/download.php?d='. $file_hash.'">http://localhost/filehosting/download.php?d='.$file_hash.'</a>'; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("filehosting"); $sql="INSERT INTO data(ID, file_location, file_hash, file_ip_address) VALUES ('','$filename','$file_hash','$ip_address')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only files under 25MBs are accepted for upload"; echo 'Upgrade your account to upload bigger files.'; } } else { echo "<h2>Upload:</h2> <form enctype='multipart/form-data' action='test.php' method='post'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000' /><br /> Choose a file to upload:<br /> <input name='uploaded_file' type='file' /><br /> <input type='submit' name='submit' value='Upload' /><br /> </form>"; } ?> I have updated this code. and its working fine here. just replace <form enctype='multipart/form-data' action='test.php' method='post'> test.php here with your script name.
-
LoL, its because of my code editor software, anyway I figured out what is the problem 1. $newname = dirname(__FILE__).'/upload/'.$_SESSION['username'].''.$filename; Check here do you have directories at this location ?
-
<?php if(isset($_POST)) { //Сheck that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); //$ext = substr($filename, strrpos($filename, '.') + 1); if (($_FILES["uploaded_file"]["size"] < 26214400)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/upload/'.$_SESSION['username'].''.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { $ip_address = $_SERVER['REMOTE_ADDR']; $file_hash = hash('ripemd160', '$filename'); echo 'Link to your file: <a href="http://localhost/filehosting/download.php?d='. $file_hash.'">http://localhost/filehosting/download.php?d='.$file_hash.'</a>'; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("filehosting"); $sql="INSERT INTO data(ID, file_location, file_hash, file_ip_address) VALUES ('','$filename','$file_hash','$ip_address')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only files under 25MBs are accepted for upload"; echo 'Upgrade your account to upload bigger files.'; } } else { echo "Error: No file uploaded"; } } else { echo "<h2>Upload:</h2> <form enctype='multipart/form-data' action='' method='post'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000' /><br /> Choose a file to upload:<br /> <input name='uploaded_file' type='file' /><br /> <input type='submit' value='Upload' /><br /> </form>"; } ?>
-
if ($HTTP_POST_VARS['uploaded_file']) { // code of upload.php or require_once("includes/upload.php"); } else { // show form } Check actual submission of form.
-
If you check echo "Events Added!"; in my updated code. U can simply echo all the form elements. like $fairname = $_POST['fairname']; $fairadd = $_POST['fairadd']; // And so on after this echo "We have added following records into the database:<br/>Event name = \"$fairname\"<br/>Event address = \"$fairadd\"<br/>And so on...";
-
It can be done with cron jobs. Run a specific script at specific time from cron job and trigger a flag in database. Like PAGE: cronjob.php @ 4.00 pm mysql_query("UPDATE pf_events SET notify='1'"); PAGE : index.php Select flag from database. $selectflag = "SELECT * FROM pf_events'"; $selectflag2=mysql_query($selectflag); $selectflag3=mysql_fetch_array($selectflag2); if($selectflag3[notify] == "1") { // paste your popup code here } } Also, you can create another cron job script and run it on 4:05 PM daily to set notify flag again to 0
-
page1.php <?php ?> <leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"> <center><form name="fairlistlist" method="POST" action="page2.php"> <TABLE width="450" height="119" border=0 cellPadding=3 cellSpacing=2 bgcolor="#fff568"> <TBODY> <TR> <TD class=mainText width="100"><b>Event Name</b></TD> <TD width="305" class=frmInput> <INPUT class=mainFormBox style="WIDTH: 320px" type="text" name=" fairname"></TD> </TR> <TR> <TD class=mainText width="100"><B>Event Address</B></TD> <TD class=frmInput> <INPUT name="fairadd" type="text" class=mainFormBox id="fairadd" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event City</b></TD> <TD class=frmInput> <INPUT name="faircity" type="text" class=mainFormBox id="faircity" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event County</b></TD> <TD class=frmInput> <INPUT name="faircty" type="text" class=mainFormBox id="faircty" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event State</b></TD> <TD class=frmInput> <INPUT name="fairstate" type="text" class=mainFormBox id="fairstate" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Country</b></TD> <TD class=frmInput> <INPUT name="fairctry" type="text" class=mainFormBox id="fairctry" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Opening Date</b></TD> <TD class=frmInput> <INPUT name="fairopen" type="text" class=mainFormBox id="fairopen" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Closing Date</b></TD> <TD class=frmInput> <INPUT name="fairclose" type="text" class=mainFormBox id="fairlose" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Contact Email</b></TD> <TD class=frmInput> <INPUT name="fairmail" type="text" class=mainFormBox id="fairmail" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Website</b></TD> <TD class=frmInput> <INPUT name="fairweb" type="text" class=mainFormBox id="fairweb" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=frmDescription width="56"> </TD> <TD class=frmInput> <div align="right"> <input type="submit" name="submit" value="Add my Event" /> </div></TD> </TR> </TBODY> </TABLE> </form></center> </body>'; //note that I added a new field called submit and it's hidden .. page2.php <?php if (!isset($_POST['submit'])) { /*I added addslashes() so it escape any special char in the form .. if you want to show your inserted record , you need to use stripslashes() to remove any slashes from the record .. this is only to avoid some security problems in the query ..*/ $fairname=trim(addslashes($_POST['fairname'])); $fairadd=trim(addslashes($_POST['fairadd'])); $faircity=trim(addslashes($_POST['faircity'])); $faircty=trim(addslashes($_POST['faircty'])); $fairstate=trim(addslashes($_POST['fairstate'])); $fairctry=trim(addslashes($_POST['fairctry'])); $fairopen=trim(addslashes($_POST['fairopen'])); $fairclose=trim(addslashes($_POST['fairclose'])); $fairmail=trim(addslashes($_POST['fairmail'])); $fairweb=trim(addslashes($_POST['fairweb'])); include("Connections/local.php"); $link = mysql_connect($hostname_local,$username_local, $password_local) or die("Could not connect"); mysql_select_db('fair123') or die("Could not select database"); $insert=mysql_query("INSERT INTO events (fairidnum, fairname, fairadd, faircity, faircty, fairstate, fairctry, fairopen, fairclose, fairmail, fairweb) VALUES('NULL', '$fairname', '$fairadd', '$faircity', '$faircty','$fairstate', '$fairctry','$fairopen', '$fairclose', '$fairmail', '$fairweb')")or die('couldn\'t Insert record into database :'.mysql_error()); echo "Events Added!"; } else { header( 'Location: page1.php' ) ; } ?>
-
How can I get the current script's filename without path info?
inversesoft123 replied to DWilliams's topic in PHP Coding Help
<?php function currenturl() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } $currurl = currenturl(); echo $currurl; // PRINTS FULL URL $scriptname = end(explode('/',$currurl)); echo "<br/>"; echo $scriptname; // PRINTS SCRIPT NAME ?> -
I am trying to filter search bots from redirecting to mobile version of website. I am planning to create crawlers array and prevent them to redirect to mobile version of site. function cDetect($USER_AGENT) { $crawlers = array( array('Google', 'Google'), array('msnbot', 'MSN'), array('Rambler', 'Rambler'), array('Yahoo', 'Yahoo') ); foreach ($crawlers as $c) { if (stristr($USER_AGENT, $c[0])) { return($c[1]); } } return false; } //// Now let us work on it $findcrawler = cDetect($_SERVER['HTTP_USER_AGENT']); if ($findcrawler) { }else{ header ("Location: http://m.domain.com/"); } Now when I change user agent of browser with each and every bot user agent and browse the site, code works fine and shows me web version of site and I am happy with that. Now, is it require that search bots must contains "search engine name" in their user agent ? In other words, can google bot crawl my site using another user agent ? Is this a valid way to detect user agents of search bots ? Please guide me. Thanx in advance.