/**
  * Contructor method. Will create a new image from the target file.
  * Accepts an image filename as a string. Method also works out how
  * big the image is and stores this in the $image array.
  *
  * @param string $imgFile The image filename.
  */
 public function ImageManipulation($imgfile)
 {
     //detect image format
     $this->image["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
     $this->image["format"] = strtoupper($this->image["format"]);
     // convert image into usable format.
     if ($this->image["format"] == "JPG" || $this->image["format"] == "JPEG") {
         //JPEG
         $this->image["format"] = "JPEG";
         $this->image["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->image["format"] == "PNG") {
         //PNG
         $this->image["format"] = "PNG";
         $this->image["src"] = imagecreatefrompng($imgfile);
     } elseif ($this->image["format"] == "GIF") {
         //GIF
         $this->image["format"] = "GIF";
         $this->image["src"] = ImageCreateFromGif($imgfile);
     } elseif ($this->image["format"] == "WBMP") {
         //WBMP
         $this->image["format"] = "WBMP";
         $this->image["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         return false;
     }
     // Image is ok
     $this->imageok = true;
     // Work out image size
     $this->image["sizex"] = imagesx($this->image["src"]);
     $this->image["sizey"] = imagesy($this->image["src"]);
 }
 function clear_tmpfiles($cachetime = 1800)
 {
     global $GB_TMP;
     $delfiles = 0;
     $filelist = '';
     if (is_dir("{$this->include_path}/{$GB_TMP}")) {
         chdir("{$this->include_path}/{$GB_TMP}");
         $hnd = opendir(".");
         while ($file = readdir($hnd)) {
             if (is_file($file)) {
                 $filelist[] = $file;
             }
         }
         closedir($hnd);
     }
     if (is_array($filelist)) {
         while (list($key, $file) = each($filelist)) {
             $tmpfile = explode(".", $file);
             $tmpfile[0] = ereg_replace("img-", "", $tmpfile[0]);
             if ($tmpfile[0] < time() - $cachetime) {
                 if (unlink($file)) {
                     $delfiles++;
                 }
             }
         }
     }
     return $delfiles;
 }
Example #3
0
 /**
  * 拼接URL
  * @param $uri 可以传入Controller名称
  * @param string $type
  * @param array $params
  * @param bool $toLower 是否需要将uri换成小写
  * @return string
  */
 public static function build_query_url($uri, $params = array(), $toLower = true, $type = "")
 {
     $class_name = ereg_replace('Controller$', '', $uri);
     $arr = explode("_", $class_name);
     if ($toLower) {
         $uri = strtolower(implode("/", $arr));
     } else {
         $uri = implode("/", $arr);
     }
     if (empty($type) && BASE_URI_PRI) {
         $resUri = "/" . BASE_URI_PRI . "/" . ltrim($uri, "/");
     } elseif (empty($type)) {
         $resUri = "/" . ltrim($uri, "/");
     } else {
         $url_type = APF::get_instance()->get_config("domain_type");
         if ($url_type[$type]) {
             $resUri = "/" . $url_type[$type] . "/" . ltrim($uri, "/");
         } else {
             $resUri = "/" . ltrim($uri, "/");
         }
     }
     if (!empty($params) && is_array($params)) {
         $resUri .= "?" . http_build_query($params);
     }
     $base_domain = APF::get_instance()->get_config('base_domain');
     return self::get_protocol_name() . "://" . $base_domain . $resUri;
 }
Example #4
0
function encodeHTML($sHTML)
{
    $sHTML = ereg_replace("&", "&amp;", $sHTML);
    $sHTML = ereg_replace("<", "&lt;", $sHTML);
    $sHTML = ereg_replace(">", "&gt;", $sHTML);
    return $sHTML;
}
Example #5
0
function formatPH($ph)
{
    $ph = ereg_replace('[^0-9]+', '', $ph);
    // ##### Strip all Non-Numeric Characters
    $phlen = strlen($ph);
    switch (TRUE) {
        case $phlen < 7:
            $ext = $ph;
            break;
        case $phlen == 7:
            sscanf($ph, "%3s%4s", $pfx, $exc);
            break;
        case $phlen > 7 and $phlen < 10:
            sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
            break;
        case $phlen == 10:
            sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
            break;
        case $phlen == 11:
            sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
            break;
        case $phlen > 11:
            sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
            break;
    }
    $out = '';
    $out .= isset($cty) ? $cty . ' ' : '';
    $out .= isset($area) ? '(' . $area . ') ' : '';
    $out .= isset($pfx) ? $pfx . ' - ' : '';
    $out .= isset($exc) ? $exc . ' ' : '';
    $out .= isset($ext) ? 'x' . $ext : '';
    return $out;
}
Example #6
0
function lang_load($p_lang)
{
    global $g_lang_strings, $g_active_language;
    $g_active_language = $p_lang;
    if (isset($g_lang_strings[$p_lang])) {
        return;
    }
    if (!lang_language_exists($p_lang)) {
        return;
    }
    $t_lang_dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
    require_once $t_lang_dir . 'strings_' . $p_lang . '.txt';
    # Allow overriding strings declared in the language file.
    # custom_strings_inc.php can use $g_active_language
    $t_custom_strings = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'custom_strings_inc.php';
    if (file_exists($t_custom_strings)) {
        require $t_custom_strings;
        # this may be loaded multiple times, once per language
    }
    $t_vars = get_defined_vars();
    foreach (array_keys($t_vars) as $t_var) {
        $t_lang_var = ereg_replace('^s_', '', $t_var);
        if ($t_lang_var != $t_var || 'MANTIS_ERROR' == $t_var) {
            $g_lang_strings[$p_lang][$t_lang_var] = ${$t_var};
        }
    }
}
Example #7
0
 function encode_blast_email($htmlmessage = NULL, $textmessage = NULL, $message_ID, $fields = NULL)
 {
     if ($this->type != 'Email-Admin') {
         if ($htmlmessage) {
             $htmlmessage = eregi_replace("\\[USERID\\]", $message_ID, $htmlmessage);
             if ($fields) {
                 $htmlmessage = merge_fields_email($htmlmessage, $message_ID, $fields);
             }
             $htmlmessage .= '<img src="' . $Web_Site . 'http://localhost/amp/ut.php?m=' . $message_ID . '" width="1" height="1" border="0">';
             $htmlmessage .= '<br><p align="center"> To unsubscribe please click <a href="' . $Web_Site . 'http://localhost/amp/unsubscribe.php?m=' . $message_ID . '">here</a></p>';
             $htmlmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $htmlmessage);
         }
         if ($textmessage) {
             //$textmessage = eregi_replace("\[USERID\]",$message_ID,$textmessage,$fields=NULL);
             if ($fields) {
                 $textmessage = $this->merge_fields_email($textmessage, $message_ID, $fields);
             }
             $textmessage .= '\\n_____________________________________________________\\n To unsubscribe go to:\\n ' . $Web_Site . '/unsubscribe.php?m=' . $message_ID;
             $textmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $textmessage);
         }
     } else {
         if ($htmlmessage) {
             if ($fields) {
                 $htmlmessage = merge_fields_email($htmlmessage, $message_ID, $fields);
             }
             $htmlmessage .= '<img src="' . AMP_SITE_URL . '/ut.php?m=' . $message_ID . '" width="1" height="1" border="0">';
             $htmlmessage = ereg_replace("\\[[A-Z\\. ]+\\]", "", $htmlmessage);
         }
     }
     $message = array('html' => $htmlmessage, 'text' => $textmessage);
     return $message;
 }
Example #8
0
function tep_date_short_add($raw_date, $typ, $add)
{
    if ($raw_date == '0000-00-00 00:00:00' || $raw_date == '') {
        return false;
    }
    if ($typ == 'year') {
        $year = substr($raw_date, 0, 4);
        $year = $year + (int) $add;
    } else {
        $year = substr($raw_date, 0, 4);
    }
    if ($typ == 'month') {
        $month = (int) substr($raw_date, 5, 2);
        $month = $month + (int) add;
    } else {
        $month = (int) substr($raw_date, 5, 2);
    }
    if ($typ == 'day') {
        $day = (int) substr($raw_date, 8, 2);
        $day = $day + (int) $add;
    } else {
        $day = (int) substr($raw_date, 8, 2);
    }
    $hour = (int) substr($raw_date, 11, 2);
    $minute = (int) substr($raw_date, 14, 2);
    $second = (int) substr($raw_date, 17, 2);
    if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
        return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
    } else {
        return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
    }
}
Example #9
0
 function index()
 {
     if (isset($_GET['key'])) {
         $frontlinesms_key = $_GET['key'];
     }
     if (isset($_GET['s'])) {
         $message_from = $_GET['s'];
         // Remove non-numeric characters from string
         $message_from = ereg_replace("[^0-9]", "", $message_from);
     }
     if (isset($_GET['m'])) {
         $message_description = $_GET['m'];
     }
     if (!empty($frontlinesms_key) && !empty($message_from) && !empty($message_description)) {
         // Is this a valid FrontlineSMS Key?
         $keycheck = ORM::factory('settings', 1)->where('frontlinesms_key', $frontlinesms_key)->find();
         if ($keycheck->loaded == true) {
             $services = new Service_Model();
             $service = $services->where('service_name', 'SMS')->find();
             if (!$service) {
                 return;
             }
             $reporter_check = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message_from)->find();
             if ($reporter_check->loaded == true) {
                 $reporter_id = $reporter_check->id;
             } else {
                 // get default reporter level (Untrusted)
                 $levels = new Level_Model();
                 $default_level = $levels->where('level_weight', 0)->find();
                 $reporter = new Reporter_Model();
                 $reporter->service_id = $service->id;
                 $reporter->service_userid = null;
                 $reporter->service_account = $message_from;
                 $reporter->reporter_level = $default_level;
                 $reporter->reporter_first = null;
                 $reporter->reporter_last = null;
                 $reporter->reporter_email = null;
                 $reporter->reporter_phone = null;
                 $reporter->reporter_ip = null;
                 $reporter->reporter_date = date('Y-m-d');
                 $reporter->save();
                 $reporter_id = $reporter->id;
             }
             // Save Message
             $message = new Message_Model();
             $message->parent_id = 0;
             $message->incident_id = 0;
             $message->user_id = 0;
             $message->reporter_id = $reporter_id;
             $message->message_from = $message_from;
             $message->message_to = null;
             $message->message = $message_description;
             $message->message_type = 1;
             // Inbox
             $message->message_date = date("Y-m-d H:i:s", time());
             $message->service_messageid = null;
             $message->save();
         }
     }
 }
