'; return NULL; } if (! @mysql_select_db($CPG['database'],$db) ) { echo 'Unable to locate the picture database
'; mysql_close($DB); return NULL; } return $db; } function cpg_canConnect(){ if (!($db = cpg_start())){ echo 'Failed to connect to CPG
'; return; } echo 'Connected to CPG successfully
'; cpg_end($db); } function truncate($str,$len = 0){ if ($len <= 0) return $str; if (strlen($str) > $len) return (substr($str,0,$len) . '...'); else return $str; } function cpg_displayImageList($page = 0, $lineBreak = NULL, $manage = false, $url = NULL){ global $serendipity; global $CPG; $album = (isset($CPG['album'])) ? $CPG['album'] : NULL; if ($album == -1) $album = NULL; $sort_row_interval = array(8, 16, 50, 100); $sort_order = array('ctime' => 'Date', 'owner_id' => 'Owner', 'pid' => 'ID'); $perPage = (isset($CPG['sortorder']['perpage']) ? $CPG['sortorder']['perpage'] : $sort_row_interval[1]); $start = ($page-1)*$perPage; $order = 'ctime DESC'; if (isset($CPG['sortorder']['order']) && isset($CPG['sortorder']['order'])) $order = $CPG['sortorder']['order'] . ' ' . $CPG['sortorder']['ordermode']; $images = cpg_getImages($totalImages, $start, $perPage, $album, $order, $serendipity['thumbSize']); $albums = cpg_getAlbums(); $extraParams = ''; $importParams = array('adminModule', 'htmltarget', 'filename_only', 'textarea'); foreach($importParams AS $importParam) { if (isset($CPG[$importParam])) { $extraParams .= $importParam . '='. $CPG[$importParam] .'&'; } } if (isset($CPG['only_path']) && !empty($CPG['only_path']) ) { $extraParams .= 'only_path='. $CPG['only_path'] .'&'; serendipity_uploadSecure($CPG['only_path'], true); } foreach ( (array)$CPG['sortorder'] as $k => $v ) { $extraParams .= 'sortorder['. $k .']='. $v .'&'; } $extraParams .= 'album='.((isset($album))?$album:-1).'&'; if (is_null($lineBreak)) { $lineBreak = floor(750 / ($serendipity['thumbSize'] + 20)); } $link = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/plugin/' . CPG_EVENT . '&'; $left = '' . "\n"; $right = '' . "\n"; // $left = '' . "\n"; // $right = '' . "\n"; ?>
$g_val) { if ( !is_array($g_val) && $g_key != 'page' ) { echo ''; } } ?>
Album
>
'; echo '
' . $image['thumbnail'] . '
'; if (isset($url)) echo ''; echo '
' . truncate($image['file'],16) . '
'; echo '
' . $image['owner'] . '
'; echo '
' . date('d/m/y',$image['date']) . '
'; ?>
'; return NULL; } $where = ''; if (isset($album)) $where = 'WHERE aid = ' . $album; $query = "SELECT count(*) FROM " . $CPG['prefix'] . "pictures {$where}"; $result = @mysql_query($query,$db); if (!$result){ echo 'Error performing query: ' . mysql_error() . '
'; cpg_end($db); return NULL; } $row = mysql_fetch_array($result); $totalImages = $row[0]; $query = "SELECT * FROM " . $CPG['prefix'] . "pictures {$where} ORDER BY {$order} LIMIT {$first}, {$count}"; $result = @mysql_query($query,$db); if (!$result){ echo 'Error performing query: ' . mysql_error() . '
'; cpg_end($db); return NULL; } while ($row = mysql_fetch_array($result)){ $image = array(); $image['aid'] = $row['aid']; $image['id'] = $row['pid']; $image['width'] = $row['pwidth']; $image['height'] = $row['pheight']; $image['owner'] = $row['owner_name']; $image['date'] = $row['ctime']; $image['file'] = $row['filename']; $image['path'] = $row['filepath']; if ((int)$image['width'] > 0 && (int)$image['height'] > 0) { $aspect = $image['width'] / $image['height']; } else { $aspect = 1; } if ($aspect >= 1){ $image['iconWidth'] = $iconSize; $image['iconHeight'] = floor($iconSize / $aspect); } else { $image['iconWidth'] = floor($iconSize * $aspect); $image['iconHeight'] = $iconSize; } $image['link'] = $CPG['path'] . 'displayimage.php?album=' . $image['aid'] . '&pos=-' . $image['id']; $image['thumbnail'] = '' . $image['file'] . ''; $images[] = $image; } cpg_end($db); return $images; } function cpg_getImage($id){ global $serendipity; global $CPG; $iconSize = $serendipity['thumbSize']; if (!($db = cpg_start())){ echo 'Failed to connect to CPG
'; return NULL; } $query = "SELECT * FROM " . $CPG['prefix'] . "pictures WHERE pid = {$id}"; $result = @mysql_query($query,$db); if (!$result){ echo 'Error performing query: ' . mysql_error() . '
'; cpg_end($db); return NULL; } if (!($row = mysql_fetch_array($result))){ echo 'Error: image not found (' . $id . ')
'; cpg_end($db); return NULL; } cpg_end($db); $image = array(); $image['aid'] = $row['aid']; $image['id'] = $row['pid']; $image['width'] = $row['pwidth']; $image['height'] = $row['pheight']; $image['owner'] = $row['owner_name']; $image['date'] = $row['ctime']; $image['filename'] = $row['filename']; $aspect = $image['width'] / $image['height']; if ($aspect >= 1){ $image['iconWidth'] = $iconSize; $image['iconHeight'] = floor($iconSize / $aspect); } else { $image['iconWidth'] = floor($iconSize * $aspect); $image['iconHeight'] = $iconSize; } if ($CPG['maxwidth'] && is_numeric($CPG['maxwidth']) && (int)$CPG['maxwidth'] > 0 && (int)$image['width'] > (int)$CPG['maxwidth']) { $image['width'] = $CPG['maxwidth']; $image['height'] = floor($CPG['maxwidth'] / $aspect); } if ($CPG['maxheight'] && is_numeric($CPG['maxheight']) && (int)$CPG['maxheight'] > 0 && (int)$image['width'] > (int)$CPG['maxheight']) { $image['width'] = floor($CPG['maxheight'] * $aspect); $image['height'] = $CPG['maxheight']; } if ($CPG['usenormal'] == 'true') { $image['file'] = $CPG['path'] . 'albums/' . $row['filepath']. 'normal_' . $row['filename']; } else { $image['file'] = $CPG['path'] . 'albums/' . $row['filepath']. $row['filename']; } $image['thumbnail'] = $CPG['path'] . 'albums/' . $row['filepath'] . 'thumb_' . $row['filename']; $image['link'] = $CPG['path'] . 'displayimage.php?pos=-' . $image['id']; return $image; } function cpg_getAlbums(){ global $CPG; $albums = array(); if (!($db = cpg_start())){ echo 'Failed to connect to CPG
'; return NULL; } $query = "SELECT aid,title,description,category FROM " . $CPG['prefix'] . "albums ORDER BY title ASC"; $result = @mysql_query($query,$db); if (!$result){ echo 'Error performing query: ' . mysql_error() . '
'; cpg_end($db); return NULL; } while ($row = mysql_fetch_array($result)) $albums[] = $row; cpg_end($db); return $albums; } function cpg_window(){ global $CPG; global $serendipity; cpg_init(); ?> <?php echo SELECT_FILE; ?>

:



:




:



Coppermine options:


: