$extension = strtolower($extension[extension]);
$valid_ext_types = array('jpeg', 'jpg', 'gif', 'png');
if (!in_array($extension, $valid_ext_types)) {
    $error .= "File type does not appear to be a supported image (" . $extension . "). Please try another format.<br>";
}
if (strlen($error) == 0) {
    $uploaddir = 'storage/originals/';
    $newfilename = randomfilename() . "." . $extension;
    $uploadfile = $uploaddir . $newfilename;
    if (!move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile)) {
        $error .= "Could not move file into storage, please try again later.";
        log_data("ERROR: " . $error);
    } else {
        // add to db
        $userip = $_SERVER['REMOTE_ADDR'];
        list($originalwidth, $originalheight, $type, $attr) = getimagesize($uploadfile);
        $tracker = randomfilename();
        $insert_image = "INSERT INTO images (dateadded, mimetype, originalfilename, filename, filesize, description, originalip, originalwidth, originalheight, lastaccessed, tracker, mutracker) VALUES (NOW(), '" . preparedata($contenttype) . "', '" . preparedata($filename) . "', '" . preparedata($newfilename) . "', '" . preparedata($filesize) . "', '', '" . preparedata($userip) . "', '" . $originalwidth . "', '" . $originalheight . "', NOW(), '" . preparedata($tracker) . "', '" . preparedata($mutracker) . "')";
        $do_insert_image = @mysql_query($insert_image);
        $item_id = mysql_insert_id();
        if ($do_insert_image) {
            log_data("SUCCESS: Image successfully uploaded. Ref: " . $item_id);
        } else {
            log_data("ERROR: SQL INSERT FAILED - " . $insert_image);
        }
    }
} else {
    log_data("ERROR: " . $error);
}
log_data("Finished import process for " . $_FILES['Filedata']['name'] . "\n\r");
function send2weibo_via_apikey($s_email, $s_pwd, $tweet, $apikey)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://api.t.sina.com.cn/statuses/update.json");
    curl_setopt($ch, CURLOPT_USERPWD, "{$s_email}:{$s_pwd}");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "source=" . $apikey . "&status=" . urlencode($tweet));
    $rs = json_decode(curl_exec($ch), true);
    if (!empty($rs['error'])) {
        $rs['email'] = $s_email;
        //$rs['pwd'] = $s_pwd;
        $rs['tweet'] = $tweet;
        $rs['apikey'] = $apikey;
        log_data('[ERROR] 使用 API 同步新浪微博失败:' . str_replace('\\/', '/', my_json_encode($rs)));
        return false;
    }
    curl_close($ch);
    return true;
}
Exemple #3
0
<?php

include "base.php";
$username = $_SESSION['Username'];
log_data($username, "Logged out");
//log log out
$_SESSION = array();
session_destroy();
?>
<meta http-equiv="refresh" content="0;index.php">
Exemple #4
0
    if (mysqli_num_rows($checklogin) == 1) {
        $row = mysqli_fetch_array($checklogin);
        $email = $row['EmailAddress'];
        $_SESSION['Username'] = $username;
        $_SESSION['EmailAddress'] = $email;
        $_SESSION['LoggedIn'] = 1;
        ?>
   
        <div id="quotPan">
         <h3 style = "width:473px"><span>successfully logged in to </span>Code-Art</h3>
         <br>
        <p>Redirecting to member login page... </p>
      
        <meta http-equiv="refresh" content="2;index.php">
      <?php 
        log_data($username, "Logged in");
    } else {
        echo "<h1>Error</h1>";
        echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>";
    }
} else {
    ?>
    <div id="ct_pan">
    <p>Log in to <span>Code-Art</span> to see your stats and start playing.</p>
   </div>
   
   <div id="quotPan">
    <h3><span>login to </span>Code-Art</h3>
    <form method="post" action="index.php" name="loginform" id="loginform">
   
    <input name="username" type="text" placeholder="your name" class="txt" />
Exemple #5
0
</div>

<div id="main">
<?php 
if (!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['email']) && !empty($_POST['college']) && !empty($_POST['phone'])) {
    $username = mysqli_real_escape_string($link, $_POST['username']);
    $password = md5(mysqli_real_escape_string($link, $_POST['password']));
    $email = mysqli_real_escape_string($link, $_POST['email']);
    $college = mysqli_real_escape_string($link, $_POST['college']);
    $phone = mysqli_real_escape_string($link, $_POST['phone']);
    $checkusername = mysqli_query($link, "SELECT * FROM users WHERE Username = '******'");
    if (mysqli_num_rows($checkusername) == 1) {
        echo "<h1>Error</h1>";
        echo "<p>Sorry, that username is taken. Please go back and try again.</p>";
    } else {
        log_data($username, "Registered");
        //log registration
        $registerquery = mysqli_query($link, "INSERT INTO users (Username, Password, EmailAddress, College, Phone) VALUES('" . $username . "', '" . $password . "', '" . $email . "', '" . $college . "', '" . $phone . "')");
        if ($registerquery) {
            echo "<h1>Success</h1>";
            echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>";
        } else {
            echo "<h1>Error</h1>";
            echo "<p>Sorry, your registration failed. Please go back and try again.</p>";
        }
    }
} else {
    ?>
     
     
    <div id="quotPanReg">
Exemple #6
0
            ?>
<script>
          bootbox.dialog({
          message: "We are experiencing difficulties at the moment. Please bear with us, while we rectify the problem. We have saved your code in the meanwhile, to be evaluated at a later time. Thank you for your patience.",
          title: "Fatal Error",
          buttons: {
              main: {
              label: "OK",
              className: "btn-danger"    }
          }
        });
          </script><?php 
            mysqli_query($link, "INSERT INTO error_data (UserID, Language, Code, Round)\n           VALUES ('{$userIDn}', '{$lang}', '{$code_data}', '{$rno}')");
            log_data($username, "API trouble", $code_data);
        } else {
            log_data($username, "Compilation error", $code_data);
            ?>
<script>
          var data = <?php 
            echo json_encode($run_status);
            ?>
;
          bootbox.dialog({
          message: data,
          title: "Compilation Error",
          buttons: {
              main: {
              label: "OK",
              className: "btn-danger"    }
          }
        });