Ejemplo n.º 1
0
 if (!$isauth && $needs_auth) {
     continue;
 }
 // Zend appears to break class auto-loading. Therefore, if we
 //detect there is a module that requires Zend
 // we will include all the potential classes at this point.
 $needs_zend = isset($module['depends']['phpcomponent']) && stristr($module['depends']['phpcomponent'], 'zend');
 if (!$force_autoload && $needs_zend) {
     fpbx_framework_autoloader(true);
     $force_autoload = true;
 }
 //do we have a license file
 $licFileExists = glob('/etc/schmooze/license-*.zl');
 $complete_zend = !function_exists('zend_loader_install_license') || empty($licFileExists);
 try {
     if ($needs_zend && class_exists('\\Schmooze\\Zend') && file_exists($file) && \Schmooze\Zend::fileIsLicensed($file) && $complete_zend) {
         $file_exists = false;
         $zendedbroken[] = $key;
     }
     //emergency mode
     if ($needs_zend && $file_exists && !empty($bootstrap_settings['fix_zend'])) {
         $file_exists = false;
         $zended[$key] = $file;
     }
     //$file_exists = false;
 } catch (\Exception $e) {
     //Some fatal error happened
     freepbx_log(FPBX_LOG_WARNING, $e->getMessage());
     $file_exists = false;
     $zendedbroken[] = $key;
 }
Ejemplo n.º 2
0
 /**
  * Try to load a functions.inc.php if not previously loaded
  * @param  string $module The module rawname
  */
 public function loadFunctionsInc($module)
 {
     if ($this->checkStatus($module)) {
         $path = $this->FreePBX->Config->get("AMPWEBROOT");
         $ifiles = get_included_files();
         $relative = $module . "/functions.inc.php";
         $absolute = $path . "/admin/modules/" . $relative;
         $data = \FreePBX::Modules()->getInfo($module);
         $needs_zend = isset($data[$module]['depends']['phpcomponent']) && stristr($data[$module]['depends']['phpcomponent'], 'zend');
         $licFileExists = glob('/etc/schmooze/license-*.zl');
         $complete_zend = !function_exists('zend_loader_install_license') || empty($licFileExists);
         if (file_exists($absolute)) {
             if ($needs_zend && class_exists('\\Schmooze\\Zend', false) && \Schmooze\Zend::fileIsLicensed($absolute) && $complete_zend) {
                 return false;
             }
             $include = true;
             foreach ($ifiles as $file) {
                 if (strpos($file, $relative) !== false) {
                     $include = false;
                     break;
                 }
             }
             if ($include) {
                 include $absolute;
             }
         }
     }
 }
