Esempio n. 1
0
function requestRecommendation($user_id, $author, $email, $message)
{
    if (!checkLock("peer")) {
        return 6;
    }
    $config = $GLOBALS['config'];
    $user_id = escape($user_id);
    $author = escape($author);
    $email = escape($email);
    if (!validEmail($email)) {
        return 1;
    }
    if (strlen($author) <= 3) {
        return 2;
    }
    //make sure there aren't too many recommendations already
    $result = mysql_query("SELECT COUNT(*) FROM recommendations WHERE user_id = '{$user_id}'");
    $row = mysql_fetch_row($result);
    if ($row[0] >= $config['max_recommend']) {
        return 4;
        //too many recommendations
    }
    //ensure this email hasn't been asked with this user already
    $result = mysql_query("SELECT COUNT(*) FROM recommendations WHERE user_id = '{$user_id}' AND email = '{$email}'");
    $row = mysql_fetch_row($result);
    if ($row[0] > 0) {
        return 5;
        //email address already asked
    }
    lockAction("peer");
    //first create an instance
    $instance_id = customCreate(customGetCategory('recommend', true), $user_id);
    //insert into recommendations table
    $auth = escape(uid(64));
    mysql_query("INSERT INTO recommendations (user_id, instance_id, author, email, auth, status, filename) VALUES ('{$user_id}', '{$instance_id}', '{$author}', '{$email}', '{$auth}', '0', '')");
    $recommend_id = mysql_insert_id();
    $userinfo = getUserInformation($user_id);
    //array (username, email address, name)
    //send email now
    $content = page_db("request_recommendation");
    $content = str_replace('$USERNAME$', $userinfo[0], $content);
    $content = str_replace('$USEREMAIL$', $userinfo[1], $content);
    $content = str_replace('$NAME$', $userinfo[2], $content);
    $content = str_replace('$AUTHOR$', $author, $content);
    $content = str_replace('$EMAIL$', $email, $content);
    $content = str_replace('$MESSAGE$', page_convert($message), $content);
    $content = str_replace('$AUTH$', $auth, $content);
    $content = str_replace('$SUBMIT_ADDRESS$', $config['site_address'] . "/recommend.php?id={$recommend_id}&user_id={$user_id}&auth={$auth}", $content);
    $result = one_mail("Recommendation request", $content, $email);
    if ($result) {
        return 0;
    } else {
        return 3;
    }
}
Esempio n. 2
0
 /**
  * 从RSS抓取数据
  * @author Mr.Cong <*****@*****.**>
  */
 public function getData($parameters)
 {
     $feed = FeedsFacade::make($this->base_uri);
     $data = array('title' => $feed->get_title(), 'permalink' => $feed->get_permalink(), 'items' => $feed->get_items());
     $log_name = 'chinagdg.lock';
     $lock_title = $data['items'][0]->get_title();
     if (checkLock($log_name, $lock_title)) {
         //开始读取数据保存进数据库
         $this->saveData($data);
     }
     print 0;
     exit;
 }
