Ejemplo n.º 1
0
 /**
  * Set a new activation key for the system
  * @param string $key the new key
  * @param int $type key type TYPE_ACTIVATION / TYPE_EXTENSION
  */
 public static function putNewKey($key)
 {
     $type = self::getType($key);
     if (!$type) {
         return false;
     }
     $cur_key = kConf::get('kaltura_activation_key');
     $replace_passwords = kConf::get('replace_passwords');
     if ($cur_key && $type == ActKeyUtils::TYPE_ACTIVATION) {
         return false;
         // cannot recieve type activation when system was already activated
     }
     if (!$cur_key && $type == ActKeyUtils::TYPE_EXTENSION) {
         return false;
         // cannot recieve type extension on first activation
     } else {
         $data = @file_get_contents(KCONF_FILE);
         if (!$data) {
             return false;
         } else {
             $key_line = '/"kaltura_activation_key"(\\s)*=>(\\s)*(.+),/';
             $replacement = '"kaltura_activation_key" => "' . $key . '",';
             $data = preg_replace($key_line, $replacement, $data);
             if (!@file_put_contents(KCONF_FILE, $data)) {
                 return false;
             }
             if ($replace_passwords) {
                 require_once SECRET_REPLACE_SCRIPT;
             }
         }
         ActKeyUtils::sendReport($key);
         return true;
     }
 }
 /**
  * Set a new activation key for the system
  * @param string $key the new key
  * @param int $type key type TYPE_ACTIVATION / TYPE_EXTENSION
  */
 public static function putNewKey($key)
 {
     $type = self::getType($key);
     if (!$type) {
         return false;
     }
     $cur_key = kConf::get('kaltura_activation_key');
     $replace_passwords = kConf::get('replace_passwords');
     if ($cur_key && $type == ActKeyUtils::TYPE_ACTIVATION) {
         return false;
         // cannot recieve type activation when system was already activated
     }
     if (!$cur_key && $type == ActKeyUtils::TYPE_EXTENSION) {
         return false;
         // cannot recieve type extension on first activation
     } else {
         $data = @file_get_contents(KCONF_FILE);
         if (!$data) {
             return false;
         } else {
             $key_line = '/kaltura_activation_key(\\s)*=(\\s)*(.+)/';
             $replacement = 'kaltura_activation_key = ' . $key;
             $data = preg_replace($key_line, $replacement, $data);
             if (!@file_put_contents(KCONF_FILE, $data)) {
                 return false;
             }
             if ($replace_passwords) {
                 require_once SECRET_REPLACE_SCRIPT;
             }
         }
         //refresh local.ini
         @touch(dirname(__FILE__) . '/../../cache/base.reload');
         ActKeyUtils::sendReport($key);
         return true;
     }
 }