Jump to content

Jocka

Members
  • Posts

    344
  • Joined

  • Last visited

Posts posted by Jocka

  1. looks like the number of plays is set in tags like this:

    <span class="count"><span class="flip">1</span></span>

     

    So u could use regex to get the value

    $play_span = preg_match("/<span class=\/"count\/">(.*?)<\/span>/", $html, $matches);
    $play_span = $matches[1];
    
    // NOW STRIP THE SPAN TAGS (i'm sure there is a better way but im too tired to think
    $erase_me = array("<span class=/"flip/">", "</span>");
    $plays = str_replace($erase_me, "", $play_span);
    

     

    that should work..

     

  2. I know this isn't really advice but just study the file system: http://www.php.net/manual/en/ref.filesystem.php

     

    All the functions are pretty self explanatory. As far as the rest goes, it's mostly just up to you on how you would like your blog to function.

     

    I would store blogs in separate files under a folder like blog_files.

    You could use something like filemtime() to get the date it was modified but if you did that then if u had to go back and edit a page, it would jump to the front.

     

    I'd suggest possibly naming the blog text files by blog title and microtime (add blog title just to make it easier to find if there are any complications). Then just get the list of contents in the directory and sort it so that the latest entry (where microtime comes into play) is the first to be viewed.

     

    Having a seperate text file holding information such as Author, Date, Blog Title; would come in handy for editing later on. Possibly a different text file per Author holding all of their information?

     

    It's really up to you how to handle all that. Just my suggestions for it.

  3. This should do, but had to take out the IF statement so all emails should send without warning.

     

    <?php
    
    session_start();
    
    if ($_POST['Submit'] == 'Send')
    
    {
    
    
    $to = $_POST['toemail'];
    
    $subject = $_POST['subject'];
    
    $message = $_POST['message'];
    
    $fromemail = $_POST['fromemail'];
    
    $fromname = $_POST['fromname'];
    
    $lt= '<';
    
    $gt= '>';
    
    $sp= ' ';
    
    $from= 'From:';
    
    $headers = $from.$fromname.$sp.$lt.$fromemail.$gt;
    
    mail($to,$subject,$message,$headers);
    
    header("Location: sendmail.php?msg= Mail Sent!");
    
    exit();
    
    }
    
    ?>
    
    <html>
    
    <head>
    
    <title>Email </title>
    
    </head>
    
    <body bgcolor="#ffffcc">
    
    <h2 align="center">
    
    Email
    </h2>
    
    <h3 align="center">
    
    Please do not misuse this script.
    </h3><br>
    
    <p style="margin-left:15px">
    
    <form action="sendmail.php" method="POST">
    
    <b>From Name:</b><br>
    
    <input type="text" name="fromname" size="50"><br>
    
    <br><b>From Email:</b><br>
    
    <input type="text" name="fromemail" size="50"><br>
    
    <br><b>To Email:</b><br>
    
    <input type="text" name="toemail" size="50"><br>
    
    <br><b>Subject:</b><br>
    
    <input type="text" name="subject" size="74"><br>
    
    <br><b>Your Message:</b><br>
    
    <textarea name="message" rows="5" cols="50">
    
    </textarea><br>
    
    <input type="submit" name="Submit" value="Send">
    
    <input type="reset" value="Reset">
    
    </form>
    
    </p>
    
    <?php if (isset($_GET['msg'])) { echo "<font color=\"red\"><h3 align=\"center\"> $_GET[msg] </h3></font>"; } ?>
    
    </body>
    
    </html>
    

  4. I don't like to use others files. Just makes me feel like I'm cheating lol.

     

    BUT I did find a solution of anyone wants to copy it somewhere for future reference. This function I wrote works pretty well (although I must admit the main code I needed was found here http://refactormycode.com/codes/708-innerhtml-of-a-domelement )

     

    <?php
    
    function get_between_tags($html, $tag){	
    
    $domdoc= new DOMDocument;
    $domdoc->validateOnParse = true;
    $domdoc->loadHTML($html);
    
    // FINDING THE TAG BY ID
    $dom_tags = $domdoc->getElementById($tag);
    
    // GET INNERHTML
     $parse_doc = new DOMDocument();
     foreach ($dom_tags->childNodes as $child){
    	$parse_doc->appendChild($parse_doc->importNode($child, true));
     }
    
    $dom_array = '';
    $dom_array[0] = html_entity_decode($domdoc->saveXML($dom_tags));
    $dom_array[1] =  $parse_doc->saveHTML();
    return $dom_array;
    }
    
    $html_info ="<html>
    <body>
    <div id=\"thisrow\">
        <div id=\"thatrow\">
              <div id=\"testrow\">
                    THIS IS THE TEST ROW
               </div>
         </div>
    </div>
    </body>
    </html>";
    
    // $tag_array holds both html/text WITH tags [0] and without tags [1]
    $tag_array = get_between_tags($html_info, 'testrow');
    print_r ($tag_array);
    
    ?>
    

     

    which prints:

    Array
    (
        [0] =>           <div id="testrow">
                    THIS IS THE TEST ROW
               </div>
        [1] =>
              
                    THIS IS THE TEST ROW
               
    )
    

    I hope this helps someone else it. It seems much faster than the old preg_match I used to do.

  5. somebody help.. lol

     

    This works MOSTLY

    <?php
    function get_between_tags($html, $tag){
    
    $domdoc= new DOMDocument;
    //$domdoc->validateOnParse = true;
    $domdoc->loadHTML($html);
    $div_tags = $domdoc->getElementById($tag);
    
    return $domdoc->savexml($div_tags);
    
    }
    ?>
    

     

    it ALMOST works. Except it includes the DIV tags:

    <div class="testrow" id="testrow">
    
    <tr><td width="50%">
    		ROW_NUM
    	</td>
    
    </tr></div>
    

    so when I edit it, it repeats the DIV which just adds all this extra DIV code that I don't want or need. Please help me out here.. this is ridiculous. It seems A LOT faster than the old regex code I used to use but I just can't figure out why i cant get JUST the innerHTML from the DIV tag.

  6. working on the code.. can't seem to get it to work ..

    <?php
    
    function get_between_tags($html, $tag){
    
    $domdoc= new DOMDocument();
    $domdoc->validateOnParse = true;
    $domdoc->loadHTML($html);
    //$domx = new DOMXPath($domdoc);
    //$items = $domx->query("*/div[@class=\"".$tag."\"]");
    
    return $domdoc->getElementById($tag)->innerHtml;
    
    }
    ?>
    

     

    when I try to echo it, it says: "Notice: Trying to get property of non-object in C:\wamp\www\template.php on line 18"

    which line 18 is "return $domdoc->getElementById($tag)->innerHtml;"

  7. I am trying to write a simple (or at least i thought it was simple) code using DOM to catch data between tags. such as:

    <table width="100%" cellpadding="2" cellspacing="2">
    <tr>
    	<td colspan="2" align="center">
    		TEST
    	</td>
    </tr>
    
    <div class="test_row">
    
    <tr>
    	<td width="50%">
    		<//ROW_NUM//>
    	</td>
    </tr>
    
    </div>
    
    </table>
    

     

    then everything goes wrong here. trying to figure out how to catch the data in <div class="test_row">

    <?php
    
    function get_between_tags($html, $tag){
    
    $domdoc= new DOMDocument();
    $domdoc->loadHTML($html);
    $domx = new DOMXPath($domdoc);
    $items = $domx->query("*/div[@class=\"".$tag."\"]");
    
    return $items->item(0)->nodevalue;
    
    }
    $html = file_get_contents("test.html");
    $row = get_between_tags($html, "test_row");
    
    ?>
    

    This was actually a code I found online but it called for $domx->execute which it says EXECUTE isn't a function or something.. .. any help would be appreciated.

    I tried GOOGLEING php and DOM since the php website isn't much help on it, but i'm having a hard time finding any tutorials or info at all really.

  8. hm i've never done queries like that.. I always have issues when i do the damn > < signs. Usually adding = makes it work for me though. <=

     

    why not just do a while statement for the query though.. like this:

     

    <?php
    while ($row = mysql_fetch_array($result, MYSQL_NUM){
    $f1 = $row['ID'];
    $f2 = $row['UID'];
    $f3 = $row['Site'];
    $f4 = $row['Uname'];
    $f5 = $row['Pass'];
    ?>
    

    so on so forth.. same idea here just a different method.

  9. No I don't intend to go on a rampage lol. Although I hae a grudge, I'm not gonna go make myself look like an idiot.

     

    What's weird is in the U.S. we have the BBB (better business bureau) u can complain to but if u complain publically its a crime? According to the law, a company is not allowed to "retaliate" so where is the difference between reporting too bbb and going public?

    The bbb is supposed to make all complaints public anyway. So we can only complain if its thru the government?

  10. I've said things but nothing aimed directly at a particular person or company. And nothing that could not be proven, therefore not "slander". Im extremely careful about What I say.

     

    By legal definition, the person making the comments have to be proven guilty. Lets say u. Posted anonymous. Would that make that website it is posted on liable?

  11. log session_id's and ip addresses along with date/time would be a good way. then you could just have some code to check if the time is beyond the allotted time you have in mind (say, 5 minutes). Then if it's past that time, automatically forward to the registration page.

  12. Right, which falls under defamation of character. But by law they can only sue for damages. I suppose saying they cheat lie or steal could be libel or slander. But lets say you just put something like:

    "My supervisor always rambles on about how stupid clients are. ((Company name)) doesn't seem to have any respect for their clients or any of their employees, in my opinion."

     

    That statement may be damaging in some way if a client reads it. But in court I think it'd be hard to prove either way that it is a true or false statement. Seems like it would be a waste of money to drag through court over nothing.

  13. I just happened to be on this website while I was having this argument. I couldn't find anything on google about it.

     

    I don't believe that legally anything could be done about talking bad about a company is there? Let's say ur just mad about your day and your like "NEVER WORK FOR ((company name)) THEY CHEAT LIE STEAL.." etc etc..

     

    Does anyone know if this is illegal? I imagine you could possibly be hit with like some defamation of character lawsuit but given that there really could be no "damages" that come of this, I don't see how they COULD sue.

     

    Any thoughts on this?

  14. seems like they would either choose one person, which invites others (etc etc etc). or it's a random thing maybe. Either way I figure maybe they have something in a database that has like release_content set with like 0 for now or 1 for yes depending on if u were invited or one of the random people selected.

    Just my two cents on it.

  15. if you don't have a lot of PHP code on your footer area or the entire page (depending how you created it) it might be better to just clean it up.

     

    footer area:

      <br />
      <center>Copyright &copy 2010 <a href="http://www.website.com">www.WEBSITE.com</a></center>
    
      <?php include('includes/start_admincheck.php'); ?>
    
    </body>
    
    </html>
    

     

    start_admincheck.php:

    <?php include('variables/variables.php'); ?>
    
    <?php
      mysql_connect("$mysql_hostname", "$mysql_username", "$mysql_password") or die(mysql_error());
      mysql_select_db("$mysql_database") or die(mysql_error());
    
      if(isset($cUsername))
      {
        $check = mysql_query("SELECT * FROM users WHERE username = '$cUsername'")or die(mysql_error());
    
        while($info = mysql_fetch_array( $check ))
        {
          if (($cAdmin == 1) && ($info['admin'] == 1))
          {
              echo "<center><a href=\"<?php echo $homedir .'admin.php'; ?>\">Go to Administration Panel</a></center>";
          }
    
          else
            die(); 
        } 
      }
      else
        die();
    ?>
    

  16. I don't think it's possible to just end php ?> without closing if/while tags.. then again I've never tried that. But that seems to be the error your getting here.

     

    It's obvious you are trying to keep your html and php seperate but with this particular code, I don't know that u have a choice.

  17. As it goes right now I have 2 basic files: ((edited, sorry my original file was ridiculous))

     

    THE FILE THAT READS/WRITES THE INFO

    <?php
    // &#36; = $
    
    $content = "<?php
    
    &#36;info1 = \"new info\";
    &#36;info2 = \"new info 2\";
    &#36;info3 = \"new info 3\";
    
    ?>";
    
    $handle = fopen('info_holder.php', 'w+');
    
    fwrite($handle, html_entity_decode($content));
    fclose($handle);
    
    include ('info_holder.php');
    echo $info1;
    
    ?>

     

    THE FILE THAT HOLDS THE INFO

    <?php
    
    $info1 = "info number 1";
    $info2 = "info number 2";
    $info3 = "info number 3";
    
    ?>

     

    Any other ideas for this small ideas on a better way would be nice. Otherwise I'll stick with this little script idea for now.

  18. I haven't really messed with PHP in like 2 years. Just little fixes on old scripts every now and then. I've been kind of in an argument with myself the past couple of days while writing a script.

     

    The thing is I only have around 3 or 4 sets of information I need. Such as:

     

    option1: information for option 1
    option2: information for option 2
    option3: information for option 3
    etc..
    

     

    NOW, at first I was doing this all in a text file. This information doesn't necessarily need to be private but i also don't want people to know what file needs to be edited right off the bat.

     

    I don't see any reason at all for using databases here, I'd much rather stick to files.

     

    I'm thinking it may be best to store this is strings in a seperate PHP file and include it? Then if I need to edit it, I can simply write a new file.

     

    Any suggestions?

  19. The only way i can think of to make it work is like this (hate to give out the secret :P lol)

     

    Set up a MAIN 'bot' account that ALL messages will be sent to. Then assign the users their 'email address' which really doesn't exist but nobody has to know that. Example: thisguy@yoursite.com

     

    so then somebody emails thisguy@yoursite.com and it's transfered to mailbot@yoursite.com . you then have the PHP script check for who this is directed to, match it in the db, and save the message in the db according to the right person (blah blah blah).

     

    In theory, that would work. I have yet to try it but do plan to take that challenge on myself.

  20. something like:

    [code]
    <?php

    class mod{

        mod(){}

        display(){
        echo"<div id=mod_id>SOME COMPUTING DONE HERE AND STUFF DISPLAYED</div>";
        }

        refresh(){
        echo "new text without the divs";
        }
    }

    if($_GET['refresh']){
      $mod = new mod();
      echo $mod->refresh();
    }
    ?>
    [/code]

    then send to

    [b]mod.class.php?refresh[/b]

    or something to that nature
  21. Ok, straight to the point. I'm searching for "A" between one zip code and another zip code. But I have to go through B to do it.

    The problem is I say "SELECT bid FROM btable WHERE zip IN ('55555','55554,'55553,'55552,'55551')" and then I have the B information from the zip search. Now A gets it's information judging by bid. HOWEVER, I don't want to have it list out like this:

    b1-a1
    b1-a2
    b1-a3
    b2-a1
    b2-a2
    b3-a1
    b4-a1

    See what I'm saying? I don't want to draw out each A for the b. I want to draw out by the latest A regardless of the 'bid' ..

    I know some of you are confused. I just confused myself a little.
    The next best thing to do is save the 'bid' and 'zip' to A but I'd rather not. I can if I HAVE to but again, i'd rather not.

    There may be a way to do it with MYSQL alone but I'm not real good with MYSQL.
×
×
  • 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.