function manualAddPic($imagename) { $imgarray; $sql = "SELECT * FROM " . cms_db_prefix() . "module_showtime WHERE show_id = 1"; $result = mysql_query($sql); $picturenumber = mysql_num_rows($result); //echo $imagename ." ". $picturenumber . " total"; $path = 'uploads/images/Gallery'; $imgarray = Showtime::ListFiles($path); sort($imgarray); $i = 1; $sql = "SELECT id FROM " . cms_db_prefix() . "module_showtime_seq"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $pictureid = $row['id']; } $query = "DELETE FROM " . cms_db_prefix() . "module_showtime"; mysql_query($query) or die('delete err'); foreach ($imgarray as $key => $file) { $stat = stat($file); if ($i >= 7) { break; } $imgarray[$i] = $file; $pictureid++; $picturenumber++; $imagepath =& $file; $the_path = dirname($imagepath); $the_path = str_replace('uploads/images', '', $the_path); $imagepath = str_replace('uploads/images', '', $imagepath); $pos = strpos($the_path, '/', strlen($the_path) - 1); if ($pos === false) { $thumbpath = $the_path . '/thumb_' . basename($imagepath); } if ($pos !== false) { $thumbpath = $the_path . 'thumb_' . basename($imagepath); } $thumbpath = str_replace('\\', '', $thumbpath); $query2 = "INSERT INTO " . cms_db_prefix() . "module_showtime (picture_id, picture_name,show_id, thumbnail_path, picture_path, picture_number) VALUES (" . $pictureid . ",'" . basename($file) . "',1,'" . $thumbpath . "','" . $imagepath . "'," . $picturenumber . ");"; mysql_query($query2) or die('insert err'); //echo $query2 . "<br /><br />"; $i++; } $query3 = "UPDATE " . cms_db_prefix() . "module_showtime_seq SET id=" . $pictureid; mysql_query($query3) or die('update err'); return; }
protected function initRelations() { $this->setOneToMany('showtimes', Showtime::manager()); }