Esempio n. 3
0
function requestPGP($email, $key)
{
    require_once includePath() . "/lock.php";
    global $config, $lang;
    if (!checkLock('requestpgp')) {
        return $lang['submit_error_trylater'];
    }
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return $lang['submit_error_bademail'];
    }
    if (strlen($email) > 256 || strlen($key) > 1024 * 32) {
        return $lang['submit_error_toolong'];
    }
    if (!isAscii($key)) {
        return $lang['submit_error_nonascii'];
    }
    //housekeeping
    databaseQuery("DELETE FROM gpgmw_keys WHERE time < DATE_SUB(NOW(), INTERVAL 48 HOUR) AND confirm != '' AND status = 0");
    //if we already have an unaccepted key for this user, only replace if one day has elapsed since the last request
    // this may prevent spam
    $result = databaseQuery("SELECT HOUR(TIMEDIFF(time, NOW())), id FROM gpgmw_keys WHERE email = ? AND status = 0", array($email));
    if ($row = $result->fetch()) {
        if ($row[0] < 24) {
            return $lang['submit_error_alreadyqueue'];
        } else {
            databaseQuery('DELETE FROM gpgmw_keys WHERE id = ?', array($row[1]));
        }
    }
    //if PGP key verification is enabled, do it
    if ($config['pgpverify_enable']) {
        require_once includePath() . "/gpg.php";
        if (!verifyPGPKey($key, $email)) {
            return $lang['submit_error_badkey'];
        }
    }
    //well, it looks good, let's submit it
    lockAction('requestpgp');
    $confirm = uid(32);
    $confirm_link = "{$config['site_url']}/confirm.php?email=" . urlencode($email) . "&confirm={$confirm}";
    $result = gpgmw_mail($config['email_subject_requestpgp'], sprintf($lang['mail_confirm'], $confirm_link), $email);
    if (!$result) {
        return $lang['submit_error_emailfail'];
    }
    databaseQuery("INSERT INTO gpgmw_keys (email, publickey, confirm) VALUES (?, ?, ?)", array($email, $key, $confirm));
    return true;
}
Esempio n. 4
0
function authChangePassword($user_id, $old_password, $new_password)
{
    global $config, $db;
    if (!checkLock("checkuser")) {
        return "Too many failed attempts. Please try again later.";
    }
    if (strlen($new_password) < 6) {
        return "The new password is too short. Please use at least six characters.";
    }
    if ($old_password == $new_password) {
        return "The old and new passwords are identical.";
    }
    if (!authCheckPassword($user_id, $old_password, "id")) {
        lockAction("checkuser");
        return "The password you entered is not correct.";
    }
    $user_id = escape($user_id);
    require_once includePath() . "/pbkdf2.php";
    $new_password = escape("*pbkdf2*" . pbkdf2_create_hash($new_password));
    $db->query("UPDATE accounts SET password = '******' WHERE id = '{$user_id}'");
    return true;
}
Esempio n. 5
0
 /**
  * 从RSS抓取数据
  * @author Mr.Cong <*****@*****.**>
  */
 public function getData($fids = array())
 {
     foreach ($fids as $key => $fid) {
         $this->fid = $fid;
         $this->build_query = sprintf('forum.php?mod=rss&fid=%s&auth=0', $fid);
         $feed = FeedsFacade::make($this->base_uri . $this->build_query);
         $data = array('title' => $feed->get_title(), 'permalink' => $feed->get_permalink(), 'items' => $feed->get_items());
         /*
          * 获取到最新的一条的标题
          */
         $log_name = $fid . '.lock';
         $lock_title = $data['items'][0]->get_title();
         if (checkLock($log_name, $lock_title)) {
             //开始读取数据保存进数据库
             $this->saveData($data);
         } else {
             break;
         }
         unset($feed);
         unset($data);
         unset($log_name);
         unset($lock_title);
     }
 }
