@@ -423,302 +423,12 @@ public function generate_customer_no(){
423423 global $ app ;
424424 // generate customer no.
425425 $ customer_no = mt_rand (100000 , 999999 );
426- while ($ app ->db ->queryOneRecord ("SELECT client_id FROM client WHERE customer_no = ' " . $ customer_no. " ' " )) {
426+ while ($ app ->db ->queryOneRecord ("SELECT client_id FROM client WHERE customer_no = ? " , $ customer_no)) {
427427 $ customer_no = mt_rand (100000 , 999999 );
428428 }
429429
430430 return $ customer_no ;
431431 }
432-
433- public function generate_activation_code (){
434-
435- $ activation_code = str_pad (mt_rand (0 , 99999999 ), 8 , '0 ' , STR_PAD_LEFT );
436-
437- return $ activation_code ;
438- }
439-
440- public function client_activate ($ client_id ){
441- global $ app , $ conf ;
442-
443- if (!is_file (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' )) return false ;
444- include (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' );
445-
446- $ context = stream_context_create (array (
447- 'ssl ' => array (
448- 'verify_peer ' => false ,
449- 'verify_peer_name ' => false ,
450- )
451- ));
452-
453- $ soap_client = new SoapClient (null , array ('location ' => $ robot_conf ['soap ' ]['soap_location ' ],
454- 'uri ' => $ robot_conf ['soap ' ]['soap_uri ' ],
455- 'trace ' => 1 ,
456- 'exceptions ' => 1 ,
457- 'stream_context ' => $ context ));
458-
459-
460- try {
461- if ($ session_id = $ soap_client ->login ($ robot_conf ['soap ' ]['username ' ] , $ robot_conf ['soap ' ]['password ' ])) {
462- //echo 'Logged successfull. Session ID:'.$session_id.'<br />';
463- }
464- $ error = '' ;
465- $ client_record = $ soap_client ->client_get ($ session_id , $ client_id );
466-
467- $ client_record ['password ' ] = $ this ->password ();
468- if (trim ($ client_record ['customer_no ' ]) == '' ) $ client_record ['customer_no ' ] = $ this ->generate_customer_no ();
469- $ client_record ['username ' ] = 'c ' .$ client_record ['customer_no ' ];
470- //die($client_record['customer_no']);
471- //$client_record['locked'] = 'n';
472- $ client_record ['canceled ' ] = 'n ' ;
473- $ soap_client ->client_update ($ session_id , $ client_id , 0 , $ client_record );
474-
475- $ app ->db ->query ("UPDATE client SET validation_status = 'accept', activation_code = '' WHERE client_id = " .$ client_id );
476-
477- $ activation_letter_filename = ISPC_ROOT_PATH .'/pdf/activation_letters/c ' .$ client_id .'- ' .$ client_record ['activation_code ' ].'.pdf ' ;
478- if (is_file ($ activation_letter_filename )) unlink ($ activation_letter_filename );
479-
480- $ webdetails ['ispconfiguser ' ] = $ client_record ['username ' ];
481- $ webdetails ['ispconfigpassword ' ] = $ client_record ['password ' ];
482- $ webdetails ['customer_no ' ] = $ client_record ['customer_no ' ];
483- $ webdetails ['contact ' ] = ($ client_record ['contact_firstname ' ] != '' ? $ client_record ['contact_firstname ' ].' ' : '' ).$ client_record ['contact_name ' ];
484- $ webdetails ['salutation_de ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Frau ' : 'Herr ' );
485- $ webdetails ['salutation_en ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Mrs. ' : 'Mr. ' );
486- $ webdetails ['ispconfigurl ' ] = 'http ' .($ _SERVER ['HTTPS ' ] == 'on ' ? 's ' : '' ).':// ' .$ _SERVER ['HTTP_HOST ' ];
487- $ webdetails ['signature_de ' ] = $ robot_conf ['textbaustein ' ]['emailfooter ' ];
488- $ webdetails ['signature_en ' ] = $ robot_conf ['textbaustein_en ' ]['emailfooter ' ];
489-
490- if ($ error == '' ){
491- // send email with login details
492- $ invoice_client_settings = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_client_settings WHERE client_id = " .intval ($ client_id ));
493- $ company = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_company WHERE invoice_company_id = " .$ invoice_client_settings ['invoice_company_id ' ]);
494-
495- $ subject = '[ ' .$ company ['company_name_short ' ].'] Zugangsdaten zu unserem Kundeninterface / Login details for our customer interface ' ;
496-
497- $ app ->uses ('tpl ' );
498- $ tpl = new tpl ;
499- $ tpl ->newTemplate (ISPC_WEB_PATH ."/client/templates/ispconfig_login.master " );
500- $ tpl ->setVar ($ webdetails );
501- $ message = $ tpl ->grab ();
502-
503- if ($ robot_conf ['production_mode ' ]){
504- $ app ->functions ->mail (trim ($ client_record ['email ' ]), $ subject , $ message , 'support@timmehosting.de ' , '' , 'application/pdf ' , '' , '' , 'f.timme@timmehosting.de,hetzner@timmehosting.de ' , 'TimmeHosting.de Support ' );
505-
506- $ app ->db ->query ("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', " .intval ($ client_id ).", ' " .$ app ->db ->quote ($ subject )."', ' " .$ app ->db ->quote ($ message )."', ' " .date ('Y-m-d ' )."', " .time ().", 'support@timmehosting.de', ' " .trim ($ client_record ['email ' ])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de') " );
507- }
508- }
509-
510- if ($ soap_client ->logout ($ session_id )) {
511- //echo 'Logged out.<br />';
512- }
513-
514- } catch (SoapFault $ e ) {
515- //$error .= $client->__getLastResponse();
516- $ error .= 'SOAP Error: ' .$ e ->getMessage ();
517- }
518- }
519-
520- public function client_activation_failed ($ client ){
521- global $ app , $ conf ;
522-
523- if (!is_file (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' )) return false ;
524- include (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' );
525-
526- $ client_id = intval ($ client ['client_id ' ]);
527- $ webdetails ['contact ' ] = ($ client ['contact_firstname ' ] != '' ? $ client ['contact_firstname ' ].' ' : '' ).$ client ['contact_name ' ];
528- $ webdetails ['salutation_de ' ] = ($ client ['gender ' ] == 'f ' ? 'Frau ' : 'Herr ' );
529- $ webdetails ['salutation_en ' ] = ($ client ['gender ' ] == 'f ' ? 'Mrs. ' : 'Mr. ' );
530- $ webdetails ['signature_de ' ] = $ robot_conf ['textbaustein ' ]['emailfooter ' ];
531- $ webdetails ['signature_en ' ] = $ robot_conf ['textbaustein_en ' ]['emailfooter ' ];
532-
533-
534- // send email with login details
535- $ invoice_client_settings = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_client_settings WHERE client_id = " .intval ($ client_id ));
536- $ company = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_company WHERE invoice_company_id = " .$ invoice_client_settings ['invoice_company_id ' ]);
537- $ subject = '[ ' .$ company ['company_name_short ' ].'] Aktivierung Ihres Kundenaccounts fehlgeschlagen / Activation of your customer account failed ' ;
538-
539- $ app ->uses ('tpl ' );
540- $ tpl = new tpl ;
541- $ tpl ->newTemplate (ISPC_WEB_PATH ."/client/templates/ispconfig_client_activation_failed.master " );
542- $ tpl ->setVar ($ webdetails );
543- $ message = $ tpl ->grab ();
544-
545- if ($ robot_conf ['production_mode ' ]){
546- $ app ->functions ->mail (trim ($ client ['email ' ]), $ subject , $ message , 'support@timmehosting.de ' , '' , 'application/pdf ' , '' , '' , 'f.timme@timmehosting.de,hetzner@timmehosting.de ' , 'TimmeHosting.de Support ' );
547-
548- $ app ->db ->query ("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', " .intval ($ client_id ).", ' " .$ app ->db ->quote ($ subject )."', ' " .$ app ->db ->quote ($ message )."', ' " .date ('Y-m-d ' )."', " .time ().", 'support@timmehosting.de', ' " .trim ($ client ['email ' ])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de') " );
549- }
550- }
551-
552- public function client_review ($ client_id ){
553- global $ app , $ conf ;
554-
555- if (!is_file (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' )) return false ;
556- include (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' );
557-
558- $ context = stream_context_create (array (
559- 'ssl ' => array (
560- 'verify_peer ' => false ,
561- 'verify_peer_name ' => false ,
562- )
563- ));
564-
565- $ soap_client = new SoapClient (null , array ('location ' => $ robot_conf ['soap ' ]['soap_location ' ],
566- 'uri ' => $ robot_conf ['soap ' ]['soap_uri ' ],
567- 'trace ' => 1 ,
568- 'exceptions ' => 1 ,
569- 'stream_context ' => $ context ));
570-
571- try {
572- if ($ session_id = $ soap_client ->login ($ robot_conf ['soap ' ]['username ' ] , $ robot_conf ['soap ' ]['password ' ])) {
573- //echo 'Logged successfull. Session ID:'.$session_id.'<br />';
574- }
575- $ error = '' ;
576- $ client_record = $ soap_client ->client_get ($ session_id , $ client_id );
577-
578- if (trim ($ client_record ['customer_no ' ]) == '' ){
579- $ client_record ['customer_no ' ] = $ this ->generate_customer_no ();
580- $ soap_client ->client_update ($ session_id , $ client_id , 0 , $ client_record );
581- }
582-
583- $ activation_code = $ this ->generate_activation_code ();
584- $ app ->db ->query ("UPDATE client SET activation_code = ' " .$ activation_code ."' " .($ client_record ['validation_status ' ] != 'review ' ? ", validation_status = 'review' " : "" )." WHERE client_id = " .$ client_id );
585-
586- $ webdetails ['customer_no ' ] = $ client_record ['customer_no ' ];
587- $ webdetails ['contact ' ] = ($ client_record ['contact_firstname ' ] != '' ? $ client_record ['contact_firstname ' ].' ' : '' ).$ client_record ['contact_name ' ];
588- $ webdetails ['salutation_de ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Frau ' : 'Herr ' );
589- $ webdetails ['salutation_en ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Mrs. ' : 'Mr. ' );
590- $ webdetails ['signature_de ' ] = $ robot_conf ['textbaustein ' ]['emailfooter ' ];
591- $ webdetails ['signature_en ' ] = $ robot_conf ['textbaustein_en ' ]['emailfooter ' ];
592- $ webdetails ['email ' ] = $ client_record ['email ' ];
593- include ISPC_LIB_PATH .'/lang/ ' .strtolower ($ client_record ['language ' ]).'.lng ' ;
594- $ webdetails ['latest_activation_date ' ] = date ($ wb ['conf_format_dateshort ' ], $ client_record ['created_at ' ] + 14 * 86400 );
595-
596- if ($ error == '' ){
597- // send email with login details
598- $ invoice_client_settings = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_client_settings WHERE client_id = " .intval ($ client_id ));
599- $ company = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_company WHERE invoice_company_id = " .$ invoice_client_settings ['invoice_company_id ' ]);
600-
601- $ subject = '[ ' .$ company ['company_name_short ' ].'] Aktivierung Ihres Kundenkontos / Activation of your customer account ' ;
602- $ webdetails ['company_name_short ' ] = $ company ['company_name_short ' ];
603-
604- $ app ->uses ('tpl ' );
605- $ tpl = new tpl ;
606- $ tpl ->newTemplate (ISPC_WEB_PATH ."/client/templates/ispconfig_client_activation_email.master " );
607- $ tpl ->setVar ($ webdetails );
608- $ message = $ tpl ->grab ();
609-
610- if ($ robot_conf ['production_mode ' ]){
611- $ app ->functions ->mail (trim ($ client_record ['email ' ]), $ subject , $ message , 'support@timmehosting.de ' , '' , 'application/pdf ' , '' , '' , 'f.timme@timmehosting.de,hetzner@timmehosting.de ' , 'TimmeHosting.de Support ' );
612-
613- $ app ->db ->query ("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', " .intval ($ client_id ).", ' " .$ app ->db ->quote ($ subject )."', ' " .$ app ->db ->quote ($ message )."', ' " .date ('Y-m-d ' )."', " .time ().", 'support@timmehosting.de', ' " .trim ($ client_record ['email ' ])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de') " );
614- }
615- }
616-
617- // create activation letter pdf
618- $ app ->uses ('pdf ' );
619- $ app ->pdf ->AliasNbPages ();
620- $ app ->pdf ->createActivationLetter ($ client_id );
621-
622- $ pdf_content = $ app ->pdf ->Output ('doc.pdf ' , 'S ' );
623-
624- $ activation_letter_filename = ISPC_ROOT_PATH .'/pdf/activation_letters/c ' .$ client_id .'- ' .$ activation_code .'.pdf ' ;
625- file_put_contents ($ activation_letter_filename , $ pdf_content );
626-
627- if (is_file ($ activation_letter_filename )){
628- include (ISPC_WEB_PATH .'/billing/lib/onlinebrief24/Net/SFTP.php ' );
629- $ sftp = new Net_SFTP ('api.letterei-onlinebrief.de ' );
630- if (!$ sftp ->login ($ company ['onlinebrief24_user ' ], $ company ['onlinebrief24_password ' ])) {
631- $ error_msg = $ app ->lng ('onlinebrief24_login_failed_txt ' );
632- $ app ->error ($ error_msg );
633- }
634- $ upload_filename = ($ company ['onlinebrief24_print ' ] == 'coloured ' ? '1 ' : '0 ' ).'00 ' .($ client_record ['country ' ] == 'DE ' ? '1 ' : '0 ' ).'000000000-c ' .$ client_id .'- ' .$ activation_code .'.pdf ' ;
635- //die($upload_filename);
636- $ sftp ->chdir ('upload/api ' );
637- $ sftp ->put ($ upload_filename , $ activation_letter_filename , NET_SFTP_LOCAL_FILE );
638- }
639-
640- if ($ soap_client ->logout ($ session_id )) {
641- //echo 'Logged out.<br />';
642- }
643-
644- } catch (SoapFault $ e ) {
645- //$error .= $client->__getLastResponse();
646- $ error .= 'SOAP Error: ' .$ e ->getMessage ();
647- }
648- }
649-
650- public function client_reject ($ client_id ){
651- global $ app , $ conf ;
652-
653- if (!is_file (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' )) return false ;
654- include (ISPC_WEB_PATH .'/robot/lib/robot_config.inc.php ' );
655-
656- $ context = stream_context_create (array (
657- 'ssl ' => array (
658- 'verify_peer ' => false ,
659- 'verify_peer_name ' => false ,
660- )
661- ));
662-
663- $ soap_client = new SoapClient (null , array ('location ' => $ robot_conf ['soap ' ]['soap_location ' ],
664- 'uri ' => $ robot_conf ['soap ' ]['soap_uri ' ],
665- 'trace ' => 1 ,
666- 'exceptions ' => 1 ,
667- 'stream_context ' => $ context ));
668-
669- try {
670- if ($ session_id = $ soap_client ->login ($ robot_conf ['soap ' ]['username ' ] , $ robot_conf ['soap ' ]['password ' ])) {
671- //echo 'Logged successfull. Session ID:'.$session_id.'<br />';
672- }
673- $ error = '' ;
674- $ client_record = $ soap_client ->client_get ($ session_id , $ client_id );
675-
676- $ client_record ['locked ' ] = 'y ' ;
677- $ client_record ['canceled ' ] = 'y ' ;
678- $ soap_client ->client_update ($ session_id , $ client_id , 0 , $ client_record );
679-
680- $ app ->db ->query ("UPDATE client SET validation_status = 'reject', activation_code = '' WHERE client_id = " .$ client_id );
681- $ app ->db ->query ("DELETE FROM th_order WHERE client_id = " .$ client_id );
682-
683- $ activation_letter_filename = ISPC_ROOT_PATH .'/pdf/activation_letters/c ' .$ client_id .'- ' .$ client_record ['activation_code ' ].'.pdf ' ;
684- if (is_file ($ activation_letter_filename )) unlink ($ activation_letter_filename );
685-
686- $ webdetails ['contact ' ] = ($ client_record ['contact_firstname ' ] != '' ? $ client_record ['contact_firstname ' ].' ' : '' ).$ client_record ['contact_name ' ];
687- $ webdetails ['salutation_de ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Frau ' : 'Herr ' );
688- $ webdetails ['salutation_en ' ] = ($ client_record ['gender ' ] == 'f ' ? 'Mrs. ' : 'Mr. ' );
689- $ webdetails ['signature_de ' ] = $ robot_conf ['textbaustein ' ]['emailfooter ' ];
690- $ webdetails ['signature_en ' ] = $ robot_conf ['textbaustein_en ' ]['emailfooter ' ];
691-
692- if ($ error == '' ){
693- // send email with login details
694- $ invoice_client_settings = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_client_settings WHERE client_id = " .intval ($ client_id ));
695- $ company = $ app ->db ->queryOneRecord ("SELECT * FROM invoice_company WHERE invoice_company_id = " .$ invoice_client_settings ['invoice_company_id ' ]);
696-
697- $ subject = '[ ' .$ company ['company_name_short ' ].'] Sperrung Ihres Kundenaccounts / Suspension of your customer account ' ;
698-
699- $ app ->uses ('tpl ' );
700- $ tpl = new tpl ;
701- $ tpl ->newTemplate (ISPC_WEB_PATH ."/client/templates/ispconfig_client_rejection.master " );
702- $ tpl ->setVar ($ webdetails );
703- $ message = $ tpl ->grab ();
704-
705- if ($ robot_conf ['production_mode ' ]){
706- $ app ->functions ->mail (trim ($ client_record ['email ' ]), $ subject , $ message , 'support@timmehosting.de ' , '' , 'application/pdf ' , '' , '' , 'f.timme@timmehosting.de,hetzner@timmehosting.de ' , 'TimmeHosting.de Support ' );
707-
708- $ app ->db ->query ("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', " .intval ($ client_id ).", ' " .$ app ->db ->quote ($ subject )."', ' " .$ app ->db ->quote ($ message )."', ' " .date ('Y-m-d ' )."', " .time ().", 'support@timmehosting.de', ' " .trim ($ client_record ['email ' ])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de') " );
709- }
710- }
711-
712- if ($ soap_client ->logout ($ session_id )) {
713- //echo 'Logged out.<br />';
714- }
715-
716- } catch (SoapFault $ e ) {
717- //$error .= $client->__getLastResponse();
718- $ error .= 'SOAP Error: ' .$ e ->getMessage ();
719- }
720- }
721-
722432}
723433
724434?>
0 commit comments