--- /dev/null
+/* Modified by: xChaos, 20121011 */\r
+\r
+#include "cll1-0.6.2.h"\r
+#include "ipstruct.h"\r
+\r
+extern struct IP *ips, *ip;\r
+\r
+void write_json_traffic(char *json)\r
+{\r
+ FILE *f=fopen(json, "w");\r
+ if(f > 0)\r
+ {\r
+ int jsoncount=0;\r
+ fprintf(f, "{\n");\r
+ for_each(ip, ips)\r
+ {\r
+ if( ip->lmsid > 0 \r
+ and (ip->traffic or ip->direct or ip->proxy or ip->upload))\r
+ {\r
+ if(jsoncount)\r
+ {\r
+ fprintf(f, ",\n");\r
+ }\r
+ fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d }",\r
+ ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, ip->min, ip->desired, ip->max);\r
+ jsoncount++;\r
+ }\r
+ }\r
+ fprintf(f, "}\n");\r
+ fclose(f);\r
+ puts("done.");\r
+ }\r
+ else\r
+ {\r
+ perror(json);\r
+ }\r
+}
\ No newline at end of file