Ejemplo n.º 3
0
 // let hooking modules process the $_REQUEST
 $module_hook->process_hooks($itemid, $module_name, $module_page, $_REQUEST);
 // BMO: Pre display hooks.
 // getPreDisplay and getPostDisplay should probably never
 // be used.
 $bmo->GuiHooks->getPreDisplay($module_name, $_REQUEST);
 $licFileExists = glob('/etc/schmooze/license-*.zl');
 $complete_zend = !(!function_exists('zend_loader_install_license') || empty($licFileExists));
 // include the module page
 if (isset($cur_menuitem['disabled']) && $cur_menuitem['disabled']) {
     show_view($amp_conf['VIEW_MENUITEM_DISABLED'], $cur_menuitem);
     break;
     // we break here to avoid the generateconfigpage() below
     //
 } else {
     if (file_exists($module_file) && class_exists('\\Schmooze\\Zend') && \Schmooze\Zend::fileIsLicensed($module_file) && $complete_zend) {
         $amp_conf['VIEW_ZEND_CONFIG'] = empty($amp_conf['VIEW_ZEND_CONFIG']) ? 'views/zend_config.php' : $amp_conf['VIEW_ZEND_CONFIG'];
         if (file_exists($amp_conf['VIEW_ZEND_CONFIG'])) {
             echo load_view($amp_conf['VIEW_ZEND_CONFIG']);
         } else {
             die_freepbx(_("Your Zend Configuration is not fully setup. Please recitfy the problem and reload this page"));
         }
     } else {
         if (file_exists($module_file)) {
             //check module first and foremost, but not during quietmode
             if (!isset($_REQUEST['quietmode']) && $amp_conf['SIGNATURECHECK'] && !isset($_REQUEST['fw_popover'])) {
                 //Since we are viewing this module update it's signature
                 $gpgstatus = module_functions::create()->updateSignature($module_name, false);
                 //check all cached signatures
                 $modules = module_functions::create()->getAllSignatures();
                 if (!$modules['validation']) {
Ejemplo n.º 4
0
 /**
  * Find the file for the object
  * @param string $objname The Object Name (same as class name, filename)
  * @param string $hint The location of the Class file
  * @return bool True if found or throws exception
  */
 private function loadObject($objname, $hint = null)
 {
     $objname = str_replace('FreePBX\\modules\\', '', $objname);
     $class = class_exists($this->moduleNamespace . $objname, false) ? $this->moduleNamespace . $objname : (class_exists($this->freepbxNamespace . $objname, false) ? $this->freepbxNamespace . $objname : $objname);
     // If it already exists, we're fine.
     if (class_exists($class, false) && $class != "Directory") {
         //do reflection tests for ARI junk, we **dont** want to load ARI
         $class = new \ReflectionClass($class);
         //this is a stop gap, remove in 13 or 14 when ARI is no longer used
         if (!$class->hasMethod('navMenu') && !$class->hasMethod('rank')) {
             return true;
         }
     }
     // This is the file we loaded the class from, for debugging later.
     $loaded = false;
     if ($hint) {
         if (!file_exists($hint)) {
             throw new \Exception(sprintf(_("Attempted to load %s with a hint of %s and it didn't exist"), $objname, $hint));
         } else {
             $try = $hint;
         }
     } else {
         // Does this exist as a default Library inside BMO?
         $try = __DIR__ . "/{$objname}.class.php";
     }
     if (file_exists($try)) {
         include $try;
         $loaded = $try;
     } else {
         // It's a module, hopefully.
         // This is our root to search from
         $objname = $this->Modules->cleanModuleName($objname);
         $path = $this->Config->get_conf_setting('AMPWEBROOT') . "/admin/modules/";
         $active_modules = array_keys(\FreePBX::create()->Modules->getActiveModules());
         foreach ($active_modules as $module) {
             // Lets try this one..
             //TODO: this needs to look with dirname not from webroot
             $try = $path . $module . "/{$objname}.class.php";
             if (file_exists($try)) {
                 //Now we need to make sure this is not a revoked module!
                 try {
                     $signature = \FreePBX::Modules()->getSignature($module);
                     if (!empty($signature['status'])) {
                         $revoked = $signature['status'] & GPG::STATE_REVOKED;
                         if ($revoked) {
                             return false;
                         }
                     }
                 } catch (\Exception $e) {
                 }
                 $info = \FreePBX::Modules()->getInfo($module);
                 $needs_zend = isset($info[$module]['depends']['phpcomponent']) && stristr($info[$module]['depends']['phpcomponent'], 'zend');
                 $licFileExists = glob('/etc/schmooze/license-*.zl');
                 $complete_zend = !function_exists('zend_loader_install_license') || empty($licFileExists);
                 if ($needs_zend && class_exists('\\Schmooze\\Zend', false) && \Schmooze\Zend::fileIsLicensed($try) && $complete_zend) {
                     break;
                 }
                 include $try;
                 $loaded = $try;
                 break;
             }
         }
     }
     // Right, after all of this we should now have our object ready to create.
     if (!class_exists($objname, false) && !class_exists($this->moduleNamespace . $objname, false) && !class_exists($this->freepbxNamespace . $objname, false)) {
         // Bad things have happened.
         if (!$loaded) {
             $sobjname = strtolower($objname);
             throw new \Exception(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"), $objname) . sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) fwconsole ma install %s 2) fwconsole ma enable %s"), $sobjname, $sobjname));
             //die_freepbx(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"),$objname), sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) amportal a ma install %s 2) amportal a ma enable %s"),$sobjname,$sobjname));
         }
         // We loaded a file that claimed to represent that class, but didn't.
         throw new \Exception(sprintf(_("Attempted to load %s but it didn't define the class %s"), $try, $objname));
     }
     return true;
 }