/**
  * Checks if the new package is compatible with
  * the package that is about to be updated.
  *
  * @return 	boolean 	isValidUpdate
  */
 public function isValidUpdate()
 {
     // Check name of the installed package against the name of the update. Both must be identical.
     if ($this->packageInfo['name'] != $this->package->getPackage()) {
         return false;
     }
     // Check if the version number of the installed package is lower than the version number to which
     // it's about to be updated.
     if (Package::compareVersion($this->packageInfo['version'], $this->package->getVersion()) != 1) {
         return false;
     }
     // Check if the package provides an instructions block for the update from the installed package version
     if ($this->update === null) {
         return false;
     }
     return true;
 }
 /**
  * @see FileHandler::checkFiles()
  */
 public function checkFiles(&$files)
 {
     if ($this->packageInstallation->getPackage()->getPackage() != 'com.woltlab.wcf') {
         $packageID = $this->packageInstallation->getPackageID();
         // build sql string with ACP-templateNames
         $fileCondition = '';
         $fileNames = array();
         foreach ($files as $file) {
             $fileName = preg_replace("%\\.tpl\$%", "", $file);
             $fileNames[] = $fileName;
             if (!empty($fileCondition)) {
                 $fileCondition .= ',';
             }
             $fileCondition .= "'" . escapeString($fileName) . "'";
         }
         // check if files are existing already
         if (!empty($fileCondition)) {
             // get by other packages registered files
             $sql = "SELECT\t\t*\n\t\t\t\t\tFROM\t\twcf" . WCF_N . $this->tableName . "\n\t\t\t\t\tWHERE\t\tpackageID <> " . $packageID . "\n\t\t\t\t\t\t\tAND packageID IN (\n\t\t\t\t\t\t\t\tSELECT\tpackageID\n\t\t\t\t\t\t\t\tFROM \twcf" . WCF_N . "_package\n\t\t\t\t\t\t\t\tWHERE \tpackageDir = '" . escapeString($this->packageInstallation->getPackage()->getDir()) . "'\n\t\t\t\t\t\t\t\tAND \tstandalone = 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\tAND \t\ttemplateName IN (" . $fileCondition . ")";
             $result = WCF::getDB()->sendQuery($sql);
             $lockedFiles = array();
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $lockedFiles[$row['templateName']] = $row['packageID'];
             }
             // check if files from installing package are in conflict with already installed files
             if (!$this->packageInstallation->getPackage()->isStandalone() && count($lockedFiles) > 0) {
                 foreach ($fileNames as $key => $file) {
                     if (isset($lockedFiles[$file]) && $packageID != $lockedFiles[$file]) {
                         $owningPackage = new Package($lockedFiles[$file]);
                         throw new SystemException("A non-standalone package can't overwrite template files. Only an update from the package which owns the template can do that. (Package '" . $this->packageInstallation->getPackage()->getPackage() . "' tries to overwrite template '" . $file . "', which is owned by package '" . $owningPackage->getPackage() . "')", 13026);
                     }
                 }
             }
         }
     }
 }
 /**
  * This method is called by the launcher (index.php5)
  */
 static function processHTTP() {
   ob_start();
   
   $request = Request::parseHTTP();
   $responce = new Responce($request);
   
   $pkg = Package::getPackageByName('freeform');
     
   // Initialize session
   $sessionImpl = $pkg->getProperty('session.impl');
   $class = new ReflectionClass($sessionImpl);
   $method = $class->getMethod('load');
   Session::setHandler($method->invoke(null, $request));
   
   // See if we have the server cache hit here
   if(!$responce->getFromCache()) {
     // Initialize action
     $action = $request->getParameter('action', $da = $pkg->getProperty('action.default'));
     try {
       $class = new ReflectionClass($action);
       if(!$class->isSubclassOf('Action') || $class->isAbstract()) {
         throw new Exception('Can not execute action ' . $class->getName());
       }
     } catch(Exception $e) {
       $class = new ReflectionClass($pkg->getProperty('action.error', $da));
       if($class->isSubclassOf('Action') && !$class->isAbstract()) {
         $responce->relocate(new Location($class->getName()));
         $responce->setStatusCode(Response::STATUS_ERR_ACTION);
       } else {
         throw new ConfigurationException('freeform', 'action.error, action.default', 'do not denote a valid instantiable Action subclass');
       }
     }
     
     if(!$responce->isRelocation()) {
       // Initialize, secure and execute
       $action = $class->newInstance($request, $responce, true);
       Package::setEntryPackage(Package::getPackage($action));
       try {
         self::process($action);
       } catch(AccessDeniedException $ade) {
         $responce->setStatusCode(Responce::STATUS_ERR_ACCESS);
         $action->onAccessDenied();
       }
     }
   }
   
   // Send back the document
   foreach($responce->getHeaders() as $header) {
     header($header, false);
   }
   if($output = trim(ob_get_contents())) {
     error_log('Executed Action ' . $class->getName() . ' produced output: ' . $output);
   }
   ob_end_clean();
   echo $responce->getBody();
 }
 /**
  * Checks whether this package is required by other packages.
  * If so than a template will be displayed to warn the user that 
  * a further uninstallation will uninstall also the dependent packages 
  */
 public static function checkDependencies()
 {
     $packageID = 0;
     if (isset($_REQUEST['activePackageID'])) {
         $packageID = intval($_REQUEST['activePackageID']);
     }
     // get packages info
     try {
         // create object of uninstalling package
         $package = new Package($packageID);
     } catch (SystemException $e) {
         throw new IllegalLinkException();
     }
     // can not uninstall wcf package.
     if ($package->getPackage() == 'com.woltlab.wcf') {
         throw new IllegalLinkException();
     }
     $dependentPackages = array();
     if ($package->isRequired()) {
         // get packages that requires this package
         $dependentPackages = self::getPackageDependencies($package->getPackageID());
         $uninstallAvailable = true;
         foreach ($dependentPackages as $dependentPackage) {
             if ($dependentPackage['packageID'] == PACKAGE_ID) {
                 $uninstallAvailable = false;
                 break;
             }
         }
         // show uninstall dependencies template
         if (!isset($_POST['send']) && count($dependentPackages)) {
             WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.package');
             // show delete requirements sure template
             WCF::getTPL()->assign(array('packageObj' => $package, 'dependentPackages' => $dependentPackages, 'activePackageID' => $packageID, 'uninstallAvailable' => $uninstallAvailable));
             WCF::getTPL()->display('packageUninstallationDependencies');
             exit;
         } else {
             if (!$uninstallAvailable) {
                 throw new IllegalLinkException();
             }
             self::addQueueEntries($package, $dependentPackages);
         }
     }
     // no dependencies. add this package to queue
     self::addQueueEntries($package);
 }
