Пример #1
0
function getConnection()
{
    $host = GetHost();
    $db_user = GetUsername();
    $db_pw = GetPassword();
    $database = GetDatabase();
    $mysqli = new mysqli($host, $db_user, $db_pw, $database);
    $mysqli->set_charset('utf8');
    return $mysqli;
}
Пример #2
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 25/11/15
 * Time: 3:55 PM
 */
function HandleUsernameRequest($Request)
{
    include '../common/controller/Username.php';
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    if (validate_Username_request($Request) == "True") {
        if (GetUsername($Request) == ERROR_DATA_NOT_FOUND) {
            $Response["SUCCESS"] = "True";
        } else {
            $Response["SUCCESS"] = "False";
        }
        return $Response;
    } else {
        $Response["SUCCESS"] = "False";
        $Response["STATUS CODE"] = PAYLOAD_MISSING;
        return $Response;
    }
}
Пример #3
0
function newArticle($titre, $contenu, $categorie)
{
    // Si un utilisateur est connecté
    if (isLoged()) {
        // Requête pour inserer un article dans la table article
        // (contenu, nom, catégorie, auteur)
        $req = 'INSERT INTO Article
                    (
                        contenu_Article,
                        nom_Article,
                        Categorie_Article,
                        Auteur_Article
                    )
                    VALUES
                    (
                        "' . $contenu . '",
                        "' . $titre . '",
                        "' . $categorie . '",
                        "' . GetUsername() . '"
                    )';
        queryDB($req);
    }
}
/**
 * get Owner (username)
 *
 * @param $transfer
 * @return string
 */
