function zb_PhpConsoleCreateTemplate($name, $body) { $key = 'PHPCONSOLETEMPLATE:' . zb_rand_string(16); $newtemplatedata = array(); $newtemplatedata['name'] = $name; $newtemplatedata['body'] = $body; $value = serialize($newtemplatedata); zb_StorageSet($key, $value); }
/** * Stores message in email sending queue. Use this method in your modules. * * @param string $email * @param string $subj * @param string $message * @param string $module * * @return bool */ public function sendEmail($email, $subj, $message, $module = '') { $result = false; $email = trim($email); $subj = trim($subj); $module = !empty($module) ? ' MODULE ' . $module : ''; if (!empty($email)) { $message = trim($message); $filename = self::QUEUE_PATH . 'eml_' . zb_rand_string(8); $storedata['email'] = $email; $storedata['subj'] = $subj; $storedata['message'] = $message; $storedata = json_encode($storedata); file_put_contents($filename, $storedata); log_register('UEML SEND EMAIL `' . $email . '`' . $module); $result = true; } return $result; }
/** * Stores message in telegram sending queue. Use this method in your modules. * * @param int $chatid * @param string $message * @param bool $translit * @param string $module * * @return bool */ public function sendMessage($chatid, $message, $translit = false, $module = '') { $result = false; $chatid = trim($chatid); $module = !empty($module) ? ' MODULE ' . $module : ''; if (!empty($chatid)) { $message = str_replace(array("\n\r", "\n", "\r"), ' ', $message); if ($translit) { $message = zb_TranslitString($message); } $message = trim($message); $filename = self::QUEUE_PATH . 'tlg_' . zb_rand_string(8); $storedata = 'CHATID="' . $chatid . '"' . "\n"; $storedata .= 'MESSAGE="' . $message . '"' . "\n"; file_put_contents($filename, $storedata); log_register('UTLG SEND MESSAGE `' . $chatid . '`' . $module); $result = true; } return $result; }
/** * Stores SMS in sending queue * * @param string $number Mobile number in international format. Eg: +380506666666 * @param string $message Text message for sending * @param bool $translit force message transliteration * @param string $module module that inits SMS sending * * @return bool */ public function sendSMS($number, $message, $translit = true, $module = '') { $result = false; $number = trim($number); $module = !empty($module) ? ' MODULE ' . $module : ''; if (!empty($number)) { if (ispos($number, '+')) { $message = str_replace(array("\n\r", "\n", "\r"), ' ', $message); if ($translit) { $message = zb_TranslitString($message); } $message = trim($message); $filename = self::QUEUE_PATH . 'us_' . zb_rand_string(8); $storedata = 'NUMBER="' . $number . '"' . "\n"; $storedata .= 'MESSAGE="' . $message . '"' . "\n"; file_put_contents($filename, $storedata); log_register('USMS SEND SMS `' . $number . '`' . $module); $result = true; } } return $result; }
/** * Stores SMS in sending queue * * @param string $number Mobile number in international format. Eg: +380506666666 * @param string $message Text message for sending * @param bool $translit force message transliteration * @return bool */ public function sendSMS($number, $message, $translit = true) { $result = false; $number = trim($number); if (!empty($number)) { if (ispos($number, '+')) { $message = str_replace('\\r\\n', ' ', $message); if ($translit) { $message = zb_TranslitString($message); } $message = trim($message); $filename = self::QUEUE_PATH . 'us_' . zb_rand_string(8); $storedata = 'NUMBER="' . $number . '"' . "\n"; $storedata .= 'MESSAGE="' . $message . '"' . "\n"; $result['number'] = $number; $result['message'] = $message; file_put_contents($filename, $storedata); log_register("USMS SEND SMS `" . $number . "`"); $result = true; } } return $result; }
function web_MigrationPrepare($import_rawdata, $import_opts) { $import_rawdata = unserialize(base64_decode($import_rawdata)); $import_opts = unserialize(base64_decode($import_opts)); $cells = wf_TableCell('#'); $cells .= wf_TableCell('[login]'); $cells .= wf_TableCell('[password]'); $cells .= wf_TableCell('[ip]'); $cells .= wf_TableCell('[mac]'); $cells .= wf_TableCell('[tariff]'); $cells .= wf_TableCell('[cash]'); $cells .= wf_TableCell('[phone]'); $cells .= wf_TableCell('[mobile]'); $cells .= wf_TableCell('[email]'); $cells .= wf_TableCell('[credit]'); $cells .= wf_TableCell('[creditex]'); $cells .= wf_TableCell('[address]'); $cells .= wf_TableCell('[realname]'); $cells .= wf_TableCell('[contract]'); $cells .= wf_TableCell('[ao]'); $cells .= wf_TableCell('[down]'); $cells .= wf_TableCell('[passive]'); $rows = wf_TableRow($cells, 'row1'); $regdata = array(); $i = 0; foreach ($import_rawdata as $eachrow) { $i++; $cells = wf_TableCell($i); if ($import_opts['login_col'] != 'RANDOM') { $login = $eachrow[$import_opts['login_col']]; } else { $login = '******' . zb_rand_string(8); } $cells .= wf_TableCell($login); if ($import_opts['password_col'] != 'RANDOM') { $password = $eachrow[$import_opts['password_col']]; } else { $password = zb_rand_string(10); } $cells .= wf_TableCell($password); $ip = $eachrow[$import_opts['ip_col']]; $cells .= wf_TableCell($ip); if ($import_opts['mac_col'] != 'RANDOM') { $mac = $eachrow[$import_opts['mac_col']]; } else { $mac = '14:' . '88' . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99); } $cells .= wf_TableCell($mac); $tariff = $eachrow[$import_opts['tariff_col']]; $cells .= wf_TableCell($tariff); $cash = $eachrow[$import_opts['cash_col']]; $cells .= wf_TableCell($cash); if ($import_opts['phone_col'] != 'NONE') { $phone = $eachrow[$import_opts['phone_col']]; } else { $phone = ''; } $cells .= wf_TableCell($phone); if ($import_opts['mobile_col'] != 'NONE') { $mobile = $eachrow[$import_opts['mobile_col']]; } else { $mobile = ''; } $cells .= wf_TableCell($mobile); if ($import_opts['email_col'] != 'NONE') { $email = $eachrow[$import_opts['email_col']]; } else { $email = ''; } $cells .= wf_TableCell($email); if ($import_opts['credit_col'] != 'ZERO') { $credit = $eachrow[$import_opts['credit_col']]; } else { $credit = 0; } $cells .= wf_TableCell($credit); if ($import_opts['creditex_col'] != 'NONE') { $creditex = $eachrow[$import_opts['creditex_col']]; } else { $creditex = '0'; } $cells .= wf_TableCell($creditex); if ($import_opts['address_col'] != 'NONE') { $address = $eachrow[$import_opts['address_col']]; } else { $address = ''; } $cells .= wf_TableCell($address); if ($import_opts['realname_col'] != 'NONE') { $realname = $eachrow[$import_opts['realname_col']]; } else { $realname = ''; } $cells .= wf_TableCell($realname); if ($import_opts['contract_col'] != 'NONE') { $contract = $eachrow[$import_opts['contract_col']]; } else { $contract = ''; } $cells .= wf_TableCell($contract); if ($import_opts['ao_col'] != 'AO_1') { $ao = $eachrow[$import_opts['ao_col']]; } else { $ao = 1; } $cells .= wf_TableCell($ao); if ($import_opts['down_col'] != 'DOWN_0') { $down = $eachrow[$import_opts['down_col']]; } else { $down = 0; } $cells .= wf_TableCell($down); if ($import_opts['passive_col'] != 'PASSIVE_0') { $passive = $eachrow[$import_opts['passive_col']]; } else { $passive = 0; } $cells .= wf_TableCell($passive); $rows .= wf_TableRow($cells, 'row3'); // filling userreg array $regdata[$login]['login'] = $login; $regdata[$login]['password'] = $password; $regdata[$login]['ip'] = $ip; $regdata[$login]['mac'] = $mac; $regdata[$login]['tariff'] = $tariff; $regdata[$login]['cash'] = $cash; $regdata[$login]['phone'] = $phone; $regdata[$login]['mobile'] = $mobile; $regdata[$login]['email'] = $email; $regdata[$login]['credit'] = $credit; $regdata[$login]['creditex'] = $creditex; $regdata[$login]['address'] = $address; $regdata[$login]['realname'] = $realname; $regdata[$login]['contract'] = $contract; $regdata[$login]['ao'] = $ao; $regdata[$login]['down'] = $down; $regdata[$login]['passive'] = $passive; } $regdata_save = serialize($regdata); $regdata_save = base64_encode($regdata_save); zb_StorageSet('IMPORT_REGDATA', $regdata_save); $preparse = wf_TableBody($rows, '100%', '0', ''); show_window(__('All correct') . '?', $preparse); $inputs = wf_Link('?module=migration', 'No I want to try another import settings', false, 'ubButton'); $inputs .= wf_Link('?module=migration&setpointers=true&goregister=ok', 'Yes proceed registeration of this users', false, 'ubButton'); show_window('', $inputs); }
/** * installs new license key * * @param $key string valid license key * * @return bool */ public function createKey($key) { $key = mysql_real_escape_string($key); if ($this->checkLicenseValidity($key)) { $keyname = 'AVLICENSE_' . zb_rand_string('8'); $query = "INSERT INTO `ubstorage` (`id`, `key`, `value`) VALUES (NULL, '" . $keyname . "', '" . $key . "');"; nr_query($query); log_register("AVARICE INSTALL KEY `" . $keyname . '`'); return true; } else { log_register("AVARICE TRY INSTALL WRONG KEY"); return false; } }
/** * extracts data from agentPring cache for future export in CSV * * @param int $agentid Existing agent ID in database * * @return void */ public function exportCSV($agentid) { $tmpArr = array(); $result = ''; if (!empty($this->altcfg)) { $altercfg = $this->altcfg; } else { global $ubillingConfig; $this->altcfg = $ubillingConfig->getAlter(); $altercfg = $this->altcfg; } if (file_exists(self::EXPORT_PATH . 'report_agentfinance.prindataraw')) { $rawData = file_get_contents(self::EXPORT_PATH . 'report_agentfinance.prindataraw'); $tmpArr = unserialize($rawData); $allservicenames = zb_VservicesGetAllNamesLabeled(); $this->loadUserRealnames(); $this->loadCashTypes(); if (!empty($tmpArr)) { if (isset($tmpArr[$agentid])) { if (!empty($tmpArr[$agentid])) { //CSV header $result .= __('ID') . ';' . __('Date') . ';' . __('Cash') . ';' . __('Login') . ';' . __('Full address') . ';' . __('Real Name') . ';' . __('Contrahent name') . ';' . __('Payment type') . ';' . __('Notes') . ';' . __('Admin') . "\n"; //CSV data foreach ($tmpArr[$agentid] as $io => $each) { $summ = str_replace('.', ',', $each['summ']); //need for normal summ in excel $result .= $each['id'] . ';' . $each['date'] . ';' . $summ . ';' . $each['login'] . ';' . @$this->alladdress[$each['login']] . ';' . @$this->userRealnames[$each['login']] . ';' . @$this->agentsNamed[$this->assigns[$each['login']]] . ';' . __(@$this->cashtypes[$each['cashtypeid']]) . ';' . zb_TranslatePaymentNote($each['note'], $allservicenames) . ';' . $each['admin'] . "\n"; } } } } } $saveCsvName = self::EXPORT_PATH . 'report_agentfinance_' . $agentid . '_' . zb_rand_string(8) . '.csv'; $result = iconv('utf-8', 'windows-1251', $result); file_put_contents($saveCsvName, $result); zb_DownloadFile($saveCsvName, 'csv'); die; }
/** * Stores SMS for some employee for further sending with watchdog run * * @param int $employeeid * @param string $message * @return array * @throws Exception */ function ts_SendSMS($employeeid, $message) { $query = "SELECT `mobile`,`name` from `employee` WHERE `id`='" . $employeeid . "'"; $empData = simple_query($query); $mobile = $empData['mobile']; $employeeName = $empData['name']; $result = array(); if (!empty($mobile)) { if (ispos($mobile, '+')) { $message = str_replace('\\r\\n', ' ', $message); $message = zb_TranslitString($message); $message = trim($message); $number = trim($mobile); $filename = 'content/tsms/ts_' . zb_rand_string(8); $storedata = 'NUMBER="' . $number . '"' . "\n"; $storedata .= 'MESSAGE="' . $message . '"' . "\n"; $result['number'] = $number; $result['message'] = $message; file_put_contents($filename, $storedata); log_register("TASKMAN SEND SMS `" . $number . "` FOR `" . $employeeName . "`"); } else { throw new Exception('BAD_MOBILE_FORMAT'); } } return $result; }
function zb_NewMacShow() { global $ubillingConfig; $billing_config = $ubillingConfig->getBilling(); $alter_config = $ubillingConfig->getAlter(); $allarp = array(); $sudo = $billing_config['SUDO']; $cat = $billing_config['CAT']; $grep = $billing_config['GREP']; $tail = $billing_config['TAIL']; $alter_conf = parse_ini_file(CONFIG_PATH . 'alter.ini'); $leases = $alter_conf['NMLEASES']; $leasemark = $alter_conf['NMLEASEMARK']; $command = $sudo . ' ' . $cat . ' ' . $leases . ' | ' . $grep . ' "' . $leasemark . '" | ' . $tail . ' -n 200'; $rawdata = shell_exec($command); $allusedMacs = zb_getAllUsedMac(); $result = ''; //fdb cache preprocessing $fdbData_raw = rcms_scandir('./exports/', '*_fdb'); if (!empty($fdbData_raw)) { $fdbArr = sn_SnmpParseFdbCacheArray($fdbData_raw); $fdbColumn = true; } else { $fdbArr = array(); $fdbColumn = false; } $cells = wf_TableCell(__('MAC')); if (!empty($fdbColumn)) { $cells .= wf_TableCell(__('Switch')); } if ($alter_config['MACVEN_ENABLED']) { $cells .= wf_TableCell(__('Manufacturer')); } $rows = wf_TableRow($cells, 'row1'); if (!empty($rawdata)) { $cleardata = exploderows($rawdata); foreach ($cleardata as $eachline) { preg_match('/[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}/i', $eachline, $matches); if (!empty($matches)) { $allarp[] = $matches[0]; } } $un_arr = array_unique($allarp); if (!empty($un_arr)) { if ($alter_config['MACVEN_ENABLED']) { //adding ajax loader $result .= wf_AjaxLoader(); } foreach ($un_arr as $io => $eachmac) { if (zb_checkMacFree($eachmac, $allusedMacs)) { $cells = wf_TableCell(@$eachmac); if (!empty($fdbColumn)) { $cells .= wf_TableCell(sn_SnmpParseFdbExtract(@$fdbArr[$eachmac])); } if ($alter_config['MACVEN_ENABLED']) { $containerName = 'NMRSMCNT_' . zb_rand_string(8); $lookupVendorLink = wf_AjaxLink('?module=macvendor&mac=' . @$eachmac . '&raw=true', wf_img('skins/macven.gif', __('Device vendor')), $containerName, false, ''); $lookupVendorLink .= wf_tag('span', false, '', 'id="' . $containerName . '"') . '' . wf_tag('span', true); $cells .= wf_TableCell($lookupVendorLink, '350'); } $rows .= wf_TableRow($cells, 'row3'); } } } } $result .= wf_TableBody($rows, '100%', '0', 'sortable'); return $result; }
/** * Returns new user password proposal * * @return string */ function zb_RegPasswordProposal() { $alterconf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini"); if (isset($alterconf['PASSWORD_GENERATION_LENGHT']) and isset($alterconf['PASSWORD_TYPE'])) { if ($alterconf['PASSWORD_TYPE']) { $password = zb_rand_string($alterconf['PASSWORD_GENERATION_LENGHT']); } else { $password = zb_rand_digits($alterconf['PASSWORD_GENERATION_LENGHT']); } } else { die(strtoupper('you have missed a essential option. before update read release notes m**********r!')); } return $password; }
/** * Collects billing stats * * @param bool $quiet */ function zb_BillingStats($quiet = false) { $ubstatsurl = 'http://stats.ubilling.net.ua/'; $statsflag = 'exports/NOTRACK'; //detect host id $hostid_q = "SELECT * from `ubstats` WHERE `key`='ubid'"; $hostid = simple_query($hostid_q); if (empty($hostid)) { //register new ubilling $randomid = 'UB' . md5(curdatetime() . zb_rand_string(8)); $newhostid_q = "INSERT INTO `ubstats` (`id` ,`key` ,`value`) VALUES (NULL , 'ubid', '" . $randomid . "');"; nr_query($newhostid_q); $thisubid = $randomid; } else { $thisubid = $hostid['value']; } //detect stats collection feature $thiscollect = file_exists($statsflag) ? 0 : 1; //disabling collect subroutine if (isset($_POST['editcollect'])) { if (!isset($_POST['collectflag'])) { file_put_contents($statsflag, 'Im greedy bastard'); } else { if (file_exists($statsflag)) { unlink($statsflag); } } rcms_redirect("?module=report_sysload"); } //detect total user count $usercount_q = "SELECT COUNT(`login`) from `users`"; $usercount = simple_query($usercount_q); $usercount = $usercount['COUNT(`login`)']; //detect tariffs count $tariffcount_q = "SELECT COUNT(`name`) from `tariffs`"; $tariffcount = simple_query($tariffcount_q); $tariffcount = $tariffcount['COUNT(`name`)']; //detect nas count $nascount_q = "SELECT COUNT(`id`) from `nas`"; $nascount = simple_query($nascount_q); $nascount = $nascount['COUNT(`id`)']; //detect payments count $paycount_q = "SELECT COUNT(`id`) from `payments`"; $paycount = simple_query($paycount_q); $paycount = $paycount['COUNT(`id`)']; $paycount = $paycount / 100; $paycount = round($paycount); //detect ubilling actions count $eventcount_q = "SELECT COUNT(`id`) from `weblogs`"; $eventcount = simple_query($eventcount_q); $eventcount = $eventcount['COUNT(`id`)']; $eventcount = $eventcount / 100; $eventcount = round($eventcount); //detect ubilling version $releaseinfo = file_get_contents("RELEASE"); $ubversion = explode(' ', $releaseinfo); $ubversion = vf($ubversion[0], 3); $releasebox = wf_tag('span', false, '', 'id="lastrelease"'); $releasebox .= wf_tag('span', true) . wf_tag('br'); $updatechecker = wf_AjaxLink('?module=report_sysload&checkupdates=true', $releaseinfo . ' (' . __('Check updates') . '?)', 'lastrelease', false, ''); $ubstatsinputs = zb_AjaxLoader(); $ubstatsinputs .= wf_tag('b') . __('Serial key') . ': ' . wf_tag('b', true) . $thisubid . wf_tag('br'); $ubstatsinputs .= wf_tag('b') . __('Use this to request technical support') . ': ' . wf_tag('b', true) . wf_tag('font', false, '', 'color="#076800"') . substr($thisubid, -4) . wf_tag('font', true) . wf_tag('br'); $ubstatsinputs .= wf_tag('b') . __('Ubilling version') . ': ' . wf_tag('b', true) . $updatechecker . wf_tag('br'); $ubstatsinputs .= $releasebox; $ubstatsinputs .= wf_HiddenInput('editcollect', 'true'); $ubstatsinputs .= wf_CheckInput('collectflag', 'I want to help make Ubilling better', false, $thiscollect); $ubstatsinputs .= ' ' . wf_Submit('Save'); $ubstatsform = wf_Form("", 'POST', $ubstatsinputs, 'glamour'); $ubstatsform .= wf_CleanDiv(); $statsurl = $ubstatsurl . '?u=' . $thisubid . 'x' . $usercount . 'x' . $tariffcount . 'x' . $nascount . 'x' . $paycount . 'x' . $eventcount . 'x' . $ubversion; $tracking_code = wf_tag('div', false, '', 'style="display:none;"') . wf_tag('iframe', false, '', 'src="' . $statsurl . '" width="1" height="1" frameborder="0"') . wf_tag('iframe', true) . wf_tag('div', true); if ($quiet == false) { show_window(__('Billing info'), $ubstatsform); } if ($thiscollect) { show_window('', $tracking_code); } }
/** * Catches file upload in background * * @return void */ public function catchFileUpload() { if (wf_CheckGet(array('uploadfilephoto'))) { if (!empty($this->scope)) { $allowedExtensions = array("jpg", "gif", "png", "jpeg"); $fileAccepted = true; foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { $fileAccepted = false; } } } if ($fileAccepted) { $newFilename = zb_rand_string(16) . '_upload.jpg'; $newSavePath = self::STORAGE_PATH . $newFilename; move_uploaded_file($_FILES['photostorageFileUpload']['tmp_name'], $newSavePath); if (file_exists($newSavePath)) { $uploadResult = wf_tag('span', false, 'alert_success') . __('Photo upload complete') . wf_tag('span', true); $this->registerImage($newFilename); rcms_redirect(self::MODULE_URL . '&scope=' . $this->scope . '&itemid=' . $this->itemId . '&mode=loader&preview=' . $newFilename); } else { $uploadResult = wf_tag('span', false, 'alert_error') . __('Photo upload failed') . wf_tag('span', true); } } else { $uploadResult = wf_tag('span', false, 'alert_error') . __('Photo upload failed') . ': ' . self::EX_WRONG_EXT . wf_tag('span', true); } } else { $uploadResult = wf_tag('span', false, 'alert_error') . __('Strange exeption') . ': ' . self::EX_NOSCOPE . wf_tag('span', true); } show_window('', $uploadResult); show_window('', wf_Link(self::MODULE_URL . '&scope=' . $this->scope . '&itemid=' . $this->itemId . '&mode=loader', __('Back'), false, 'ubButton')); } }
/** * Creates new typical answer preset in database * * @param string $taptext * * @return void */ function zb_TicketsTAPCreate($taptext) { $keyName = 'HELPDESKTAP_' . zb_rand_string(8); $storeData = base64_encode($taptext); zb_StorageSet($keyName, $storeData); log_register('TICKET TAP CREATE `' . $keyName . '`'); }
/** * Sends all sms storage via sms-fly.com service * */ protected function smsflyPushMessages() { $result = ''; $apiUrl = $this->settings['SMSFLY_GATEWAY']; $source = $this->safeEscapeString($this->settings['SMSFLY_SIGN']); $description = "Ubilling_" . zb_rand_string(8); $start_time = 'AUTO'; $end_time = 'AUTO'; $rate = 1; $lifetime = 4; $user = $this->settings['SMSFLY_LOGIN']; $password = $this->settings['SMSFLY_PASSWORD']; $allSmsQueue = $this->smsQueue->getQueueData(); if (!empty($allSmsQueue)) { foreach ($allSmsQueue as $io => $eachsms) { $number = str_replace('+', '', $eachsms['number']); //numbers in international format without + $myXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $myXML .= "<request>"; $myXML .= "<operation>SENDSMS</operation>"; $myXML .= ' <message start_time="' . $start_time . '" end_time="' . $end_time . '" lifetime="' . $lifetime . '" rate="' . $rate . '" desc="' . $description . '" source="' . $source . '">' . "\n"; $myXML .= "\t\t<body>" . $eachsms['message'] . "</body>"; $myXML .= "\t\t<recipient>" . $number . "</recipient>"; $myXML .= "</message>"; $myXML .= "</request>"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERPWD, $user . ':' . $password); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $apiUrl); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Accept: text/xml")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $myXML); $result .= curl_exec($ch); curl_close($ch); //remove old sent message $this->smsQueue->deleteSms($eachsms['filename']); } } }
/** * Catches file upload * * @return string */ public function catchFileUpload() { $result = ''; $allowedExtensions = array("kml", "txt"); $fileAccepted = true; foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (@(!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions))) { $fileAccepted = false; } } } if ($fileAccepted) { $newFilename = zb_rand_string(10) . '_custmap.kml'; $newSavePath = self::UPLOAD_PATH . $newFilename; move_uploaded_file($_FILES['itemsUploadFile']['tmp_name'], $newSavePath); if (file_exists($newSavePath)) { $uploadResult = wf_tag('span', false, 'alert_success') . __('Upload complete') . wf_tag('span', true); $result = $newFilename; } else { $uploadResult = wf_tag('span', false, 'alert_error') . __('Upload failed') . wf_tag('span', true); } } else { $uploadResult = wf_tag('span', false, 'alert_error') . __('Upload failed') . ': ' . self::EX_WRONG_EXT . wf_tag('span', true); } show_window('', $uploadResult); if ($result) { $this->itemsImportKml($newFilename, $_GET['showitems'], $_POST['itemsUploadTypes']); } return $result; }
zb_UserCreateContract($randomLogin, ''); zb_UserCreateEmail($randomLogin, ''); zb_UserCreateSpeedOverride($randomLogin, 0); multinet_change_mac($randomIp, $randomMac); multinet_rebuild_all_handlers(); $billing->settariff($randomLogin, $tariff); $billing->setao($randomLogin, '1'); $billing->setdstat($randomLogin, '1'); zb_UserRegisterLog($randomLogin); log_register("SAMPLE GENERATION OF (" . $randomLogin . ") DONE"); } } else { //fast SQL users generation directly in database for ($i = 1; $i <= $neednum; $i++) { $randomLogin = '******' . zb_rand_string(10); $randomPassword = zb_rand_string(8); $randomName = $names[array_rand($names)] . ' ' . $surnames[array_rand($surnames)]; $randomPhone = rand(111111, 999999); $randomMobile = '380' . rand(1111111, 9999999); $randomMac = '14:' . '88' . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99); $randomApt = $i; $randomCash = rand(0, 500); $randomIp = multinet_get_next_freeip('nethosts', 'ip', $netID); $randomFloor = rand(1, 9); $randomEntrance = rand(1, 4); //registering subroutine $querybuff = "\n INSERT INTO `users` (\n `login`,\n `Password`,\n `Passive`,\n `Down`,\n `DisabledDetailStat`,\n `AlwaysOnline`,\n `Tariff`,\n `Address`,\n `Phone`,\n `Email`,\n `Note`,\n `RealName`,\n `StgGroup`,\n `Credit`,\n `TariffChange`,\n `Userdata0`,\n `Userdata1`,\n `Userdata2`,\n `Userdata3`,\n `Userdata4`,\n `Userdata5`,\n `Userdata6`,\n `Userdata7`,\n `Userdata8`,\n `Userdata9`,\n `CreditExpire`,\n `IP`,\n `D0`,\n `U0`,\n `D1`,\n `U1`,\n `D2`,\n `U2`,\n `D3`,\n `U3`,\n `D4`,\n `U4`,\n `D5`,\n `U5`, \n `D6`, \n `U6`,\n `D7`, \n `U7`, \n `D8`,\n `U8`,\n `D9`,\n `U9`,\n `Cash`,\n `FreeMb`,\n `LastCashAdd`,\n `LastCashAddTime`,\n `PassiveTime`,\n `LastActivityTime`,\n `NAS`)\n VALUES (\n '" . $randomLogin . "',\n '" . $randomPassword . "',\n '0',\n '0',\n '1',\n '1',\n '" . $tariff . "',\n '',\n '',\n '',\n '',\n '',\n '',\n '0',\n '', \n '',\n '',\n '',\n '', \n '', \n '', \n '', \n '',\n '', \n '', \n '0',\n '" . $randomIp . "',\n '0',\n '0',\n '0',\n '0',\n '0', \n '0',\n '0',\n '0', \n '0',\n '0',\n '0',\n '0',\n '0', \n '0',\n '0',\n '0', \n '0', \n '0', \n '0', \n '0', \n '" . $randomCash . "',\n '0',\n '0', \n '0',\n '0', \n '0',\n '');\n "; //push da query! nr_query($querybuff); zb_AddressCreateApartment($lastBuildId, $randomEntrance, $randomFloor, $randomApt); zb_AddressCreateAddress($randomLogin, zb_AddressGetLastid());
function web_PaymentSearch($markers) { if (wf_CheckPost(array('searchtable'))) { if ($_POST['searchtable'] == 'payments') { $table = 'payments'; } if ($_POST['searchtable'] == 'corrections') { $table = 'paymentscorr'; } } else { $table = 'payments'; } $query = "SELECT * from `" . $table . "`"; $query .= $markers; $altercfg = rcms_parse_ini_file(CONFIG_PATH . "alter.ini"); $csvdata = ''; $allpayments = simple_queryall($query); if ($altercfg['FINREP_CONTRACT']) { $allcontracts = zb_UserGetAllContracts(); $allcontracts = array_flip($allcontracts); } if ($altercfg['FINREP_TARIFF']) { $alltariffs = zb_TariffsGetAllUsers(); } $allrealnames = zb_UserGetAllRealnames(); $alladdress = zb_AddressGetFulladdresslist(); $alltypes = zb_CashGetAllCashTypes(); $allservicenames = zb_VservicesGetAllNamesLabeled(); $allpaysyspercents = zb_PaySysPercentGetAll(); $totalsumm = 0; $paysyssumm = 0; $profitsumm = 0; $totalcount = 0; $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('Cash')); $cells .= wf_TableCell(__('PS%')); $cells .= wf_TableCell(__('Profit')); $cells .= wf_TableCell(__('Login')); if ($altercfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(__('Contract')); } $cells .= wf_TableCell(__('Full address')); $cells .= wf_TableCell(__('Real Name')); if ($altercfg['FINREP_TARIFF']) { $cells .= wf_TableCell(__('Tariff')); } $cells .= wf_TableCell(__('Payment type')); $cells .= wf_TableCell(__('Notes')); $cells .= wf_TableCell(__('Admin')); $rows = wf_TableRow($cells, 'row1'); if (!empty($allpayments)) { if ($altercfg['FINREP_TARIFF']) { $csvTariffColumn = ';' . __('Tariff'); } else { $csvTariffColumn = ''; } $csvdata .= __('ID') . ';' . __('Date') . ';' . __('Cash') . ';' . __('PS%') . ';' . __('Profit') . ';' . __('Login') . ';' . __('Full address') . ';' . __('Real Name') . $csvTariffColumn . ';' . __('Payment type') . ';' . __('Notes') . ';' . __('Admin') . "\n"; foreach ($allpayments as $io => $each) { $cells = wf_TableCell($each['id']); $cells .= wf_TableCell($each['date']); $cells .= wf_TableCell($each['summ']); //detecting paymentsystem and calc percent if (isset($allpaysyspercents[$each['note']])) { $currPc = $allpaysyspercents[$each['note']]['percent']; $rawSumm = $each['summ']; $paySysPc = $rawSumm / 100 * $currPc; $ourProfit = $rawSumm - $paySysPc; } else { $paySysPc = 0; $ourProfit = $each['summ']; } $cells .= wf_TableCell($paySysPc); $cells .= wf_TableCell($ourProfit); $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], web_profile_icon() . ' ' . $each['login'], false, '')); if ($altercfg['FINREP_CONTRACT']) { $cells .= wf_TableCell(@$allcontracts[$each['login']]); } @($paymentRealname = $allrealnames[$each['login']]); @($paymentCashType = __($alltypes[$each['cashtypeid']])); @($paymentAddress = $alladdress[$each['login']]); $cells .= wf_TableCell($paymentAddress); $cells .= wf_TableCell($paymentRealname); if ($altercfg['FINREP_TARIFF']) { @($userTariff = $alltariffs[$each['login']]); $cells .= wf_TableCell($userTariff); $csvTariff = ';' . $userTariff; } else { $csvTariff = ''; } $cells .= wf_TableCell($paymentCashType); //payment notes translation if ($altercfg['TRANSLATE_PAYMENTS_NOTES']) { $paynote = zb_TranslatePaymentNote($each['note'], $allservicenames); } else { $paynote = $each['note']; } $cells .= wf_TableCell($paynote); $cells .= wf_TableCell($each['admin']); $rows .= wf_TableRow($cells, 'row3'); //calculating totals if ($each['summ'] > 0) { $totalsumm = $totalsumm + $each['summ']; $totalcount++; } if ($paySysPc > 0) { $paysyssumm = $paysyssumm + $paySysPc; } if ($ourProfit > 0) { $profitsumm = $profitsumm + $ourProfit; } $csvSumm = str_replace('.', ',', $each['summ']); $csvdata .= $each['id'] . ';' . $each['date'] . ';' . $csvSumm . ';' . $paySysPc . ';' . $ourProfit . ';' . $each['login'] . ';' . $paymentAddress . ';' . $paymentRealname . $csvTariff . ';' . $paymentCashType . ';' . $paynote . ';' . $each['admin'] . "\n"; } } //saving report for future download if (!empty($csvdata)) { $csvSaveName = 'exports/payfind_' . zb_rand_string(8) . '.csv'; $csvSaveNameEnc = base64_encode($csvSaveName); $csvdata = iconv('utf-8', 'windows-1251', $csvdata); file_put_contents($csvSaveName, $csvdata); $csvDownloadLink = wf_Link('?module=payfind&downloadcsv=' . $csvSaveNameEnc, wf_img('skins/excel.gif', __('Export')), false); } else { $csvDownloadLink = ''; } $result = wf_TableBody($rows, '100%', '0', 'sortable'); //additional total counters $result .= wf_tag('div', false, 'glamour') . __('Count') . ': ' . $totalcount . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Total payments') . ': ' . $totalsumm . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Payment systems %') . ': ' . $paysyssumm . wf_tag('div', true); $result .= wf_tag('div', false, 'glamour') . __('Our final profit') . ': ' . $profitsumm . wf_tag('div', true); $result .= wf_CleanDiv(); show_window(__('Payments found') . ' ' . $csvDownloadLink, $result); }
public function sendSMS($number, $message) { $number = trim($number); $filename = 'content/tsms/wd_' . zb_rand_string(8); $storedata = 'NUMBER="' . $this->safeEscapeString($number) . '"' . "\n"; $storedata .= 'MESSAGE="' . $this->safeEscapeString($message) . '"' . "\n"; file_put_contents($filename, $storedata); log_register("WATCHDOG SEND SMS `" . $number . "`"); }
/** * Do the search in dead switches time machine * * @param string $query * @return string */ function ub_SwitchesTimeMachineSearch($request) { $request = strtolower_utf8($request); $result = ''; $query = "SELECT * from `switchdeadlog` ORDER BY `id` DESC"; $raw = simple_queryall($query); $deadcount = 0; $tmpArr = array(); if (!empty($raw)) { foreach ($raw as $io => $each) { if (!empty($each)) { $switchData = unserialize($each['swdead']); foreach ($switchData as $switchIp => $switchLocation) { if (ispos(strtolower_utf8($switchIp), $request) or ispos(strtolower_utf8($switchLocation), $request)) { $searchId = zb_rand_string(8); $tmpArr[$searchId]['date'] = $each['date']; $tmpArr[$searchId]['ip'] = $switchIp; $tmpArr[$searchId]['location'] = $switchLocation; } } } } } if (!empty($tmpArr)) { $cells = wf_TableCell(__('Date')); $cells .= wf_TableCell(__('IP')); $cells .= wf_TableCell(__('Location')); $rows = wf_TableRow($cells, 'row1'); foreach ($tmpArr as $ia => $eachResult) { $cells = wf_TableCell($eachResult['date']); $cells .= wf_TableCell($eachResult['ip']); $cells .= wf_TableCell($eachResult['location']); $rows .= wf_TableRow($cells, 'row3'); $deadcount++; } $result = wf_TableBody($rows, '100%', 0, 'sortable'); $result .= __('Total') . ': ' . $deadcount; } else { $result = __('Nothing found'); } return $result; }
$documents = new ProfileDocuments(); if (wf_CheckGet(array('username'))) { $documents->setLogin($_GET['username']); } //template printing subroutine if (wf_CheckGet(array('print'))) { //back link show_window('', wf_Link('?module=pl_documents&username='******'Back', true, 'ubButton')); $docId = vf($_GET['print'], 3); $availableTemplates = $documents->getTemplates(); $templatePath = $documents::TEMPLATES_PATH; $documentsSavePath = $documents::DOCUMENTS_PATH; $templateFile = $availableTemplates[$docId]['path']; $templateName = $availableTemplates[$docId]['name']; $fullPath = $templatePath . $templateFile; $saveFileName = $documents->getLogin() . '_' . $docId . '_' . zb_rand_string(8) . '.docx'; $saveFullPath = $documentsSavePath . $saveFileName; $documents->loadAllUserData(); $templateData = $documents->getUserData(); $userAgentData = $documents->getUserAgentData(); $templateData = array_merge($templateData, $userAgentData); if (wf_checkget(array('custom'))) { show_window(__('Custom template fields'), $documents->customDocumentFieldsForm()); if (wf_CheckPost(array('customfields'))) { $documents->setCustomFields(); $templateData = array_merge($templateData, $documents->getCustomFields()); //parse document template $docx = new DOCXTemplate($fullPath); $docx->set($templateData); $docx->saveAs($saveFullPath); //registering generated custom fields document
/** * do the docx template upload subroutine * * @return boolean */ public function doUpload() { $uploaddir = self::TEMPLATES_PATH; $allowedExtensions = array("docx"); $result = false; $extCheck = true; //check file type foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (@(!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions))) { $extCheck = false; } } } if ($extCheck) { if (wf_CheckPost(array('templatedisplayname'))) { $displayName = $_POST['templatedisplayname']; $templatePublic = isset($_POST['publictemplate']) ? 1 : 0; $filename = zb_rand_string(8) . '.docx'; $uploadfile = $uploaddir . $filename; if (move_uploaded_file($_FILES['uldocxtempplate']['tmp_name'], $uploadfile)) { $result = true; //save template into database $this->registerTemplateDB($filename, $displayName, $templatePublic); } else { show_error(__('Error'), __('Cant upload file to') . ' ' . self::TEMPLATES_PATH); } } else { show_error(__('No display name for template')); } } else { show_error(__('Wrong file type')); } return $result; }
/** * Prepares data array to json encoding * * @param array $data data array to transform * @param string $category data category * @param string $type globalsearch type * @return array */ protected function transformArray($data, $category, $type) { $result = array(); if (!empty($data)) { foreach ($data as $io => $each) { if (!empty($each)) { $result[zb_rand_string(8)] = array('label' => $each, 'lower' => strtolower_utf8($each), 'category' => $category, 'type' => $type); } } } return $result; }
/** * process of uploading of bank statement * * @return void */ public function bankstaDoUpload() { $uploaddir = self::BANKSTA_PATH; $allowedExtensions = array("dbf"); $result = array(); $extCheck = true; //check file type foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (@(!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions))) { $extCheck = false; } } } if ($extCheck) { $filename = zb_rand_string(8) . '.dbf'; $uploadfile = $uploaddir . $filename; if (move_uploaded_file($_FILES['ukvbanksta']['tmp_name'], $uploadfile)) { $fileContent = file_get_contents(self::BANKSTA_PATH . $filename); $fileHash = md5($fileContent); $fileContent = ''; //free some memory if ($this->bankstaCheckHash($fileHash)) { $result = array('filename' => $_FILES['ukvbanksta']['name'], 'savedname' => $filename, 'hash' => $fileHash); } else { log_register('UKV BANKSTA DUPLICATE TRY ' . $fileHash); show_error(__('Same bank statement already exists')); } } else { show_error(__('Cant upload file to') . ' ' . self::BANKSTA_PATH); } } else { show_error(__('Wrong file type')); log_register('UKV BANKSTA WRONG FILETYPE'); } return $result; }
/** * Returns available taskbar notifications as floating widget * * @return string */ public function renderTaskbarNotify() { $result = ''; $output = ''; $delimiterId = '{' . zb_rand_string(8) . '}'; $delimiterCode = ''; $offsetLeft = 0; if (!empty($this->activenotes)) { foreach ($this->activenotes as $io => $each) { if (empty($each['reminddate']) or strtotime($each['reminddate']) < time()) { $tmpText = $each['text']; $tmpText = strip_tags($tmpText); $output = $tmpText; $output .= $delimiterId; $output = str_replace($delimiterId, $delimiterCode, $output); $output = $this->cutString($output, 190); $output = nl2br($output); $result .= $this->renderStickyNote($output, $offsetLeft); $offsetLeft = $offsetLeft + 10; } } if (!empty($output)) { } } return $result; }