Ejemplo n.º 5
0
<?php

session_start();
require_once "../lib/config.inc.php";
require_once "../lib/classes/Admin.php";
require_once "../lib/classes/Package.php";
$PackageObj = new Package();
$adminObj = new Admin();
$adminObj->validateAdmin();
$commonObj->cleanInput();
if (isset($_GET['package'])) {
    $line = $PackageObj->getPackage(intval($_GET['package']));
}
?>
<!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>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php 
echo ucfirst(SITE_ADMIN_TITLE);
?>
</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<link rel="stylesheet" href="uikit/css/uikit.min.css" />
<!-- Add jQuery library -->
	<script type="text/javascript" src="fancybox/lib/jquery-1.10.1.min.js"></script>
	<!-- Add fancyBox main JS and CSS files -->
Ejemplo n.º 6
0
 /**
  * A shortcut to <tt>Package::getPackage($this)</tt>
  * @return  Package   the package where this action was defined
  */
 function getPackage() {
   return Package::getPackage($this);
 }
Ejemplo n.º 7
0
 /**
  * Updates an existing package.
  * 
  * @param	integer		$packageID
  * @param	string		$version	new package version
  */
 protected function updatePackage($packageID, $version)
 {
     // get package info
     $package = new Package($packageID);
     // get current package version
     $packageVersion = $package->getVersion();
     if (isset($this->virtualPackageVersions[$packageID])) {
         $packageVersion = $this->virtualPackageVersions[$packageID];
         // check virtual package version
         if (Package::compareVersion($packageVersion, $version, '>=')) {
             // virtual package version is greater than requested version
             // skip package update
             return;
         }
     }
     // get highest version of the required major release
     if (preg_match('/(\\d+\\.\\d+\\.)/', $version, $match)) {
         $packageVersions = array();
         $sql = "SELECT\tDISTINCT packageVersion\n\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\tWHERE\tpackageUpdateID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t)\n\t\t\t\t\tAND packageVersion LIKE '" . escapeString($match[1]) . "%'";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $packageVersions[] = $row['packageVersion'];
         }
         if (count($packageVersions) > 1) {
             // sort by version number
             usort($packageVersions, array('Package', 'compareVersion'));
             // get highest version
             $version = array_pop($packageVersions);
         }
     }
     // get all fromversion
     $fromversions = array();
     $sql = "SELECT\t\tpuv.packageVersion, puf.fromversion\n\t\t\tFROM\t\twcf" . WCF_N . "_package_update_fromversion puf\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_update_version puv\n\t\t\tON\t\t(puv.packageUpdateVersionID = puf.packageUpdateVersionID)\n\t\t\tWHERE\t\tpuf.packageUpdateVersionID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateVersionID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\t\t\tWHERE \tpackageUpdateID IN (\n\t\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t)";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!isset($fromversions[$row['packageVersion']])) {
             $fromversions[$row['packageVersion']] = array();
         }
         $fromversions[$row['packageVersion']][$row['fromversion']] = $row['fromversion'];
     }
     // sort by version number
     uksort($fromversions, array('Package', 'compareVersion'));
     // find shortest update thread
     $updateThread = self::findShortestUpdateThread($package->getPackage(), $fromversions, $packageVersion, $version);
     // process update thread
     foreach ($updateThread as $fromversion => $toVersion) {
         $packageUpdateVersions = self::getPackageUpdateVersions($package->getPackage(), $toVersion);
         // resolve requirements
         $this->resolveRequirements($packageUpdateVersions[0]['packageUpdateVersionID']);
         // download package
         $download = '';
         if ($this->download) {
             $download = $this->downloadPackage($package->getPackage(), $packageUpdateVersions);
         }
         // add to stack
         $this->packageInstallationStack[] = array('packageName' => $package->getName(), 'instanceNo' => $package->getInstanceNo(), 'fromversion' => $fromversion, 'toVersion' => $toVersion, 'package' => $package->getPackage(), 'packageID' => $packageID, 'archive' => $download, 'action' => 'update');
         // update virtual versions
         $this->virtualPackageVersions[$packageID] = $toVersion;
     }
 }
