コード例 #1
1
unset($output);
// Calling arp without the full path was reported to fail on some systems
// Use the builtin unix command "type" to tell us where the command is
$arp_command = '';
$result = explode(" ", ZM_PATH_ARP);
if (!is_executable($result[0])) {
    if (ZM_PATH_ARP) {
        Warning("User assigned ARP tool not found. Verify ZM_PATH_ARP points to a valid arp tool and is executable by the web user account.");
    }
    $result = exec('type -p arp', $output, $status);
    if ($status) {
        Warning("Unable to determine path for arp command, type -p arp returned '{$status}' output is: " . implode("\n", $output));
        unset($output);
        $result = exec('which arp', $output, $status);
        if ($status) {
            Warning("Unable to determine path for arp command, which arp returned '{$status}'");
            if (file_exists('/usr/sbin/arp')) {
                $arp_command = '/usr/sbin/arp -a';
            }
        } else {
            $arp_command = $output[0] . " -a";
        }
    } else {
        $arp_command = $output[0] . " -a";
    }
} else {
    $arp_command = ZM_PATH_ARP;
}
// Now that we know where arp is, call it using the full path
unset($output);
$result = exec(escapeshellcmd($arp_command), $output, $status);
コード例 #2
0
ファイル: image.php プロジェクト: moeiscool/ZoneMinder-video
        if (!$imageOk) {
            $errorText = "No image permissions";
        }
    }
}
if (true) {
    // Simple version
    if ($errorText) {
        Error($errorText);
    } else {
        readfile(ZM_DIR_EVENTS . '/' . $path);
    }
} else {
    // Not so simple version
    if (!function_exists("imagecreatefromjpeg")) {
        Warning("The imagecreatefromjpeg function is not present, php-gd not installed?");
    }
    if (!$errorText) {
        if (!($image = imagecreatefromjpeg(ZM_DIR_EVENTS . '/' . $path))) {
            $errorText = "Can't load image";
            $error = error_get_last();
            Error($error['message']);
        }
    }
    if ($errorText) {
        if (!($image = imagecreatetruecolor(160, 120))) {
            $error = error_get_last();
            Error($error['message']);
        }
        if (!($textColor = imagecolorallocate($image, 255, 0, 0))) {
            $error = error_get_last();
コード例 #3
0
ファイル: makefont.php プロジェクト: Grasia/bolotweet
function GetInfoFromType1($file, $embed, $map)
{
    // Return informations from a Type1 font
    if ($embed) {
        $f = fopen($file, 'rb');
        if (!$f) {
            Error('Can\'t open font file');
        }
        // Read first segment
        $a = unpack('Cmarker/Ctype/Vsize', fread($f, 6));
        if ($a['marker'] != 128) {
            Error('Font file is not a valid binary Type1');
        }
        $size1 = $a['size'];
        $data = fread($f, $size1);
        // Read second segment
        $a = unpack('Cmarker/Ctype/Vsize', fread($f, 6));
        if ($a['marker'] != 128) {
            Error('Font file is not a valid binary Type1');
        }
        $size2 = $a['size'];
        $data .= fread($f, $size2);
        fclose($f);
        $info['Data'] = $data;
        $info['Size1'] = $size1;
        $info['Size2'] = $size2;
    }
    $afm = substr($file, 0, -3) . 'afm';
    if (!file_exists($afm)) {
        Error('AFM font file not found: ' . $afm);
    }
    $a = file($afm);
    if (empty($a)) {
        Error('AFM file empty or not readable');
    }
    foreach ($a as $line) {
        $e = explode(' ', rtrim($line));
        if (count($e) < 2) {
            continue;
        }
        $entry = $e[0];
        if ($entry == 'C') {
            $w = $e[4];
            $name = $e[7];
            $cw[$name] = $w;
        } elseif ($entry == 'FontName') {
            $info['FontName'] = $e[1];
        } elseif ($entry == 'Weight') {
            $info['Weight'] = $e[1];
        } elseif ($entry == 'ItalicAngle') {
            $info['ItalicAngle'] = (int) $e[1];
        } elseif ($entry == 'Ascender') {
            $info['Ascender'] = (int) $e[1];
        } elseif ($entry == 'Descender') {
            $info['Descender'] = (int) $e[1];
        } elseif ($entry == 'UnderlineThickness') {
            $info['UnderlineThickness'] = (int) $e[1];
        } elseif ($entry == 'UnderlinePosition') {
            $info['UnderlinePosition'] = (int) $e[1];
        } elseif ($entry == 'IsFixedPitch') {
            $info['IsFixedPitch'] = $e[1] == 'true';
        } elseif ($entry == 'FontBBox') {
            $info['FontBBox'] = array((int) $e[1], (int) $e[2], (int) $e[3], (int) $e[4]);
        } elseif ($entry == 'CapHeight') {
            $info['CapHeight'] = (int) $e[1];
        } elseif ($entry == 'StdVW') {
            $info['StdVW'] = (int) $e[1];
        }
    }
    if (!isset($info['FontName'])) {
        Error('FontName missing in AFM file');
    }
    $info['Bold'] = isset($info['Weight']) && preg_match('/bold|black/i', $info['Weight']);
    if (isset($cw['.notdef'])) {
        $info['MissingWidth'] = $cw['.notdef'];
    } else {
        $info['MissingWidth'] = 0;
    }
    $widths = array_fill(0, 256, $info['MissingWidth']);
    for ($c = 0; $c <= 255; $c++) {
        $name = $map[$c]['name'];
        if ($name != '.notdef') {
            if (isset($cw[$name])) {
                $widths[$c] = $cw[$name];
            } else {
                Warning('Character ' . $name . ' is missing');
            }
        }
    }
    $info['Widths'] = $widths;
    return $info;
}
コード例 #4
0
ファイル: logger.php プロジェクト: moeiscool/ZoneMinder-video
 public function databaseLevel($databaseLevel = NULL)
 {
     if (!is_null($databaseLevel)) {
         $databaseLevel = $this->limit($databaseLevel);
         if ($this->databaseLevel != $databaseLevel) {
             $this->databaseLevel = $databaseLevel;
             if ($this->databaseLevel > self::NOLOG) {
                 if ((include_once 'database.php') === FALSE) {
                     $this->databaseLevel = self::NOLOG;
                     Warning("Unable to write log entries to DB, database.php not found");
                 }
             }
         }
     }
     return $this->databaseLevel;
 }
コード例 #5
0
ファイル: ServiceManager.php プロジェクト: marco-c/peter.sh
 public function scheduleTask($intervalString, $callback)
 {
     $interval = DateInterval::createFromDateString($intervalString);
     $seconds = $interval->s + $interval->i * 60 + $interval->h * 60 * 60 + $interval->d * 60 * 60 * 24 + $interval->m * 60 * 60 * 24 * 30.25 + $interval->y * 60 * 60 * 24 * 365;
     if ($interval === false || $seconds <= 0) {
         Warning('Scheduled task for service "' . $this->m_currentService . '" has an invalid interval: "' . $intervalString . '"');
         return;
     }
     if (!is_callable($callback)) {
         Warning('Scheduled task for service "' . $this->m_currentService . '" has an invalid callback.');
         return;
     }
     $unique_id = sha1($seconds . implode(' ', $callback));
     $this->m_tasks[] = array('interval' => $seconds, 'callback' => $callback, 'service' => $this->m_currentService, 'unique_id' => $unique_id);
 }
コード例 #6
0
ファイル: functions.php プロジェクト: schrorg/ZoneMinder
function canStreamApplet()
{
    if (ZM_OPT_CAMBOZOLA && !file_exists(ZM_PATH_WEB . '/' . ZM_PATH_CAMBOZOLA)) {
        Warning("ZM_OPT_CAMBOZOLA is enabled, but the system cannot find " . ZM_PATH_WEB . "/" . ZM_PATH_CAMBOZOLA);
    }
    return ZM_OPT_CAMBOZOLA && file_exists(ZM_PATH_WEB . '/' . ZM_PATH_CAMBOZOLA);
}
コード例 #7
0
ファイル: Event.php プロジェクト: schrorg/ZoneMinder
 public function delete()
 {
     dbQuery('DELETE FROM Events WHERE Id = ?', array($this->{'Id'}));
     if (!ZM_OPT_FAST_DELETE) {
         dbQuery('DELETE FROM Stats WHERE EventId = ?', array($this->{'Id'}));
         dbQuery('DELETE FROM Frames WHERE EventId = ?', array($this->{'Id'}));
         if (ZM_USE_DEEP_STORAGE) {
             # Assumption: All events haev a start time
             $start_date = date_parse($this->{'StartTime'});
             $start_date['year'] = $start_date['year'] % 100;
             $Storage = $this->Storage();
             # So this is  because ZM creates a link under teh day pointing to the time that the event happened.
             $eventlink_path = $Storage->Path() . '/' . $this->Link_Path();
             if ($id_files = glob($eventlink_path)) {
                 # I know we are using arrays here, but really there can only ever be 1 in the array
                 $eventPath = preg_replace('/\\.' . $event['Id'] . '$/', readlink($id_files[0]), $id_files[0]);
                 deletePath($eventPath);
                 deletePath($id_files[0]);
                 $pathParts = explode('/', $eventPath);
                 for ($i = count($pathParts) - 1; $i >= 2; $i--) {
                     $deletePath = join('/', array_slice($pathParts, 0, $i));
                     if (!glob($deletePath . "/*")) {
                         deletePath($deletePath);
                     }
                 }
             } else {
                 Warning("Found no event files under {$eventlink_path}");
             }
             # end if found files
         } else {
             $eventPath = $this->Path();
             deletePath($eventPath);
         }
         # USE_DEEP_STORAGE OR NOT
     }
     # ! ZM_OPT_FAST_DELETE
 }
コード例 #8
0
ファイル: CommandLineFlags.php プロジェクト: marco-c/peter.sh
 private function parsePreProcessorLine($filename, $line)
 {
     $type = substr($line, 1, strcspn($line, " \t") - 1);
     $text = trim(substr($line, strlen($type) + 1));
     switch ($type) {
         case 'if':
         case 'ifdef':
             $directive = $this->parsePreProcessorDirective($filename, $text, false);
             if ($directive === false) {
                 return false;
             }
             array_push($this->m_preProcessorStack, $directive);
             break;
         case 'ifndef':
             $directive = $this->parsePreProcessorDirective($filename, $text, true);
             if ($directive === false) {
                 return false;
             }
             array_push($this->m_preProcessorStack, $directive);
             break;
         case 'elif':
         case 'else':
             if (!count($this->m_preProcessorStack)) {
                 Warning('CommandLineFlags: Invalid pre-processor directive nesting level in "' . $filename . '" (elif/else).');
                 return false;
             }
             $conditions = array_pop($this->m_preProcessorStack);
             foreach ($conditions as &$condition) {
                 $condition['negate'] = !$condition['negate'];
             }
             if ($type == 'elif') {
                 $additionalConditions = $this->parsePreProcessorDirective($filename, $text, false);
                 if ($additionalConditions === false) {
                     return false;
                 }
                 foreach ($additionalConditions as $condition) {
                     $conditions[] = $condition;
                 }
             }
             array_push($this->m_preProcessorStack, $conditions);
             break;
         case 'endif':
             if (!count($this->m_preProcessorStack)) {
                 Warning('CommandLineFlags: Invalid pre-processor directive nesting level in "' . $filename . '" (endif).');
                 return false;
             }
             array_pop($this->m_preProcessorStack);
             break;
         case 'include':
             // Valid pre-processor directives, but we don't need them and thus ignore them.
             break;
         default:
             Warning('CommandLineFlags: Unrecognized pre-processor directive: ' . $type . ' (in "' . $filename . '").');
             return false;
     }
     return true;
 }
コード例 #9
0
ファイル: index.php プロジェクト: renzg/JAWStats
if (isset($g_aConfig["parts"])) {
    $aParts = explode(",", $g_aConfig["parts"]);
} else {
    $aParts[0] = "";
}
$clsAWStats = array();
$arrMissingParts = array();
foreach ($aParts as $part) {
    $dot_part = "";
    if (strlen($part) > 0) {
        $dot_part = "." . $part;
    }
    // create class
    $clsAWStats[$part] = new clsAWStats($g_sConfig . $dot_part, array_key_exists("statspath", $g_aConfig) ? $g_aConfig["statspath"] : NULL, array_key_exists("statsname", $g_aConfig) ? $g_aConfig["statsname"] : NULL, date("Y", $g_aLogFiles[$g_iThisLog][0]), date("n", $g_aLogFiles[$g_iThisLog][0]));
    if ($clsAWStats[$part]->bLoaded != true) {
        Warning(WARN_MISSING_PART, $part, $clsAWStats[$part]->sFileName);
        $arrMissingParts[$part] = $clsAWStats[$part]->sFileName;
    } else {
        $bHaveLog = true;
    }
}
if (!$bHaveLog) {
    Error("CannotOpenLog", $clsAWStats[$aParts[0]]->sFileName);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title><?php 
コード例 #10
0
ファイル: class.Park.php プロジェクト: jfefes/ORK3
 public function SetParkDetails($request)
 {
     logtrace("SetParkDetails", $request);
     $response = array();
     $this->park->clear();
     if (trimlen($request['Name']) > 0) {
         $this->park->name = trim($request['Name']);
         if ($this->park->find()) {
             if ($this->park->park_id != $request['ParkId']) {
                 return InvalidParameter('This park name already exists.');
             }
         }
     }
     $this->park->clear();
     $this->park->park_id = $request['ParkId'];
     if ($this->park->find()) {
         if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $request['ParkId'], AUTH_EDIT)) {
             $this->log->Write('Park', $mundane_id, LOG_EDIT, $request);
             $this->park->modified = date("Y-m-d H:i:s", time());
             if (Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $this->park->kingdom_id, AUTH_EDIT)) {
                 $this->park->name = trimlen($request['Name']) == 0 ? $this->park->name : $request['Name'];
                 $this->park->abbreviation = trimlen($request['Abbreviation']) == 0 ? $this->park->abbreviation : $request['Abbreviation'];
                 $parktitle = new yapo($this->db, DB_PREFIX . 'parktitle');
                 $parktitle->clear();
                 if (isset($request['ParkTitleId']) && $request['ParkTitleId'] != $this->park->parktitle_id) {
                     $parktitle->parktitle_id = $request['ParkTitleId'];
                     if ($parktitle->find()) {
                         $this->park->parktitle_id = $request['ParkTitleId'];
                     }
                 }
                 $this->park->active = trimlen($request['Active']) == 0 ? $this->park->active : $request['Active'];
             }
             $address_change = false;
             if (isset($request['Address']) && ($this->park->address != $request['Address'] || trimlen($this->park->location) == 0)) {
                 $address_change = true;
             }
             $this->park->url = isset($request['Url']) ? $request['Url'] : $this->park->url;
             $this->park->address = isset($request['Address']) ? $request['Address'] : $this->park->address;
             $this->park->city = isset($request['City']) ? $request['City'] : $this->park->city;
             $this->park->province = isset($request['Province']) ? $request['Province'] : $this->park->province;
             $this->park->postal_code = isset($request['PostalCode']) ? $request['PostalCode'] : $this->park->postal_code;
             $this->park->directions = isset($request['Directions']) ? $request['Directions'] : $this->park->directions;
             $this->park->description = isset($request['Description']) ? $request['Description'] : $this->park->description;
             $this->park->map_url = isset($request['MapUrl']) ? $request['MapUrl'] : $this->park->map_url;
             $this->park->save();
             $this->park->clear();
             $this->park->park_id = $request['ParkId'];
             if ($this->park->find()) {
                 if ($address_change) {
                     if (isset($request['GeoCode']) && trimlen($request['GeoCode']) > 0) {
                         $this->park_geocode_h($request['GeoCode']);
                     } else {
                         $this->park_geocode_h();
                     }
                 }
                 $response = Success();
                 if ($request['KingdomId'] > 0 && $this->park->kingdom_id != $request['KingdomId']) {
                     // Seriously? You couldn't work it out somehow?
                     // AKA Blackspire Code, AKA Golden Plains Exception
                     if (Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, $request['KingdomId'], AUTH_ADMIN)) {
                         $this->park->kingdom_id = $request['KingdomId'];
                     } else {
                         $response = Warning('You do not have permissions to move this Park [' . $this->park->park_id . ', ' . $this->park->kingdom_id . '] to another Kingdom [' . $request['KingdomId'] . '].');
                     }
                 }
                 if (strlen($request['Heraldry'])) {
                     Ork3::$Lib->heraldry->SetParkHeraldry($request);
                 }
                 $this->park->save();
                 $response = Success($this->park->park_id);
             } else {
                 $response = InvalidParameter('ParkId could not be found.');
             }
         } else {
             $response = NoAuthorization('You do not have permissions to perform this action: ' . $mundane_id);
         }
     } else {
         $response = InvalidParameter('ParkId could not be found.');
     }
     return $response;
 }