I recently bought an el-cheapo night light for $1 just to see how they manage to get the costs so low. I expected to meet an el-cheapo voltage regulator at best or even a bridge rectifier but alas! None exist here. I just can't figure out how or why the circuit here works with mains (240V) voltage. It does get warm during operation but I wasn't going to use it anyways so it is just a learning prop for me. I have no idea what the SOT part labelled "J6" is and if it's a transistor, what kind. Please help me figure out how it works and what that "J6" could be.
edit: R2 is the LDR, the other resistors are SMD resistors and the capacitor is an electrolytic cap.
and I've drawn the schematic as is:
simulate this circuit – Schematic created using CircuitLab