neohunter
Enviado: 17/03/2004 a las 23:03
Habitual
Karma: 0 (0 Votos)
Registrado: 28/12/03
Mensajes: 52
Estado: Desconectado Ultima visita: 10/04/05
estoy por pensar que no se puede....
que no se puede crear bloques bien...
que hay de malo en el siguiente?
por que me da un error
"Ha fallado el intento de creacion"
por otro lado...
ya casi termino el modulo de noticias y comentarios nuevo ^^_
www.subestado.com/index.php
Cita
<?php
//Bloque creado neohunter para subestado.com
$blocks_modules['4imagesramdom'] = array(
'func_display' => 'blocks_4imagesramdom_block',
'text_type' => '4imagesramdom',
'text_type_long' => '4imagesramdom por Nh [4imagesramdom v1.0]',
'allow_multiple' => true,
'form_refresh' => false,
'show_preview' => true
);
// Security
pnSecAddSchema('4imagesramdomblock::', 'Block title::');
function blocks_4imagesramdom_block($row) {
if (!pnSecAuthAction(0, '4imagesramdomblock::', "$row[title]::", ACCESS_READ)) {
return;
}
define('ROOT_PATH', '/hsphere/local/home/zsefora/photo.subestado.com/');
define('ROOT_PATH1', 'http://photo.subestado.com/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}
$sql = "SELECT COUNT(*) as total_images
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];
mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
LIMIT $number, 1";
$row = $site_db->query_firstrow($sql);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH1.THUMB_DIR."/".$cat_id."/".$row[
'image_thumb_file'];
echo "<p align=\"center\"><a href=\"".ROOT_PATH1."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\"
alt=\"$image_name\"> \n";
echo "$image_name \n";
echo "Comentarios: $image_comments \n";
}
?>