function getOwner($transfer)
{
    global $cfg, $db, $transfers;
    if (isset($transfers['owner'][$transfer])) {
        return $transfers['owner'][$transfer];
    } else {
        $uid = (int) getTransferOwnerID($transfer);
        if ($uid > 0) {
            //fast method
            return GetUsername($uid);
        } elseif (isHash($transfer)) {
            $uid = $db->GetOne("SELECT uid FROM tf_transfer_totals WHERE tid=" . $db->qstr($transfer) . " ORDER BY created DESC");
            if ($db->ErrorNo() != 0) {
                dbError($sql);
            }
            $transfers['owner'][$transfer] = GetUsername($uid);
        } else {
            //slower, needed for old transfers (before TFNG)
            // Check log to see what user has a history with this file
            $transfers['owner'][$transfer] = $db->GetOne("SELECT user_id FROM tf_log WHERE file=" . $db->qstr($transfer) . " AND (action=" . $db->qstr($cfg["constants"]["file_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["reset_owner"]) . ") ORDER BY time DESC");
            return $transfers['owner'][$transfer] != "" ? $transfers['owner'][$transfer] : resetOwner($transfer);
            // try and get the owner from the stat file;
        }
    }
}
<?php

session_name('reglogin');
session_start();
include "/export/home/mclaug67/source_html/public_html/awp/PhotoSite/Connect-webuser.php";
include "DB_Functions.php";
$uname = $_SESSION['user_id'];
$dbh = ConnectDB();
echo GetUsername($dbh, $uname);
Пример #6
0
        echo '    <dt style="text-align:center;">Photo ' . htmlspecialchars($thisone->photo_id) . " </dt> \n";
        echo '<div style="text-align:center;">';
        if ($_SESSION['user_id'] == $thisone->user_id or $_SESSION['username'] == "Admin") {
            echo '<input type="button" value="Delete Photo" onclick="deletePic(' . $thisone->photo_id . ')">';
        }
        echo '</div>';
        echo '<dd style="text-align:center;"><a href="./view_full_size.php?photoid=' . $thisone->photo_id . '&filelocation=' . urlencode($thisone->filelocation) . '
		&caption=' . $thisone->caption . '" target="_blank"><img src="' . $thisone->filelocation . '
		" alt="Failure loading image" 
		style="width:auto;height:auto;max-height:500px;max-width:500px;"/> 
		</a><br />';
        echo "<i> " . htmlspecialchars($thisone->caption) . " </i> \n";
        $commentdata = GetPicComments($dbh, $thisone->photo_id);
        echo '<div id= "commentText' . $thisone->photo_id . '">';
        foreach ($commentdata as $comments) {
            $uname = GetUsername($dbh, $comments->user_id);
            echo '<table class="center" id="commentTable' . $comments->comment_id . '">';
            echo '<tr><td><strong>' . $uname . ':</strong> ' . $comments->comment_text;
            if ($uname == $_SESSION['username'] or $_SESSION['username'] == "Admin" or $_SESSION['user_id'] == $thisone->user_id) {
                echo '<input type="button" style="float:right;" value="Delete"
              onclick="deleteComment(' . $comments->comment_id . ')"/>';
            }
            echo '</td></tr>';
            echo '</table>';
        }
        echo '</div>';
        if (isset($_SESSION['username'])) {
            echo '<table class="center">';
            echo "\n<tr><td>Add comment:";
            echo '<input type="text" id="commentInput' . $thisone->photo_id . '">';
            echo '<input type="button" value="Comment"
<?php

// This is used to delete individual user accounts and all associated comments and photos
session_name('reglogin');
session_start();
$userid = $_SESSION['user_id'];
include "/export/home/mclaug67/source_html/public_html/awp/PhotoSite/Connect-webuser.php";
include "DB_Functions.php";
$dbh = ConnectDB();
$username = GetUsername($dbh, $userid);
$baseDir = "/home/mclaug67/public_html/awp/PhotoSite/UPLOADED/archive/" . $username;
$photoList = ListAllPix($dbh, $username);
foreach ($photoList as $photo) {
    $targetname = GetPhotoLocation($dbh, $photo->photo_id);
    if (!file_exists($targetname)) {
        die("<p>File doesn't exist.</p>");
    } else {
        try {
            $junk = RemovePicComments($dbh, $photo->photo_id);
            unlink($targetname);
            RemovePicture($dbh, $photo->photo_id);
        } catch (PDOException $e) {
            die("error deleting photo");
        }
    }
}
#remove user dir
try {
    rmdir($baseDir);
} catch (PDOException $e) {
    die("error removing user");
Пример #8
0
         $tops_cache = $vbulletin->db->query_read("\n\t\t\t\tSELECT \n\t\t\t\t\t{$query_adminid} AS userid\n\t\t\t\t\t,user.username AS username\n\t\t\t\t\t,COUNT(*) AS count\n\t\t\t\t\t,SUM(ABS(donate.amount)) AS total\n\t\t\t\tFROM `" . TABLE_PREFIX . "kbank_donations` AS donate\n\t\t\t\tINNER JOIN `" . TABLE_PREFIX . "user` AS user ON (user.userid = {$query_adminid})\n\t\t\t\tWHERE donate.postid <> 0\n\t\t\t\t\tAND donate.from = 0\n\t\t\t\tGROUP BY userid\n\t\t\t\tORDER BY " . iif($name == 'topaward', 'count', 'total') . " DESC, " . iif($name == 'topaward', 'total', 'count') . " DESC\n\t\t\t");
         $tops = array();
         while ($top = $vbulletin->db->fetch_array($tops_cache)) {
             $tops[] = $top;
         }
         unset($top);
         $vbulletin->db->free_result($tops_cache);
         topChanges($tops, $cache['tops']);
         $cache = array('datetime' => TIMENOW, 'tops' => $tops);
         write_datastore($name, $cache);
     } else {
         $tops = $cache['tops'];
     }
     $top_message = array();
     foreach ($tops as $top) {
         $top_message[] = construct_phrase($vbphrase['kbank_misc_topaward_bit'], GetUsername($top, 'search.php?do=findawardedby&userid='), vb_number_format($top['count']), vb_number_format($top['total'], $vbulletin->kbank['roundup']), $vbulletin->kbank['name']) . topChangeDisplay($top);
     }
 }
 //List all available top
 if (isset($_GET[$vbulletin->kbank['url_varname']]) and !$top_message or $_GET['do'] == $vbulletin->kbank['url_varname']) {
     $url_prefix = $vbulletin->kbank['phpfile'] . "?{$session['sessionurl']}top=";
     $top_message = "<strong>{$vbphrase['kbank_misc_top']}</strong>\n\t\t\t<ul>";
     foreach (array_keys($hour2update) as $type) {
         if (in_array($type, $kBankAdminOnly)) {
             //This type is only for kBank Admin, skip
             continue;
         }
         $top_message .= "<li><a href=\"{$url_prefix}{$type}\">" . $vbphrase["kbank_misc_{$type}"] . "</a></li>";
     }
     if (havePerm($vbulletin->userinfo, KBANK_PERM_ADMIN) and count($kBankAdminOnly)) {
         //Show kBank Admin Only Lists
Пример #9
0
function updateStatFiles($bShowMissing = false)
{
    global $cfg, $db, $client;
    $rpc = Transmission::getInstance($cfg);
    // check if running and get all session variables in cache
    if (!$rpc->session_get()) {
        echo "unable to connect to transmission-daemon\n";
        return;
    }
    $tfs = $rpc->torrent_get_tf();
    if (empty($tfs)) {
        echo "no loaded torrents\n";
        return;
    }
    $sql = "SELECT hash, transfer, sharekill FROM tf_transfers WHERE type='torrent' AND client = 'transmissionrpc'";
    $hashes = array("''");
    foreach ($tfs as $hash => $t) {
        $hashes[] = "'" . strtolower($hash) . "'";
    }
    $sql .= " AND hash IN (" . implode(',', $hashes) . ")";
    $recordset = $db->Execute($sql);
    $hashes = array();
    $sharekills = array();
    while (list($hash, $transfer, $sharekill) = $recordset->FetchRow()) {
        $hash = strtolower($hash);
        $hashes[$hash] = $transfer;
        $sharekills[$hash] = $sharekill;
    }
    $max_ul = 1024.0 * $cfg['max_upload_rate'];
    $max_dl = 1024.0 * $cfg['max_download_rate'];
    //SHAREKILLS Checks
    $nbUpdate = 0;
    foreach ($tfs as $hash => $t) {
        if (!isset($sharekills[$hash])) {
            continue;
        }
        if (($t['status'] == 8 || $t['status'] == 9) && $t['sharing'] > $sharekills[$hash]) {
            $transfer = $hashes[$hash];
            $nbUpdate++;
            if (stopTransmissionTransferCron($hash)) {
                AuditAction($cfg["constants"]["debug"], $client . ": stop error {$transfer}.");
            } else {
                AuditAction($cfg["constants"]["stop_transfer"], $this->client . "-stat. : sharekill stopped {$transfer}");
                // flag the transfer as stopped (in db)
                stopTransferSettings($transfer);
            }
        }
    }
    echo " stopped {$nbUpdate} torrents.\n";
    $nbUpdate = 0;
    $missing = array();
    foreach ($tfs as $hash => $t) {
        if (!isset($hashes[$hash])) {
            if ($bShowMissing) {
                $missing[$t['rpcid']] = $t['name'];
            }
            continue;
        }
        $transfer = $hashes[$hash];
        //file_put_contents($cfg["path"].'.Transmission/'."updateStatFiles4.log",serialize($t));
        $sf = new StatFile($transfer);
        $sf->running = $t['running'];
        if (empty($sf->transferowner)) {
            $uid = getTransferOwnerID($hash);
            if ($uid > 0) {
                $sf->transferowner = GetUsername($uid);
                echo "transfer '{$transfer}' owner fixed to " . $sf->transferowner . " \n";
                $sf->write();
            }
        }
        if ($sf->running) {
            $sharebase = (int) $sharekills[$hash];
            //$sharekill = (int) round(floatval($t['seedRatioLimit']) * 100);
            if ($sharebase > 0 && (int) $sf->seedlimit == 0) {
                AuditAction($cfg["constants"]["debug"], $client . ": changed empty .stat sharekill " . $sf->seedlimit . " to {$sharebase} (from db), {$transfer}.");
                $sf->seedlimit = $sharebase;
            }
            $max_ul = max($t['urate'], $max_ul);
            $max_dl = max($t['drate'], $max_dl);
            $max_share = max($sharebase, $sharekill);
            if ($t['eta'] > 0 || $t['eta'] < -1) {
                $sf->time_left = convertTimeText($t['eta']);
            }
            $sf->percent_done = $t['percentDone'];
            $sf->sharing = round($t['sharing'], 1);
            if ($t['status'] != 9 && $t['status'] != 5) {
                $sf->peers = $t['peers'];
                $sf->seeds = $t['seeds'];
            }
            if ($t['seeds'] >= 0) {
                $sf->seeds = $t['seeds'];
            }
            if ($t['peers'] >= 0) {
                $sf->peers = $t['peers'];
            }
            if ((double) $t['speedDown'] >= 0.0) {
                $sf->down_speed = formatBytesTokBMBGBTB($t['speedDown']) . "/s";
            }
            if ((double) $t['speedUp'] >= 0.0) {
                $sf->up_speed = formatBytesTokBMBGBTB($t['speedUp']) . "/s";
            }
            if ($t['status'] == 8) {
                $sf->percent_done = 100 + $t['sharing'];
                $sf->down_speed = "&nbsp;";
                if (trim($sf->up_speed) == '') {
                    $sf->up_speed = "&nbsp;";
                }
            }
            if ($t['status'] == 9) {
                $sf->percent_done = 100 + $t['sharing'];
                $sf->up_speed = "&nbsp;";
                $sf->down_speed = "&nbsp;";
            }
        } else {
            //Stopped or finished...
            $sf->down_speed = "";
            $sf->up_speed = "";
            $sf->peers = "";
            $sf->time_left = "0";
            if ($t['eta'] < -1) {
                $sf->time_left = "Done in " . convertTimeText($t['eta']);
            } elseif ($sf->percent_done >= 100 && strpos($sf->time_left, 'Done') === false && strpos($sf->time_left, 'Finished') === false) {
                $sf->percent_done = 100;
                $sf->time_left = "Done!";
            }
            if ($sf->sharing == 0) {
                $sf->sharing = round($t['sharing'], 1);
            }
            if (is_file($cfg["transfer_file_path"] . '/' . $transfer . ".pid")) {
                unlink($cfg["transfer_file_path"] . '/' . $transfer . ".pid");
            }
            //if ($sf->percent_done < 100 && $sf->percent_done > 0)
            //	$sf->percent_done = 0 - $sf->percent_done;
        }
        $sf->downtotal = $t['downTotal'];
        $sf->uptotal = $t['upTotal'];
        if ($sf->size == 0) {
            $sf->size = $t['size'];
        }
        if ($sf->seeds = -1) {
        }
        $sf->seeds = '';
        if ($sf->write()) {
            $nbUpdate++;
        }
    }
    $nb = count($tfs);
    echo " updated {$nbUpdate}/{$nb} stat files.\n";
    //fix globall sharekill to maximum of torrents sharekill, other torrent with lower sharekill will be stopped by this cron
    /*
    if (isset($max_share))  {
    	$sharekill = getTransmissionShareKill();
    	if ($max_share > $sharekill) {
    		//set vuze global sharekill to max sharekill value
    		$rpc->session_set( array('seedRatioLimit' => round($max_share / 100, 2)) );
    		if ($cfg['debuglevel'] > 0) {
    			$msg = $client.": changed vuze global sharekill from $sharekill to $max_share.";
    			AuditAction($cfg["constants"]["debug"], $msg);
    			echo $msg."\n";
    		}
    	}
    }
    if ($max_ul > 0) {
    	$vzmaxul = getTransmissionSpeedLimitUpload();
    	if ($cfg['max_upload_rate'] > 0 && $max_ul > 0) {
    		$max_ul = min($max_ul, 1024.0 * $cfg['max_upload_rate']);
    	}
    	if ($vzmaxul != $max_ul) {
    		$max_ul = $max_ul / 1024;
    		$rpc->session_set( array('speed-limit-up' => $max_ul) );
    		if ($cfg['debuglevel'] > 0) {
    			$msg = $client.": tranmission global speed-limit-up from $vzmaxul to $max_ul.";
    			AuditAction($cfg["constants"]["debug"], $msg);
    			echo $msg."\n";
    		}
    	}
    }
    */
    if ($bShowMissing) {
        return $missing;
    }
}