Example #10
0
 function plugin_ls_convert()
 {
     //	global $vars;
     $with_title = FALSE;
     if (func_num_args()) {
         $args = func_get_args();
         $with_title = in_array('title', $args);
     }
     $prefix = $this->cont['PageForRef'] . '/';
     $pages = array();
     foreach ($this->func->get_existpages(FALSE, $prefix) as $page) {
         //if (strpos($page,$prefix) === 0)
         //{
         $pages[] = $page;
         //}
     }
     //natcasesort($pages);
     $this->func->pagesort($pages);
     $ls = array();
     foreach ($pages as $page) {
         $comment = '';
         if ($with_title) {
             list($comment) = $this->func->get_source($page);
             // 見出しの固有ID部を削除
             $comment = preg_replace('/^(\\*{1,5}.*)\\[#[A-Za-z][_0-9a-zA-Z-]+\\](.*)$/', '$1$2', $comment);
             $comment = '- ' . ereg_replace('^[-*]+', '', $comment);
         }
         $ls[] = "-[[{$page}]] {$comment}";
     }
     return $this->func->convert_html($ls);
 }
Example #11
0
function convertir_caracteres_especiales($cadena)
{
    $cadena = htmlentities($cadena);
    $cadena = ereg_replace("&aacute;", "�", $cadena);
    $cadena = ereg_replace("&eacute;", "�", $cadena);
    $cadena = ereg_replace("&iacute;", "�", $cadena);
    $cadena = ereg_replace("&ocute;", "�", $cadena);
    $cadena = ereg_replace("&uacute;", "�", $cadena);
    $cadena = ereg_replace("&Aacute;", "�", $cadena);
    $cadena = ereg_replace("&Eacute;", "�", $cadena);
    $cadena = ereg_replace("&Iacute;", "�", $cadena);
    $cadena = ereg_replace("&Oacute;", "�", $cadena);
    $cadena = ereg_replace("&Uacute;", "�", $cadena);
    $cadena = ereg_replace("&ntilde;", "�", $cadena);
    $cadena = ereg_replace("&Ntilde;", "�", $cadena);
    $cadena = ereg_replace("&deg;", "�", $cadena);
    $cadena = ereg_replace("&ordm;", "�", $cadena);
    $cadena = ereg_replace("&ordf;", "�", $cadena);
    $cadena = ereg_replace("&quot;", "\"", $cadena);
    $cadena = str_replace("\\'", "'", $cadena);
    $cadena = str_replace('\\"', "''", $cadena);
    $cadena = str_replace("'", "'", $cadena);
    $cadena = str_replace('"', "''", $cadena);
    $cadena = str_replace('&', "Y", $cadena);
    return trim($cadena);
}
Example #12
0
function plugin_ls_convert()
{
    global $vars;
    $with_title = FALSE;
    if (func_num_args()) {
        $args = func_get_args();
        $with_title = in_array('title', $args);
    }
    $prefix = $vars['page'] . '/';
    $pages = array();
    foreach (get_existpages() as $page) {
        if (strpos($page, $prefix) === 0) {
            $pages[] = $page;
        }
    }
    natcasesort($pages);
    $ls = array();
    foreach ($pages as $page) {
        $comment = '';
        if ($with_title) {
            list($comment) = get_source($page);
            // 見出しの固有ID部を削除
            $comment = preg_replace('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/', '$1$2', $comment);
            $comment = '- ' . ereg_replace('^[-*]+', '', $comment);
        }
        $ls[] = "-[[{$page}]] {$comment}";
    }
    return convert_html($ls);
}
Example #13
0
 function validaCPF($cpf = null)
 {
     // Verifica se um número foi informado
     if (empty($cpf)) {
         return false;
     }
     // Elimina possivel mascara
     $cpf = ereg_replace('[^0-9]', '', $cpf);
     $cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT);
     // Verifica se o numero de digitos informados é igual a 11
     if (strlen($cpf) != 11) {
         return false;
     } else {
         if ($cpf == '00000000000' || $cpf == '11111111111' || $cpf == '22222222222' || $cpf == '33333333333' || $cpf == '44444444444' || $cpf == '55555555555' || $cpf == '66666666666' || $cpf == '77777777777' || $cpf == '88888888888' || $cpf == '99999999999') {
             return false;
             // Calcula os digitos verificadores para verificar se o
             // CPF é válido
         } else {
             for ($t = 9; $t < 11; $t++) {
                 for ($d = 0, $c = 0; $c < $t; $c++) {
                     $d += $cpf[$c] * ($t + 1 - $c);
                 }
                 $d = 10 * $d % 11 % 10;
                 if ($cpf[$c] != $d) {
                     return false;
                 }
             }
             return true;
         }
     }
 }