Esempio n. 6
0
                    $smarty->assign('file', $_GET['file']);
                } else {
                    if ($_GET['file'] == 'resolutions.txt' && checkReadPerms($_GET['organ'])) {
                        $smarty->assign('text', readResolutions($_GET['organ']));
                        $smarty->assign('organ', $_GET['organ']);
                        $smarty->assign('file', $_GET['file']);
                    }
                }
            }
        }
    }
}
if (isset($_POST['text']) and isset($_GET['organ']) and isset($_GET['file'])) {
    //save changes
    if (checkOrgan($_GET['organ']) and checkWritePerms($_GET['organ'])) {
        if (checkFilename($_GET['file']) and checkLock($_SESSION['user'], $_GET['organ'], $_GET['file'])) {
            writeIntoFile($_POST['text'], $_GET['organ'], $_GET['file']);
            $smarty->assign('text', $_POST['text']);
            $smarty->assign('organ', $_GET['organ']);
            $smarty->assign('file', $_GET['file']);
            deleteLock($_GET['organ'], $_GET['file']);
        } else {
            if (checkAdminPerms($_GET['organ'])) {
                if ($_GET['file'] == "template") {
                    writeTemplate($_POST['text'], $_POST['organ']);
                    $smarty->assign('text', $_POST['text']);
                    $smarty->assign('organ', $_GET['organ']);
                    $smarty->assign('file', $_GET['file']);
                    deleteLock($_GET['organ'], $_GET['file']);
                } else {
                    if ($_GET['file'] == "email") {
Esempio n. 7
0
<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo "Servers Service started [" . date('d.m.Y h:i', time()) . "] with PID= " . getmypid() . "\n";
include __DIR__ . '/conf.php';
include __corePath . 'libs/service.php';
include __corePath . 'libs/ApiQuery.php';
include __corePath . 'libs/jsonDB.php';
if (checkLock('servers')) {
    die("Found .lock file, exit.\n");
}
lock('servers');
$serversList = new JsonDB(__serversdb);
foreach ($serversList->data as $key => $server) {
    if (checkServerTestTime($server, 60)) {
        $query = new ApiQuery($server['address'], $server['apiKey']);
        $info = $query->getServerInfo(true);
        if ($info['responseStatus'] == 'ok') {
            $serversList->data[$key]['name'] = $info['serverName'];
            $serversList->data[$key]['tasksCount'] = $info['tasksCount'];
            $serversList->data[$key]['tasks'] = $info['tasks'];
            $serversList->data[$key]['freeSpace'] = $info['freeSpace'];
            $serversList->data[$key]['lastCheck'] = time();
            $serversList->data[$key]['status'] = 1;
            if ($server['archSync']) {
                $tasksfiles = $query->getTasksFiles(true);
                // ----------------------------------
                foreach ($tasksfiles as $taskId => $tmpFiles) {
                    $files = array();
         $userids = Sql_Query(sprintf('select * from %s where id = 0', $tables["user"]));
     }
 }
 $affrows = Sql_Affected_Rows();
 while ($userdata = Sql_fetch_row($userids)) {
     if ($num_per_batch && $sent >= $num_per_batch) {
         output($GLOBALS['I18N']->get('batch limit reached') . ": {$sent} ({$num_per_batch})");
         $GLOBALS["wait"] = $batch_period;
         return;
     }
     $userid = $userdata[0];
     # id of the user
     $some = 1;
     set_time_limit(120);
     # check if we have been "killed"
     $alive = checkLock($send_process_id);
     if ($alive) {
         keepLock($send_process_id);
     } else {
         ProcessError($GLOBALS['I18N']->get('Process Killed by other process'));
     }
     # check if the message we are working on is still there and in process
     $status = Sql_Fetch_Array_query("select id,status from {$tables['message']} where id = {$messageid}");
     if (!$status['id']) {
         ProcessError($GLOBALS['I18N']->get('Message I was working on has disappeared'));
     } elseif ($status['status'] != 'inprocess') {
         ProcessError($GLOBALS['I18N']->get('Sending of this message has been suspended'));
     }
     flush();
     # check whether the user has already received the message
     $um = Sql_query("select entered from {$tables['usermessage']} where userid = {$userdata['0']} and messageid = {$messageid}");
Esempio n. 9
0
         Sql_Query(sprintf('update %s set confirmed = 0 where id = %d',$tables["user"],$user[0]));
         addSubscriberStatistics('auto unsubscribe',1);
         $email_req = Sql_Fetch_Row_Query(sprintf('select email from %s where id = %d',$tables["user"],$user[0]));
         $unsubscribed_users .= $email_req[0] . " [$user[0]] ($cnt)\n";
       }
     } elseif ($bounce["bounce"] == "") {
       $cnt = 0;
     }
   }*/
 #$alive = 1;$removed = 0; DT 051105
 $cnt = 0;
 $alive = 1;
 $removed = $msgokay = $unconfirmed = $unsubscribed = 0;
 #while ($alive && !$removed && $bounce = Sql_Fetch_Array($msg_req)) { DT 051105
 while ($alive && !$removed && !$msgokay && ($bounce = Sql_Fetch_Array($msg_req))) {
     $alive = checkLock($process_id);
     if ($alive) {
         keepLock($process_id);
     } else {
         bounceProcessError("Process Killed by other process");
     }
     if (stripos($bounce['status'], 'duplicate') === false && stripos($bounce['comment'], 'duplicate') === false) {
         if (sprintf('%d', $bounce["bounce"]) == $bounce["bounce"]) {
             $cnt++;
             if ($cnt >= $bounce_unsubscribe_threshold) {
                 if (!$unsubscribed) {
                     outputProcessBounce(sprintf('unsubscribing %d -> %d bounces', $user[0], $cnt));
                     $userurl = PageLink2("user&amp;id={$user['0']}", $user[0]);
                     logEvent(s('User (url:%s) has consecutive bounces (%d) over threshold (%d), user marked unconfirmed', $userurl, $cnt, $bounce_unsubscribe_threshold));
                     $emailreq = Sql_Fetch_Row_Query("select email from {$tables["user"]} where id = {$user['0']}");
                     addUserHistory($emailreq[0], s('Auto Unconfirmed'), s('Subscriber auto unconfirmed for %d consecutive bounces', $cnt));
Esempio n. 10
0
if (empty($process_id)) {
    return;
}
## only convert up to a week ago.
$lastweek = date('Y-m-d', time() - 24 * 7 * 3600);
cl_output(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
$num = Sql_Fetch_Row_Query(sprintf('select count(*) from %s lt, %s m where lt.messageid = m.id and m.entered < "%s"', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek));
output(s('%d entries still to convert', $num[0]) . '<br/>');
$c = 0;
$req = Sql_Query(sprintf('select lt.* from %s lt, %s m where lt.messageid = m.id and m.entered < "%s" limit %d', $GLOBALS['tables']['linktrack'], $GLOBALS['tables']['message'], $lastweek, $limit));
$total = Sql_Affected_Rows();
if ($total) {
    output(s('converting data') . '<br/>');
}
while ($row = Sql_Fetch_Array($req)) {
    if (checkLock($process_id)) {
        keepLock($process_id);
    } else {
        output(s('processing cancelled'));
        break;
    }
    $exists = Sql_Fetch_Row_Query(sprintf('select id from %s where url = "%s"', $GLOBALS['tables']['linktrack_forward'], $row['url']));
    if (!$exists[0]) {
        $personalise = preg_match('/uid=/', $row['forward']);
        Sql_Query(sprintf('insert into %s (url,personalise) values("%s",%d)', $GLOBALS['tables']['linktrack_forward'], $row['url'], $personalise));
        $fwdid = Sql_Insert_id();
    } else {
        $fwdid = $exists[0];
    }
    set_time_limit(600);
    $messageid = $row['messageid'];
Esempio n. 11
0
<?php

session_start();
require 'defines.php';
require 'lib.php';
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
//check if a lock file exists
if (checkOrgan($_GET['organ'])) {
    if (checkFilename($_GET['file']) or $_GET['file'] == "template" or $_GET['file'] == "email" or $_GET['file'] == "resolutions.txt") {
        if (checkLock($_SESSION['user'], $_GET['organ'], $_GET['file'])) {
            createLock($_SESSION['user'], $_GET['organ'], $_GET['file']);
            echo '<response>Get lock file until ' . date('H-i', time() + 15 * 60) . ' </response>';
        } else {
            echo "<response>Another user is editing this file</response>";
        }
    }
}
Esempio n. 12
0
function verifyLogin($user_id, $password)
{
    if (!checkLock("checkuser")) {
        return -2;
    }
    $user_id = escape($user_id);
    //decrypt the password if needed
    require_once includePath() . "/crypto.php";
    $password = decryptPassword($password);
    $result = mysql_query("SELECT password, salt FROM users WHERE id='" . $user_id . "'");
    if ($row = mysql_fetch_array($result)) {
        if (chash2($password, hex2bin($row['salt'])) == $row['password']) {
            return true;
        } else {
            lockAction("checkuser");
            return -1;
        }
    } else {
        lockAction("checkuser");
        return -1;
    }
}
Esempio n. 13
0
<?php

include_once "config.php";
include_once "includes.php";
include_once "functions.php";
checkLock();
$dbName = DB_NAME;
$dbc = new coneXion(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sql = " SELECT * FROM {$dbName}.imagenes WHERE procesado=0 LIMIT " . PROCS_PER_RUN;
$rs = mysql_query($sql, $dbc->db);
if (!$rs) {
    die("DB ERROR");
}
while ($obj = mysql_fetch_object($rs)) {
    $id = $obj->id;
    $celular = $obj->celular;
    $qrImgName = $id . ".jpg";
    $downloadOk = getFtpFiles(FTP_PATH . "/{$qrImgName}");
    if ($downloadOk === TRUE) {
        // leer qr
        $qrRead = readQRCode($qrImgName);
        // parse result
        if (qrFound($qrRead) === TRUE) {
            $qrFound = TRUE;
            $urlPush = readUrl($qrRead);
            // valido url
            if (isValidUrl($urlPush) === TRUE) {
                // send sms push
                $msgPush = "Ir a";
                $push = new pushAntel($dbc->db, SMS_SC, $celular, $msgPush);
                $sent = $push->enviarPush($urlPush, $msgPush);
Esempio n. 14
0
<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo "Service started [" . date('d.m.Y h:i', time()) . "] with PID= " . getmypid() . "\n";
include __DIR__ . '/conf.php';
include __corePath . 'libs/service.php';
include __corePath . 'libs/jsonDB.php';
include __corePath . 'libs/dumper.php';
if (checkLock('tasks')) {
    die("Found .lock file, exit.\n");
}
lock('tasks');
$tasksList = new JsonDB(__taskdb);
foreach ($tasksList->data as $key => $task) {
    $nextExec = nextExecDateTime($task);
    echo "+++++++++++++++++++++++++++++++++++++\n";
    echo $task['title'] . "\n";
    echo "+++++++++++++++++++++++++++++++++++++\n";
    echo "CurtTime = " . date('d.m.Y h:i', time()) . "\n";
    echo "Lastexec = " . date('d.m.Y h:i', $task['lastExec']) . "\n";
    echo "NextExec = " . date('d.m.Y h:i', $nextExec) . "\n";
    if (time() >= $nextExec && $nextExec > 0) {
        switch ($task['type']) {
            case 'files_backup':
                $res = 0;
                $tasksList->data[$key]['execStatus'] = 0;
                try {
                    $res = filesBackup($task);
                } catch (Exception $e) {