/**
  *
  *
  * @param unknown $plugin_guid
  * @param unknown $setting_name
  * @param unknown $keys
  * @return unknown
  */
 function __SetSettingMultiSQL($plugin_guid, $setting_name, $keys)
 {
     // Even if this function shouldn't be used by anyone, I'll document it a bit, even if it's just for me:
     // The purpose of this function is to generate a custom UPDATE query, that can update 1 or more keys for a defined setting.
     // The $keys parameter must be an associative array : keys of this array are the keynames, values are the keyvalues.
     // Beware updating this function : it's heavily used by all Set_ functions, and by the UpdateBuffer that relies mainly on this one for all
     // updates to the buffer.
     if (isarray($keys)) {
         $set_string = "";
         $parse = "";
         foreach ($keys as $key_name => $key_value) {
             $set_string .= $parse . "`{$key_name}` = '{$key_value}'";
             if ($parse == "") {
                 $parse = ", ";
             }
         }
     } else {
         return FALSE;
     }
     $sql_string = "UPDATE `{$this->settings_table}` SET {$set_string} WHERE `HostPluginGUID` = '{$plugin_guid}' AND `SettingName` = '{$setting_name}' LIMIT 1;\n";
     return $sql_string;
 }
Example #2
0
function http($target, $ref, $method, $data_array, $incl_head)
{
    # Initialize PHP/CURL handle
    $ch = curl_init();
    # HEAD method configuration
    if ($method == HEAD) {
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
        // No http head
        curl_setopt($ch, CURLOPT_NOBODY, TRUE);
        // Return body
    } else {
        curl_setopt($ch, CURLOPT_HEADER, $incl_head);
        // Include head as needed
        curl_setopt($ch, CURLOPT_NOBODY, FALSE);
        // Return body
        # GET method configuration
        if ($method == GET) {
            # Convert data array into a query string (ie animal=dog&sport=baseball)
            if (isarray($data_array)) {
                foreach ($data_array as $key => $value) {
                    if (strlen(trim($value)) > 0) {
                        $temp_string[] = $key . "=" . urlencode($value);
                    } else {
                        $temp_string[] = $key;
                    }
                }
                $query_string = join('&', $temp_string);
            } else {
                $query_string = (string) $data_array;
            }
            if (isset($query_string)) {
                $target = $target . "?" . $query_string;
            }
            curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
        }
        # POST method configuration
        if ($method == POST) {
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_array);
        }
    }
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
    // Cookie management.
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
    //curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8118"); // ENABLE TOR
    curl_setopt($ch, CURLOPT_TIMEOUT, CURL_TIMEOUT);
    // Timeout
    curl_setopt($ch, CURLOPT_USERAGENT, WEBBOT_NAME);
    // Webbot name
    curl_setopt($ch, CURLOPT_URL, $target);
    // Target site
    curl_setopt($ch, CURLOPT_REFERER, $ref);
    // Referer value
    curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
    // Minimize logs
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    // No certificate
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    // Follow redirects
    curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
    // Limit redirections to four
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    // Return in string
    # Create return array
    $return_array['FILE'] = curl_exec($ch);
    $return_array['STATUS'] = curl_getinfo($ch);
    $return_array['ERROR'] = curl_error($ch);
    # Close PHP/CURL handle
    curl_close($ch);
    # Return results
    return $return_array;
}
 /**
  * Function group returns file group owner as string or null
  * on failure
  *
  * @param mixed
  * @throws mixed
  *
  * @return string
  */
 public function group($newgroup = null)
 {
     if ($this->exists == false) {
         throw new \Exception("File does not exist");
     }
     if ($this->isReadable == false) {
         throw new \Exception("File is not readable");
     }
     $groupid = filegroup($this->value);
     if ($groupid === false) {
         throw new \Exception("Error getting group id");
     }
     $group = posixgetgrgid($groupid);
     if (!isarray($group)) {
         throw new \Exception("Error getting group id");
     }
     if ($newgroup == null) {
         return $group['name'];
     }
     if ($this->isWriteable == false) {
         throw new \Exception("File is not writeable");
     }
     if (chgrp($this->value, $newgroup) === false) {
         throw new \Exception("Unable to change File group");
     }
     clearstatcache();
     return $this->group();
 }
Example #4
0
 /**
  * @param SingleValue $values Variable-length variable.
  */
 public function __construct(SingleValue ...$values)
 {
     $this->values = $values;
     $this->count = isarray($values) ? count($values) : 1;
 }
 /**
  * Check if value in array
  *
  * @param mixed
  * @param array | optional
  *
  * @return bool
  */
 public function in($value, $array = null)
 {
     if ($array == null || !isarray($array)) {
         return in_array($value, $this->value, true);
     }
     return in_array($value, $array, true);
 }