Ejemplo n.º 1
0
function fix_private_photos($s, $uid, $item = null, $cid = 0)
{
    $a = get_app();
    logger('fix_private_photos', LOGGER_DEBUG);
    $site = substr($a->get_baseurl(), strpos($a->get_baseurl(), '://'));
    $orig_body = $s;
    $new_body = '';
    $img_start = strpos($orig_body, '[zmg');
    $img_st_close = $img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false;
    $img_len = $img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/zmg]') : false;
    while ($img_st_close !== false && $img_len !== false) {
        $img_st_close++;
        // make it point to AFTER the closing bracket
        $image = substr($orig_body, $img_start + $img_st_close, $img_len);
        logger('fix_private_photos: found photo ' . $image, LOGGER_DEBUG);
        if (stristr($image, $site . '/photo/')) {
            // Only embed locally hosted photos
            $replace = false;
            $i = basename($image);
            $x = strpos($i, '-');
            if ($x) {
                $res = substr($i, $x + 1);
                $i = substr($i, 0, $x);
                $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `scale` = %d AND `uid` = %d", dbesc($i), intval($res), intval($uid));
                if (count($r)) {
                    // Check to see if we should replace this photo link with an embedded image
                    // 1. No need to do so if the photo is public
                    // 2. If there's a contact-id provided, see if they're in the access list
                    //    for the photo. If so, embed it.
                    // 3. Otherwise, if we have an item, see if the item permissions match the photo
                    //    permissions, regardless of order but first check to see if they're an exact
                    //    match to save some processing overhead.
                    if (has_permissions($r[0])) {
                        if ($cid) {
                            $recips = enumerate_permissions($r[0]);
                            if (in_array($cid, $recips)) {
                                $replace = true;
                            }
                        } elseif ($item) {
                            if (compare_permissions($item, $r[0])) {
                                $replace = true;
                            }
                        }
                    }
                    if ($replace) {
                        $data = $r[0]['data'];
                        $type = $r[0]['type'];
                        // If a custom width and height were specified, apply before embedding
                        if (preg_match("/\\[zmg\\=([0-9]*)x([0-9]*)\\]/is", substr($orig_body, $img_start, $img_st_close), $match)) {
                            logger('fix_private_photos: scaling photo', LOGGER_DEBUG);
                            $width = intval($match[1]);
                            $height = intval($match[2]);
                            $ph = photo_factory($data, $type);
                            if ($ph->is_valid()) {
                                $ph->scaleImage(max($width, $height));
                                $data = $ph->imageString();
                                $type = $ph->getType();
                            }
                        }
                        logger('fix_private_photos: replacing photo', LOGGER_DEBUG);
                        $image = 'data:' . $type . ';base64,' . base64_encode($data);
                        logger('fix_private_photos: replaced: ' . $image, LOGGER_DATA);
                    }
                }
            }
        }
        $new_body = $new_body . substr($orig_body, 0, $img_start + $img_st_close) . $image . '[/zmg]';
        $orig_body = substr($orig_body, $img_start + $img_st_close + $img_len + strlen('[/zmg]'));
        if ($orig_body === false) {
            $orig_body = '';
        }
        $img_start = strpos($orig_body, '[zmg');
        $img_st_close = $img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false;
        $img_len = $img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/zmg]') : false;
    }
    $new_body = $new_body . $orig_body;
    return $new_body;
}
Ejemplo n.º 2
0
<?php

