Пример #1
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
define('ROOT', dirname(dirname(__FILE__)));
define('CORE_PATH', ROOT . DS . 'common');
session_start();
require_once CORE_PATH . DS . 'config.php';
require_once CORE_PATH . DS . 'basic_functions.php';
define('CLASSES_PATH', CORE_PATH . DS . 'classes');
spl_autoload_register('myautoload');
fixUrl($_SERVER['REQUEST_URI']);
//autoredirect($_SERVER['REQUEST_URI']);
//ob_start();
//$content = ob_get_clean();
//render();
Пример #2
0
$db = new PDO($dbDsn, $dbUser, $dbPass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_PERSISTENT => false));
$stmt = $db->prepare('INSERT INTO commits' . '(c_hash, c_author, c_date, c_message, c_url, c_project_name' . ', c_repository_name, c_repository_url, c_branch)' . ' VALUES' . '(:c_hash, :c_author, :c_date, :c_message, :c_url, :c_project_name' . ', :c_repository_name, :c_repository_url, :c_branch)');
$branch = $payload->ref;
if (substr($branch, 0, 11) == 'refs/heads/') {
    $branch = substr($branch, 11);
}
$project = '';
if (substr($payload->repository->url, 0, 4) == 'git@') {
    //"url": "git@gitlab.example.org:test\/jira-test.git"
    list($dummy, $urlPath) = explode(':', $payload->repository->url, 2);
    list($project, $dummy) = explode('/', $urlPath, 2);
}
$count = 0;
foreach ($payload->commits as $commit) {
    ++$count;
    $ok = $stmt->execute(array(':c_hash' => $commit->id, ':c_author' => $commit->author->name . ' <' . $commit->author->email . '>', ':c_date' => $commit->timestamp, ':c_message' => $commit->message, ':c_url' => fixUrl($commit->url), ':c_project_name' => $project, ':c_repository_name' => $payload->repository->name, ':c_repository_url' => fixUrl($payload->repository->url), ':c_branch' => $branch));
    if (!$ok) {
        handleError($stmt);
        continue;
    }
    linkKeywordsAndCommit(getKeywordsFromMessage($commit->message), $db->lastInsertId(), $db);
}
/**
 * Gitorious 3.0 has a bug: urls are broken when you use https.
 *
 * @param string $url URL to fix
 *
 * @return string Fixed url
 */
