Ejemplo n.º 1
0
 function myalbum_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB;
     include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/read_configs.php";
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "t.description" : "'' AS description";
     $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,{$select4con} FROM {$table_photos} l LEFT JOIN {$table_text} t ON t.lid=l.lid LEFT JOIN " . $xoopsDB->prefix("users") . " u ON l.submitter=u.uid WHERE status>0";
     if ($userid > 0) {
         $sql .= " AND l.submitter=" . $userid . " ";
     }
     $whr = "";
     if (is_array($keywords) && count($keywords) > 0) {
         $whr = "AND (";
         switch (strtolower($andor)) {
             case "and":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' AND ";
                 }
                 $whr = substr($whr, 0, -5);
                 break;
             case "or":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' OR ";
                 }
                 $whr = substr($whr, 0, -4);
                 break;
             default:
                 $whr .= "CONCAT(l.title,'  ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keywords[0]}%'";
                 break;
         }
         $whr .= ")";
     }
     $sql = "{$sql} {$whr} ORDER BY l.date DESC";
     $result = $xoopsDB->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     include_once XOOPS_ROOT_PATH . "/modules/{$mydirname}/class/myalbum.textsanitizer.php";
     $myts =& MyAlbumTextSanitizer::getInstance();
     while ($myrow = $xoopsDB->fetchArray($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myts->displayTarea($myrow['description'], 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array("image" => "images/pict.gif", "link" => "photo.php?lid=" . $myrow["lid"], "title" => $myrow["title"], "time" => $myrow["date"], "uid" => $myrow["submitter"], "context" => $context);
     }
     return $ret;
 }
function myalbum_get_array_for_photo_assign($fetched_result_array, $summary = false)
{
    global $my_uid, $isadmin, $global_perms;
    global $photos_url, $thumbs_url, $thumbs_dir, $mod_url, $mod_path;
    global $myalbum_makethumb, $myalbum_thumbsize, $myalbum_popular, $myalbum_newdays, $myalbum_normal_exts;
    include_once "{$mod_path}/class/myalbum.textsanitizer.php";
    $myts =& MyAlbumTextSanitizer::getInstance();
    extract($fetched_result_array);
    if (in_array(strtolower($ext), $myalbum_normal_exts)) {
        $imgsrc_thumb = "{$thumbs_url}/{$lid}.{$ext}";
        $imgsrc_photo = "{$photos_url}/{$lid}.{$ext}";
        $ahref_photo = "{$photos_url}/{$lid}.{$ext}";
        $is_normal_image = true;
        // Width of thumb
        $width_spec = "width='{$myalbum_thumbsize}'";
        if ($myalbum_makethumb) {
            list($width, $height, $type) = getimagesize("{$thumbs_dir}/{$lid}.{$ext}");
            // if thumb images was made, 'width' and 'height' will not set.
            if ($width <= $myalbum_thumbsize) {
                $width_spec = '';
            }
        }
    } else {
        $imgsrc_thumb = "{$thumbs_url}/{$lid}.gif";
        $imgsrc_photo = "{$thumbs_url}/{$lid}.gif";
        $ahref_photo = "{$photos_url}/{$lid}.{$ext}";
        $is_normal_image = false;
        $width_spec = '';
    }
    // Voting stats
    if ($rating > 0) {
        if ($votes == 1) {
            $votestring = _ALBM_ONEVOTE;
        } else {
            $votestring = sprintf(_ALBM_NUMVOTES, $votes);
        }
        $info_votes = number_format($rating, 2) . " ({$votestring})";
    } else {
        $info_votes = '0.00 (' . sprintf(_ALBM_NUMVOTES, 0) . ')';
    }
    // Submitter's name
    $submitter_name = myalbum_get_name_from_uid($submitter);
    // Category's title
    $cat_title = empty($cat_title) ? '' : $cat_title;
    // Summarize description
    if ($summary) {
        $description = $myts->extractSummary($description);
    }
    return array('lid' => $lid, 'cid' => $cid, 'ext' => $ext, 'res_x' => $res_x, 'res_y' => $res_y, 'window_x' => $res_x + 16, 'window_y' => $res_y + 16, 'title' => $myts->makeTboxData4Show($title), 'datetime' => formatTimestamp($date, 'm'), 'description' => $myts->displayTarea($description, 0, 1, 1, 1, 1, 1), 'imgsrc_thumb' => $imgsrc_thumb, 'imgsrc_photo' => $imgsrc_photo, 'ahref_photo' => $ahref_photo, 'width_spec' => $width_spec, 'can_edit' => $global_perms & GPERM_EDITABLE && ($my_uid == $submitter || $isadmin), 'submitter' => $submitter, 'submitter_name' => $submitter_name, 'hits' => $hits, 'rating' => $rating, 'rank' => floor($rating - 0.001), 'votes' => $votes, 'info_votes' => $info_votes, 'comments' => $comments, 'is_normal_image' => $is_normal_image, 'is_newphoto' => $date > time() - 86400 * $myalbum_newdays && $status == 1, 'is_updatedphoto' => $date > time() - 86400 * $myalbum_newdays && $status == 2, 'is_popularphoto' => $hits >= $myalbum_popular, 'info_morephotos' => sprintf(_ALBM_MOREPHOTOS, $submitter_name), 'cat_title' => $myts->makeTboxData4Show($cat_title));
}
Ejemplo n.º 3
0
}
//global $xoopsUser;
// inizio hack limite foto - slyss
//Hack by Danilo Tomasino (aka Dantom)
//Non permette l'inserimento di piu di $totaleFoto nell'album
if ($xoopsUser) {
    $totaleFoto = 1000;
    $result = $xoopsDB->query("SELECT * FROM {$table_photos} WHERE submitter = " . $xoopsUser->getVar('uid') . "");
    $RowsNum = $xoopsDB->getRowsNum($result);
    if ($RowsNum > $totaleFoto - 1) {
        redirect_header("../../modules/smartprofile/userinfo.php?uid=" . $xoopsUser->getVar('uid') . "", 5, "Non puoi inserire piu di " . $totaleFoto . " immagine/i nel tuo profilo");
        exit;
    }
}
// fine hack limite foto - slyss
$myts =& MyAlbumTextSanitizer::getInstance();
$cattree = new XoopsTree($table_cat, "cid", "pid");
// GET variables
$caller = @$_GET['caller'] == 'imagemanager' ? 'imagemanager' : '';
// POST variables
$preview_name = empty($_POST['preview_name']) ? '' : $_POST['preview_name'];
// check INSERTABLE
if (!($global_perms & GPERM_INSERTABLE)) {
    redirect_header(XOOPS_URL . "/user.php", 2, _ALBM_MUSTREGFIRST);
    exit;
}
// check Categories exist
$result = $xoopsDB->query("SELECT count(cid) as count FROM {$table_cat}");
list($count) = $xoopsDB->fetchRow($result);
if ($count < 1) {
    redirect_header(XOOPS_URL . "/modules/{$mydirname}/", 2, _ALBM_MUSTADDCATFIRST);