Jump to content

rubing

Members
  • Posts

    366
  • Joined

  • Last visited

    Never

Posts posted by rubing

  1. OOP is just a bunch of methods (functions) and variables put in a single place.  Think about it like an fishtank or ecosystem of php code.

     

    So do whatever you want with it.... drain the tank and put a TV inside if it makes you happy.  Once in a while its good to read a book or tutorial to get ideas and appreciate other intellects, but you really just need to get in there and tinker.  Having some kind of mission you want to accomplish always helps of course.  Good luck!

  2. whenever i type a pear command i get the following error:

     

    Failed loading /usr/lib/php5/20060613/xdebug.so:  /usr/lib/php5/20060613/xdebug.so: cannot open shared object file: No such file or directory

     

    This started happening after I uninstalled the extension.  I uninstalled it b/c I realized that I had already had it installed via ubuntu.  Now, I just keep getting that error.  I guess I could install it again with pear, but rather just get rid of the error.  thanks!

  3. I am running a current mysql 5 version on ubuntu using default myisam storage engine.  I am logging page views for a file by querying for the number of times it has been already viewed, then adding one with php before updating.  Is it ok to do it this way? 

     

    $query="SELECT num_views FROM table1";
    $result = $conn->query($query);
    
    if (($row = $result->fetch_assoc()) !== NULL)
    {
    	$new_num_views=$row['num_views'] + 1; 		
    	$query="UPDATE table1 SET num_views = $new_num_views";
    	$result=$conn->query($query);
    }

     

    Will this give me problems if two users request a page simultaneously?  Will one of the views not be recorded??

  4. I have just launched my web application and am afraid of not being able to handle my traffic, b/c I have a potentially big client  ;D.  My application is a flash mp3 player.  Basically I query mysql with php for the mp3 file and then play it using the flash mp3 player.  I may have thousands of people listening to these mp3s and am afraid that apache/mysql will be overburdened. 

     

    Is streaming an mp3 file like this a huge burden on apache?  I am going to start reading a book on apache, but may not get to know enough in time.  What do you reccomend doing if I need to scale up fast.  I was thinking of buying more ram and hiring a freelancer to optimize apache & mysql.  Any other hints?? suggestions?? ideas?  insults?? 

     

     

    Thanks!!!

  5. I started trying to read Javascript the Good Parts last night.  The guy who wrote it seems to have an incredibly deep understanding of the subject material.  Unfortunately, it is written in a heavily jargonized fashion  and is sparing with examples.  Another thing I didn't like was the author's use of railroad tracks in order to explain legal syntax.  Of course, I'm the least visual person in the world.  If you're an engineer who likes looking at circuit boards, then this book is probably great for you.  If you like lots of concrete examples and to be frequently reminded of stuff...then def not!  There's a copy online here: https://www.hasustorm.com/books/English/OReilly.JavaScript.The.Good.Parts.May.2008.chm

  6. I found a useful javascript for unobtrusively opening popup windows.  However my scriptaculous function is still inline  :-[.  I would like to move this scriptaculous function to the head section preferably as part of the popup function.    Here is my included javascript file for opening popups:

     

    window.onload = initPage;  
    // Make sure that no other javscripts assign a fuction to window.onload
    // There can be only one window.onload at a time
    
    function initPage() {
      initPopupLinks();
      // place here any other code you wish to run when the page loads.
    }
    
    function initPopupLinks()
    {
      if (!document.getElementsByTagName) return true;
      var pageLinks = document.getElementsByTagName("a");
      for (var i = 0; i < pageLinks.length; i++) 
      {
        if (((pageLinks[i].className != null) && 
             (pageLinks[i].className != "")) ||
            ((pageLinks[i].parentNode.className != null) && 
             (pageLinks[i].parentNode.className != "")))
        {
          var linkClass = " " + pageLinks[i].className + " ";
          if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
          {
            linkClass = " " + pageLinks[i].parentNode.className + " ";
          }
          for (var theKey in popupLinkConfig) 
          {
            if (linkClass.indexOf(" " + theKey + " ") > -1)
            {
              if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
              {
                pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
              }
              pageLinks[i].settings = popupLinkConfig[theKey][1];
              pageLinks[i].onclick = popUp;
            }
          }
        }
      }
      return true;
    }
    
    function popUp()
    {
      newWin = window.open(this.href, this.target, this.settings);
      newWin.focus();
      return false;
    } 
    var popupLinkConfig = new Array;
    // Delete/copy/modify the following lines to configure your popup windows.
    popupLinkConfig["popup"] = new Array ( "", "width=350,height=450,scrollbar=yes,menubar=yes");
    popupLinkConfig["glossary"] = new Array ( "help", "width=550,height=350,resizable=no,scrollbars=no");

     

     

    Now, here is the relevant html:

     

    <a class="popup" href="http://www.google.com"><img onClick="Effect.Pulsate('player8man')" id="player8man" src='playsmall.png' alt='play' /></a>

     

    Any advise?  Thanks!!

  7. I am trying to write some unobtrusive javascript using the prototype, scriptaculous, and lowpro libraries which will make an image pulsate and then open a new window.  I was doing this before in the html fine just using an onclick function.  I'm not having too much luck doing this unobtrusively. 

     

    Here is the relevant html code (full page is at bookmarkmarket.com)

     

    Call to javascript in head section:

     

    <script src="js/scriptac/lib/prototype.js" type="text/javascript"></script>
    <script src="js/scriptac/src/scriptaculous.js" type="text/javascript"></script>
    <script src="js/lowpro.js type="text/javascript"></script> 
    <script src="js/sm.js type="text/javascript"></script>
    </head>
    
    Code in Body:
    
    
    <tr class='odd'><td class='ven'>Bar Tuti</td><td class='ban'>Bisc</td><td class ='play' align='center'><div><img src='playsmall.png' class='pulsate_demo' alt='play' /></div></td> <td class='cat'>Hip Hop</td></tr>
    
    
    contents of sm.js:
    
    Event.addBehavior({
         'img.pulsate_demo:click' :function() {alert('ya just clicked');}
    });
    
    

  8. Evening Folks,

     

    I have a web application that I'd like to allow my users to skin.  I am thinking about letting the user specify their own style sheet.  The url of their style sheet would be stored in my database.  So, when they request a page I'll fetch the css url from my database and include it in the headers.  Am I exposing myself to any potential dangers with this setup???  I can't think of any.

  9. It still does not work, but at least now we can debut it!  :D  Looks like the extension is not being picked out  ???

     

    Here is my new code:

     

    $_FILES['uploadedfile']['name']=trim($_FILES['uploadedfile']['name']);
    $_FILES['uploadedfile']['name']=ereg_replace("[^A-Za-z0-9.]", "", $_FILES['uploadedfile']['name']);
    $allowed = array('.mp3','.MP3');
    $ext = strrchr('.', $_FILES['uploadedfile']['name']);
    if (!in_array($ext, $allowed))
    {
    echo "Bad file ext...<br />";
    echo "ext:";
    echo $ext;
    echo "<br />";
    print_r($_FILES);
    exit(1);
    }
    

     

    And here is the response:

     

    Bad file ext...

    ext:

    Array ( [uploadedfile] => Array ( [name] => 05madlibthebeatkonductagambleonyaboyfeat.defari.mp3 [type] => audio/mpeg [tmp_name] => /tmp/php1CtZ2n [error] => 0 => 5242805 ) )

  10. I am trying to allow mp3 uploading with the following code:

     

    $blacklist = array('.mp3');
    
    foreach($blacklist as $item)
    {
    	if(!preg_match('/$item\$/i',$_FILES['uploadedfile']['name']))
    		{
    			echo "Sorry unsupported file type...mp3's only\n";
    			echo "<br />";
    			print_r($_FILES);
    			exit;
    		}
    }

     

    Now, when I attempt to upload an mp3 file this is the response I am getting:

     

    Sorry unsupported file type...mp3's only

    Array ( [uploadedfile] => Array ( [name] => 07-madlib_the_beat_konducta-all_virtue.mp3 [type] => audio/mpeg [tmp_name] => /tmp/phpA74Crx [error] => 0 => 2408445 ) )

  11. My php code seems to be executing prematurely.  I am trying to download a file and then delete it if it is too small as follows:

     

    //this just tells curl to save a file ($file) and print info about the transfer
    $grab->get_file($url,$conn,$proxy);
    
    if (filesize($file)>60000)
    {
                    echo "file was too small";
    	unlink($file);
    }

     

     

    Now, the file i am downloading is big enough and curl reports that back to me, but php is detecting as too small and deleting it:

     

     

    Why do I think this is b/c php is prematurely executing my code????  Glad you asked!  If I change filesize to a smaller number e.g. 30,000  then it will work!  Maybe this is a bug  ???

     

    //this just tells curl to save a file ($file) and print info about the transfer
    $grab->get_file($url,$conn,$proxy);
    
    if (filesize($file)>30000)
    {
                    echo "file was too small";
    	unlink($file);
    }

×
×
  • 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.