if ($cantidad = $user->getCantidad()) { sendRensponse(array("error" => false, "mensaje" => "", "data" => $cantidad)); } else { sendRensponse(array("error" => true, "mensaje" => "¡Error al obtener cantidad de Usuarios!")); } } $request = new Request(); $action = $request->action; switch ($action) { case "nuevoUser": nuevoUser($request); break; case "validar": validateUser($request); break; case "validarMail": validateMail($request); break; case "validarUserName": validateUserName($request); break; case "obtener": getUser($request); break; case "obtenerCantidad": getCantidad($request); break; default: sendRensponse(array("error" => "true", "mensaje" => "request mal formado")); break; }
//define('IC_APIUSERNAME', ''); //Your username //define('IC_APIPASSWORD', ''); //Your password /* txt file setting */ define('FL_MAIL', 'emails.txt'); /* File error log */ define('ERROR_LOG', 'error-log.txt'); /* Install headers */ header('Expires: 0'); header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0'); header('Pragma: no-cache'); header('Content-Type: application/json; charset=utf-8'); /* AJAX check */ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { extract($_POST); try { if (isset($subscribe) && validateMail($subscribe)) { saveFile($subscribe); sendMailChimp($subscribe); sendGetResponse($subscribe); sendAWeber($subscribe); sendCompaingMonitor($subscribe); sendiContact($subscribe); } else { throw new Exception("Email not valid", 1); } } catch (Exception $e) { $code = $e->getCode(); } echo $code ? $code : 0; } else { echo 'Only Ajax request';
break; case 'getstatus': // If no data passed to validate just die if (!isset($_REQUEST['data'])) { die('Instance: Error -> No data'); } $data = $_REQUEST['data']; getStatus($data); break; case 'email': // If no data passed to validate just die if (!isset($_REQUEST['data'])) { die('Email: Error -> No data'); } $data = $_REQUEST['data']; validateMail($data); break; case 'isready': // If no data passed to validate just die if (!isset($_REQUEST['data'])) { die('Instance: Error -> No data'); } $data = $_REQUEST['data']; //header('Content-type: application/json'); header('Cache-Control: no-cache'); header('Expires: Thu, 1, Apr 2010 00:00:00 GMT'); echo isInstanceReady($data); break; case 'debug': debug(); break;
/** * Install controller. * * @return void */ function install(Core $core) { define('_ZINSTALLVER', Core::VERSION_NUM); $serviceManager = $core->getContainer(); $eventManager = $core->getDispatcher(); // Lazy load DB connection to avoid testing DSNs that are not yet valid (e.g. no DB created yet) $dbEvent = new GenericEvent(null, array('lazy' => true)); $eventManager->dispatch('doctrine.init_connection', $dbEvent); $core->init(Core::STAGE_ALL & ~Core::STAGE_THEME & ~Core::STAGE_MODS & ~Core::STAGE_LANGS & ~Core::STAGE_DECODEURLS & ~Core::STAGE_SESSIONS); // Power users might have moved the temp folder out of the root and changed the config.php // accordingly. Make sure we respect this security related settings $tempDir = isset($GLOBALS['ZConfig']['System']['temp']) ? $GLOBALS['ZConfig']['System']['temp'] : 'ztemp'; // define our smarty object $smarty = new Smarty(); $smarty->caching = false; $smarty->compile_check = true; $smarty->left_delimiter = '{'; $smarty->right_delimiter = '}'; $smarty->compile_dir = $tempDir . '/view_compiled'; $smarty->template_dir = 'install/templates'; $smarty->plugins_dir = array('plugins', 'install/templates/plugins'); $smarty->clear_compiled_tpl(); file_put_contents("{$tempDir}/view_compiled/index.html", ''); $lang = FormUtil::getPassedValue('lang', '', 'GETPOST'); $dbhost = FormUtil::getPassedValue('dbhost', '', 'GETPOST'); $dbusername = FormUtil::getPassedValue('dbusername', '', 'GETPOST'); $dbpassword = FormUtil::getPassedValue('dbpassword', '', 'GETPOST'); $dbname = FormUtil::getPassedValue('dbname', '', 'GETPOST'); $dbprefix = ''; $dbdriver = FormUtil::getPassedValue('dbdriver', '', 'GETPOST'); $dbtabletype = FormUtil::getPassedValue('dbtabletype', '', 'GETPOST'); $username = FormUtil::getPassedValue('username', '', 'POST'); $password = FormUtil::getPassedValue('password', '', 'POST'); $repeatpassword = FormUtil::getPassedValue('repeatpassword', '', 'POST'); $email = FormUtil::getPassedValue('email', '', 'GETPOST'); $action = FormUtil::getPassedValue('action', '', 'GETPOST'); $notinstalled = isset($_GET['notinstalled']); $installedState = isset($GLOBALS['ZConfig']['System']['installed']) ? $GLOBALS['ZConfig']['System']['installed'] : 0; // If somehow we are browsing the not installed page but installed, redirect back to homepage if ($installedState && $notinstalled) { $response = new RedirectResponse(System::getHomepageUrl()); return $response->send(); } // see if the language was already selected $languageAlreadySelected = $lang ? true : false; if (!$notinstalled && $languageAlreadySelected && empty($action)) { $response = new RedirectResponse(System::getBaseUri() . "/install.php?action=requirements&lang={$lang}"); return $response->send(); } // see if the language was already selected $languageAlreadySelected = $lang ? true : false; if (!$notinstalled && $languageAlreadySelected && empty($action)) { $response = new RedirectResponse(System::getBaseUri() . "/install.php?action=requirements&lang={$lang}"); return $response->send(); } // load the installer language files if (empty($lang)) { if (is_readable('config/installer.ini')) { $test = parse_ini_file('config/installer.ini'); $lang = isset($test['language']) ? $test['language'] : 'en'; } else { $available = ZLanguage::getInstalledLanguages(); $detector = new ZLanguageBrowser($available); $lang = $detector->discover(); } $lang = DataUtil::formatForDisplay($lang); } // setup multilingual $GLOBALS['ZConfig']['System']['language_i18n'] = $lang; $GLOBALS['ZConfig']['System']['multilingual'] = true; $GLOBALS['ZConfig']['System']['languageurl'] = true; $GLOBALS['ZConfig']['System']['language_detect'] = false; $serviceManager->loadArguments($GLOBALS['ZConfig']['System']); $_lang = ZLanguage::getInstance(); $_lang->setup(); $lang = ZLanguage::getLanguageCode(); $installbySQL = file_exists("install/sql/custom-{$lang}.sql") ? "install/sql/custom-{$lang}.sql" : false; $smarty->assign('lang', $lang); $smarty->assign('installbySQL', $installbySQL); $smarty->assign('langdirection', ZLanguage::getDirection()); $smarty->assign('charset', ZLanguage::getEncoding()); // show not installed case if ($notinstalled) { header('HTTP/1.1 503 Service Unavailable'); $smarty->display('notinstalled.tpl'); $smarty->clear_compiled_tpl(); file_put_contents("{$tempDir}/view_compiled/index.html", ''); exit; } // assign the values from config.php $smarty->assign($GLOBALS['ZConfig']['System']); // if the system is already installed, halt. if ($GLOBALS['ZConfig']['System']['installed']) { _installer_alreadyinstalled($smarty); } // check for an empty action - if so then show the first installer page if (empty($action)) { $action = 'lang'; } // perform tasks based on our action switch ($action) { case 'processBDInfo': $dbname = trim($dbname); $dbusername = trim($dbusername); if (empty($dbname) || empty($dbusername)) { $action = 'dbinformation'; $smarty->assign('dbconnectmissing', true); } elseif (!preg_match('/^[\\w-]*$/', $dbname) || strlen($dbname) > 64) { $action = 'dbinformation'; $smarty->assign('dbinvalidname', true); } else { update_config_php($dbhost, $dbusername, $dbpassword, $dbname, $dbdriver, $dbtabletype); update_installed_status(0); try { $dbh = new PDO("{$dbdriver}:host={$dbhost};dbname={$dbname}", $dbusername, $dbpassword); } catch (PDOException $e) { $action = 'dbinformation'; $smarty->assign('reason', $e->getMessage()); $smarty->assign('dbconnectfailed', true); } } if ($action != 'dbinformation') { $action = 'createadmin'; } break; case 'finish': if (!$username || preg_match('/[^\\p{L}\\p{N}_\\.\\-]/u', $username)) { $action = 'createadmin'; $smarty->assign('uservalidatefailed', true); $smarty->assign(array('username' => $username, 'password' => $password, 'repeatpassword' => $repeatpassword, 'email' => $email)); } elseif (mb_strlen($password) < 7) { $action = 'createadmin'; $smarty->assign('badpassword', true); $smarty->assign(array('username' => $username, 'password' => $password, 'repeatpassword' => $repeatpassword, 'email' => $email)); } elseif ($password !== $repeatpassword) { $action = 'createadmin'; $smarty->assign('passwordcomparefailed', true); $smarty->assign(array('username' => $username, 'password' => $password, 'repeatpassword' => $repeatpassword, 'email' => $email)); } elseif (!validateMail($email)) { $action = 'createadmin'; $smarty->assign('emailvalidatefailed', true); $smarty->assign(array('username' => $username, 'password' => $password, 'repeatpassword' => $repeatpassword, 'email' => $email)); } else { $installedOk = false; // if it is the distribution and the process have not failed in a previous step if ($installbySQL) { // checks if exists a previous installation with the same prefix $proceed = true; $dbnameConfig = $GLOBALS['ZConfig']['DBInfo']['databases']['default']['dbname']; $exec = $dbdriver == 'mysql' || $dbdriver == 'mysqli' ? "SHOW TABLES FROM `{$dbnameConfig}` LIKE '%'" : "SHOW TABLES FROM {$dbnameConfig} LIKE '%'"; $tables = DBUtil::executeSQL($exec); if ($tables->rowCount() > 0) { $proceed = false; $action = 'dbinformation'; $smarty->assign('dbexists', true); } if ($proceed) { // checks if file exists if (!file_exists($installbySQL)) { $action = 'dbinformation'; $smarty->assign('dbdumpfailed', true); } else { // execute the SQL dump $lines = file($installbySQL); $exec = ''; foreach ($lines as $line_num => $line) { $line = trim($line); if (empty($line) || strpos($line, '--') === 0) { continue; } $exec .= $line; if (strrpos($line, ';') === strlen($line) - 1) { if (!DBUtil::executeSQL($exec)) { $action = 'dbinformation'; $smarty->assign('dbdumpfailed', true); break; } $exec = ''; } } ModUtil::dbInfoLoad('Users', 'Users'); ModUtil::dbInfoLoad('Extensions', 'Extensions'); ModUtil::initCoreVars(true); createuser($username, $password, $email); $installedOk = true; } } } else { installmodules($lang); createuser($username, $password, $email); $installedOk = true; } if ($installedOk) { // create our new site admin // TODO: Email username/password to administrator email address. Cannot use ModUtil::apiFunc for this. $serviceManager->get('session')->start(); $authenticationInfo = array('login_id' => $username, 'pass' => $password); $authenticationMethod = array('modname' => 'Users', 'method' => 'uname'); UserUtil::loginUsing($authenticationMethod, $authenticationInfo); // add admin email as site email System::setVar('adminmail', $email); if (!$installbySQL) { Theme_Util::regenerate(); } // set site status as installed and protect config.php file update_installed_status(1); @chmod('config/config.php', 0400); if (!is_readable('config/config.php')) { @chmod('config/config.php', 0440); if (!is_readable('config/config.php')) { @chmod('config/config.php', 0444); } } // install all plugins $systemPlugins = PluginUtil::loadAllSystemPlugins(); foreach ($systemPlugins as $plugin) { PluginUtil::install($plugin); } LogUtil::registerStatus(__('Congratulations! Zikula has been successfullly installed.')); $response = new RedirectResponse(ModUtil::url('Admin', 'admin', 'adminpanel')); $response->send(); exit; } } break; case 'requirements': $checks = _check_requirements(); $ok = true; foreach ($checks as $check) { if (!$check) { $ok = false; break; } } foreach ($checks['files'] as $check) { if (!$check['writable']) { $ok = false; break; } } if ($ok) { $response = new RedirectResponse(System::getBaseUri() . "/install.php?action=dbinformation&lang={$lang}"); $response->send(); exit; } $smarty->assign('checks', $checks); break; } // check our action template exists $action = DataUtil::formatForOS($action); if ($smarty->template_exists("installer_{$action}.tpl")) { $smarty->assign('action', $action); $templateName = "installer_{$action}.tpl"; } else { $smarty->assign('action', 'error'); $templateName = 'installer_error.tpl'; } $smarty->assign('maincontent', $smarty->fetch($templateName)); $smarty->display('installer_page.tpl'); $smarty->clear_compiled_tpl(); file_put_contents("{$tempDir}/view_compiled/index.html", ''); }
} } $file = "users.json"; $mail = $_POST["mail"]; $pass = $_POST["pass"]; $sex = $_POST["sex"]; $subscribe = $_POST["subscribe"]; if (empty($subscribe)) { $subscribe = "no"; } if (!empty($mail) && !empty($pass) && !empty($sex) && validateMail($mail) && validatePass($pass)) { $formData = array("mail" => $mail, "pass" => $pass, "sex" => $sex, "subscribe" => $subscribe); $arrayData = array(); if (file_exists($file)) { $json = file_get_contents($file); $arrayData = json_decode($json, true); } $arrayData[] = $formData; $json = json_encode($arrayData, JSON_PRETTY_PRINT); if (file_put_contents($file, $json)) { echo "<script>\n \$('#alert').addClass('alert alert-success').html('You have successfully registered!');\n \$('#mail').val('');\n \$('#pass').val('');\n \$('input[name=sex][value=" . $sex . "]').attr('checked', false);" . "\n \$('input[name=subscribe][value=" . $subscribe . "]').attr('checked', false);" . "\n </script>"; } } else { echo "<script>\n \$('#mail').val('{$mail}');\n \$('#pass').val('{$pass}');\n \$('input[name=sex][value=" . $sex . "]').attr('checked', true);" . "\n \$('input[name=subscribe][value=" . $subscribe . "]').attr('checked', true);" . "\n </script>"; if (!validateMail($mail) && !empty($mail)) { echo "<script>\n \$('#alert').addClass('alert alert-danger').html('Incorrect e-mail address!');\n </script>"; } if (empty($sex)) { echo "<script>\n \$('#alert').addClass('alert alert-danger').html('All fields required!');\n </script>"; } }
$filterHtml = ""; } // No threads here if ($thread->num($thread->listRes) <= 0) { $errorParams = array("error" => $ln_no_threads); $listHtml = tkMakeHtml($tmpl["listError"], $errorParams); } // 'New thread' link if (tkCheckTags("create")) { $linkParams = array("newlink" => tkMakeURL("c=new", $confStripQueryVars)); $linkHtml = tkMakeHtml($tmpl["newlinkcon"], $linkParams); } else { $linkHtml = ""; } // Mail hint if (!validateMail($tkUser["email"])) { $mailParams = array(); $mailHtml = tkMakeHtml($tmpl["mailhint"], $mailParams); } else { $mailHtml = ""; } // Page Management $numPages = ceil($thread->numTotalElements / $tkThreadsPerPage); $paginationLinksHtml = ""; #$paginationHtml .= "pages at all: $numPages <br>"; #echo "pagelink:".$tmpl["pagelink"]; for ($page = 0; $page < $numPages; $page++) { #echo "page $page <br>"; $pageParams = array("link" => tkMakeURL("page=" . ($page + 1), $confStripQueryVars), "title" => $page + 1, "special" => $curPage == $page ? " currentPage" : ""); $paginationLinksHtml .= tkMakeHtml($tmpl["pagelink"], $pageParams); }
function sendNotify($cause, $type) { global $tmpl, $tkConfBotMail, $tkConfSysName, $ln_eNotify_titles, $tkUser; // Get all users who need to be identified $users = array(); // First option - all users who subscribed to the current thread /*if( $type == "_subscribers" )#$this->checkFrontidExistance( $type ) ) { // Get the ids of the users who described to this thread $sql = " SELECT id, userid, email_last_notify FROM ".PRFX."threads_marks WHERE threadid='".$this->dataRaw["id"]."' AND email_notification LIKE '%".$cause."%' ;"; $res = $this->query( $sql ); while( $row = $this->assoc( $res ) ) { // don't spam the users if( time() > $row["email_last_notify"] + 60 * 60 * 24 * 7 ) // maximum is: once a week $users[] = $row["userid"]; } } // Second Option - all users, who want to be notified when there is a new thread else if( $type == "_new" ) { global $confEmailNotifyUsers; $users = $confEmailNotifyUsers; }*/ // add the Global Subscription Users #$users = Array(); // We are just notifying users who want it. $users = globGetUsers(); #foreach ( $globUser as $userid ) #{ # if( !in_array( $userid, $users ) ) # $users[] = $userid; #} // Give the users for debug reasons #var_dump( $users ); /*foreach( $users as $userid ) { echo "-------------<br />"; $user = tkCbGetUserById( $userid ); echo $user["name"]; echo " -".$user["email"]."-<br />"; } exit;*/ // Now it's time to notify the users foreach ($users as $userid) { // get the details for each user $user = tkCbGetUserById($userid); // check the users mail if (!validateMail($user["email"])) { tkLog("bad mail for user \"" . $user["name"] . "\": " . $user["email"]); continue; } // Is the user even allowed to view this thread? if (tkCheckTags("viewAll", $userid) || tkCheckTags("viewOwn", $userid) && $this->dataRaw["author"] == $userid) { $access = true; } else { continue; } // only send the mail, if the user checked the rhead since last mail // (meaning, if the email_last_notify column in threads_marks != 0, then no mail) $marks = $this->getMarks($user["id"]); if ($marks["email_last_notify"] > 0) { continue; } #marker3 // send a notification mail switch ($cause) { case "onComment": $eTmpl = $tmpl["email:newComment"]; #$content = $this->posts["create"]->handleField( "text", $this->posts["create"]->dataRaw["text"] ); $content = $this->posts["create"]->dataRaw["text"]; $author = $this->posts["create"]->handleField("author", $this->posts["create"]->dataRaw["author"]); break; case "onStatusChange": $eTmpl = $tmpl["email:statusChange"]; break; case "onNew": $eTmpl = $tmpl["email:newThread"]; $content = $this->posts["create"]->dataRaw["text"]; $author = $this->handleField("author", $this->dataRaw["author"]); break; default: tkSendError("System Error: unkown notify status"); break; } $htmlContent = $this->posts["create"]->handleField("text", $content); $lastCheckOnThread = $this->getLastCheck($tkUser["id"], $dataRaw["id"]); $unreadPosts = 0; $allPosts = 0; // First unread post foreach ($this->posts as $post) { if ($post->dataRaw["build"] > $lastCheckOnThread) { if (!isset($firstUnreadPost)) { $firstUnreadPost = $post->dataRaw["id"]; } $unreadPosts++; } $allPosts++; } $subjval = $this->handleField("subject", $this->dataRaw["subject"]); $subject = $ln_eNotify_titles[$cause] . ': \'' . $subjval . '\''; global $tkConfPath; // No Br in Mails #$text = $content; #$text = str_replace( "\n", "<br />", $text ); #$text = stripslashes( $text ); #$content = $text; $params = array("username" => $user["name"], "author" => $author, "subject" => $subjval, "status" => $this->dataRaw["status"], "content" => $htmlContent, "link" => $tkConfPath . "index.php?id=" . $this->dataRaw["frontid"] . "&p=" . $firstUnreadPost . "#comment" . $firstUnreadPost, "frontid" => $this->dataRaw["frontid"]); #$message = $tkConfNotMailTmpl; $message = tkMakeHtml($eTmpl, $params); /*$headers = 'From: KG-Ticket-Notify <'.$tkConfBotMail . ">\r\n" . 'Reply-To: KG-Ticket-Notify <'.$tkConfBotMail . ">\r\n" . "MIME-Version: 1.0" . "\r\n"; "Content-type: text/html; charset=ISO-8859-1" ; "\n\n" ; $trans_table = array ( 'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue' ); $subject = str_replace( array_keys( $trans_table), $trans_table, $subject );*/ // don't notify the user himself if ($user["id"] != $tkUser["id"]) { // Send the notification mail #die( $htmlContent ); mailLog($user["email"], $user["name"], $subject, $message, $headers); #echo $user["name"]; #$x = mail( $to, $subject, $message, $headers ); #sendMail( $subject, $message, $user["email"], $user["name"], "Dies ist eine HTML-Email...man kann sie nur mit einem HTML-Email-View ansehen..." ); #die( "stop" ); #echo "sendmail"; /*echo "<pre>"."Send Mail To: $to; Subject: $subject; Message: $message"."</pre>";*/ #exit; } // prevent spam ( also at creation of ticket ) $sql = "\n UPDATE \n " . PRFX . "threads_marks\n SET\n email_last_notify='" . time() . "'\n WHERE\n threadid='" . $this->dataRaw["id"] . "' AND\n userid='" . $user["id"] . "'\n ;"; $this->query($sql); } // Send all Mails in the background #> /dev/null & system("php includes/sendmails.php > includes/maillog &", $ret); // attention, works only with Linux! #echo $ret; #die("stop"); return 0; #exit; }
} return false; } else { return true; } } if (isset($mail) && isset($pass) && isset($sex) && validateMail($mail) && validatePass($pass)) { $formData = array("mail" => $mail, "pass" => $pass, "sex" => $sex, "subscribe" => $subscribe, "avatar" => $path); $arrayData = array(); $json = file_get_contents($file); $arrayData = json_decode($json, true); $arrayData[] = $formData; $json = json_encode($arrayData, JSON_PRETTY_PRINT); } else { $correct_reg = 0; if (!validateMail($mail) && isset($mail)) { $_SESSION['reg_error'] = 'Incorrect e-mail address!'; } if (empty($sex)) { $_SESSION['reg_error'] = 'Choose your sex!'; } } if ($correct_reg) { if ($_FILES['avatar']['size'] > 5242880 || $_FILES['avatar']['error'] == 2) { $upload_status = 0; $_SESSION['file_error'] = "Sorry, your file is too large."; } if (strcasecmp($image_type, "jpg") != 0 && strcasecmp($image_type, "jpeg") != 0 && strcasecmp($image_type, "png") != 0 && strcasecmp($image_type, "gif") != 0) { $upload_status = 0; $_SESSION['file_error'] = 'Sorry, only JPG, JPEG, PNG & GIF files are allowed.'; }
<?php function validateMail($str) { if (!filter_var($str, FILTER_VALIDATE_EMAIL)) { header("Location:register.php"); die; } } if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["email"])) { validateMail($_POST["e-mail"]); $con = mysqli_connect("localhost", "root", "", "test"); if (mysqli_connect_errno($con)) { echo "Failed to connect" . mysqli_connect_error(); } $username = mysqli_real_escape_string($con, $_POST["username"]); $password = md5(mysqli_real_escape_string($con, $_POST["password"])); $email = mysqli_real_escape_string($con, $_POST["email"]); $ip = $_SERVER['REMOTE_ADDR']; $msgSql = "SELECT * FROM users WHERE User_Name='{$username}' OR e_mail='{$email}'"; $answer = mysqli_query($con, $msgSql); if ($answer->num_rows == 0) { $msgInsertSql = "INSERT INTO users (User_Name,Password,e_mail,ip) VALUES ('{$username}','{$password}','{$email}','{$ip}')"; $bool = true; $bool = mysqli_query($con, $msgInsertSql); //var_dump($bool); setcookie("name", $username, time() + 24 * 60 * 60); setcookie("password", md5($password), time() + 24 * 60 * 60); header("Location:index.php"); } else { header("Location:register.php");