function fixUrl($url)
{
Пример #3
0
function tfu_info($file)
{
    global $use_image_magic;
    unset($_SESSION['TFU_LAST_UPLOADS']);
    $_SESSION['TFU_LAST_PREVIEW'] = fixUrl(getRootUrl() . $file);
    echo '&size=' . filesize($file);
    // we check if the image can be resized
    if (is_supported_tfu_image($file)) {
        set_error_handler('on_error_no_output');
        // is needed because error are most likly but we don't care about fields we don't even know
        $oldsize = @getimagesize($file);
        set_error_handler('on_error');
        if ($oldsize) {
            if (isMemoryOk($oldsize, "")) {
                echo '&hasPreview=true&tfu_x=' . $oldsize[0] . '&tfu_y=' . $oldsize[1];
                // has preview!
            } else {
                echo '&hasPreview=error';
                // too big! - same error massage as hasPreview=false
            }
            return;
        }
        echo '&hasPreview=false';
        // no image!
    }
    if (preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file) && $use_image_magic && file_exists(dirname(__FILE__) . '/thumbs') && is_writable(dirname(__FILE__) . '/thumbs')) {
        // check if pdf
        echo '&hasPreview=true&tfu_x=1000&tfu_y=1000';
        // has preview! - pdfs are max 1000x1000';
        return;
    }
    echo '&hasPreview=false';
}
Пример #4
0
        $json .= '"' . $location . '":[';
        $count = 0;
        $count_menu_items = count($menu_items);
        foreach ((array) $menu_items as $key => $menu_item) {
            $check_id = $menu_item->db_id;
            $parent = "No";
            foreach ((array) $menu_items as $value => $menu_sub) {
                if ($check_id == $menu_sub->menu_item_parent) {
                    $parent = "Yes";
                    break;
                }
            }
            if ($menu_item->menu_item_parent > 0) {
                $json .= '{' . '"' . 'name' . '":' . '"' . esc_attr($menu_item->title) . '",' . '"' . 'link' . '":' . '"' . esc_attr(fixUrl($menu_item->url)) . '",' . '"' . 'id' . '":' . '"' . $menu_item->db_id . '",' . '"' . 'parent_id' . '":' . '"' . $menu_item->menu_item_parent . '",' . '"Parent":' . '"No"' . '}';
            } else {
                $json .= '{' . '"' . 'name' . '":' . '"' . esc_attr($menu_item->title) . '",' . '"' . 'link' . '":' . '"' . esc_attr(fixUrl($menu_item->url)) . '",' . '"' . 'id' . '":' . '"' . $menu_item->db_id . '",' . '"Parent":' . '"' . $parent . '"' . '}';
            }
            if ($count != $count_menu_items - 1) {
                $json .= ",";
            }
            $count++;
        }
        $json .= '],';
    }
}
$json = rtrim($json, ',');
$json .= '});';
print prettyPrint($json);
function fixUrl($url)
{
    if (false === strpos($url, '//')) {
Пример #5
0
        restore_split_files($_SESSION['TFU_LAST_UPLOADS']);
        resize_merged_files($_SESSION['TFU_LAST_UPLOADS'], $size);
    }
    // E-mail section
    // we only send an email for the last item of an upload cycle
    if ($upload_notification_email != '' && $remaining == 0) {
        $youremail = $upload_notification_email_from;
        $email = $upload_notification_email;
        $submailheaders = "From: {$youremail}\n";
        $submailheaders .= "Reply-To: {$youremail}\n";
        $submailheaders .= 'Content-Type: text/plain; charset=UTF-8';
        $subject = $upload_notification_email_subject;
        $filestr = "\n\n";
        foreach ($_SESSION['TFU_LAST_UPLOADS'] as $filename) {
            if ($upload_notification_use_full_path) {
                $filestr = $filestr . tfu_urlencode(fixUrl(getRootUrl() . $path_fix . $filename)) . "\n";
            } else {
                $filestr = $filestr . str_replace('./', '', str_replace('../', '', $filename)) . "\n";
            }
        }
        if ($filestr == "\n\n") {
            $filestr .= 'Please check your setup. No files where uploaded.';
        }
        $username = isset($_SESSION['TFU_USER']) ? $_SESSION['TFU_USER'] : $_SERVER['REMOTE_ADDR'];
        // if we don't have a use we use the IP
        $mailtext = sprintf($upload_notification_email_text, $username, $filestr);
        @mail($email, html_entity_decode($subject), html_entity_decode($mailtext), $submailheaders);
    }
    // end of e-mail section
    store_temp_session();
} else {
Пример #6
0
     resize_merged_files($_SESSION['TFU_LAST_UPLOADS'], $size);
 }
 // E-mail section
 // we only send an email for the last item of an upload cycle and if the e-mail plugin is not used.
 if ($upload_notification_email != '' && $remaining == 0 && !$email_plugin) {
     $submailheaders = "From: {$upload_notification_email_from}\n";
     $submailheaders .= "Reply-To: {$upload_notification_email_from}\n";
     $submailheaders .= "Return-Path: {$upload_notification_email_from}\n";
     if ($fix_utf8 != '') {
         $submailheaders .= 'Content-Type: text/plain; charset=' . $fix_utf8;
     }
     $subject = fix_decoding($upload_notification_email_subject, $fix_utf8);
     $filestr = "\n\n";
     foreach ($_SESSION['TFU_LAST_UPLOADS'] as $filename) {
         if ($upload_notification_use_full_path) {
             $filestr = $filestr . space_enc(fixUrl(getRootUrl() . $path_fix . $filename)) . "\n";
         } else {
             $filestr = $filestr . str_replace('./', '', str_replace('../', '', $filename)) . "\n";
         }
     }
     if ($filestr == "\n\n") {
         $filestr .= 'Please check your setup. No files where uploaded.';
     }
     $username = isset($_SESSION['TFU_USER']) ? $_SESSION['TFU_USER'] : $_SERVER['REMOTE_ADDR'];
     // if we don't have a use we use the IP
     $mailtext = sprintf(fix_decoding($upload_notification_email_text, $fix_utf8), $username, $filestr);
     if (isset($_SESSION['TFU_PRE_UPLOAD_DATA'])) {
         $mailtext .= "\n\n" . $_SESSION['TFU_PRE_UPLOAD_DATA'];
     }
     @mail($upload_notification_email, html_entity_decode($subject), html_entity_decode($mailtext), $submailheaders);
 }
Пример #7
0
                            </td>  
                            <td class="project_name">
                                <a href='<?php 
        echo TASKS_LIST_URL;
        echo $project['ID'];
        ?>
/'><?php 
        echo $project['NAME'];
        ?>
</a>
                                <?php 
        if ($project['PROPERTIES']["URL"]["VALUE"]) {
            ?>
<br>
                                <small><a target="_blank" href="<?php 
            echo fixUrl($project['PROPERTIES']["URL"]["VALUE"]);
            ?>
"><?php 
            echo $project['PROPERTIES']["URL"]["VALUE"];
            ?>
</a></small> 
                                <?php 
        }
        ?>
                            </td>
                            <td class="big-avatars circle_avatars">
                                <?php 
        if ($project['PROPERTIES']['CUSTOMER']['VALUE']) {
            ?>
 
                                <ul class="list-inline">
Пример #8
0
         if (isset($_GET['big'])) {
             send_thumb($file, 90, 440, 280);
             // big preview 4x bigger!
         } else {
             send_thumb($file, 90, 80, 55);
             // small preview
         }
     } else {
         return;
         // we return nothing if no image.
     }
 } else {
     if ($action == "info") {
         // get infos about a file
         unset($_SESSION["TFU_LAST_UPLOADS"]);
         $_SESSION["TFU_LAST_PREVIEW"] = fixUrl(getRootUrl() . $file);
         echo "&size=" . filesize($file);
         // we check if the image can be resized
         if (is_supported_tfu_image($file)) {
             set_error_handler("on_error_no_output");
             // is needed because error are most likly but we don't care about fields we don't even know
             $oldsize = @getimagesize($file);
             set_error_handler("on_error");
             if ($oldsize) {
                 if (isMemoryOk($oldsize, "")) {
                     echo "&hasPreview=true&tfu_x=" . $oldsize[0] . "&tfu_y=" . $oldsize[1];
                     // has preview!
                 } else {
                     echo "&hasPreview=error";
                     // too big! - same error massage as hasPreview=false
                 }