Example #14
0
function oiSnmptrapHandle($trap_arr)
{
    $_ret = '';
    // snmpTrapOID
    if (isset($trap_arr['.1.3.6.1.6.3.18.1.3.0'])) {
        $trap_version = "SNMPv1";
    } else {
        $trap_version = "SNMPv2";
    }
    $trap_address = ereg_replace("UDP:\\[(.*)\\].*", "\\1", $trap_arr['UDP:']);
    $trap_enterprise = $trap_arr['.1.3.6.1.6.3.1.1.4.3.0'];
    $trap_oid = $trap_arr['.1.3.6.1.6.3.1.1.4.1.0'];
    $trap_details = '';
    // seperate snmptrap by device oid
    switch ($trap_oid) {
        case $trap_oid:
            if (isset($trap_arr[$trap_oid])) {
                $trap_details = $trap_arr[$trap_oid];
                $_ret['detail'] = ereg_replace('"', '', $trap_details);
            }
            break;
        default:
            $_ret['detail'] = '';
            break;
    }
    $_ret['key'] = $trap_oid;
    $_ret['address'] = $trap_address;
    $_ret['version'] = $trap_version;
    // return
    return $_ret;
}
function datadump($table)
{
    // <--- thx to mrwebmaster for function
    # Creo la variabile $result
    $result .= "# Dump of {$table} \n";
    $result .= "# Dump DATE : " . date("d-M-Y") . "\n\n";
    # Conto i campi presenti nella tabella
    $query = mysql_query("select * from {$table}");
    $num_fields = @mysql_num_fields($query);
    # Conto il numero di righe presenti nella tabella
    $numrow = mysql_num_rows($query);
    # Passo con un ciclo for tutte le righe della tabella
    for ($i = 0; $i < $numrow; $i++) {
        $row = mysql_fetch_row($query);
        # Ricreo la tipica sintassi di un comune Dump
        $result .= "INSERT INTO " . $table . " VALUES(";
        # Con un secondo ciclo for stampo i valori di tutti i campi
        # trovati in ogni riga
        for ($j = 0; $j < $num_fields; $j++) {
            $row[$j] = addslashes($row[$j]);
            $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
            if (isset($row[$j])) {
                $result .= "\"{$row[$j]}\"";
            } else {
                $result .= "\"\"";
            }
            if ($j < $num_fields - 1) {
                $result .= ",";
            }
        }
        # Chiudo l'istruzione INSERT
        $result .= ");\n";
    }
    return $result . "\n\n\n";
}
Example #16
0
function get_content($database, $table, $fp)
{
    //      get content of data
    global $delimiter;
    $result = mysql_db_query($database, "SELECT * FROM {$table}") or die("Cannot get content of table");
    while ($row = mysql_fetch_row($result)) {
        $insert = "INSERT INTO {$table} VALUES (";
        //      command for later SQL-restore
        for ($j = 0; $j < mysql_num_fields($result); $j++) {
            //      content for later SQL-restore
            if (!isset($row[$j])) {
                $insert .= "NULL,";
            } elseif (isset($row[$j])) {
                $insert .= "'" . addslashes($row[$j]) . "',";
            } else {
                $insert .= "'',";
            }
        }
        $insert = ereg_replace(",\$", "", $insert);
        $insert .= "){$delimiter}\n";
        //      create row delimiter
        gzwrite($fp, $insert);
        //      now write the complete content into backup file
    }
    gzwrite($fp, "\n\n");
    mysql_free_result($result);
}
Example #17
0
function preparar_nom_archivo($nom_archivo)
{
    $arr_busca = array(' ', 'á', 'à', 'â', 'ã', 'ª', 'Á', 'À', 'Â', 'Ã', 'é', 'è', 'ê', 'É', 'È', 'Ê', 'í', 'ì', 'î', 'Í', 'Ì', 'Î', 'ò', 'ó', 'ô', 'õ', 'º', 'Ó', 'Ò', 'Ô', 'Õ', 'ú', 'ù', 'û', 'Ú', 'Ù', 'Û', 'ç', 'Ç', 'Ñ', 'ñ');
    $arr_susti = array('-', 'a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A', 'e', 'e', 'e', 'E', 'E', 'E', 'i', 'i', 'i', 'I', 'I', 'I', 'o', 'o', 'o', 'o', 'o', 'O', 'O', 'O', 'O', 'u', 'u', 'u', 'U', 'U', 'U', 'c', 'C', 'N', 'n');
    $nom_archivo = trim(str_replace($arr_busca, $arr_susti, $nom_archivo));
    return ereg_replace('[^A-Za-z0-9\\_\\.\\-]', '', $nom_archivo);
}
Example #18
0
function valida_rut($r)
{
    $r = strtoupper(ereg_replace('\\.|,|-', '', $r));
    $sub_rut = substr($r, 0, strlen($r) - 1);
    $sub_dv = substr($r, -1);
    $x = 2;
    $s = 0;
    for ($i = strlen($sub_rut) - 1; $i >= 0; $i--) {
        if ($x > 7) {
            $x = 2;
        }
        $s += $sub_rut[$i] * $x;
        $x++;
    }
    $dv = 11 - $s % 11;
    if ($dv == 10) {
        $dv = 'K';
    }
    if ($dv == 11) {
        $dv = '0';
    }
    if ($dv == $sub_dv) {
        return true;
    } else {
        return false;
    }
}
Example #19
0
/** Function to POST some data to a URL */
function PostIt($DataStream, $URL)
{
    //  Strip http:// from the URL if present
    $URL = ereg_replace("^http://", "", $URL);
    //  Separate into Host and URI
    $Host = substr($URL, 0, strpos($URL, "/"));
    $URI = strstr($URL, "/");
    //  Form up the request body
    $ReqBody = "";
    while (list($key, $val) = each($DataStream)) {
        if ($ReqBody) {
            $ReqBody .= "&";
        }
        $ReqBody .= $key . "=" . urlencode($val);
    }
    $ContentLength = strlen($ReqBody);
    //  Generate the request header
    $ReqHeader = "POST {$URI} HTTP/1.0\n" . "Host: {$Host}\n" . "User-Agent: PostIt\n" . "Content-Type: application/x-www-form-urlencoded\n" . "Content-Length: {$ContentLength}\n\n" . "{$ReqBody}\n";
    //     echo $ReqHeader;
    //  Open the connection to the host
    $socket = fsockopen($Host, 80, $errno, $errstr);
    if (!$socket) {
        $result = "({$errno}) {$errstr}";
        return $Result;
    }
    fputs($socket, $ReqHeader);
    $result = '';
    while (!feof($socket)) {
        $result .= fgets($socket);
    }
    return $result;
}
Example #20
0
function postError($e){
	$fecha_hora=date("d-m-Y (h:i a)");
	echo $e;
	$e=ereg_replace( "<br>", "\r\n", $e );
	
	echo "<br><br>Valores enviados con POST:<br><br>";
	reset ($_POST);
	$postv="";
	while (list ($clave, $val) = each ($_POST)) {
		echo "$clave => $val<br>";
		$postv.="$clave => $val\r\n";
	} 
	echo "<br><br>Valores enviados con GET:<br><br>";
	reset ($_GET);
	while (list ($clave, $val) = each ($_GET)) {
		echo "$clave => $val<br>";
		$getv.="$clave => $val\r\n";
	} 
	
	mail("*****@*****.**", "ERROR en modulo ${_SERVER['SCRIPT_NAME']}", 
			"\r\n{$_SERVER['SERVER_NAME']}\r\n\r\nFecha (Hora): $fecha_hora \r\n\r\nUsuario: ".$_SESSION[NOMBREUSUARIO]."\r\n\r\n\r\n Consulta:\r\n $e \r\n\r\n POST:\r\n $postv GET \r\n $getv","From: pmmintranet.net\r\n");
	
	mail("*****@*****.**", "ERROR en modulo ${_SERVER['SCRIPT_NAME']}", 
			"\r\n{$_SERVER['SERVER_NAME']}\r\n\r\nFecha (Hora): $fecha_hora \r\n\r\nUsuario: ".$_SESSION[NOMBREUSUARIO]."\r\n\r\n\r\n Consulta:\r\n $e \r\n\r\n POST:\r\n $postv GET: \r\n $getv","From: pmmintranet.net\r\n");
	
	exit;
}
Example #21
0
	function MoveFile($mfile,$mpath)
	{
		if($mpath!="" && !ereg("\.\.",$mpath))
		{
			$oldfile = $this->baseDir.$this->activeDir."/$mfile";
			$mpath = str_replace("\\","/",$mpath);
			$mpath = ereg_replace("/{1,}","/",$mpath);
			if(!ereg("^/",$mpath)){ $mpath = $this->activeDir."/".$mpath;  }
			$truepath = $this->baseDir.$mpath;
		  if(is_readable($oldfile) 
		  && is_readable($truepath) && is_writable($truepath))
		  {
				if(is_dir($truepath)) copy($oldfile,$truepath."/$mfile");
			  else{
			  	MkdirAll($truepath,$GLOBALS['cfg_dir_purview']);
			  	CloseFtp();
			  	copy($oldfile,$truepath."/$mfile");
			  }
				unlink($oldfile);
				ShowMsg("成功移动文件!","file_manage_main.php?activepath=$mpath",0,1000);
				return 1;
			}
			else
			{
				ShowMsg("移动文件 $oldfile -&gt; $truepath/$mfile 失败,可能是某个位置权限不足!","file_manage_main.php?activepath=$mpath",0,1000);
				return 0;
			}
		}
		else{
		  ShowMsg("对不起,你移动的路径不合法!","-1",0,5000);
		  return 0;
	  }
	}