Ejemplo n.º 8
0
        }
        ?>
				<tr class="<?php 
        echo $ClassName;
        ?>
">
                	<td height="30" width="5%" align="center"><?php 
        echo $i;
        ?>
 </td>
                    <td height="30" width="20%"><?php 
        echo $line->token;
        ?>
</td>
					<td height="30" width="20%"><?php 
        $packageDetail = $packageObj->getPackage($line->pid);
        echo $packageDetail->package_name;
        ?>
</td>
					<td height="30" width="8%">
						<?php 
        if ($line->status == 2) {
            echo '<a href="javascript:void(0)" style="color:green;" >Available</a>';
        } else {
            echo '<a href="javascript:void(0)"  style="color:red;">Used</a>';
        }
        ?>
					</td>                     
                </tr>
				<?php 
        $i++;
Ejemplo n.º 9
0
 /**
  * Writes the config.inc.php for a standalone application.
  * 
  * @param	integer		$packageID
  */
 public static function writeConfigFile($packageID)
 {
     $package = new Package($packageID);
     $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->getDir()));
     $file = new File($packageDir . PackageInstallation::CONFIG_FILE);
     $file->write("<?php\n");
     $currentPrefix = strtoupper($package->getAbbreviation());
     // get dependencies (only standalones)
     $sql = "SELECT\t\tpackage.*, IF(package.packageID = " . $packageID . ", 1, 0) AS sortOrder\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_dependency.dependency)\n\t\t\tWHERE\t\tpackage_dependency.packageID = " . $packageID . "\n\t\t\t\t\tAND package.standalone = 1\n\t\t\t\t\tAND package.packageDir <> ''\n\t\t\tORDER BY\tsortOrder DESC,\n\t\t\t\t\tpackage_dependency.priority DESC";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $dependency = new Package(null, $row);
         $dependencyDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $dependency->getDir()));
         $prefix = strtoupper($dependency->getAbbreviation());
         $file->write("// " . $dependency->getPackage() . " vars\n");
         $file->write("// " . strtolower($prefix) . "\n");
         $file->write("if (!defined('" . $prefix . "_DIR')) define('" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "dirname(__FILE__).'/'" : "'" . $dependencyDir . "'") . ");\n");
         $file->write("if (!defined('RELATIVE_" . $prefix . "_DIR')) define('RELATIVE_" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "''" : "RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, $dependencyDir) . "'") . ");\n");
         $file->write("if (!defined('" . $prefix . "_N')) define('" . $prefix . "_N', '" . WCF_N . "_" . $dependency->getInstanceNo() . "');\n");
         $file->write("\$packageDirs[] = " . $prefix . "_DIR;\n");
         $file->write("\n");
     }
     // write general information
     $file->write("// general info\n");
     $file->write("if (!defined('RELATIVE_WCF_DIR'))\tdefine('RELATIVE_WCF_DIR', RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, WCF_DIR) . "');\n");
     $file->write("if (!defined('PACKAGE_ID')) define('PACKAGE_ID', " . $package->getPackageID() . ");\n");
     $file->write("if (!defined('PACKAGE_NAME')) define('PACKAGE_NAME', '" . str_replace("'", "\\'", $package->getName()) . "');\n");
     $file->write("if (!defined('PACKAGE_VERSION')) define('PACKAGE_VERSION', '" . $package->getVersion() . "');\n");
     // write end
     $file->write("?>");
     $file->close();
 }
