Jump to content

fr600

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fr600's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here is another thing: Whenever someone visits www.domain.com, it opens up index.html. And when someone visits IP address 12.34.56.78, it opens up the same index.html. (@) I want to disallow access by IP address and allow access only by the www.domain.com. The problem is that www.domain.com is pointed to my IP address 12.34.56.78 with A record. So, when I block my IP, the domain gets blocked message. How can I do that (@)?
  2. I don't think so because when no users are connected, it works perfect. But when users keeps connecting, it keeps getting slower... and btw, I'm on a Quad Code with 2GB RAM on Windows Server 2008. So, that's not the problem... PS. I'm not just running from local, I'm accessing from local. Other users are accessing with a domain name.
  3. Does this mean that for "122.202.0.0 - 122.202.31.255" I'll have to write 32 different entries? I can't do that, otherwise my htaccess will be like 1000 line long. The list IP I showed here is just an example which will help me to understand how it works and I can use the knowledge with the rest. There must be a shorter way. I found like 100s of websites like that, but that doesn't help. Hoping for a better solution.
  4. I'm looking forward to make my server private. I'd like to grant access to some specific IP blocks and deny access from the rest. I know it can be done using htaccess but I don't know how. These are some of the blocks that I'd like to allow access: 122.202.0.0 - 122.202.31.255 158.165.224.0 - 158.165.231.255 158.145.176.0 - 158.145.191.255 178.141.228.0 - 178.141.228.127 180.78.20.172 - 180.78.20.179 195.12.167.228 - 195.12.167.231 217.110.163.192 - 217.110.163.223 Moreover, I'd like to redirect the banned users to some other website like: www.google.com Could you please help with this? Thanks.
  5. Well, I'm running a server on localhost and every now and then (not always) it takes 5-6 seconds to load the page. There are like a hundred connected users to my server. What could possibly be causing this? I'm on apache2.2 and php5.2.6 and the pages are dynamic. Any idea? Thnx
  6. Well, I've created the complete scenario. Please take a look at it and help me out. This is the database: CREATE TABLE IF NOT EXISTS categories ( id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL DEFAULT '', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO categories (id, name) VALUES (1, 'Porsche'), (2, 'Ferrari'), (3, 'Mercedes'); CREATE TABLE IF NOT EXISTS items ( id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(64) NOT NULL DEFAULT '', category int(10) unsigned NOT NULL DEFAULT '0', added_date date NOT NULL DEFAULT '0000-00-00', owner int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (id), UNIQUE KEY id (id), KEY owner (owner), KEY name (name), KEY added_date (added_date) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO items (id, name, category, added_date, owner) VALUES (1, 'Boxter', 1, '2008-07-28', 1), (2, '210 E-Class', 3, '2008-07-28', 3), (3, 'Enzo', 2, '2008-07-28', 1), (4, '575M', 2, '2008-07-29', 2), (5, '208 CLK', 3, '2008-07-29', 2), (6, '944 Cabriolet', 1, '2008-07-30', 3), (7, '944 Coupe', 1, '2008-07-30', 2), (8, '220 S-Class', 3, '2008-07-30', 2), (9, '456M', 2, '2008-07-30', 3), (10, 'F50', 2, '2008-07-31', 1), (11, '210 Wagon', 3, '2008-07-31', 1), (12, '911 Turbo', 1, '2008-07-31', 2), (13, '201 Sedans', 3, '2008-08-01', 1), (14, '575M', 2, '2008-08-01', 2), (15, '612 Scaglietti', 2, '2008-08-02', 3), (16, '356C Coupe', 1, '2008-08-02', 2); CREATE TABLE IF NOT EXISTS users ( id int(10) unsigned NOT NULL AUTO_INCREMENT, username varchar(14) NOT NULL DEFAULT '', PRIMARY KEY (id), UNIQUE KEY username (username) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO users (id, username) VALUES (1, 'admin'), (2, 'test'), (3, 'engineer'); and this the the php file (I call it test.php): <?php $mysql_hostname = "localhost"; $mysql_username = "root"; $mysql_password = "pass"; $mysql_database = "test"; @mysql_connect($mysql_hostname, $mysql_username, $mysql_password); mysql_select_db($mysql_database); function categorylist() { $ret = array(); $res = mysql_query("SELECT id, name FROM categories ORDER BY id"); while ($row = mysql_fetch_array($res)) $ret[] = $row; return $ret; } function itemstable($res) { echo "<table cellpadding=0 cellspacing=0>"; echo "<tr>"; echo "<td width=50>ID</td>"; echo "<td width=100>Category</td>"; echo "<td width=150>Name</td>"; echo "<td width=150>Added Date</td>"; echo "<td width=150>Owner</td>"; echo "</tr>"; while ($row = mysql_fetch_assoc($res)) { echo "<tr>"; echo "<td>" . $row['iid'] . "</td>"; echo "<td>" . $row['catname'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['added_date'] . "</td>"; echo "<td>" . $row['username'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "<br>"; } $cats = categorylist(); $display = ""; foreach ($cats as $rowc) { $res = mysql_query(" SELECT items.id as iid, items.*, items.added_date, categories.id, categories.name as catname, users.id, users.username FROM items LEFT JOIN categories ON category = categories.id LEFT JOIN users ON items.owner = users.id WHERE added_date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND category = " . $rowc['id'] . " ORDER BY iid DESC"); while($row = mysql_fetch_array($res)) $display .= itemstable($res); } echo "$display"; ?> It took me a long time to create this sample. Now it should be easy for you to identify what's wrong. Thanks a lot.
  7. OK, I've a weird situation here. In the database there is a row called added_date which is in date format. When I run the following query: $cats = categorylist(); $display = ""; foreach ($cats as $rowc) { $res = mysql_query(" SELECT items.id as iid, items.*, items.added_date, categories.id, users.id FROM items LEFT JOIN categories ON category = categories.id LEFT JOIN users ON items.owner = users.id WHERE added_date >= DATE_SUB(CURDATE(), INTERVAL 4 DAY) AND category = " . $rowc['id'] . " ORDER BY iid DESC"); while($row = mysql_fetch_array($res)) $display .= itemstable($res); } echo "$display"; First a list of categories are selected (with categorylist()), then for each category mysql_query is run, then the result is transferred to a function (itemstable). Here are the weird results I'm getting: 1. Some rows are missing (for example, it's not showing 1st or 2nd August rows but shows July 28-31) 2. Items outside the interval are listed (like july 28-31 instead of july30-aug02 with interval of 4 days) 3. It show blank table (via function) when mysql_query is false even though it's set otherwise. 4. Just noticed that the first row of each category is also missing. Any idea? PS. I'm using mysql 5.1.25, php 5.2.6, and apache 2.2.9.
×
×
  • 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.