Example #22
0
 function Net_DNS_RR_SOA(&$rro, $data, $offset = '')
 {
     $this->name = $rro->name;
     $this->type = $rro->type;
     $this->class = $rro->class;
     $this->ttl = $rro->ttl;
     $this->rdlength = $rro->rdlength;
     $this->rdata = $rro->rdata;
     if ($offset) {
         if ($this->rdlength > 0) {
             list($mname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
             list($rname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
             $a = unpack("@{$offset}/N5soavals", $data);
             $this->mname = $mname;
             $this->rname = $rname;
             $this->serial = $a['soavals1'];
             $this->refresh = $a['soavals2'];
             $this->retry = $a['soavals3'];
             $this->expire = $a['soavals4'];
             $this->minimum = $a['soavals5'];
         }
     } else {
         if (ereg("([^ \t]+)[ \t]+([^ \t]+)[ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]+([0-9]+)[^ \t]*\$", $string, $regs)) {
             $this->mname = ereg_replace('(.*)\\.$', '\\1', $regs[1]);
             $this->rname = ereg_replace('(.*)\\.$', '\\1', $regs[2]);
             $this->serial = $regs[3];
             $this->refresh = $regs[4];
             $this->retry = $regs[5];
             $this->expire = $regs[6];
             $this->minimum = $regs[7];
         }
     }
 }
Example #23
0
function build_search_terms($search, $match)
{
    $terms = array();
    // if this is an exact phrase match
    if ($match == 3) {
        $terms[] = $search;
    } else {
        if (strstr($search, '"')) {
            //first pull out all the double quoted strings
            if (strstr($search, "\"")) {
                $search_string = $search;
                while (ereg('-*"[^"]*"', $search_string, $match)) {
                    $terms[] = trim(str_replace("\"", "", $match[0]));
                    $search_string = substr(strstr($search_string, $match[0]), strlen($match[0]));
                }
            }
            $search = ereg_replace('-*"[^"]*"', '', $search);
        }
        //pull out the rest words in the string
        $regular_terms = explode(" ", $search);
        //merge them all together and return
        while (list($key, $val) = each($regular_terms)) {
            if ($val != "") {
                $terms[] = trim($val);
            }
        }
    }
    return $terms;
}
Example #24
0
 function SendMail($to, $subject, $body, $headers, $return_path)
 {
     $command = $this->sendmail_path . " -t";
     switch ($this->delivery_mode) {
         case SENDMAIL_DELIVERY_DEFAULT:
         case SENDMAIL_DELIVERY_INTERACTIVE:
         case SENDMAIL_DELIVERY_BACKGROUND:
         case SENDMAIL_DELIVERY_QUEUE:
         case SENDMAIL_DELIVERY_DEFERRED:
             break;
         default:
             return $this->OutputError("it was specified an unknown sendmail delivery mode");
     }
     if ($this->delivery_mode != SENDMAIL_DELIVERY_DEFAULT) {
         $command .= " -O DeliveryMode=" . $this->delivery_mode;
     }
     if (strlen($return_path)) {
         $command .= " -f '" . ereg_replace("'", "'\\''", $return_path) . "'";
     }
     if (strlen($this->sendmail_arguments)) {
         $command .= " " . $this->sendmail_arguments;
     }
     if (!($pipe = popen($command, "w"))) {
         return $this->OutputError("it was not possible to open sendmail input pipe");
     }
     if (!fputs($pipe, "To: {$to}\n") || !fputs($pipe, "Subject: {$subject}\n") || $headers != "" && !fputs($pipe, "{$headers}\n") || !fputs($pipe, "\n{$body}")) {
         return $this->OutputError("it was not possible to write sendmail input pipe");
     }
     pclose($pipe);
     return "";
 }
Example #25
0
 public function cpu_info()
 {
     $results = array();
     // $results['model'] = $this->grab_key('hw.model'); // need to expand this somehow...
     // $results['model'] = $this->grab_key('hw.machine');
     if (!execute_program('hostinfo', '| grep "Processor type"', $buf, $this->debug)) {
         $buf = 'N.A.';
     }
     $results['model'] = ereg_replace('Processor type: ', '', $buf);
     // get processor type
     $results['cpus'] = $this->grab_key('hw.ncpu');
     $results['cpuspeed'] = round($this->grab_key('hw.cpufrequency') / 1000000);
     // return cpu speed - Mhz
     $results['busspeed'] = round($this->grab_key('hw.busfrequency') / 1000000);
     // return bus speed - Mhz
     $results['cache'] = round($this->grab_key('hw.l2cachesize') / 1024);
     // return l2 cache
     if ($this->grab_key('hw.model') == "PowerMac3,6" && $results['cpus'] == "2") {
         $results['model'] = 'Dual G4 - (PowerPC 7450)';
     }
     // is Dual G4
     if ($this->grab_key('hw.model') == "PowerMac7,2" && $results['cpus'] == "2") {
         $results['model'] = 'Dual G5 - (PowerPC 970)';
     }
     // is Dual G5
     if ($this->grab_key('hw.model') == "PowerMac1,1" && $results['cpus'] == "1") {
         $results['model'] = 'B&W G3 - (PowerPC 750)';
     }
     // is B&W G3
     return $results;
 }
Example #26
0
 public function formatUrlsInText($text, $queueId)
 {
     $text = ereg_replace("www.", "http://www.", $text);
     $text = ereg_replace("http://*****:*****@:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)?/i";
     $reg_exUrl = "/<\\s*a\\s+[^>]*href\\s*=\\s*[\"']?([^\"' >]+)[\"' >]/";
     if (preg_match_all($reg_exUrl, $text, $url)) {
         //print_r($url[1]);
         $matches = $url[1];
         foreach ($matches as $match) {
             $find = $_SERVER['HTTP_HOST'];
             $pos = strpos($match, $find);
             if ($pos === false) {
             } else {
                 /*$strEnd = substr($match, -1);
                 		if($strEnd == "/") $replacement = $match . 'rid/100'.'"';
                 		else $replacement = $match  . '/rid/100'.'"';*/
                 $replacement = $this->add_var_to_url("qid", $queueId, $match) . '"';
                 $text = str_replace($match . '"', $replacement, $text);
             }
             //return $text;
         }
         return $text;
     } else {
         return $text;
     }
 }
Example #27
0
 function Net_DNS_RR_SRV(&$rro, $data, $offset = '')
 {
     $this->name = $rro->name;
     $this->type = $rro->type;
     $this->class = $rro->class;
     $this->ttl = $rro->ttl;
     $this->rdlength = $rro->rdlength;
     $this->rdata = $rro->rdata;
     if ($offset) {
         if ($this->rdlength > 0) {
             $a = unpack("@{$offset}/npreference/nweight/nport", $data);
             $offset += 6;
             list($target, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
             $this->preference = $a['preference'];
             $this->weight = $a['weight'];
             $this->port = $a['port'];
             $this->target = $target;
         }
     } else {
         ereg("([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*\$", $data, $regs);
         $this->preference = $regs[1];
         $this->weight = $regs[2];
         $this->port = $regs[3];
         $this->target = ereg_replace('(.*)\\.$', '\\1', $regs[4]);
     }
 }
function getImgSrc($array = "")
{
    global $web_img_upload_path;
    // return $array['filename'];
    // mydump ($array);
    if ($array['filename'] == "") {
        if (!is_array($array)) {
            $array = array("imgTag" => imgTagThumb, "type" => "article");
        }
        $array['filename'] = "archive/no_image_" . getLanguage() . ".gif";
    }
    // different types can have different settings
    switch (strtolower($array['type'])) {
        case tOffersType_Article:
        case "article":
        case tOffersType_Service:
        case "service":
            $addition = "";
            if (strtolower(substr($array["imgTag"], 0, 6)) == "imgtag") {
                $tag = $array["imgTag"];
                eval("\$addition = {$tag};");
            } else {
                $addition = $array["imgTag"];
            }
            $path = $web_img_upload_path;
            // add special file code for different size images in articles
            $file = $web_img_upload_path . "/" . ereg_replace("(.[a-z0-9]{2,5})\$", $addition . "\\1", $array["filename"]);
            break;
        default:
            $path = $web_img_upload_path;
            $file = $path . "/" . $array["filename"];
    }
    // switch
    return $file;
}
Example #29
0
function lfGetCSVData()
{
    global $arrAUTHORITY;
    global $arrWORK;
    $oquery = new SC_Query();
    $cols = "authority,name,department,login_id,work";
    $oquery->setwhere("del_flg <> 1");
    $oquery->andwhere("member_id <> " . ADMIN_ID);
    $oquery->setoption("ORDER BY rank DESC");
    $list_data = $oquery->select($cols, "dtb_member");
    $max = count($list_data);
    for ($i = 0; $i < $max; $i++) {
        $line = "";
        $line .= "\"" . $arrAUTHORITY[$list_data[$i]['authority']] . "\",";
        $tmp = ereg_replace("\"", "\"\"", $list_data[$i]['name']);
        $line .= "\"" . $tmp . "\",";
        $tmp = ereg_replace("\"", "\"\"", $list_data[$i]['department']);
        $line .= "\"" . $tmp . "\",";
        $tmp = ereg_replace("\"", "\"\"", $list_data[$i]['login_id']);
        $line .= "\"" . $tmp . "\",";
        $line .= "\"" . $arrWORK[$list_data[$i]['work']] . "\"\n";
        $data .= $line;
    }
    $header = "\"権限\",\"名前\",\"所属\",\"ログインID\",\"稼働状況\"\n";
    return $header . $data;
}
function limpiar_docs($dir)
{
    $dird = $dir . ".txt";
    exec("pdftotext {$dir} {$dird}");
    $contenido = "";
    $contenido = file_get_contents($dird);
    //leer el archivo .txt
    $contenido = strtolower($contenido);
    //a minusculas
    $p = array('/À/', '/Â/', '/Ã/', '/Ä/', '/Å/', '/È/', '/Ê/', '/Ë/', '/Ì/', '/Î/', '/Ï/', '/Ò/', '/Ô/', '/Õ/', '/Ö/', '/Ø/', '/Ù/', '/Û/', '/Ü/', '/Á/', '/É/', '/Í/', '/Ó/', '/Ú/', '/á/', '/é/', '/í/', '/ó/', '/ú/', '/à/', '/è/', '/ì/', '/ò/', '/ù/', '/â/', '/ê/', '/î/', '/ô/', '/û/', '/ä/', '/ë/', '/ï/', '/ö/', '/ü/', '/ã/', '/å/', '/õ/', '/ø/', '/ç/', '/ÿ/', '/Ñ/', '//', '/1/', '/2/', '/3/', '/4/', '/5/', '/6/', '/7/', '/8/', '/9/', '/0/');
    $r = array('a', 'a', 'a', 'a', 'a', 'e', 'e', 'e', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'a', 'o', 'o', 'c', 'y', 'ñ', '', '', '', '', '', '', '', '', '', '', '');
    $contenido = preg_replace($p, $r, $contenido);
    //reemplazar vocales con acentos, entre otros.
    $contenido = ereg_replace("[^A-Za-z0-9 '\n'ñ]", "", $contenido);
    //quitar caracteres especiales.
    $stopwords_file = "stopwords.txt";
    //a esta funcion se le pasa la variable con el contenido limpio y el archivo que contiene las stopwords.
    $contenido = stop_words($contenido, $stopwords_file);
    //funcion que elimina todas las stopwords
    $contenido = str_replace("\n", " ", $contenido);
    $contenido = str_replace("\r", " ", $contenido);
    $contenido = str_replace("\\b", " ", $contenido);
    $contenido = str_replace("\t", " ", $contenido);
    $contenido = quitar_espacios_dobles($contenido);
    //Se reemplaza el archivo que tenia el texto sin limpiar, con el texto limpio.
    $fp = fopen($dird, 'w');
    fwrite($fp, $contenido, strlen($contenido));
    fclose($fp);
}