//TODO: Move these to a helper as they'll be shared here and with the tasks page
function taskhrefedit($nr, $date)
{
    echo "<a href=\"/tasks/char/{$date}/{$nr}\" title=\"Click to see tasks for this Character\">";
}
function editqueuehrefedit($nr)
{
    echo "<a href=\"/queue/edit/{$nr}\" title=\"Click to edit this Queue\">";
}
function itemhrefedit($nr)
{
    echo "<a href=\"/item/view/{$nr}\" title=\"Click to open Database\">";
}
$rights = has_permissions($permissions, "Administrator,EditQueue");
?>
<div class="tytul">Corporate Queue <?php 
echo $year . "-" . $month;
?>
</div>
<?php 
switch ($month) {
    case 1:
        $NEXTMONTH = str_pad(2, 2, "0", STR_PAD_LEFT);
        $NEXTYEAR = $year;
        $PREVMONTH = 12;
        $PREVYEAR = $year - 1;
        break;
    case 12:
        $NEXTMONTH = str_pad(1, 2, "0", STR_PAD_LEFT);
Ejemplo n.º 3
0
function fault()
{
    exit;
}
if (!isset($_GET["file"])) {
    fault();
}
$name = $_GET["file"];
if (substr($name, 0, 4) == "auth") {
    fault();
}
if (!preg_match("/^[a-zA-Z0-9-. _]*\$/i", $name)) {
    fault();
}
$file = $datafolder . $name;
if (!file_exists($file)) {
    if (!has_permissions()) {
        fault();
    }
    $file = $datafolder . "auth-" . $name;
    if (!file_exists($file)) {
        fault();
    }
}
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($file)) {
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT', true, 304);
} else {
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT', true, 200);
    header('Content-Length: ' . filesize($file));
    echo file_get_contents($file);
}
Ejemplo n.º 4
0
<?php

