Beispiel #1
0
<?php

/**
 * this driver is for the new site, it'll be named "adc" (keep diff from the others)
 */
include "../app/vendors/extrakits.inc.php";
include "../app/vendors/zmysqlConn.class.php";
$ip = __getclientip();
$tz = "EST";
$now = new DateTime("now", new DateTimeZone($tz));
/*
 * just log every POST/GET at the very beginning
*/
$logpath = "./logs/dt01.log";
$from = "from ip: {$ip}";
$ending = " [" . $ip . "/" . $now->format("Y-m-d H:i:s") . "({$tz})]\n";
error_log("######\n", 3, $logpath);
if (empty($_POST) && empty($_GET)) {
    error_log($from . "\nNothing posted here" . $ending, 3, $logpath);
    echo "nothing posted";
} else {
    if (!empty($_POST)) {
        error_log($from . "(POST)\n" . print_r($_POST, true) . $ending, 3, $logpath);
    }
    if (!empty($_GET)) {
        error_log($from . "(GET)\n" . print_r($_GET, true) . $ending, 3, $logpath);
    }
}
//exit(); //for debugging
$err = "";
$s = "";
 function __go($siteid, $typeid, $url, $referer, $agentid, $clicktime, $linkid = null)
 {
     if (__isblocked(__getclientip())) {
         //if (false) {
         $this->Session->setFlash('Sorry, you\'re not allowed to check the link.');
         //$this->render('/trans/go');
         $this->redirect('http://dating.com');
         return;
     } else {
         //$this->Session->setFlash('Normal redirecting for debugging.' . __getclientip());
         //$this->render('/trans/go');
         //return;
         /*log this click*/
         $this->data['TransClickout']['linkid'] = $linkid;
         $this->data['TransClickout']['agentid'] = $agentid;
         $this->data['TransClickout']['clicktime'] = $clicktime;
         $this->data['TransClickout']['fromip'] = __getclientip();
         $this->data['TransClickout']['siteid'] = $siteid;
         $this->data['TransClickout']['typeid'] = $typeid;
         $this->data['TransClickout']['url'] = $url;
         $this->data['TransClickout']['referer'] = $referer;
         $this->TransClickout->save($this->data);
         /*and redirect to the real url*/
         $this->redirect($url);
     }
 }
 function __go($siteid, $typeid, $url, $referer, $agentid, $clicktime, $linkid = null)
 {
     //if (__isblocked(__getclientip())) {
     if (false) {
         $this->Session->setFlash('Sorry, you\'re not allowed to check the link.');
         $this->render('/accounts/go');
         return;
     } else {
         /*log this click*/
         $this->request->data['Clickout']['linkid'] = $linkid;
         $this->request->data['Clickout']['agentid'] = $agentid;
         $this->request->data['Clickout']['clicktime'] = $clicktime;
         $this->request->data['Clickout']['fromip'] = __getclientip();
         $this->request->data['Clickout']['siteid'] = $siteid;
         $this->request->data['Clickout']['typeid'] = $typeid;
         $this->request->data['Clickout']['url'] = $url;
         $this->request->data['Clickout']['referer'] = $referer;
         $this->Clickout->save($this->request->data);
         /*and redirect to the real url*/
         $this->redirect($url);
     }
 }
