Jump to content

JD*

Members
  • Posts

    230
  • Joined

  • Last visited

Posts posted by JD*

  1. Absolutely. Whatever session is storing their username, just prepend it to the filename string like this:

     

    ##/ Filename randomized

                  $fileName    = $_SESSION['LOGIN_NAME'].rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).'.' . substr($_FILES[file][name][$i], -3);

                }

  2. Do you want to base this on a login scenario for the username, or just have a field that someone can type a name and then place that in front of the file name?

     

    In either case, you'll change this line:

                  $fileName    = rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).'.' . substr($_FILES[file][name][$i], -3);

     

    to

                  $fileName    = $username."_".rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).'.' . substr($_FILES[file][name][$i], -3);

     

    Let me know what you're thinking and we can work through how you get to that username

  3. It's not too hard. You'll want to look up how to export to a file, and then you'd write all of your results where each column would have a \t after it and each row would have a \r after it. When you go to import it into your spreadsheet program, it'll see it as a comma-delimited file (the \t for tabs) and should import it without a problem.

     

    If you want a more concrete description (with code) let me know.

  4. Sleep does not always work properly...I find in my code it will pause ALL execution of code for the number of seconds defined, then continue on.

     

    That's what sleep() is supposed to do.

     

    Yes, but I find that many people on here suggest using it as something that will do this:

     

    Processing code.....

     

    [tell php to sleep, so it looks like we're loading while playing an animated gif]

     

    Finished processing

     

    Just warning that sleep does not do that...I don't think that was the intention of the people above, but just an FYI

  5. Sleep does not always work properly...I find in my code it will pause ALL execution of code for the number of seconds defined, then continue on.

     

    What you can, instead, is this:

     

    echo '<meta http-equiv="Refresh" content="10">';
    

     

    and replace the "10" with your duration (in seconds)

     

    -- Edit --

     

    Sorry, I didn't see that the above code has no HTML as part of it...my tip works if you have other HTML in the page and code is going to be executed (such as display a message on the same page, then redirect for a logout or something similar).

  6. Hey all,

     

    Been bashing my head against this for a bit...I'm trying to grab users from a particular building using a LIKE statement, but I think I need some outside perspective.

     

    For my site, users are assigned to building in a column like:

     

    User Name Building
    Joe Smith 1,2
    Jane Smith 2,4
    Don Ho 12,3

     

    What I'm looking to do is pull all users where the building, lets say, is 2. Currently, doing this:

     

    SELECT * FROM table WHERE building LIKE "%2%"
    

     

    Is going to return both Joe Smith, Jane Smith AND Don Ho, when I only want Joe and Jane. If I add in a "%,2,%", I'm not going to get Jane Smith because there is no comma in front of her building number.

     

    Now, I know I can put a 0 in front of my single digit numbers, but before I do so, I wanted to know if I'm missing anything. This all ties into a function where I pass the current building I'm looking for, so it needs to be fairly flexible.

     

    Thanks!

  7. Change this

     

    $image = addslashes(file_get_contents($_FILES["userfile"]["tmp_name"]));
    

     

    to this

     

    $fp = fopen($_FILES['userfile']['tmp_name'], 'r');
    $content = fread($fp, filesize($_FILES['userfile']['tmp_name']));
    $image = base64_encode($content);
    

     

    This will get your content into the database. On display, make sure to use base64_decode or you'll just get gibberish

  8. <?php
    $link = mysql_connect("host", "user", "pass") or die (mysql_error ());
    mysql_select_db ('cbnames', $link) or die (mysql_error ());
    $sql = mysql_query ("SELECT `name` FROM `cb` ORDER BY RAND() LIMIT 0,1") or die (mysql_error ());
    $res = mysql_fetch_assoc ($sql);
    $randomname = $res['name'];
    echo '<div align="center"><img src="http://www.mysite.com:/names/namesdisplay.php?char='.$randomname.'" /><br />'.$randomname.'</div>';
    ?>
    

  9. I usually do the reverse of what you have:

    <?php
    if($fList[$i] != '.' || $fList[$i] != '..') 
    { 
    if(@ftp_chdir($conn, $fList[$i]))
    { 
    	@ftp_cdup($conn); ?>
    	<img src='folder.gif'> <a href='ftp.php?command=listFiles&currDir=<?php echo $fList[$i]; ?>'> <?php echo $trimFile; ?> </a> <br>
    <?php
    } else {
    ?>
    	<img src='file.gif'> <a href='ftp.php?command=getFile&currFile=<?php echo $fList[$i]; ?>&currDir=<?php echo $currDir; ?>'> <?php echo $trimFile; ?> </a> <br>
    <?php
    }
    }
    

     

    Using the != should skip past them with no problem

  10. Alin19 is somewhat correct. It sounds like you need to do a couple of things:

     

    When the page loads, check the database to against the current time. If it's chat time, skip the rest and load the chat. If it's not time, call out a javascript function that will do the countdown and pass the time left to it via some subtraction (chat time - now).

     

    In the javascript counter you'll need to place some code that will have an ajax-like functionality so that when the time is up, it will automatically load the chat for people sitting on the page.

     

    In your chat script, when the chat is over, also have an ajax-like function that will either reload the page for everyone (thus doing the above check and starting the timer again) or have it close down the part of the page that the chat is on and then query the db again to start the counter.

     

    Let me know if you need more explanation on any part.

  11. I'm trying to figure out the best way to do some replacement on a file. I have an HTML page that I'm reading into my script, tearing out some code I don't want and then posting it again.

     

    I currently have it working with a lot of str_replace statements, but I wanted to see if I could trim this up. I'm removing class and style tags from table code (so tags: table, th, tr and td), and right now I have all searches hard coded but I wanted to make it more dynamic.

     

    Here is an example of some of the code that I'm working with (it's a tv guide type thing):

    <th style="background-color: #ffcc77; font-weight: normal; font-size: 14px; margin: 0px; padding: 2px 0px 2px 5px; widt
    h: 9em;">Time</th>
    <tr>
          <td style="vertical-align: top; background-color: #ededed;">09:00:00 AM</td>
          <td style="vertical-align: top; background-color: #ededed;">
            <table style="width: 100%; padding: 0px; margin: 0px;">
    <tr>
    <td class="program_guide_filler" style="height: 40px; background-color: #ededed; border-top: thick solid #FFCC77;">
    <span style="font-weight: bolder;">Spring Sports Awards 2008</span>
    <br/> 1 hour and 49 minutes
    </td>
    </tr>
    </table>
    </td>      
    
    So what I'd like to do is find a better way to say "Anything between a < >, remove style and class tags. I've been reading up on the three subject-referenced functions but got lost real quick.
    
    Thanks!
    
    

  12. ServerRoot "D:/Apache"
    
    Listen 81
    
    ServerName site1.homeftp.org
    
    ServerAdmin jd@myserver.com
    
    DocumentRoot "E:/site1.com/html"
    
      # LoadModule foo_module modules/mod_foo.so
      LoadModule actions_module modules/mod_actions.so
      LoadModule alias_module modules/mod_alias.so
      LoadModule asis_module modules/mod_asis.so
      LoadModule auth_basic_module modules/mod_auth_basic.so
      # LoadModule auth_digest_module modules/mod_auth_digest.so
      # LoadModule authn_alias_module modules/mod_authn_alias.so
      # LoadModule authn_anon_module modules/mod_authn_anon.so
      # LoadModule authn_dbd_module modules/mod_authn_dbd.so
      # LoadModule authn_dbm_module modules/mod_authn_dbm.so
      LoadModule authn_default_module modules/mod_authn_default.so
      LoadModule authn_file_module modules/mod_authn_file.so
      # LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
      # LoadModule authz_dbm_module modules/mod_authz_dbm.so
      LoadModule authz_default_module modules/mod_authz_default.so
      LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
      LoadModule authz_host_module modules/mod_authz_host.so
      # LoadModule authz_owner_module modules/mod_authz_owner.so
      LoadModule authz_user_module modules/mod_authz_user.so
      LoadModule autoindex_module modules/mod_autoindex.so
      # LoadModule cache_module modules/mod_cache.so
      # LoadModule cern_meta_module modules/mod_cern_meta.so
      LoadModule cgi_module modules/mod_cgi.so
      # LoadModule charset_lite_module modules/mod_charset_lite.so
      # LoadModule dav_module modules/mod_dav.so
      # LoadModule dav_fs_module modules/mod_dav_fs.so
      # LoadModule dav_lock_module modules/mod_dav_lock.so
      # LoadModule dbd_module modules/mod_dbd.so
      # LoadModule deflate_module modules/mod_deflate.so
      LoadModule dir_module modules/mod_dir.so
      # LoadModule disk_cache_module modules/mod_disk_cache.so
      # LoadModule dumpio_module modules/mod_dumpio.so
      LoadModule env_module modules/mod_env.so
      # LoadModule expires_module modules/mod_expires.so
      # LoadModule ext_filter_module modules/mod_ext_filter.so
      # LoadModule file_cache_module modules/mod_file_cache.so
      # LoadModule filter_module modules/mod_filter.so
      # LoadModule headers_module modules/mod_headers.so
      # LoadModule ident_module modules/mod_ident.so
      # LoadModule imagemap_module modules/mod_imagemap.so
      LoadModule include_module modules/mod_include.so
      # LoadModule info_module modules/mod_info.so
      LoadModule isapi_module modules/mod_isapi.so
      # LoadModule ldap_module modules/mod_ldap.so
      # LoadModule logio_module modules/mod_logio.so
      LoadModule log_config_module modules/mod_log_config.so
      # LoadModule log_forensic_module modules/mod_log_forensic.so
      # LoadModule mem_cache_module modules/mod_mem_cache.so
      LoadModule mime_module modules/mod_mime.so
      # LoadModule mime_magic_module modules/mod_mime_magic.so
      LoadModule negotiation_module modules/mod_negotiation.so
      # LoadModule proxy_module modules/mod_proxy.so
      # LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
      # LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
      # LoadModule proxy_connect_module modules/mod_proxy_connect.so
      # LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
      # LoadModule proxy_http_module modules/mod_proxy_http.so
      # LoadModule rewrite_module modules/mod_rewrite.so
      LoadModule setenvif_module modules/mod_setenvif.so
      # LoadModule speling_module modules/mod_speling.so
      # LoadModule ssl_module modules/mod_ssl.so
      # LoadModule status_module modules/mod_status.so
      # LoadModule substitute_module modules/mod_substitute.so
      # LoadModule unique_id_module modules/mod_unique_id.so
      # LoadModule userdir_module modules/mod_userdir.so
      # LoadModule usertrack_module modules/mod_usertrack.so
      # LoadModule version_module modules/mod_version.so
      # LoadModule vhost_alias_module modules/mod_vhost_alias.so
    
    <IfModule !mpm_netware_module>
      <IfModule !mpm_winnt_module>
        User daemon
        Group daemon
      </IfModule>
    </IfModule>
    
    # 
    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    <IfModule dir_module>
      DirectoryIndex index.php
    </IfModule>
    
    # 
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    <FilesMatch "^\.ht">
      Order allow,deny
      Deny from all
      Satisfy All
    </FilesMatch>
    
    ErrorLog "logs/error.log"
    
    LogLevel warn
    
    <IfModule log_config_module>
      # 
      # The following directives define some format nicknames for use with
      # a CustomLog directive (see below).
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
      LogFormat "%h %l %u %t \"%r\" %>s %b" common
    
      <IfModule logio_module>
        # You need to enable mod_logio.c to use %I and %O
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
      </IfModule>
    
      CustomLog "logs/access.log" common
    </IfModule>
    
    <IfModule alias_module>
      ScriptAlias /cgi-bin/ "D:/Apache/cgi-bin/"
    </IfModule>
    
    DefaultType text/plain
    
    <IfModule mime_module>
      TypesConfig "conf/mime.types"
      AddType application/x-compress .Z
      AddType application/x-gzip .gz .tgz
    </IfModule>
    
    <IfModule ssl_module>
      SSLRandomSeed startup builtin
      SSLRandomSeed connect builtin
    </IfModule>
    
    
    # BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    PHPIniDir "D:/PHP/"
    LoadModule php5_module "D:/PHP/php5apache2_2.dll"
    
    <Directory "/">
      Options FollowSymLinks
      Deny from all
      Order deny,allow
      AllowOverride None
      # END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    </Directory>
    
    <Directory "E:/site2.homeftp.org">
      Allow from All
      Order Allow,Deny
    </Directory>
    
    <VirtualHost site2.homeftp.org:81>
      ServerName site2.homeftp.org
      DirectoryIndex index.php
      DocumentRoot "E:/site2.homeftp.org"
    </VirtualHost>
    

     

    Removed most of the comments for the sake of length, but the important stuff is there.

     

    Thanks!

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