Alternc  latest
Alternc logiel libre pour l'hébergement
variables.php File Reference

Go to the source code of this file.

Functions

 variable_init ($conf=array())
 Persistent variable table. More...
 
 variable_init_maybe ()
 Initialize the global $conf array if necessary. More...
 
 variable_get ($name, $default=null, $createit_comment=null)
 Return a persistent variable. More...
 
 variable_set ($name, $value, $comment=null)
 Set a persistent variable. More...
 
 variable_del ($name)
 Unset a persistent variable. More...
 
 variables_list ()
 List all variables. More...
 

Function Documentation

◆ variable_del()

variable_del (   $name)

Unset a persistent variable.

Parameters
$nameThe name of the variable to undefine.

Definition at line 146 of file variables.php.

146  {
147  global $conf, $db;
148  $db->query("DELETE FROM `variable` WHERE name = ?;", array($name));
149  unset($conf[$name]);
150 }
if(! $admin->enabled) $conf
Manages global variables of AlternC.
global $db
Definition: bootstrap.php:26

References $conf, and $db.

◆ variable_get()

variable_get (   $name,
  $default = null,
  $createit_comment = null 
)

Return a persistent variable.

Parameters
$nameThe name of the variable to return.
$defaultThe default value to use if this variable has never been set.
$createit_commentIf variable doesn't exist, create it with the default value and createit_comment value as comment
Returns
The value of the variable.
Parameters
global$confA cache of the configuration.

Definition at line 85 of file variables.php.

85  {
86  global $conf;
87 
89 
90  if (isset($conf[$name])) {
91  return $conf[$name];
92  } elseif (!is_null($createit_comment)) {
93  variable_set($name, $default, $createit_comment);
94  }
95  return $default;
96 }
variable_set($name, $value, $comment=null)
Set a persistent variable.
Definition: variables.php:108
variable_init_maybe()
Initialize the global $conf array if necessary.
Definition: variables.php:62
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))

References $conf, elseif, variable_init_maybe(), and variable_set().

Referenced by m_admin\__construct(), m_mysql\__construct(), m_mem\_get_reset_url(), m_mysql\add_db(), m_admin\add_shared_domain(), m_mysql\add_user(), m_action\archive(), m_admin\checkalldom(), m_messages\debug(), m_admin\dom_list(), m_ssl\get_fqdn_specials(), m_admin\hook_admin_add_member(), m_mail\hook_dom_add_mx_domain(), m_dom\m_dom(), m_ftp\m_ftp(), m_lxc\m_lxc(), m_mail\m_mail(), m_piwik\m_piwik(), m_quota\m_quota(), m_ssl\m_ssl(), m_mysql\put_mysql_backup(), m_mysql\put_mysql_details(), m_mem\requires_old_password_for_change(), m_mem\send_reset_url(), m_mem\temporary_login(), m_ssl\update_specials_match(), and m_mem\validate_reset_url().

◆ variable_init()

variable_init (   $conf = array())

Persistent variable table.

Author
Drupal Developpement Team &view=auto Load the persistent variable table. The variable table is composed of values that have been saved in the table with variable_set() as well as those explicitly specified in the configuration file.

Definition at line 36 of file variables.php.

36  {
37  global $db;
38  $result = $db->query('SELECT * FROM `variable`');
39  $variables=array();
40  while ($db->next_record($result)) {
41  /* maybe the data is *not* serialized, in that case, take it verbatim */
42  $variable = $db->Record;
43  if (($variables[$variable['name']] = @unserialize($variable['value'])) === FALSE) {
44  $variables[$variable['name']] = $variable['value'];
45  }
46  }
47 
48  foreach ($conf as $name => $value) {
49  $variables[$name] = $value;
50  }
51 
52  return $variables;
53 }
$value

References $conf, $db, and $value.

Referenced by variable_init_maybe().

◆ variable_init_maybe()

variable_init_maybe ( )

Initialize the global $conf array if necessary.

Parameters
global$confthe global conf array @uses variable_init()

Definition at line 62 of file variables.php.

62  {
63  global $conf;
64  if (!isset($conf)) {
65  $conf = variable_init();
66  }
67 }
variable_init($conf=array())
Persistent variable table.
Definition: variables.php:36

References $conf, and variable_init().

Referenced by variable_get(), and variable_set().

◆ variable_set()

variable_set (   $name,
  $value,
  $comment = null 
)

Set a persistent variable.

Parameters
$nameThe name of the variable to set.
$valueThe value to set. This can be any PHP data type; these functions take care of serialization as necessary.

Definition at line 108 of file variables.php.

108  {
109  global $conf, $db, $msg, $hooks;
110  $msg->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+');
111 
113 
114  if (is_object($value) || is_array($value)) {
115  $value2 = serialize($value);
116  } else {
117  $value2 = $value;
118  }
119  if (array_key_exists($name, $conf)) {
120  $previous = $conf[$name];
121  } else {
122  $previous = null;
123  }
124  if (!array_key_exists($name, $conf) || $value != $conf[$name]) {
125  $conf[$name] = $value;
126  if (empty($comment)) {
127  $query = "INSERT INTO variable (name, value) values ( ?, ?) on duplicate key update name= ?, value= ? ;";
128  $query_args = array($name, $value2, $name, $value2);
129 
130  } else {
131  $query = "INSERT INTO variable (name, value, comment) values ( ?, ?, ?) on duplicate key update name= ?, value= ?, comment= ? ;";
132  $query_args = array($name, $value2, $comment, $name, $value2, $comment);
133  }
134  $db->query($query, $query_args);
135  $hooks->invoke("hook_variable_set", array("name" => $name, "old" => $previous, "new" => $value));
136  }
137 }
$query
Definition: 3.0.0~3.php:37
$hooks
Definition: bootstrap.php:74
$msg
Definition: bootstrap.php:75

References $conf, $db, $hooks, $msg, $query, $value, and variable_init_maybe().

Referenced by m_ssl\cron_new_certs(), and variable_get().

◆ variables_list()

variables_list ( )

List all variables.

Definition at line 156 of file variables.php.

156  {
157  global $db;
158  $t = array();
159  $db->query("SELECT * FROM `variable` WHERE `comment` IS NOT NULL ORDER BY `name`");
160  while ($db->next_record()) {
161  $t[] = $db->Record;
162  }
163  return $t;
164 }
foreach($domaines_user as $domaine) $t

References $db, and $t.