Posts Tagged ‘Block’

Block Port Scanning With Iptables

Thursday, March 5th, 2009 by hejian

I wrote down some rules to block commonly used port scanning technique. The rules are below:

$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG \
--log-prefix "NMAP-XMAS SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j LOG \
--log-prefix "NMAP-NULL SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j LOG \
--log-prefix "SYN/RST SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG \
--log-prefix "SYN/FIN SCAN:" --log-tcp-options --log-ip-options
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP

Drupal Page Specific visibility settings

Sunday, October 19th, 2008 by hejian

Show block only to logged in user:

global $user;
if ($user->uid){
return true;
} else {
return false;
}

Show block only on specific node type:

$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if ($type == 'story') {
$match = TRUE;
}
}
return $match;

“Latest Post” Drupal Block

Saturday, May 31st, 2008 by hejian

Latest Posts dupal block:

$nlimit = 10;
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.status = 1 ORDER BY n.created DESC"), 0, $nlimit);
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;

Just display the list:

print node_title_list($result);

In specific node type:

$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.status = 1 AND n.type = 'type' ORDER BY n.created DESC"), 0, $nlimit);

In specific category:

$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE n.status = 1 AND n.type = 'type' AND tn.tid = n ORDER BY n.created DESC"), 0, $nlimit);

User’s recent post:

if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
......
$uid = arg(1);
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND n.uid = $uid ORDER BY n.created DESC"), 0, $nlimit);
......
}

Display a Drupal block

Thursday, March 15th, 2007 by hejian

This way can display a block in Drupal module:

$block_data = module_invoke("module-name", "block", "view", 0);
$page_content .= "<div class="block block-module-name">";
$page_content .= "<h2 class="title">" . $block_data['subject'] . “</h2>”;
$page_content .= “<div class=”content”>” . $block_data['content'] . “</div>”;
$page_content .= “</div>”;

Wordpress template made by HeJian