Common subdirectories: phpfreechat/extras and drupal-6.16/sites/all/modules/contrib/phpfreechat/extras Only in drupal-6.16/sites/all/modules/contrib/phpfreechat: phpfreechat diff -up phpfreechat/phpfreechat.inc drupal-6.16/sites/all/modules/contrib/phpfreechat/phpfreechat.inc --- phpfreechat/phpfreechat.inc 2009-01-22 22:12:14.000000000 -0500 +++ drupal-6.16/sites/all/modules/contrib/phpfreechat/phpfreechat.inc 2010-10-25 13:28:42.000000000 -0400 @@ -83,20 +83,54 @@ function _phpfreechat_clear_cache() { /** * Delete logs of a chat room. * @params $rid - * Room Id + * @param $nid Optionally supply a node id (for per node chats) */ -function _phpfreechat_nuke($rid) { +function _phpfreechat_nuke($rid, $nid = NULL) { $params = phpfreechat_load_params(); - $data = $params['data_private_path'] .'/chat/'. $rid .'/messages.data'; - $index = $params['data_private_path'] .'/chat/'. $rid .'/messages.index'; - file_delete($data); - file_create_path($data); - file_delete($index); - file_create_path($index); - drupal_set_message('Chat room contents cleared.'); - drupal_goto(''); - - drupal_set_message('rid: '. $rid .', data: '. $data .', index: '. $index); + $chatlog_filepath = $params['data_private_path'] .'/logs/'. $rid; + $chatmeta_filepath = $params['data_private_path'] .'/chat/s_'. $rid; + + $cache_filepath = $params['data_private_path'] .'/cache/'. $rid .'.php'; + file_delete($cache_filepath); + + if (_phpfreechat_rm_recursive($chatlog_filepath) &&_phpfreechat_rm_recursive($chatmeta_filepath)) { + drupal_set_message('Chat room contents cleared.'); + } + else { + drupal_set_message('Chat room contents not cleared', 'error'); + } + if ($nid) { + drupal_goto('node/'. $nid); + } + else { + drupal_goto(); + } +} +/** + * Recursively delete a directory with chat room cache + * + * @param $filepath The directory path that you want to delete. + */ +function _phpfreechat_rm_recursive($filepath) { + // recheck the user access, in an excess of caution + // (in case the function is called from elsewhere) + if (user_access('administer phpfreechat')) { + if (is_dir($filepath) && !is_link($filepath)) { + if ($dh = opendir($filepath)) { + while (($sf = readdir($dh)) !== false) { + if ($sf == '.' || $sf == '..' ) { + continue; + } + if (!_phpfreechat_rm_recursive($filepath.'/'.$sf)) { + drupal_set_message($filepath.'/'.$sf.' could not be deleted.', 'error'); + } + } + closedir($dh); + } + return rmdir($filepath); + } + return unlink($filepath); + } } /** Only in drupal-6.16/sites/all/modules/contrib/phpfreechat: phpfreechat.inc~ diff -up phpfreechat/phpfreechat.module drupal-6.16/sites/all/modules/contrib/phpfreechat/phpfreechat.module --- phpfreechat/phpfreechat.module 2009-01-22 22:12:14.000000000 -0500 +++ drupal-6.16/sites/all/modules/contrib/phpfreechat/phpfreechat.module 2010-10-25 13:37:00.000000000 -0400 @@ -32,7 +32,7 @@ function phpfreechat_menu() { $items['phpfreechat/nuke'] = array( 'title' => 'Clear chats!', 'page callback' => 'phpfreechat_nuke', - 'page arguments' => array(arg(2)), + 'page arguments' => array(2), 'access arguments' => array('admin phpfreechat'), 'type' => MENU_CALLBACK); $items['admin/settings/phpfreechat'] = array( @@ -47,11 +47,22 @@ function phpfreechat_menu() { /** * Delete logs of a chat room. - * @params $rid - * Room Id + * @params $nid + * Node Id */ -function phpfreechat_nuke($rid) { - _phpfreechat_nuke($rid); +function phpfreechat_nuke($nid) { + if (is_numeric($nid)) { + $node = node_load($nid); + // make sure that we are only operating on nodes that have chat enabled. + // to keep other directories from getting deleted + if ($node->phpfreechat_enabled == 1) { + $rid = md5('node'. $nid); + _phpfreechat_nuke($rid, $nid); + } + else { + return; + } + } } /** @@ -558,7 +569,7 @@ function phpfreechat_room($node) { $output .= $chat->printChat(TRUE); if (user_access('admin phpfreechat')) { - $output .= l('Clear chat log for '. $node->title, 'phpfreechat/nuke/'. strtolower(str_replace(' ', '', $node->title))); + $output .= l('Clear chat log for '. $node->title, 'phpfreechat/nuke/'. $node->nid); } $output .= ''; } Only in drupal-6.16/sites/all/modules/contrib/phpfreechat: phpfreechat.module~