Ejemplo n.º 10
0
<?php

session_start();
require_once "lib/config.inc.php";
require_once "lib/classes/User.php";
require_once "lib/classes/Package.php";
$userObj = new User();
$commonObj->cleanInput();
$userObj->validateUserLogin();
if (isset($_GET['pid'])) {
    $PackageObj = new Package();
    $packageList = $PackageObj->getPackage(intval($_GET['pid']));
}
if ($_SESSION['UID']) {
    //$id = 'SM100'.;
    $result = $userObj->getUser($_SESSION['UID']);
}
if (isset($_POST['submitForm']) && $_POST['submitForm'] == 'Yes') {
    $userObj->ChangeUserPin($_POST);
    //echo '<pre>';
    //print_r($_POST);
}
?>
<!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>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php 
echo ucfirst(SITE_TITLE);
  function onOpen() {
    $this->wml = $this->getDocument() instanceof WMLDocument;
    
    if(!$this->key) {
      $this->key = $this->getAttribute('key');
      $this->removeAttribute('key');
    }
    
    $this->form = $this->getDocument()->getVariable($this->key);
    if(is_null($this->form)) {
      return self::SKIP_BODY;
    }
    
    $this->parameters = new HTMLTag($this, 'div', array());
    $this->parameters->setExposed(false);
    
    if($this->ifError = $this->getTagByName('iferror')) {
      $this->ifError->setExposed(false);
    }
    if($this->ifInputErrors = $this->getTagByName('ifinputerrors')) {
      $this->ifInputErrors->setExposed(false);
    }
    
    if($this->wml) {
      $this->setName('fieldset');
      $this->action->name = 'postfield';
      $do = new HTMLTag($this, 'do', array());
      $do->setAttribute('type', 'Accept');
      $go = new HTMLTag($this, 'go', array());
      $go->setAttribute('href', '?');
      $go->setAttribute('method', $this->form->getMethod() == Request::METHOD_POST ? 'post' : 'get');
      $go->addNode($this->parameters);
      $do->addNode($go);
      $this->addNode($do);
    } else {
      $this->setAttribute('method', $this->form->getMethod() == Request::METHOD_POST ? 'post' : 'get');
      if($this->getAttribute('method') == 'post') {
	       $this->setAttribute('enctype', 'multipart/form-data');
      }
      $this->setName('form');
      $this->setAttribute('action', htmlSpecialChars(Request::$URL, ENT_QUOTES, 'UTF-8')); 
      // Set the HTML4.01 attribute accept-encoding if we generate 4.01 HTML pages
      // !!! Must use version_compare !!!
      if(Package::getPackage($this)->getProperty('html.version') == '4.01') {
        $this->setAttribute('accept-charset', 'UTF-8');
      }
      $this->addNode($this->parameters);
    }
		
    // Pass over parameters
    $pars = $this->form->getParameters();
    
    if($this->wml) {
      foreach(array_keys($this->form->getFields()) as $fname) {
        $pars[$fname] = '$(' . $fname . ')';
      }
    }
    
    $pars['action'] = $this->form->getLocation()->getAction();
    foreach($pars as $k=>$v) {
      $a = new HTMLTag($this, $this->wml ? 'postfield' : 'input', array());
      $a->setAttribute('name', htmlSpecialChars($k, ENT_QUOTES, 'UTF-8'));
      $a->setAttribute('value', htmlSpecialChars($v, ENT_QUOTES, 'UTF-8'));
        
      if(!$this->wml) {
        $a->setAttribute('type', 'hidden');
      }
      $this->parameters->addNode($a);
    }
      
    if($this->ifInputErrors) {
      $this->ifInputErrors->setEnabled(
        $this->form->isSubmitted() && !$this->form->isValid());
    }
      
    return self::PROCESS_BODY;
  } 
Ejemplo n.º 12
0
 /**
  * Create an URL to access an action with a given set of parameters.
  * This will use the class specified in the <tt>locationRewriter</tt> config option 
  * of the <package>freeform</package> package to rewrite the URLs of other actions.
  * @param  bool $disableRewrite  flag to disable the rewriting of the URL
  * @return  string  the URL of the action and set of parameters contained in this Location object
  */
 function toURL() {
   if(is_null(self::$rewriter)) {
     $lrc = Package::getPackage($this)->getProperty('locationRewriter', 'Location');
     try {
       $rc = new ReflectionClass($lrc);
       self::$rewriter = $rc->getMethod('rewrite');
     } catch(ReflectionException $re) {
       throw new ConfigurationException('freeform', 'locationRewriter', 'denotes non-existent class ' . $lrc);
     }
   } 
   return self::$rewriter->invoke(null, $this);    
 }