function quickUpdate() { global $db, $prefix, $iConfig, $moduleName, $user, $cookie, $admin, $aid; if (is_user($user)) { $submitter = $cookie[0]; } elseif (is_admin($admin)) { $submitter = substr($aid, 0, 25); } $picturesPath = $iConfig['pictures_path']; $thumbsPath = $iConfig['thumbs_path']; $picturesRealPath = iPath($picturesPath); $thumbsRealPath = iPath($thumbsPath); $albumList = scanAlbums($picturesRealPath); foreach ($albumList as $albums) { $albumRelativePath = substr(str_replace($picturesRealPath, '', $albums), 0, -1); $albumName = basename($albums); $parentPath = substr($albumRelativePath, 0, strlen($albumRelativePath) - 1); $parentPath = substr($parentPath, 0, strrpos($parentPath, '/')); $exists = $db->sql_numrows($db->sql_query('SELECT album_id FROM ' . $prefix . '_igallery_albums WHERE album_folder=\'' . $albumRelativePath . '\'')); if (!$exists) { if (!empty($parentPath)) { $parentId = $db->sql_fetchrow($db->sql_query('SELECT album_id FROM ' . $prefix . '_igallery_albums WHERE album_folder=\'' . $parentPath . '\' LIMIT 0,1')); } else { $parentId = 1; } $right = updateNodes($parentId); if ($right[0]) { // Insert new category $sql = 'INSERT INTO ' . $prefix . '_igallery_albums values (\'\', \'' . $right[0] . '\', \'' . ($right[0] + 1) . '\', \'0\', \'' . $albumName . '\', \'\', \'' . $albumRelativePath . '\', \'\', \'' . time() . '\') ;'; if ($result = $db->sql_query($sql)) { if (!file_exists($thumbsRealPath . $albumRelativePath)) { @mkdir($thumbsRealPath . $albumRelativePath); } echo _IG_ADDEDALBUM . ' <b>' . $albumName . '</b>... ' . $albumRelativePath . '/<br />' . PHP_EOL; } } } } echo '<hr />' . PHP_EOL; $row = $db->sql_query('SELECT album_id, album_folder FROM ' . $prefix . '_igallery_albums;'); while ($result = $db->sql_fetchrow($row)) { $albumId = $result['album_id']; $folderName = $result['album_folder']; if (is_dir($picturesRealPath . $folderName)) { if ($dir2 = opendir($picturesRealPath . $folderName)) { while (($picture = readdir($dir2)) !== false) { if (preg_match('#^(.*)\\.(' . allowedExt('preg') . ')$#i', $picture) && is_file($picturesRealPath . $folderName . '/' . $picture) && $picture !== "." && $picture !== "..") { $current = $db->sql_numrows($db->sql_query('SELECT picture_id FROM ' . $prefix . '_igallery_pictures WHERE picture_file=\'' . $picture . '\' AND album_id=\'' . $albumId . '\'')); if ($current == 0 && $picture !== ' .' && $picture !== '. .' && !is_dir($picture)) { $result = $db->sql_query('INSERT INTO ' . $prefix . '_igallery_pictures VALUES(NULL, \'' . $albumId . '\', \'' . $picture . '\', \'\', \'' . $picture . '\', 0, 0, \'' . time() . '\', \'' . $submitter . '\', 0, 0, \'\')'); if ($result) { echo _IG_ADDEDPIC . ' <b>' . $folderName . '/' . $picture . '</b><br />' . PHP_EOL; } else { echo _IG_ADDEDPICFAIL . ' <b>' . $folderName . '/' . $picture . '</b>... ' . mysql_error() . '<br />' . PHP_EOL; } createThumb($moduleName, $folderName, $picture); } } } closedir($dir2); } } } echo '<br /><center><b>' . _IG_QUICKADDFINISHED . '</b></center><br />'; }
function galAlbumSave($ajaxForm = 0) { global $db, $prefix, $admin_file, $iConfig, $moduleName; if (!empty($_POST['album_id'])) { $albumId = intval($_POST['album_id']); } if (!empty($_POST['parent_orig'])) { $parentOriginal = intval($_POST['parent_orig']); } $what = $_POST['what']; $title = mysql_real_escape_string($_POST['album_title']); $parent = intval($_POST['album_parent']); $folder = mysql_real_escape_string($_POST['album_folder']); $description = mysql_real_escape_string($_POST['album_desc']); $active = intval($_POST['album_active']); $cover = ''; //$_POST['album_cover']; $sqlError = ''; if ($what === 'AlbumSaveNew') { $picturesPath = $iConfig['pictures_path']; $picturesRealPath = iPath($picturesPath); if (!file_exists($picturesRealPath . $folder)) { @mkdir($picturesRealPath . $folder); } if (!empty($title) && !empty($folder) && !empty($description)) { $right = updateNodes($parent); if ($right[0]) { // Insert new category $sql = 'INSERT INTO ' . $prefix . '_igallery_albums values (\'\', \'' . $right[0] . '\', \'' . ($right[0] + 1) . '\', \'' . $active . '\', \'' . $title . '\', \'' . $description . '\', \'' . $folder . '\', \'' . $cover . '\', \'' . time() . '\') ;'; if ($result = $db->sql_query($sql)) { echo '<div class="warning"><ul><li>' . _IG_ADM_CONFIGSAVED . '</li></ul></div>'; } else { echo '<div class="warning"><ul><li>' . _IG_ADM_CONFIGERROR . ': ' . mysql_error() . '</li></ul></div>'; } } else { echo '<div class="warning"><ul><li>' . _IG_ADM_CONFIGERROR . ': ' . $right[1] . '</li></ul></div>'; } } else { echo '<div class="warning"><ul><li>' . _IG_ADM_ADDNEWERROR . '</li></ul></div>'; } } elseif ($what === 'AlbumSaveEdit') { if ($parent !== $parentOriginal) { $update = updateNodes($parent); } else { $update = true; } if ($update) { $result = $db->sql_query('UPDATE ' . $prefix . '_igallery_albums SET album_active=' . $active . ', album_title=\'' . $title . '\', album_desc=\'' . $description . '\', album_folder=\'' . $folder . '\', album_cover=\'' . $cover . '\' WHERE album_id=' . $albumId . ' LIMIT 1 ;'); if ($result) { echo '<div class="warning"><ul><li>' . _IG_ADM_ALBUMSAVED . '</li></ul></div>'; } else { echo '<div class="warning"><ul><li>' . _IG_ADM_CONFIGERROR . ': ' . mysql_error() . '</li></ul></div>'; } } } if ($ajaxForm == 0) { header('location: ' . $admin_file . '.php?op=galAlbums'); } }