Skip to content

Instantly share code, notes, and snippets.

<?php
#!/usr/bin/php
/*
* Script: lgaetz-tctoggle.php (Modified)
* Original Author: lgaetz - https://gist.github.com/lgaetz/28d41cf0ff5af1179d7840d67aae971c
* Modifications by: Eugene Robertus, 2025
*
* License: GNU GPL v3+
* This script and its modifications are distributed under the same GPL license.
/*
* Overview:
* This script is designed to clean and optimize the Call Detail Records (CDR)
* and Channel Event Logging (CEL) tables in an Asterisk-based PBX system.
* The process involves creating new temporary tables (`cdr_new` and `cel_new`)
* with the same structure as the existing ones, filtering and copying relevant
* data into these new tables, and then replacing the old tables with the new ones.
*
* Key Steps:
* 1. Drop any existing temporary tables to avoid conflicts.