break; } } } // destruction of Exercise unset($objExerciseTmp); Security::clear_token(); } if (!empty($hpchoice)) { switch ($hpchoice) { case 'delete': // deletes an exercise $imgparams = array(); $imgcount = 0; GetImgParams($file, $documentPath, $imgparams, $imgcount); $fld = GetFolderName($file); for ($i = 0; $i < $imgcount; $i++) { FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/" . $imgparams[$i]); FileManager::update_db_info("delete", $uploadPath . "/" . $fld . "/" . $imgparams[$i]); } if (FileManager::my_delete($documentPath . $file)) { FileManager::update_db_info("delete", $file); } // hotpotatoes folder may contains several tests so don't delete folder if not empty : #2165 if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !FileManager::folder_is_empty($documentPath . $uploadPath . "/" . $fld . "/"))) { FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/"); } break; case 'enable': // enables an exercise $newVisibilityStatus = "1";
<?php include dirname(__FILE__) . "/init.php"; $count = 0; $counttotal = 0; $query = "SELECT categoryid, catimagefile FROM isc_categories WHERE catimagefile !=''"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $FolderName = GetFolderName($row['categoryid']); $FolderName = preg_replace("#[^\\w.]#i", "", $FolderName); $FolderName = strtolower($FolderName); if (MoveAndUpdate($row['categoryid'], $row['catimagefile'], $FolderName)) { $count++; } $counttotal++; } echo $count . " out of " . $counttotal . " images moved and updated successfully"; function GetFolderName($catid) { $query1 = "SELECT pc.catname parentcatname, sc.catname subcatname FROM isc_categories sc\n LEFT JOIN isc_categories pc ON pc.categoryid = sc.catparentid\n WHERE sc.categoryid ='{$catid}'"; $result1 = $GLOBALS['ISC_CLASS_DB']->Query($query1); while ($row1 = $GLOBALS['ISC_CLASS_DB']->Fetch($result1)) { if ($row1['parentcatname'] != '') { return $row1['parentcatname']; } else { return $row1['subcatname']; } } } function MoveAndUpdate($CatId, $ImageFile, $FolderName) {