/*
############################################
##  MIDDIX FILE LIBRARY                   ##
##  By Alex                               ##
##  Directory delete by lixlpixel         ##
############################################
*/
session_start();
include "../Core/filepermissions.php";
if ($_SESSION["User_Loggedin"]) {
    $action = $_REQUEST["a"];
    $filepath = urldecode($_REQUEST["f"]);
    $fileperms = has_permissions($filepath);
    $filepath = "../." . $fileperms[1];
    if ($fileperms[0][0]) {
        $ufilepath = $filepath;
    } else {
        $ufilepath = "\$";
    }
    if (!$fileperms[0][1]) {
        $filepath = "///";
    }
    if ($action == "md") {
        mkdir($filepath);
    }
    if ($action == "w") {
        $contents = str_replace("&#43;", "+", urldecode($_REQUEST["c"]));
        file_put_contents($filepath, stripslashes($contents));
    }
Ejemplo n.º 5
0
function fix_private_photos($s, $uid, $item = null, $cid = 0)
{
    $a = get_app();
    logger('fix_private_photos', LOGGER_DEBUG);
    $site = substr($a->get_baseurl(), strpos($a->get_baseurl(), '://'));
    if (preg_match("/\\[img(.*?)\\](.*?)\\[\\/img\\]/is", $s, $matches)) {
        $image = $matches[2];
        logger('fix_private_photos: found photo ' . $image, LOGGER_DEBUG);
        if (stristr($image, $site . '/photo/')) {
            $replace = false;
            $i = basename($image);
            $i = str_replace('.jpg', '', $i);
            $x = strpos($i, '-');
            if ($x) {
                $res = substr($i, $x + 1);
                $i = substr($i, 0, $x);
                $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` = %d AND `uid` = %d", dbesc($i), intval($res), intval($uid));
                if (count($r)) {
                    // Check to see if we should replace this photo link with an embedded image
                    // 1. No need to do so if the photo is public
                    // 2. If there's a contact-id provided, see if they're in the access list
                    //    for the photo. If so, embed it.
                    // 3. Otherwise, if we have an item, see if the item permissions match the photo
                    //    permissions, regardless of order but first check to see if they're an exact
                    //    match to save some processing overhead.
                    // Currently we only embed one private photo per message so as not to hit import
                    // size limits at the receiving end.
                    // To embed multiples, we would need to parse out the embedded photos on message
                    // receipt and limit size based only on the text component. Would also need to
                    // ignore all photos during bbcode translation and item localisation, as these
                    // will hit internal regex backtrace limits.
                    if (has_permissions($r[0])) {
                        if ($cid) {
                            $recips = enumerate_permissions($r[0]);
                            if (in_array($cid, $recips)) {
                                $replace = true;
                            }
                        } elseif ($item) {
                            if (compare_permissions($item, $r[0])) {
                                $replace = true;
                            }
                        }
                    }
                    if ($replace) {
                        logger('fix_private_photos: replacing photo', LOGGER_DEBUG);
                        $s = str_replace($image, 'data:image/jpg;base64,' . base64_encode($r[0]['data']), $s);
                        logger('fix_private_photos: replaced: ' . $s, LOGGER_DATA);
                    }
                }
            }
        }
    }
    return $s;
}
Ejemplo n.º 6
0
                echo $point->hrsPerPoint;
                echo "</a>";
            }
            ?>
                                        </td></tr>
                                <?php 
        }
        ?>
                            </table>

                            <strong>1 point = <?php 
        echo number_format($ONEPOINT, 2, $DECIMAL_SEP, $THOUSAND_SEP);
        ?>
 ISK</strong>
                            <?php 
        if (has_permissions($permissions, "Administrator")) {
            ?>
                                <input type="button" value="Edit" onclick="location.href = '?id=5&id2=0';">
                            <?php 
        }
        ?>
                            <br/>
                            <?php 
        $pointsDisplayed = true;
    }
    ?>

                    </td><td width="60%" style="vertical-align: top;">

                        <?php 
    $sumstat = 0.0;
Ejemplo n.º 7
0
 public function loadMenu($menuConfigs)
 {
     $this->benchmark->mark('LMeveControllerLoadMenu_start');
     $menu = '';
     foreach ($menuConfigs as $menuConfig) {
         $class = 'menu';
         if ($this->getName() === strtolower($menuConfig['name'])) {
             $class = 'menua';
         }
         if (has_permissions($this->data['permissions'], "Administrator," . $menuConfig['rootPerm'])) {
             $menu = $menu . '<td class="' . $class . '"> <a href="' . $menuConfig['path'] . '">' . $menuConfig['name'] . '</a><br></td>';
         }
     }
     $this->data['menu'] = $menu;
     $this->benchmark->mark('LMeveControllerLoadMenu_end');
 }
Ejemplo n.º 8
0
            $destination_folder = $destination_folder . '/';
        }
        $vzip = new SimpleUnzip($filename);
        foreach ($vzip->Entries as $extr) {
            $path = $extr->Path;
            $path_folder = explode('/', $path);
            $new_path = '';
            foreach ($path_folder as $folder) {
                $new_path .= $folder . '/';
                $to_create = $destination_folder . $new_path;
                if (substr($to_create, -1) == '/') {
                    $to_create = substr($to_create, 0, strlen($to_create) - 1);
                }
                @mkdir($to_create, 0777);
            }
            $new_path = '';
            $filev = fopen($destination_folder . $extr->Path . '/' . $extr->Name, 'w');
            fwrite($filev, $extr->Data);
            fclose($filev);
        }
    }
    $filepath = urldecode($_REQUEST["t"]);
    $fileperms = has_permissions($filepath);
    $filepath = $fileperms[1];
    $zippath = urldecode($_REQUEST["z"]);
    $zipperms = has_permissions($zippath);
    $zippath = $zipperms[1];
    if ($fileperms[0][1] && $zipperms[0][0]) {
        unzipFile("../../" . $zippath, "../../" . $filepath);
    }
}
Ejemplo n.º 9
0
                <form method="get" action="/database/orechart.html">
                    <input type="submit" value="Ore Chart" />
                </form>
            </td>
        <?php 
}
?>
        <?php 
if (has_permissions($permissions, "Administrator,ViewProfitCalc")) {
    ?>
            <td>
                <form method="get" action="/database/profitexplorer.html">
                    <input type="submit" value="Profit Explorer" />
                </form>
            </td>
        <?php 
}
?>
        <?php 
if (has_permissions($permissions, "Administrator,ViewProfitCalc")) {
    ?>
            <td>
                <form method="get" action="/database/profitchart.html">
                    <input type="submit" value="Profit Chart" title="WARNING: it can take a very long time to load!"/>
                </form>
            </td>
        <?php 
}
?>
    </tr>
</table>
Ejemplo n.º 10
0
 private function requireViewQueue()
 {
     if (!has_permissions($this->data['permissions'], 'Administrator,ViewQueue')) {
         $this->template->load('layout', 'unauthorized');
     }
 }