Пример #1
0
 public function updataPoiInfo($id, $data)
 {
     if (!$id || !is_numeric($id)) {
         return false;
     }
     $poi_info = self::findFirst($id);
     if (isset($data['photo_list'])) {
         $data['photo_list'] = json_encode($data['photo_list']);
     }
     if ($poi_info->save($data, array('telephone', 'recommend', 'special', 'introduction', 'open_time', 'avg_price', 'photo_list'))) {
         return $poi_info->poi_id;
     } else {
         logWarning('error:' . json_encode($this->getMessages()) . ' data:' . json_encode($data));
         return false;
     }
     return false;
 }
Пример #2
0
<?php

session_start();
define('DB_NAME', 'dream');
define('DB_USER', 'da');
define('DB_PASSWORD', 'dream-admin2015');
include_once '../include/functions.php';
include_once '../include/DBF.php';
$user = "******";
if (notNull($_SESSION) && notNull($_SESSION['user'])) {
    $user = $_SESSION['user'];
}
$url = explode("/", currentPage());
$page = $url[sizeof($url) - 1];
$myDB = new DBFactory();
$sql = $myDB->getMysqlConnexionWithPDO();
$sql->beginTransaction();
try {
    $statement = "INSERT INTO deadlinks (link) VALUES(:link)";
    $query = $sql->prepare($statement);
    $query->execute(array('link' => currentPage()));
    $sql->commit();
} catch (Exception $e) {
    $sql->rollBack();
}
logWarning($user, 2, $user . " requested a dead link : " . currentPage());
?>
<h1>404</h1>
<p>La page que vous avez demand&eacute; n'existe pas ou plus</p>
<a href="/">Retourner &agrave; l'accueil</a>
    /**
     * Issue/manage an user's warning status.
     * @uses ProfileAccount template issueWarning sub template
     * @uses Profile template
     */
    public function action_issuewarning()
    {
        global $txt, $scripturl, $modSettings, $mbname, $context, $cur_profile;
        $memID = currentMemberID();
        // make sure the sub-template is set...
        loadTemplate('ProfileAccount');
        $context['sub_template'] = 'issueWarning';
        // We need this because of template_load_warning_variables
        loadTemplate('Profile');
        loadJavascriptFile('profile.js');
        // jQuery-UI FTW!
        $modSettings['jquery_include_ui'] = true;
        loadCSSFile('jquery.ui.slider.css');
        loadCSSFile('jquery.ui.theme.css');
        // Get all the actual settings.
        list($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']);
        // This stores any legitimate errors.
        $issueErrors = array();
        // Doesn't hurt to be overly cautious.
        if (empty($modSettings['warning_enable']) || $context['user']['is_owner'] && !$cur_profile['warning'] || !allowedTo('issue_warning')) {
            fatal_lang_error('no_access', false);
        }
        // Get the base (errors related) stuff done.
        loadLanguage('Errors');
        $context['custom_error_title'] = $txt['profile_warning_errors_occurred'];
        // Make sure things which are disabled stay disabled.
        $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
        $modSettings['warning_moderate'] = !empty($modSettings['warning_moderate']) && !empty($modSettings['postmod_active']) ? $modSettings['warning_moderate'] : 110;
        $modSettings['warning_mute'] = !empty($modSettings['warning_mute']) ? $modSettings['warning_mute'] : 110;
        $context['warning_limit'] = allowedTo('admin_forum') ? 0 : $modSettings['user_limit'];
        $context['member']['warning'] = $cur_profile['warning'];
        $context['member']['name'] = $cur_profile['real_name'];
        // What are the limits we can apply?
        $context['min_allowed'] = 0;
        $context['max_allowed'] = 100;
        if ($context['warning_limit'] > 0) {
            require_once SUBSDIR . '/Moderation.subs.php';
            $current_applied = warningDailyLimit($memID);
            $context['min_allowed'] = max(0, $cur_profile['warning'] - $current_applied - $context['warning_limit']);
            $context['max_allowed'] = min(100, $cur_profile['warning'] - $current_applied + $context['warning_limit']);
        }
        // Defaults.
        $context['warning_data'] = array('reason' => '', 'notify' => '', 'notify_subject' => '', 'notify_body' => '');
        // Are we saving?
        if (isset($_POST['save'])) {
            // Security is good here.
            checkSession('post');
            // This cannot be empty!
            $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
            if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
                $issueErrors[] = 'warning_no_reason';
            }
            $_POST['warn_reason'] = Util::htmlspecialchars($_POST['warn_reason']);
            // If the value hasn't changed it's either no JS or a real no change (Which this will pass)
            if ($_POST['warning_level'] == 'SAME') {
                $_POST['warning_level'] = $_POST['warning_level_nojs'];
            }
            $_POST['warning_level'] = (int) $_POST['warning_level'];
            $_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
            if ($_POST['warning_level'] < $context['min_allowed']) {
                $_POST['warning_level'] = $context['min_allowed'];
            } elseif ($_POST['warning_level'] > $context['max_allowed']) {
                $_POST['warning_level'] = $context['max_allowed'];
            }
            require_once SUBSDIR . '/Moderation.subs.php';
            // Do we actually have to issue them with a PM?
            $id_notice = 0;
            if (!empty($_POST['warn_notify']) && empty($issueErrors)) {
                $_POST['warn_sub'] = trim($_POST['warn_sub']);
                $_POST['warn_body'] = trim($_POST['warn_body']);
                if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
                    $issueErrors[] = 'warning_notify_blank';
                } else {
                    require_once SUBSDIR . '/PersonalMessage.subs.php';
                    $from = array('id' => 0, 'name' => $context['forum_name'], 'username' => $context['forum_name']);
                    sendpm(array('to' => array($memID), 'bcc' => array()), $_POST['warn_sub'], $_POST['warn_body'], false, $from);
                    // Log the notice.
                    $id_notice = logWarningNotice($_POST['warn_sub'], $_POST['warn_body']);
                }
            }
            // Just in case - make sure notice is valid!
            $id_notice = (int) $id_notice;
            // What have we changed?
            $level_change = $_POST['warning_level'] - $cur_profile['warning'];
            // No errors? Proceed! Only log if you're not the owner.
            if (empty($issueErrors)) {
                // Log what we've done!
                if (!$context['user']['is_owner']) {
                    logWarning($memID, $cur_profile['real_name'], $id_notice, $level_change, $_POST['warn_reason']);
                }
                // Make the change.
                updateMemberData($memID, array('warning' => $_POST['warning_level']));
                // Leave a lovely message.
                $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
            } else {
                // Try to remember some bits.
                $context['warning_data'] = array('reason' => $_POST['warn_reason'], 'notify' => !empty($_POST['warn_notify']), 'notify_subject' => isset($_POST['warn_sub']) ? $_POST['warn_sub'] : '', 'notify_body' => isset($_POST['warn_body']) ? $_POST['warn_body'] : '');
            }
            // Show the new improved warning level.
            $context['member']['warning'] = $_POST['warning_level'];
        }
        // Taking a look first, good idea that one.
        if (isset($_POST['preview'])) {
            $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
            $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim(Util::htmlspecialchars($_POST['warn_sub'])) : '';
            if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
                $issueErrors[] = 'warning_notify_blank';
            }
            if (!empty($_POST['warn_body'])) {
                require_once SUBSDIR . '/Post.subs.php';
                preparsecode($warning_body);
                $warning_body = parse_bbc($warning_body, true);
            }
            // Try to remember some bits.
            $context['warning_data'] = array('reason' => $_POST['warn_reason'], 'notify' => !empty($_POST['warn_notify']), 'notify_subject' => isset($_POST['warn_sub']) ? $_POST['warn_sub'] : '', 'notify_body' => isset($_POST['warn_body']) ? $_POST['warn_body'] : '', 'body_preview' => $warning_body);
        }
        if (!empty($issueErrors)) {
            // Fill in the suite of errors.
            $context['post_errors'] = array();
            foreach ($issueErrors as $error) {
                $context['post_errors'][] = $txt[$error];
            }
        }
        $context['page_title'] = $txt['profile_issue_warning'];
        // Let's use a generic list to get all the current warnings
        require_once SUBSDIR . '/GenericList.class.php';
        require_once SUBSDIR . '/Profile.subs.php';
        // Work our the various levels.
        $context['level_effects'] = array(0 => $txt['profile_warning_effect_none'], $modSettings['warning_watch'] => $txt['profile_warning_effect_watch'], $modSettings['warning_moderate'] => $txt['profile_warning_effect_moderation'], $modSettings['warning_mute'] => $txt['profile_warning_effect_mute']);
        $context['current_level'] = 0;
        foreach ($context['level_effects'] as $limit => $dummy) {
            if ($context['member']['warning'] >= $limit) {
                $context['current_level'] = $limit;
            }
        }
        // Build a list to view the warnings
        $listOptions = array('id' => 'issued_warnings', 'title' => $txt['profile_viewwarning_previous_warnings'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['profile_viewwarning_no_warnings'], 'base_href' => $scripturl . '?action=profile;area=issuewarning;sa=user;u=' . $memID, 'default_sort_col' => 'log_time', 'get_items' => array('function' => 'list_getUserWarnings', 'params' => array($memID)), 'get_count' => array('function' => 'list_getUserWarningCount', 'params' => array($memID)), 'columns' => array('issued_by' => array('header' => array('value' => $txt['profile_warning_previous_issued'], 'style' => 'width: 20%;'), 'data' => array('function' => create_function('$warning', '
							return $warning[\'issuer\'][\'link\'];
						')), 'sort' => array('default' => 'lc.member_name DESC', 'reverse' => 'lc.member_name')), 'log_time' => array('header' => array('value' => $txt['profile_warning_previous_time'], 'style' => 'width: 30%;'), 'data' => array('db' => 'time'), 'sort' => array('default' => 'lc.log_time DESC', 'reverse' => 'lc.log_time')), 'reason' => array('header' => array('value' => $txt['profile_warning_previous_reason']), 'data' => array('function' => create_function('$warning', '
							global $scripturl, $txt, $settings;

							$ret = \'
							<div class="floatleft">
								\' . $warning[\'reason\'] . \'
							</div>\';

							// If a notice was sent, provide a way to view it
							if (!empty($warning[\'id_notice\']))
								$ret .= \'
							<div class="floatright">
								<a href="\' . $scripturl . \'?action=moderate;area=notice;nid=\' . $warning[\'id_notice\'] . \'" onclick="window.open(this.href, \\\'\\\', \\\'scrollbars=yes,resizable=yes,width=400,height=250\\\');return false;" target="_blank" class="new_win" title="\' . $txt[\'profile_warning_previous_notice\'] . \'"><img src="\' . $settings[\'images_url\'] . \'/filter.png" alt="" /></a>
							</div>\';

							return $ret;'))), 'level' => array('header' => array('value' => $txt['profile_warning_previous_level'], 'style' => 'width: 6%;'), 'data' => array('db' => 'counter'), 'sort' => array('default' => 'lc.counter DESC', 'reverse' => 'lc.counter'))));
        // Create the list for viewing.
        createList($listOptions);
        $warning_for_message = isset($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : false;
        $warned_message_subject = '';
        // Are they warning because of a message?
        if (isset($_REQUEST['msg']) && 0 < (int) $_REQUEST['msg']) {
            require_once SUBSDIR . '/Messages.subs.php';
            $message = basicMessageInfo((int) $_REQUEST['msg']);
            if (!empty($message)) {
                $warned_message_subject = $message['subject'];
            }
        }
        require_once SUBSDIR . '/Maillist.subs.php';
        // Any custom templates?
        $context['notification_templates'] = array();
        $notification_templates = maillist_templates('warntpl');
        foreach ($notification_templates as $row) {
            // If we're not warning for a message skip any that are.
            if (!$warning_for_message && strpos($row['body'], '{MESSAGE}') !== false) {
                continue;
            }
            $context['notification_templates'][] = array('title' => $row['title'], 'body' => $row['body']);
        }
        // Setup the "default" templates.
        foreach (array('spamming', 'offence', 'insulting') as $type) {
            $context['notification_templates'][] = array('title' => $txt['profile_warning_notify_title_' . $type], 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($warning_for_message) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]));
        }
        // Replace all the common variables in the templates.
        foreach ($context['notification_templates'] as $k => $name) {
            $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $warning_for_message . ']' . un_htmlspecialchars($warned_message_subject) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => replaceBasicActionUrl($txt['regards_team'])));
        }
    }
Пример #4
0
    $myDB = new DBFactory();
    $sql = $myDB->getMysqlConnexionWithPDO();
    $query = $sql->prepare("SELECT * FROM users WHERE login = :login;");
    $query->execute(array('login' => $_POST['auth_login']));
    $result = $query->fetch();
    if (notNull($result)) {
        $sent_pass = sha1($_POST['auth_pass'] . $result['salt']);
        $stored_pass = $result['pass'];
        if ($sent_pass == $stored_pass) {
            $_SESSION['logged'] = "LOGGED";
            $_SESSION['user'] = ucfirst($result['login']);
            $_SESSION['role'] = $result['role'];
            $_SESSION['id'] = $result['id'];
            logSuccess($result['login'], 0, "User " . $result['login'] . " successfully logged in from IP " . get_client_ip());
        } else {
            $_SESSION['logged'] = "NOT_LOGGED";
            $_SESSION['user'] = "******";
            $_SESSION['role'] = 0;
            logWarning($result['login'], 0, "User " . $result['login'] . " failed to log from IP " . get_client_ip());
        }
    }
}
if ($logged) {
    if (notNull($_POST['auth_from'])) {
        header('Location:' . $_POST['auth_from']);
    } else {
        header('Location:/');
    }
} else {
    header('Location:/');
}
Пример #5
0
/**
* This is the method that inserts 200 recent Twitter response objects with their Twitter handles in 
* the DB (Table: Tweets). 
*/
function insertTweetInDB()
{
    //$users = array("result" => ["@katyperry"]);
    $users = getAllTwitterUsers();
    $twitterApiCallCount = 0;
    foreach ($users['result'] as $user) {
        if ($twitterApiCallCount % 180 == 0 && $twitterApiCallCount != 0) {
            // Sleep for 15mins and 30 seconds
            break;
        }
        // strip the initial character '@' and get 200 Twitter Responses for that screen-name.
        $twitterResp = getTweet(substr($user, 1), 200);
        $twitterApiCallCount += 1;
        $count = 1;
        mysqli_query(getConnection(), "START TRANSACTION;");
        foreach ($twitterResp as $response) {
            $response["source"] = str_replace('"', '\\"', $response["source"]);
            $response["text"] = str_replace('"', '\\"', $response["text"]);
            $object = json_encode($response);
            // Escaping all the ' character from the Tweet Data
            $object = str_replace("'", "\\'", $object);
            $query = "REPLACE INTO Tweets(Number, TwitterHandle, TwitterResp) VALUES('" . (string) $count . "', '" . $user . "', '" . $object . "');";
            $count += 1;
            $res = mysqli_query(getConnection(), $query);
            if (false === $res) {
                logWarning('tweetylogs.txt', "Insertion for Tweet #" . $count . " for Twitter User " . $user . " failed. Insertion error: " . mysqli_error($link));
                logWarning('warning.txt', "Insertion for Tweet #" . $count . " for Twitter User " . $user . " failed. Insertion error: " . mysqli_error($link));
                logWarning('tweetylogs.html', "Insertion for <b>Tweet #" . $count . "</b> for <b>Twitter User " . $user . "</b> failed. Insertion error: " . mysqli_error($link));
            }
        }
        if ($count >= 200) {
            logSuccess('tweetylogs.txt', "Insertion for 200 Tweets for Twitter User " . $user . " succeded.");
            logSuccess('warning.txt', "Insertion for 200 Tweets for Twitter User " . $user . " succeded.");
            logSuccess('tweetylogs.html', "Insertion for 200 Tweets for <b>Twitter User " . $user . "</b> succeded.");
        }
        mysqli_query(getConnection(), "COMMIT;");
    }
}
Пример #6
0
$_pinkie->s_AdminAprove = $_SESSION['Username'];
if (strcmp($_POST['status'], ApprovedByAdmin) == 0) {
    $_pinkie->s_Submitter = $_SESSION['Username'];
    $_pinkie->s_AdminAprove = $_SESSION['Username'];
    $_pinkie->s_SubmittedFor = $_POST['submitTo'];
    $_pinkie->s_Status = Dispatched;
    $_pinkie->toDatabase();
    logGeneral($_pinkie->i_PinkieID, $_SESSION['Username'], "Pinkie was approved by admin: " . getName());
} else {
    if (strcmp($_POST['status'], RejectedByAdmin) == 0) {
        $_tmp = $_pinkie->s_Submitter;
        $_pinkie->s_Submitter = $_POST['submitTo'];
        $_pinkie->s_SubmittedFor = $tmp;
        $_pinkie->s_Status = $_POST['status'];
        $_pinkie->toDatabase();
        logGeneral($_pinkie->i_PinkieID, $_SESSION['Username'], "Pinkie was rejected by admin: " . getName());
    } else {
        if (strcmp($_POST['status'], Cancelled) == 0) {
            $_pinkie->s_Status = $_POST['status'];
            $_pinkie->toDatabase();
            logGeneral($_pinkie->i_PinkieID, $_SESSION['Username'], "Pinkie was cancelled by: " . getName());
        } else {
            if (strcmp($_POST['status'], Archived) == 0) {
                $_pinkie->s_Status = $_POST['status'];
                $_pinkie->toDatabase();
                logWarning($_pinkie->i_PinkieID, $_SESSION['Username'], "Pinkie was archived by: " . getName());
            }
        }
    }
}
header("Location: ./home.php");
Пример #7
0
function uploads($upload_dir, $size = 2097152, $type = array('jpg', 'png'))
{
    $request = new \Phalcon\Http\Request();
    if (true != $request->isPost()) {
        return false;
    }
    if ($request->hasFiles()) {
        $upload_dir = trim($upload_dir, '/\\') . DIRECTORY_SEPARATOR . date('Y-m-d');
        if (!file_exists($upload_dir)) {
            mkdir($upload_dir, 777, true);
        }
        $php_post_max_size = (int) ini_get('post_max_size') * 1024 * 1024;
        $php_upload_max_filesize = (int) ini_get('upload_max_filesize') * 1024 * 1024;
        if ($php_post_max_size < $size) {
            logWarning('PHP php_post_max_size < uploads\'s Size');
            throw new \Exception('php.ini php_post_max_size 上传文件大小未设置');
        }
        if ($php_upload_max_filesize < $size) {
            logWarning('PHP php_upload_max_filesize < uploads\'s Size');
            throw new \Exception('php.ini php_upload_max_filesize 上传文件大小未设置');
        }
        foreach ($request->getUploadedFiles() as $file) {
            if ($file->getError() != 0) {
                continue;
            }
            if (!in_array($file->getExtension(), $type)) {
                $upload_errors[] = array('error' => UPLOADS_ERROR_10001, 'key' => $file->getKey());
                break;
            }
            if ($file->getSize() > $size) {
                $upload_errors[] = array('error' => UPLOADS_ERROR_10002, 'key' => $file->getKey());
                break;
            }
            $file_name = uniqid() . time() . mt_rand(10000, 999999) . '.' . $file->getExtension();
            if ($file->moveTo($upload_dir . DIRECTORY_SEPARATOR . $file_name)) {
                $files[$file->getKey()] = $upload_dir . DIRECTORY_SEPARATOR . $file_name;
            }
        }
        if (isset($upload_errors)) {
            if (isset($files)) {
                foreach ($files as $val) {
                    if (!unlink(ROOT_DIR . DIRECTORY_SEPARATOR . $val)) {
                        logWarning('delete upload file error ::' . $val);
                    }
                }
            }
            return $upload_errors;
        }
        if (isset($files) && is_array($files) && count($files) > 0) {
            return $files;
        }
    }
    return false;
}
Пример #8
0
date_default_timezone_set("America/Chicago");
function logMessage($logLevel, $message)
{
    $todaysDate = date("Y-m-d");
    $todaysDateTime = date("h:i:s A");
    $filename = "log-{$todaysDate}.log";
    $handle = fopen($filename, 'a');
    $formattedMessage = $todaysDate . " " . $todaysDateTime . " " . $logLevel . " " . $message . PHP_EOL;
    fwrite($handle, $formattedMessage);
    fclose($handle);
}
function logInfo($message)
{
    logMessage("INFO", $message);
}
function logError($message)
{
    logMessage("ERROR", $message);
}
function logWarning($message)
{
    logMessage("WARNING", $message);
}
function logCritical($message)
{
    logMessage("CRITICAL", $message);
}
logInfo("This is an INFO message.");
logError("This is an ERROR message.");
logWarning("This is a WARNING message.");
logCritical("This is a CRITICAL message.");