$v) { $r[] = '\\1'; $f[$k] = "/(".$v.")/iu"; } } else { if ($f == "") return $str; $f = "/(".$f.")/i"; $r = '\\1'; } //echo "replace: "; var_dump($f); echo " "; var_dump($r); echo " ".$str."
"; return preg_replace($f,$r,$str); } ////////////////////////////////////////////////////////////////////////////////////////// /* Prints alert-window with message $str */ function aks_alert($str) { echo ''; return true; } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /* Prints alert-window with message $str */ function aks_confirm($str,$action_ja,$action_nein) { echo ''; return true; } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /* Trimming the string str. Set length to size and cut to nearest space-symbol */ function aks_trim_string($str,$size,$leaveTags="
") { $ret_str = $str; $ret_str = strip_tags($ret_str,$leaveTags); mb_internal_encoding('UTF-8'); if (mb_strlen($ret_str) > $size) { $ret_str = mb_substr($ret_str,0,$size); $pos = mb_strrpos($ret_str," "); $ret_str = mb_substr($ret_str,0,$pos); $pos1 = mb_strrpos($ret_str,'>'); $pos2 = mb_strrpos($ret_str,'<'); if ($pos2 > $pos1) { $pos = mb_strpos($ret_str, ">", $pos2); $str_ = mb_substr($ret_str,$pos2,$pos-$pos2+1); if (mb_strpos($str_,"$file) { $img1_name = $file; if ($img1_name == "") continue; $img1_type = $types[$k]; $sizelim = "no"; //Do you want size limit, yes or no $size = "2000000"; //What do you want size limited to be if there is one //all image types to upload $cert1 = "image/pjpeg"; //Jpeg type 1 $cert2 = "image/jpeg"; //Jpeg type 2 $cert3 = "image/gif"; //GIF $log = ""; //Checks if file is an image if (($img1_type == $cert1) || ($img1_type == $cert2) || ($img1_type == $cert3)) { $uploaddir = $uppath; $pos = strrpos($img1_name,"."); // $filename = translit(substr($img1_name,0,$pos)); $extension = substr($img1_name,$pos); //$new_imgname = date("dmYHis").strtolower($filename.$extension); $new_imgname = generateFileID($uploaddir."gross/",$extension); $image = $uploaddir.$new_imgname.".tmp"; global $LANG; if (move_uploaded_file($tmp_names[$k], $image)) $log = $LANG["image_upload_successfull"]; else { die(); return false; } require_once LIBPATH."SmartImage/SmartImage.class.php"; if ($thumb) { // Start! $img = new SmartImage($image); // Resize and save to file $img->resize($img_sizes["width"]["klein"], $img_sizes["height"]["klein"], isset($img_sizes["cut"]["klein"]) && $img_sizes["cut"]["klein"]); $img->saveImage($uploaddir."klein/".$new_imgname,IMAGE_QUALITY); chmod($uploaddir."klein/".$new_imgname,0644); $img->close(); unset($img); } if (isset($img_sizes["width"]["mitte"])) { // Start! $img = new SmartImage($image); // Resize and save to file $img->resize($img_sizes["width"]["mitte"], $img_sizes["height"]["mitte"], isset($img_sizes["cut"]["mitte"]) && $img_sizes["cut"]["mitte"]); $img->saveImage($uploaddir."mitte/".$new_imgname,IMAGE_QUALITY); chmod($uploaddir."mitte/".$new_imgname,0644); $img->close(); unset($img); } // Start! $img = new SmartImage($image); // Resize and save to file if ( (($img->getWidth() > $img_sizes["width"]["gross"]) && $img_sizes["width"]["gross"]) || (($img->getHeight() > $img_sizes["height"]["gross"]) && $img_sizes["height"]["gross"] ) ) $img->resize($img_sizes["width"]["gross"], $img_sizes["height"]["gross"], isset($img_sizes["cut"]["gross"]) && $img_sizes["cut"]["gross"]); if ($watermark) { $horizontal = ($img->getWidth()>$img->getHeight()); if (is_array($xWM)) $xWM = $xWM[!$horizontal]; if (is_array($yWM)) $yWM = $yWM[!$horizontal]; if (is_array($watermarkFileName)) $watermarkFileName = $watermarkFileName[!$horizontal]; $wm_img = new SmartImage($watermarkFileName); if ($xWM === 'center') $xWM = intval(($img->getWidth() - $wm_img->getWidth()) / 2); if ($yWM === 'center') $yWM = intval(($img->getHeight() - $wm_img->getHeight()) / 2); if ($xWM<0) $xWM = $img->getWidth() - $wm_img->getWidth() + $xWM; if ($yWM<0) $yWM = $img->getHeight()+ $wm_img->getHeight() + $yWM; $img->addWaterMarkImage( $watermarkFileName, $WMopacity, $xWM, $yWM); } $img->saveImage($uploaddir."gross/".$new_imgname,IMAGE_QUALITY); chmod($uploaddir."gross/".$new_imgname,0644); $img->close(); unset($img); unlink($image); $new_imgnames[] = $new_imgname; } else { if ($log != "") aks_alert($log); } } return $new_imgnames; } // end of aks_upload_image /////////////////////////////////////////////////////////////////////////////// function generateFileID($prefix,$extension) { $extension = strtolower($extension); $count = 0; while (1 && (++$count < 10)) { $str = strtolower(substr( str_replace("=","",base64_encode( (int)(rand()*1000+1) )),0, 100)); if (!file_exists($prefix."/".$str.$extension)) { if ($f = fopen($prefix."/".$str.$extension,"w+")) { fclose($f); unlink($prefix."/".$str.$extension); return $str.$extension; } } } return 'img'.time().$extension; } ///////////////////////////////////////////////////////////////////////// // checks if $val is in array $arr function aks_is_in_array($arr,$val) { for($i=0;$i=0; $i-- ) { if ( $price[$i] == "," ) break; else $res = $price[$i].$res; } $res = ",".$res; $i--; $digitCounter = 0; for( ; $i>=0; $i-- ) { $digitCounter++; $res = $price[$i].$res; if ( $digitCounter == 3 && $i != 0 ) { $res = ".".$res; $digitCounter = 0; } } return ($withPrecision)?$res:preg_replace('/,\d+$/','',$res); } function arrRemoveEmpty(&$array,&$array2 = null,$bindeworter=array()) { //for($i=0;$i$v) { if ( isset($array[$i]) && ((strlen(trim($array[$i]))<=3) || in_array(trim($array[$i]),$bindeworter))) { unset ($array[$i]); if (!is_null($array2)) unset ($array2[$i]); } } } function aks_isEmail($str) { return preg_match('/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/', $str); } function mailClient($mail_an, $subject, $message, $mail_from, $enctype = 'text/html', array $attaches = []) { include_once 'includes/libraries/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); $mail->SetLanguage('de', 'includes/libraries/phpmailer/language/'); $mail->CharSet = 'UTF-8'; $mail->From = $mail_from; $mail->ContentType = $enctype; $mail->FromName = ''; $mail->Hostname = $_SERVER['SERVER_NAME']; $mail->Mailer = "mail"; $mail->AddAddress($mail_an); foreach ($attaches as $name => $path) { $mail->AddAttachment($path, $name); } $mail->Subject = $subject; $mail->Body = $message; // $mail->AltBody = strip_tags($message); // str_replace(array("
",'
','
'), array("\n","\n","\n"), // strip_tags(str_replace(array("\n","\r"),array('',''),$message),'
')); $result = $mail->Send(); if ($mail->IsError()) { echo ''; return false; } return $result; } /** * @param array $data * @return mPDF * @throws MpdfException */ function createAnmeldebogenPDF(array $data) { require_once dirname(__FILE__).'/../../vendor/autoload.php'; require_once dirname(__FILE__).'/smarty/libs/Smarty.class.php'; $smarty = new Smarty(); $smarty->assign('post', $data); $html = $smarty->fetch(dirname(__FILE__).'/../../templates/anmeldebogen.pdf.tpl'); $mpdf = new mPDF('c', 'A4', '', 'chelvetica', 20, 15, 16, 25, 10, 10); $mpdf->simpleTables = true; $mpdf->SetDisplayMode('fullpage'); // LOAD a stylesheet $stylesheet = file_get_contents(dirname(__FILE__).'/../../styles/anmeldebogen.css'); $mpdf->WriteHTML($stylesheet, 1); // The parameter 1 tells that this is css/style only and no body/html/text $mpdf->WriteHTML($html); return $mpdf; }",$values[$i]); if ($quotes) $values[$i] = mysql_escape_string($values[$i]); $values_str .= $add_str."'".$values[$i]."'"; $add_str = ", "; } $sql .= "($names_str) values ($values_str)"; if (isset($DEBUG) && $DEBUG) echo "INSERT: $sql"; $res = mysql_query($sql); if ($res == 0) { aks_alert("Error in aks_SQL_insert!"); return false; } else { global $dbase; $fields = mysql_list_fields($dbase, $tabelle, $link); $id_fld = mysql_field_name($fields, 0); $sql = "select MAX($id_fld) from $tabelle"; $res = mysql_query($sql); $new_id = mysql_result($res,0,0); if (isset($DEBUG) && $DEBUG) echo "new_id: $new_id
"; mysql_free_result($res); return $new_id; } } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /* Executes UPDATE command @param tabelle table for updating @param fields array of fields to update @param values array of values for fields @param id where instruction. STRING! e.g. " art_id=10" @return bool true if success, otherwise - false */ function aks_SQL_update($tabelle,$fields,$values,$id) { if ( !is_array($fields) || !is_array($values) || (sizeof($fields) == 0) || (sizeof($values) == 0) || (strlen(trim($tabelle)) == 0) || (sizeof($fields) != sizeof($values)) || (strlen(trim($id)) == 0) ) return false; global $cr; global $quotes; $link = aks_link(); $add_str = ""; $sql = "UPDATE $tabelle SET "; for($i=0;$i",$values[$i]); if ($quotes) $values[$i] = preg_replace("/([\"\'])/","\$1",$values[$i]); $sql .= $add_str.$fields[$i]."='".$values[$i]."'"; $add_str = ", "; } $sql .= " where $id"; global $DEBUG; if (isset($DEBUG) && $DEBUG) echo "UPDATE: $sql
"; $res = mysql_query($sql); if ($res == 0) { aks_alert("Error in aks_SQL_update!"); return false; } else return true; } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /* Executes DELETE command @param tabelle table for updating @param id where instruction. STRING! e.g. " art_id=10" @return bool true if success, otherwise - false */ function aks_SQL_delete($tabelle,$id) { if ( (strlen(trim($tabelle)) == 0) || (strlen(trim($id)) == 0) ) return false; $link = aks_link(); $sql = "delete from $tabelle where $id"; global $DEBUG; if (isset($DEBUG) && $DEBUG) echo "DELETE: $sql"; $res = mysql_query($sql); if ($res == 0) { aks_alert("Error in aks_SQL_delete!"); return false; } else return (mysql_affected_rows() > 0); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /* Returns a value of field $field in table $tabelle @param tabelle table name @param fields field name @param id where instruction. STRING! e.g. " art_id=10" @param default default value @param delim delimiter in ReturnZeile @return bool true if success, otherwise - false */ function aks_get_field_value($tabelle,$field,$id,$default="",$delim = ";", $onlyArray=0) { if ( (strlen(trim($field)) == 0) || (strlen(trim($tabelle)) == 0) || (strlen(trim($id)) == 0) ) return false; $link = aks_link(); $sql = "select $field from $tabelle where $id"; global $DEBUG; if (isset($DEBUG) && $DEBUG) echo "aks_get_field_value: $sql
"; if ($res = execSQL($sql)) { $num = mysql_num_rows($res); if ($num > 0) { $return = array(); while ($row = mysql_fetch_array($res,MYSQL_NUM)) $return[] = implode ($delim, $row); if ( (sizeof($return) == 1) && !$onlyArray) return $return[0]; else return $return; } else return $default; } else return false; } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /* Returns a value of field $field in table $tabelle @param tabelle table name @param fields field name @param id where instruction. STRING! e.g. " art_id=10" @param default default value @param delim delimiter in ReturnZeile @return bool true if success, otherwise - false */ function aks_get_field_value2($tabelle,$field,$id,$default="", $onlyArray=0 ) { if ( (strlen(trim($field)) == 0) || (strlen(trim($tabelle)) == 0) || (strlen(trim($id)) == 0) ) return false; $link = aks_link(); $sql = "select $field from $tabelle where $id"; global $DEBUG; if (isset($DEBUG) && $DEBUG) echo "aks_get_field_value2: $sql
"; if (($res = execSQL($sql)) && (mysql_num_rows($res) > 0)){ $return = array(); while ($row = mysql_fetch_array($res,MYSQL_ASSOC)) $return[] = $row; if ( (sizeof($return) == 1) && !$onlyArray) return $return[0]; else return $return; } else return $default; } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// /* gets a value of a property $eigenschaft from DB. If it's not set, returns $default value @param eigenschaft name of a property @param default default value @return if found - value of a property, otherwise - $default value */ function aks_get_config_value() { $link = aks_link(); global $config_tabelle; $CONFIG = array(); $sql = "select eigenschaft,wert from $config_tabelle order by id"; if ($res = execSQL($sql)) while ($row = mysql_fetch_array($res)) $CONFIG[$row["eigenschaft"]] = $row["wert"]; return $CONFIG; } ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// /* Returns tree of records in table with Parent-Child relations @param tabelle table name @param where_add where instruction. STRING! e.g. " art_id=10" @param topID id of top record @param forSelect true - if forms the string for SELECT tag @param levelStr offset in '; $newLevelStr = $levelStr."----"; } else { $returnStr .= ''; $returnStr .= $levelStr.aks_trim_string($row[$fieldName],40); $returnStr .= ''; //$DEBUG=1; $art_count = (integer)aks_get_field_value($artikel_tabelle,"COUNT($countField)","$topForCountField=".$row["id"],0); //unset($DEBUG); $returnStr .= ' ('.$art_count.')
'; $newLevelStr = "    ".$levelStr; } $returnStr .= "\n"; $returnStr .= aksGetChildRecords($tabelle,$where_add,$row["id"],$forSelect,$newLevelStr,$fieldName,$orderField,$countField,$topForCountField); } mysql_free_result($res); return $returnStr; } ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// /* Moves active Rubrik UP or DOWN @param id id of Rubrik to Moving @param nachOben true - if moving UP, otherwise - DOWN @return integer id of a new position in Navigation */ function aksSmartRubrikSchieben($id_,$nachOben) { global $rubrik_tabelle, $artikel_tabelle, $DEBUG; $link = aks_link(); // $DEBUG=1; $new_id = aksSchieben($rubrik_tabelle, aks_get_field_value($rubrik_tabelle,"sort_order","id=$id_",0), $nachOben,"sort_order",0, "top_rubrik=".aks_get_field_value($rubrik_tabelle,"top_rubrik","id=$id_",0) ); // aksSchieben($rubrik_tabelle,$id_,$nachOben,"top_rubrik",$new_id); // aksSchieben($artikel_tabelle,$id_,$nachOben,"top_rubrik",$new_id); //unset ($DEBUG); return $new_id; } ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// /* Moves an Object in DB UP or DOWN @param tabelle table with records @param id_ id to Moving @param new_id new id (only for Moving by Top Rubrik) @param feld field in table @param nachOben true - if moving UP, otherwise - DOWN @return integer id of a new position in Navigation */ function aksSchieben($tabelle,$id_,$nachOben=true,$feld="id",$new_id=0,$where="1") { global $DEBUG; $id_max = ((integer)aks_get_field_value($tabelle,"MAX($feld)","1","0"))+1; $rows = aks_get_field_value2($tabelle,"DISTINCT $feld",$where." order by 1",""); // var_dump($rows); die; if (!isset($rows[0])) $rows = array($rows); if ($new_id == 0) { $prev = array(); foreach ($rows as $key=>$row) { if ($row[$feld] == $id_) break; $prev = $row; } if (!$nachOben) $prev = $rows[$key+1]; // $prev = (isset($rows[$key+1])) ? $rows[$key+1] : array($feld=>$id_); $neu_id = $prev[$feld]; } else $neu_id = $new_id; aks_SQL_update($tabelle,array($feld),array($id_max),"($feld=".$neu_id.")"); aks_SQL_update($tabelle,array($feld),array($neu_id),"($feld=".$id_.")"); aks_SQL_update($tabelle,array($feld),array($id_),"($feld=".$id_max.")"); return $neu_id; } //////////////////////////////////////////////////////////////////////////////////////////// function getLeftNav($sql) { global $rubrik_tabelle; $return = array(); if ($res = execSQL($sql)) { while($id = mysql_fetch_array($res)) { $row = aks_get_field_value2($rubrik_tabelle, 'page_url,rubrik,id,top_rubrik','id='.$id[0].' order by sort_order, id',array()); $next = aksGetChildRecordsWithURLs2(array($id[0])); $return[] = array( 'page_url' => $row["page_url"], 'rubrik' => $row["rubrik"], 'id' => $row["id"], 'top_rubrik' => $row["top_rubrik"], 'level' => 0, 'has_children' => isset($next[0]) && $next[0]['level'] === 1, ); $return = array_merge($return, $next); } } return $return; } function aksGetChildRecordsWithURLs2($topIDs=array(),$levelStr=1) { global $rubrik_tabelle; if (!is_array($topIDs)) return array(); global $link, $topURL; $return = array(); foreach($topIDs as $topID) { $sql = "select * from $rubrik_tabelle where (top_rubrik=$topID) order by sort_order, id"; global $DEBUG; if (isset($DEBUG) && $DEBUG) echo "aksGetChildRecordsWithURLs2: $sql
"; if ($res = execSQL($sql)) { while ($row = mysql_fetch_array($res)) { $return[] = array( 'page_url' => $row["page_url"], 'rubrik' => $row["rubrik"], 'id' => $row["id"], 'top_rubrik' => $row["top_rubrik"], 'level' => $levelStr, ); // if ( ($levelStr <1) || (($levelStr==1) && ($row["page_url"]==$topURL))) // $return = array_merge($return, aksGetChildRecordsWithURLs2(array($row["id"]),$levelStr+1)); } mysql_free_result($res); } } return $return; } ?>