Beispiel #4
0
function loadsharingcopy($_file, $dstpath, $accountid, $intro = " ")
{
    $fitwidth = 400;
    $fitheight = 640;
    $hdwidth = 640;
    $hdheight = 1024;
    $thumbwidth = 180;
    $thumbheight = 240;
    /*
     * try to get $dir and $file following namespace rules mentioned above
     */
    $dir = $file = "";
    $zconn = new zmysqlConn();
    do {
        /*
         * get filename by namespace rules
         */
        $fn = get6lenstr();
        $dir = substr($fn, 0, 3);
        $file = substr($fn, 3, 3);
        /*
         * check if $dir + $file exists,
         * if it does, reget them
         */
        $sql = "select * from pictures where fileserial = '{$fn}'";
        $rs = mysql_query($sql, $zconn->dblink) or die("~failed~~db_err:" . mysql_error() . "~~failed~");
    } while (mysql_num_rows($rs) > 0);
    /*
     * see if $dir exists, if not, create it
     */
    if (!is_dir($dstpath . '/' . $dir)) {
        if (!mkdir($dstpath . '/' . $dir)) {
            exit("~failed~~failed to create a directory.~~failed~");
        }
    }
    $filenameparts = explode(".", $_file['name']);
    $fileext = $filenameparts[count($filenameparts) - 1];
    if (count($filenameparts) == 1 || !in_array($fileext, array("jpg", "jpeg", "png", "bmp"))) {
        echo "~failed~~" . $_file['name'] . "is not a well-known (jpg, jpeg, png, bmp) picture format.~~failed~";
        exit;
    }
    $filename = $dstpath . '/' . $dir . '/' . $file . '.' . $fileext;
    if (!copy($_file['tmp_name'], $filename)) {
        echo "~failed~~Failed to copy file '" . $filename . "'.~~failed~";
        exit;
    } else {
        /*
         * could put some picture quality control here.
         */
        list($imgwidth, $imgheight) = getimagesize($filename);
        $source = null;
        switch ($fileext) {
            case "jpg":
            case "jpeg":
                $source = imagecreatefromjpeg($filename);
                break;
            case "png":
                $source = imagecreatefrompng($filename);
                break;
            case "bmp":
                $source = imagecreatefrombmp($filename);
                break;
        }
        if ($source === false) {
            echo "~failed~~Failed to resize the picture(0).~~failed~";
            exit;
        }
        /*
         * save into a thumb one
         */
        list($twidth, $theight) = actualresizedrect($imgwidth, $imgheight, $thumbwidth, $thumbheight);
        $thumb = imagecreatetruecolor($twidth, $theight);
        if ($thumb === false) {
            echo "~failed~~Failed to resize into a thumb(1).~~failed~";
            exit;
        }
        if (!imagecopyresized($thumb, $source, 0, 0, 0, 0, $twidth, $theight, $imgwidth, $imgheight)) {
            echo "~failed~~Failed to resize into a thumb(2).~~failed~";
            exit;
        }
        $jpgfilename = $dstpath . '/' . $dir . '/' . $file . 't.jpg';
        if (!imagejpeg($thumb, $jpgfilename)) {
            echo "~failed~~Failed to resize into a thumb(3).~~failed~";
            exit;
        }
        /*
         * save into a fit one
         */
        list($fwidth, $fheight) = actualresizedrect($imgwidth, $imgheight, $fitwidth, $fitheight);
        $fit = imagecreatetruecolor($fwidth, $fheight);
        if ($fit === false) {
            echo "~failed~~Failed to resize into a fit one(1).~~failed~";
            exit;
        }
        if (!imagecopyresized($fit, $source, 0, 0, 0, 0, $fwidth, $fheight, $imgwidth, $imgheight)) {
            echo "~failed~~Failed to resize into a fit one(2).~~failed~";
            exit;
        }
        $jpgfilename = $dstpath . '/' . $dir . '/' . $file . 'f.jpg';
        if (!imagejpeg($fit, $jpgfilename)) {
            echo "~failed~~Failed to resize into a fit one(3).~~failed~";
            exit;
        }
    }
    if ($_file['error'] == 0 && $_file['size'] > 0) {
        /*
         * if file uploaded and then try to put the information about it into DB
         */
        $ip = __getclientip();
        $sql = sprintf("insert pictures (filename, relpath, time, ip, accountid, fileserial, clicks, likes, dislikes, intro)" . " values ('%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, '%s')", $_file['name'], $dstpath, date('Y-m-d H:i:s'), $ip === false ? '0.0.0.0' : $ip, $accountid, $dir . $file, 0, 0, 0, $intro);
        mysql_query($sql, $zconn->dblink) or die("~failed~~db_err:" . mysql_error() . "~~failed~");
        echo "~successful~File \"" . $_file['name'] . "\" uploaded.~successful~";
    } else {
        echo "~failed~~Something wrong with upload.~~failed~";
    }
}